21
21
# The internal structure is as follows
22
22
# - _chol! returns the factor and info without checking positive definiteness
23
23
# - chol/chol! returns the factor and checks for positive definiteness
24
- # - cholfact/cholfact! returns Cholesky with checking positive definiteness
24
+ # - cholfact/cholfact! returns Cholesky without checking positive definiteness
25
25
26
26
# FixMe? The dispatch below seems overly complicated. One simplification could be to
27
27
# merge the two Cholesky types into one. It would remove the need for Val completely but
@@ -207,8 +207,8 @@ chol(x::Number, args...) = ((C, info) = _chol!(x, nothing); @assertposdef C info
207
207
208
208
# cholfact!. Destructive methods for computing Cholesky factorization of real symmetric
209
209
# or Hermitian matrix
210
- # # No pivoting
211
- function cholfact! (A:: RealHermSymComplexHerm , :: Type{Val{false}} )
210
+ # # No pivoting (default)
211
+ function cholfact! (A:: RealHermSymComplexHerm , :: Type{Val{false}} = Val{ false } )
212
212
if A. uplo == ' U'
213
213
CU, info = _chol! (A. data, UpperTriangular)
214
214
Cholesky (CU. data, ' U' , info)
220
220
221
221
# ## for StridedMatrices, check that matrix is symmetric/Hermitian
222
222
"""
223
- cholfact!(A, [uplo::Symbol,] Val{false}) -> Cholesky
223
+ cholfact!(A, Val{false}) -> Cholesky
224
224
225
225
The same as [`cholfact`](@ref), but saves space by overwriting the input `A`,
226
226
instead of creating a copy. An [`InexactError`](@ref) exception is thrown if
@@ -239,18 +239,9 @@ julia> cholfact!(A)
239
239
ERROR: InexactError()
240
240
```
241
241
"""
242
- function cholfact! (A:: StridedMatrix , uplo :: Symbol , :: Type{Val{false}} )
242
+ function cholfact! (A:: StridedMatrix , :: Type{Val{false}} = Val{ false })
243
243
ishermitian (A) || non_hermitian_error (" cholfact!" )
244
- return cholfact! (Hermitian (A, uplo), Val{false })
245
- end
246
-
247
- # ## Default to no pivoting (and storing of upper factor) when not explicit
248
- cholfact! (A:: RealHermSymComplexHerm ) = cholfact! (A, Val{false })
249
-
250
- # ### for StridedMatrices, check that matrix is symmetric/Hermitian
251
- function cholfact! (A:: StridedMatrix , uplo:: Symbol = :U )
252
- ishermitian (A) || non_hermitian_error (" cholfact!" )
253
- return cholfact! (Hermitian (A, uplo))
244
+ return cholfact! (Hermitian (A), Val{false })
254
245
end
255
246
256
247
@@ -270,37 +261,34 @@ cholfact!(A::RealHermSymComplexHerm{<:Real}, ::Type{Val{true}};
270
261
271
262
# ## for StridedMatrices, check that matrix is symmetric/Hermitian
272
263
"""
273
- cholfact!(A, [uplo::Symbol,] Val{true}; tol = 0.0) -> CholeskyPivoted
264
+ cholfact!(A, Val{true}; tol = 0.0) -> CholeskyPivoted
274
265
275
266
The same as [`cholfact`](@ref), but saves space by overwriting the input `A`,
276
267
instead of creating a copy. An [`InexactError`](@ref) exception is thrown if the
277
268
factorization produces a number not representable by the element type of `A`,
278
269
e.g. for integer types.
279
270
"""
280
- function cholfact! (A:: StridedMatrix , uplo :: Symbol , :: Type{Val{true}} ; tol = 0.0 )
271
+ function cholfact! (A:: StridedMatrix , :: Type{Val{true}} ; tol = 0.0 )
281
272
ishermitian (A) || non_hermitian_error (" cholfact!" )
282
- return cholfact! (Hermitian (A, uplo ), Val{true }; tol = tol)
273
+ return cholfact! (Hermitian (A), Val{true }; tol = tol)
283
274
end
284
275
285
276
# cholfact. Non-destructive methods for computing Cholesky factorization of real symmetric
286
277
# or Hermitian matrix
287
- # # No pivoting
288
- cholfact (A:: RealHermSymComplexHerm{<:Real,<:StridedMatrix} , :: Type{Val{false}} ) =
289
- cholfact! (copy_oftype (A, promote_type (typeof (chol (one (eltype (A)))),Float32)), Val{ false } )
278
+ # # No pivoting (default)
279
+ cholfact (A:: RealHermSymComplexHerm{<:Real,<:StridedMatrix} , :: Type{Val{false}} = Val{ false } ) =
280
+ cholfact! (copy_oftype (A, promote_type (typeof (chol (one (eltype (A)))),Float32)))
290
281
291
282
# ## for StridedMatrices, check that matrix is symmetric/Hermitian
292
283
"""
293
- cholfact(A, [uplo::Symbol,] Val{false}) -> Cholesky
284
+ cholfact(A, Val{false}) -> Cholesky
294
285
295
286
Compute the Cholesky factorization of a dense symmetric positive definite matrix `A`
296
287
and return a `Cholesky` factorization. The matrix `A` can either be a [`Symmetric`](@ref) or [`Hermitian`](@ref)
297
- `StridedMatrix` or a *perfectly* symmetric or Hermitian `StridedMatrix`. In the latter case,
298
- the optional argument `uplo` may be `:L` for using the lower part or `:U` for the upper part of `A`.
299
- The default is to use `:U`.
288
+ `StridedMatrix` or a *perfectly* symmetric or Hermitian `StridedMatrix`.
300
289
The triangular Cholesky factor can be obtained from the factorization `F` with: `F[:L]` and `F[:U]`.
301
290
The following functions are available for `Cholesky` objects: [`size`](@ref), [`\\ `](@ref),
302
291
[`inv`](@ref), and [`det`](@ref).
303
- A `PosDefException` exception is thrown in case the matrix is not positive definite.
304
292
305
293
# Example
306
294
@@ -331,18 +319,9 @@ julia> C[:L] * C[:U] == A
331
319
true
332
320
```
333
321
"""
334
- function cholfact (A:: StridedMatrix , uplo:: Symbol , :: Type{Val{false}} )
335
- ishermitian (A) || non_hermitian_error (" cholfact" )
336
- return cholfact (Hermitian (A, uplo), Val{false })
337
- end
338
-
339
- # ## Default to no pivoting (and storing of upper factor) when not explicit
340
- cholfact (A:: RealHermSymComplexHerm{<:Real,<:StridedMatrix} ) = cholfact (A, Val{false })
341
-
342
- # ### for StridedMatrices, check that matrix is symmetric/Hermitian
343
- function cholfact (A:: StridedMatrix , uplo:: Symbol = :U )
322
+ function cholfact (A:: StridedMatrix , :: Type{Val{false}} = Val{false })
344
323
ishermitian (A) || non_hermitian_error (" cholfact" )
345
- return cholfact (Hermitian (A, uplo ))
324
+ return cholfact (Hermitian (A))
346
325
end
347
326
348
327
@@ -353,22 +332,20 @@ cholfact(A::RealHermSymComplexHerm{<:Real,<:StridedMatrix}, ::Type{Val{true}}; t
353
332
354
333
# ## for StridedMatrices, check that matrix is symmetric/Hermitian
355
334
"""
356
- cholfact(A, [uplo::Symbol,] Val{true}; tol = 0.0) -> CholeskyPivoted
335
+ cholfact(A, Val{true}; tol = 0.0) -> CholeskyPivoted
357
336
358
337
Compute the pivoted Cholesky factorization of a dense symmetric positive semi-definite matrix `A`
359
338
and return a `CholeskyPivoted` factorization. The matrix `A` can either be a [`Symmetric`](@ref)
360
339
or [`Hermitian`](@ref) `StridedMatrix` or a *perfectly* symmetric or Hermitian `StridedMatrix`.
361
- In the latter case, the optional argument `uplo` may be `:L` for using the lower part or `:U`
362
- for the upper part of `A`. The default is to use `:U`.
363
340
The triangular Cholesky factor can be obtained from the factorization `F` with: `F[:L]` and `F[:U]`.
364
341
The following functions are available for `PivotedCholesky` objects:
365
342
[`size`](@ref), [`\\ `](@ref), [`inv`](@ref), [`det`](@ref), and [`rank`](@ref).
366
343
The argument `tol` determines the tolerance for determining the rank.
367
344
For negative values, the tolerance is the machine precision.
368
345
"""
369
- function cholfact (A:: StridedMatrix , uplo :: Symbol , :: Type{Val{true}} ; tol = 0.0 )
346
+ function cholfact (A:: StridedMatrix , :: Type{Val{true}} ; tol = 0.0 )
370
347
ishermitian (A) || non_hermitian_error (" cholfact" )
371
- return cholfact (Hermitian (A, uplo ), Val{true }; tol = tol)
348
+ return cholfact (Hermitian (A), Val{true }; tol = tol)
372
349
end
373
350
374
351
# # Number
0 commit comments