@@ -306,21 +306,25 @@ function materialize!(M::Rmul{<:Any,<:AdjQRPackedQLayout})
306
306
end
307
307
308
308
309
- __qr (layout, lengths, A; kwds... ) = invoke (qr, Tuple{AbstractMatrix{eltype (A)}}, A; kwds... )
310
- _qr (layout, axes, A; kwds... ) = __qr (layout, map (length, axes), A; kwds... )
311
- _qr (layout, axes, A, pivot:: P ; kwds... ) where P = invoke (qr, Tuple{AbstractMatrix{eltype (A)},P}, A, pivot; kwds... )
312
- _qr! (layout, axes, A, args... ; kwds... ) = error (LazyString (" Overload _qr!(::" , typeof (layout), " , axes, A)" ))
313
- _lu (layout, axes, A; kwds... ) = invoke (lu, Tuple{AbstractMatrix{eltype (A)}}, A; kwds... )
314
- _lu (layout, axes, A, pivot:: P ; kwds... ) where P = invoke (lu, Tuple{AbstractMatrix{eltype (A)},P}, A, pivot; kwds... )
315
- _lu! (layout, axes, A, args... ; kwds... ) = error (LazyString (" Overload _lu!(::" , typeof (layout), " , axes, A)" ))
316
- _cholesky (layout, axes, A, :: CNoPivot = CNoPivot (); check:: Bool = true ) = cholesky! (cholcopy (A); check = check)
317
- _cholesky (layout, axes, A, :: CRowMaximum ; tol = 0.0 , check:: Bool = true ) = cholesky! (cholcopy (A), CRowMaximum (); tol = tol, check = check)
318
- _factorize (layout, axes, A) = qr (A) # Default to QR
319
-
320
-
321
- _factorize (:: AbstractStridedLayout , axes, A) = lu (A)
309
+
310
+ _qr_layout (layout, lengths, A; kwds... ) = invoke (qr, Tuple{AbstractMatrix{eltype (A)}}, A; kwds... )
311
+ qr_layout (layout, axes, A; kwds... ) = _qr_layout (layout, map (length, axes), A; kwds... )
312
+ qr_layout (layout, axes, A, pivot:: P ; kwds... ) where P = invoke (qr, Tuple{AbstractMatrix{eltype (A)},P}, A, pivot; kwds... )
313
+ qr!_layout (layout, axes, A, args... ; kwds... ) = error (LazyString (" Overload qr!_layout(::" , typeof (layout), " , axes, A)" ))
314
+ lu_layout (layout, axes, A; kwds... ) = invoke (lu, Tuple{AbstractMatrix{eltype (A)}}, A; kwds... )
315
+ lu_layout (layout, axes, A, pivot:: P ; kwds... ) where P = invoke (lu, Tuple{AbstractMatrix{eltype (A)},P}, A, pivot; kwds... )
316
+ lu!_layout (layout, axes, A, args... ; kwds... ) = error (LazyString (" Overload lu!_layout(::" , typeof (layout), " , axes, A)" ))
317
+ cholesky_layout (layout, axes, A, :: CNoPivot = CNoPivot (); check:: Bool = true ) = cholesky! (cholcopy (A); check = check)
318
+ cholesky_layout (layout, axes, A, :: CRowMaximum ; tol = 0.0 , check:: Bool = true ) = cholesky! (cholcopy (A), CRowMaximum (); tol = tol, check = check)
319
+
320
+
321
+
322
+ factorize_layout (layout, axes, A) = qr (A) # Default to QR
323
+
324
+
325
+ factorize_layout (:: AbstractStridedLayout , axes, A) = lu (A)
322
326
if VERSION < v " 1.8-"
323
- function _lu! (:: AbstractColumnMajor , axes, A:: AbstractMatrix{T} , pivot:: Union{NoPivot, RowMaximum} = RowMaximum ();
327
+ function lu!_layout (:: AbstractColumnMajor , axes, A:: AbstractMatrix{T} , pivot:: Union{NoPivot, RowMaximum} = RowMaximum ();
324
328
check:: Bool = true ) where T<: BlasFloat
325
329
if pivot === NoPivot ()
326
330
return generic_lufact! (A, pivot; check = check)
@@ -330,7 +334,7 @@ if VERSION < v"1.8-"
330
334
return LU {T,typeof(A)} (lpt[1 ], lpt[2 ], lpt[3 ])
331
335
end
332
336
else
333
- function _lu! (:: AbstractColumnMajor , axes, A:: AbstractMatrix{T} , pivot:: Union{NoPivot, RowMaximum} = RowMaximum ();
337
+ function lu!_layout (:: AbstractColumnMajor , axes, A:: AbstractMatrix{T} , pivot:: Union{NoPivot, RowMaximum} = RowMaximum ();
334
338
check:: Bool = true ) where T<: BlasFloat
335
339
if pivot === NoPivot ()
336
340
return generic_lufact! (A, pivot; check = check)
@@ -375,13 +379,13 @@ end
375
379
376
380
_chol! (_, A, UL) = LinearAlgebra. _chol! (A, UL)
377
381
378
- function _cholesky! (layout, axes, A:: RealHermSymComplexHerm , :: CNoPivot ; check:: Bool = true )
382
+ function cholesky!_layout (layout, axes, A:: RealHermSymComplexHerm , :: CNoPivot ; check:: Bool = true )
379
383
C, info = _chol! (layout, A. data, A. uplo == ' U' ? UpperTriangular : LowerTriangular)
380
384
check && LinearAlgebra. checkpositivedefinite (info)
381
385
return Cholesky (C. data, A. uplo, info)
382
386
end
383
387
384
- function _cholesky! (:: SymmetricLayout{<:AbstractColumnMajor} , axes, A:: AbstractMatrix{<:BlasReal} ,
388
+ function cholesky!_layout (:: SymmetricLayout{<:AbstractColumnMajor} , axes, A:: AbstractMatrix{<:BlasReal} ,
385
389
:: CRowMaximum ; tol = 0.0 , check:: Bool = true )
386
390
AA, piv, rank, info = LAPACK. pstrf! (A. uplo, A. data, tol)
387
391
if VERSION < v " 1.8"
@@ -401,7 +405,7 @@ function _inv_eye(A, ::Type{T}, (rows,cols)) where T
401
405
dest
402
406
end
403
407
404
- function _inv (layout, axes, A)
408
+ function inv_layout (layout, axes, A)
405
409
T = eltype (A)
406
410
(rows,cols) = axes
407
411
n = checksquare (A)
@@ -414,17 +418,17 @@ end
414
418
415
419
macro _layoutfactorizations (Typ)
416
420
esc (quote
417
- LinearAlgebra. cholesky (A:: $Typ , v:: ArrayLayouts.CNoPivot = ArrayLayouts. CNoPivot (); kwds... ) = ArrayLayouts. _cholesky (ArrayLayouts. MemoryLayout (A), axes (A), A, v; kwds... )
418
- LinearAlgebra. cholesky (A:: $Typ , v:: ArrayLayouts.CRowMaximum ; kwds... ) = ArrayLayouts. _cholesky (ArrayLayouts. MemoryLayout (A), axes (A), A, v; kwds... )
419
- LinearAlgebra. cholesky! (A:: LinearAlgebra.RealHermSymComplexHerm{<:Real,<:$Typ} , v:: ArrayLayouts.CNoPivot = ArrayLayouts. CNoPivot (); check:: Bool = true ) = ArrayLayouts. _cholesky! (ArrayLayouts. MemoryLayout (A), axes (A), A, v; check= check)
420
- LinearAlgebra. cholesky! (A:: LinearAlgebra.RealHermSymComplexHerm{<:Real,<:$Typ} , v:: ArrayLayouts.CRowMaximum ; check:: Bool = true , tol = 0.0 ) = ArrayLayouts. _cholesky! (ArrayLayouts. MemoryLayout (A), axes (A), A, v; check= check, tol= tol)
421
- LinearAlgebra. qr (A:: $Typ , args... ; kwds... ) = ArrayLayouts. _qr (ArrayLayouts. MemoryLayout (A), axes (A), A, args... ; kwds... )
422
- LinearAlgebra. qr! (A:: $Typ , args... ; kwds... ) = ArrayLayouts. _qr! (ArrayLayouts. MemoryLayout (A), axes (A), A, args... ; kwds... )
423
- LinearAlgebra. lu (A:: $Typ , pivot:: Union{ArrayLayouts.NoPivot,ArrayLayouts.RowMaximum} ; kwds... ) = ArrayLayouts. _lu (ArrayLayouts. MemoryLayout (A), axes (A), A, pivot; kwds... )
424
- LinearAlgebra. lu (A:: $Typ{T} ; kwds... ) where T = ArrayLayouts. _lu (ArrayLayouts. MemoryLayout (A), axes (A), A; kwds... )
425
- LinearAlgebra. lu! (A:: $Typ , args... ; kwds... ) = ArrayLayouts. _lu! (ArrayLayouts. MemoryLayout (A), axes (A), A, args... ; kwds... )
426
- LinearAlgebra. factorize (A:: $Typ ) = ArrayLayouts. _factorize (ArrayLayouts. MemoryLayout (A), axes (A), A)
427
- Base. inv (A:: $Typ ) = ArrayLayouts. _inv (ArrayLayouts. MemoryLayout (A), axes (A), A)
421
+ LinearAlgebra. cholesky (A:: $Typ , v:: ArrayLayouts.CNoPivot = ArrayLayouts. CNoPivot (); kwds... ) = ArrayLayouts. cholesky_layout (ArrayLayouts. MemoryLayout (A), axes (A), A, v; kwds... )
422
+ LinearAlgebra. cholesky (A:: $Typ , v:: ArrayLayouts.CRowMaximum ; kwds... ) = ArrayLayouts. cholesky_layout (ArrayLayouts. MemoryLayout (A), axes (A), A, v; kwds... )
423
+ LinearAlgebra. cholesky! (A:: LinearAlgebra.RealHermSymComplexHerm{<:Real,<:$Typ} , v:: ArrayLayouts.CNoPivot = ArrayLayouts. CNoPivot (); check:: Bool = true ) = ArrayLayouts. cholesky!_layout (ArrayLayouts. MemoryLayout (A), axes (A), A, v; check= check)
424
+ LinearAlgebra. cholesky! (A:: LinearAlgebra.RealHermSymComplexHerm{<:Real,<:$Typ} , v:: ArrayLayouts.CRowMaximum ; check:: Bool = true , tol = 0.0 ) = ArrayLayouts. cholesky!_layout (ArrayLayouts. MemoryLayout (A), axes (A), A, v; check= check, tol= tol)
425
+ LinearAlgebra. qr (A:: $Typ , args... ; kwds... ) = ArrayLayouts. qr_layout (ArrayLayouts. MemoryLayout (A), axes (A), A, args... ; kwds... )
426
+ LinearAlgebra. qr! (A:: $Typ , args... ; kwds... ) = ArrayLayouts. qr!_layout (ArrayLayouts. MemoryLayout (A), axes (A), A, args... ; kwds... )
427
+ LinearAlgebra. lu (A:: $Typ , pivot:: Union{ArrayLayouts.NoPivot,ArrayLayouts.RowMaximum} ; kwds... ) = ArrayLayouts. lu_layout (ArrayLayouts. MemoryLayout (A), axes (A), A, pivot; kwds... )
428
+ LinearAlgebra. lu (A:: $Typ{T} ; kwds... ) where T = ArrayLayouts. lu_layout (ArrayLayouts. MemoryLayout (A), axes (A), A; kwds... )
429
+ LinearAlgebra. lu! (A:: $Typ , args... ; kwds... ) = ArrayLayouts. lu!_layout (ArrayLayouts. MemoryLayout (A), axes (A), A, args... ; kwds... )
430
+ LinearAlgebra. factorize (A:: $Typ ) = ArrayLayouts. factorize_layout (ArrayLayouts. MemoryLayout (A), axes (A), A)
431
+ Base. inv (A:: $Typ ) = ArrayLayouts. inv_layout (ArrayLayouts. MemoryLayout (A), axes (A), A)
428
432
LinearAlgebra. ldiv! (L:: LU{<:Any,<:$Typ} , B) = ArrayLayouts. ldiv! (L, B)
429
433
LinearAlgebra. ldiv! (L:: LU{<:Any,<:$Typ} , B:: $Typ ) = ArrayLayouts. ldiv! (L, B)
430
434
end )
@@ -434,11 +438,20 @@ macro layoutfactorizations(Typ)
434
438
esc (quote
435
439
ArrayLayouts. @_layoutfactorizations $ Typ
436
440
ArrayLayouts. @_layoutfactorizations SubArray{<: Any ,2 ,<: $Typ }
437
- ArrayLayouts. @_layoutfactorizations LinearAlgebra. RealHermSymComplexHerm{<: Real ,<: $Typ }
438
- ArrayLayouts. @_layoutfactorizations LinearAlgebra. RealHermSymComplexHerm{<: Real ,<: SubArray{<:Real,2,<:$Typ} }
441
+ ArrayLayouts. @_layoutfactorizations ArrayLayouts. RealHermSymComplexHerm{<: Real ,<: $Typ }
442
+ ArrayLayouts. @_layoutfactorizations ArrayLayouts. RealHermSymComplexHerm{<: Real ,<: SubArray{<:Real,2,<:$Typ} }
443
+ ArrayLayouts. @_layoutfactorizations ArrayLayouts. LowerTriangular{<: Any ,<: $Typ }
444
+ ArrayLayouts. @_layoutfactorizations ArrayLayouts. LowerTriangular{<: Any ,<: SubArray{<:Any,2,<:$Typ} }
445
+ ArrayLayouts. @_layoutfactorizations ArrayLayouts. UpperTriangular{<: Any ,<: $Typ }
446
+ ArrayLayouts. @_layoutfactorizations ArrayLayouts. UpperTriangular{<: Any ,<: SubArray{<:Any,2,<:$Typ} }
447
+ ArrayLayouts. @_layoutfactorizations ArrayLayouts. UnitLowerTriangular{<: Any ,<: $Typ }
448
+ ArrayLayouts. @_layoutfactorizations ArrayLayouts. UnitLowerTriangular{<: Any ,<: SubArray{<:Any,2,<:$Typ} }
449
+ ArrayLayouts. @_layoutfactorizations ArrayLayouts. UnitUpperTriangular{<: Any ,<: $Typ }
450
+ ArrayLayouts. @_layoutfactorizations ArrayLayouts. UnitUpperTriangular{<: Any ,<: SubArray{<:Any,2,<:$Typ} }
439
451
end )
440
452
end
441
453
454
+
442
455
function ldiv! (C:: Cholesky{<:Any,<:AbstractMatrix} , B:: LayoutArray )
443
456
if C. uplo == ' L'
444
457
return ldiv! (adjoint (LowerTriangular (C. factors)), ldiv! (LowerTriangular (C. factors), B))
449
462
450
463
LinearAlgebra. ldiv! (L:: LU{<:Any,<:LayoutMatrix} , B:: LayoutVector ) = ArrayLayouts. ldiv! (L, B)
451
464
465
+
466
+
467
+ # for back compatibility, TODO : deprecate
468
+ const _factorize = factorize_layout
469
+ const __qr = _qr_layout
470
+ const _qr = qr_layout
471
+ const _qr! = qr!_layout
472
+ const _lu = lu_layout
473
+ const _cholesky = cholesky_layout
474
+ const _cholesky! = cholesky!_layout
475
+ const _lu! = lu!_layout
476
+ const _inv = inv_layout
0 commit comments