@@ -440,17 +440,32 @@ matrix_colors(A::Bidiagonal) = _cycle(1:2, Base.size(A, 2))
440440matrix_colors (A:: Union{Tridiagonal, SymTridiagonal} ) = _cycle (1 : 3 , Base. size (A, 2 ))
441441_cycle (repetend, len) = repeat (repetend, div (len, length (repetend)) + 1 )[1 : len]
442442
443- """
444- bunchkaufman_instance(A, pivot = LinearAlgebra.RowMaximum()) -> bunchkaufman_factorization_instance
445-
446- Returns an instance of the Bunch-Kaufman factorization object with the correct type
447- cheaply.
448- """
449- function bunchkaufman_instance (A:: Matrix{T} ) where T
450- return bunchkaufman (similar (A, 0 , 0 ), check = false )
451- end
452- function bunchkaufman_instance (A:: SparseMatrixCSC )
453- bunchkaufman (sparse (similar (A, 1 , 1 )), check = false )
443+ @static if VERSION > v " 1.9-"
444+ """
445+ bunchkaufman_instance(A, pivot = LinearAlgebra.RowMaximum()) -> bunchkaufman_factorization_instance
446+
447+ Returns an instance of the Bunch-Kaufman factorization object with the correct type
448+ cheaply.
449+ """
450+ function bunchkaufman_instance (A:: Matrix{T} ) where T
451+ return bunchkaufman (similar (A, 0 , 0 ), check = false )
452+ end
453+ function bunchkaufman_instance (A:: SparseMatrixCSC )
454+ bunchkaufman (sparse (similar (A, 1 , 1 )), check = false )
455+ end
456+ else
457+ """
458+ bunchkaufman_instance(A, pivot = LinearAlgebra.RowMaximum()) -> bunchkaufman_factorization_instance
459+
460+ Returns an instance of the Bunch-Kaufman factorization object with the correct type
461+ cheaply.
462+ """
463+ function bunchkaufman_instance (A:: Matrix{T} ) where T
464+ return bunchkaufman (similar (A, 0 , 0 ))
465+ end
466+ function bunchkaufman_instance (A:: SparseMatrixCSC )
467+ bunchkaufman (sparse (similar (A, 1 , 1 )))
468+ end
454469end
455470
456471"""
@@ -473,18 +488,34 @@ else
473488 const DEFAULT_CHOLESKY_PIVOT = LinearAlgebra. NoPivot ()
474489end
475490
476- """
477- cholesky_instance(A, pivot = LinearAlgebra.RowMaximum()) -> cholesky_factorization_instance
491+ @static if VERSION > v " 1.9-"
492+ """
493+ cholesky_instance(A, pivot = LinearAlgebra.RowMaximum()) -> cholesky_factorization_instance
478494
479- Returns an instance of the Cholesky factorization object with the correct type
480- cheaply.
481- """
482- function cholesky_instance (A:: Matrix{T} , pivot = DEFAULT_CHOLESKY_PIVOT) where {T}
483- return cholesky (similar (A, 0 , 0 ), pivot, check = false )
484- end
495+ Returns an instance of the Cholesky factorization object with the correct type
496+ cheaply.
497+ """
498+ function cholesky_instance (A:: Matrix{T} , pivot = DEFAULT_CHOLESKY_PIVOT) where {T}
499+ return cholesky (similar (A, 0 , 0 ), pivot, check = false )
500+ end
501+
502+ function cholesky_instance (A:: Union{SparseMatrixCSC,Symmetric{<:Number,<:SparseMatrixCSC}} , pivot = DEFAULT_CHOLESKY_PIVOT)
503+ cholesky (sparse (similar (A, 1 , 1 )), check = false )
504+ end
505+ else
506+ """
507+ cholesky_instance(A, pivot = LinearAlgebra.RowMaximum()) -> cholesky_factorization_instance
508+
509+ Returns an instance of the Cholesky factorization object with the correct type
510+ cheaply.
511+ """
512+ function cholesky_instance (A:: Matrix{T} , pivot = DEFAULT_CHOLESKY_PIVOT) where {T}
513+ return cholesky (similar (A, 0 , 0 ), pivot)
514+ end
485515
486- function cholesky_instance (A:: Union{SparseMatrixCSC,Symmetric{<:Number,<:SparseMatrixCSC}} , pivot = DEFAULT_CHOLESKY_PIVOT)
487- cholesky (sparse (similar (A, 1 , 1 )), check = false )
516+ function cholesky_instance (A:: Union{SparseMatrixCSC,Symmetric{<:Number,<:SparseMatrixCSC}} , pivot = DEFAULT_CHOLESKY_PIVOT)
517+ cholesky (sparse (similar (A, 1 , 1 )))
518+ end
488519end
489520
490521"""
@@ -494,13 +525,23 @@ Returns the number.
494525"""
495526cholesky_instance (a:: Number , pivot = DEFAULT_CHOLESKY_PIVOT) = a
496527
497- """
498- cholesky_instance(a::Any, pivot = LinearAlgebra.RowMaximum()) -> cholesky(a, check=false)
499-
500- Slow fallback which gets the instance via factorization. Should get
501- specialized for new matrix types.
502- """
503- cholesky_instance (a:: Any , pivot = DEFAULT_CHOLESKY_PIVOT) = cholesky (a, pivot, check = false )
528+ @static if VERSION > v " 1.9-"
529+ """
530+ cholesky_instance(a::Any, pivot = LinearAlgebra.RowMaximum()) -> cholesky(a, check=false)
531+
532+ Slow fallback which gets the instance via factorization. Should get
533+ specialized for new matrix types.
534+ """
535+ cholesky_instance (a:: Any , pivot = DEFAULT_CHOLESKY_PIVOT) = cholesky (a, pivot, check = false )
536+ else
537+ """
538+ cholesky_instance(a::Any, pivot = LinearAlgebra.RowMaximum()) -> cholesky(a, check=false)
539+
540+ Slow fallback which gets the instance via factorization. Should get
541+ specialized for new matrix types.
542+ """
543+ cholesky_instance (a:: Any , pivot = DEFAULT_CHOLESKY_PIVOT) = cholesky (a, pivot)
544+ end
504545
505546"""
506547ldlt_instance(A) -> ldlt_factorization_instance
@@ -511,8 +552,15 @@ cheaply.
511552function ldlt_instance (A:: Matrix{T} ) where {T}
512553 return ldlt (SymTridiagonal (similar (A, 0 , 0 )))
513554end
514- function ldlt_instance (A:: SparseMatrixCSC )
515- ldlt (sparse (similar (A, 1 , 1 )), check= false )
555+
556+ @static if VERSION > v " 1.9-"
557+ function ldlt_instance (A:: SparseMatrixCSC )
558+ ldlt (sparse (similar (A, 1 , 1 )), check= false )
559+ end
560+ else
561+ function ldlt_instance (A:: SparseMatrixCSC )
562+ ldlt (sparse (similar (A, 1 , 1 )))
563+ end
516564end
517565
518566"""
@@ -565,13 +613,23 @@ Returns the number.
565613"""
566614lu_instance (a:: Number ) = a
567615
568- """
616+ @static if VERSION > v " 1.9-"
617+ """
618+ lu_instance(a::Any) -> lu(a, check=false)
619+
620+ Slow fallback which gets the instance via factorization. Should get
621+ specialized for new matrix types.
622+ """
623+ lu_instance (a:: Any ) = lu (a, check = false )
624+ else
625+ """
569626 lu_instance(a::Any) -> lu(a, check=false)
570627
571- Slow fallback which gets the instance via factorization. Should get
572- specialized for new matrix types.
573- """
574- lu_instance (a:: Any ) = lu (a, check = false )
628+ Slow fallback which gets the instance via factorization. Should get
629+ specialized for new matrix types.
630+ """
631+ lu_instance (a:: Any ) = lu (a)
632+ end
575633
576634"""
577635 qr_instance(A) -> qr_factorization_instance
0 commit comments