@@ -515,6 +515,10 @@ Compute a KLU sparse LU factorization.
515515- `fully_preallocated = nothing`: select automatic workspace preallocation;
516516 pass `true` or `false` to override it.
517517- `detect_banded = true`: detect narrow BTF blocks and use natural ordering.
518+ - `tol = 0.001`: Pivot on a column's diagonal instead of largest entry if it is
519+ at least `tol` times larger in magnitude. Set `tol = 1.0` for partial pivoting,
520+ and `tol = 0.0` to always use the diagonal. Only applies to the numeric
521+ factorization; `klu!` reuses the existing pivot ordering.
518522
519523# Returns
520524- A `KLUFactorization` that implements `LinearAlgebra.Factorization`.
@@ -536,11 +540,12 @@ function klu(
536540 check:: Bool = true , allowsingular:: Bool = false ,
537541 full_factor:: Bool = true , use_fma = true ,
538542 fully_preallocated:: Union{Bool, Nothing} = nothing ,
539- detect_banded:: Bool = true ,
543+ detect_banded:: Bool = true , tol :: Float64 = 0.001 ,
540544 ) where {Ti <: KLUITypes , Tv <: KLUGenericTypes }
541545 K = KLUFactorization (n, colptr, rowval, nzval)
542546 K. common. use_fma = _as_val (use_fma)
543547 K. common. detect_banded = detect_banded
548+ K. common. tol = tol
544549 if fully_preallocated isa Bool
545550 K. common. fully_preallocated = fully_preallocated
546551 return full_factor ? klu_factor! (K; check, allowsingular) : klu_analyze! (K; check)
@@ -554,13 +559,14 @@ function klu(
554559 A:: SparseMatrixCSC{Tv, Ti} ; check:: Bool = true ,
555560 allowsingular:: Bool = false , full_factor:: Bool = true ,
556561 use_fma = true , fully_preallocated:: Union{Bool, Nothing} = nothing ,
557- detect_banded:: Bool = true ,
562+ detect_banded:: Bool = true , tol :: Float64 = 0.001 ,
558563 ) where {Tv <: KLUGenericTypes , Ti <: KLUITypes }
559564 n = size (A, 1 )
560565 n == size (A, 2 ) || throw (DimensionMismatch ())
561566 return klu (
562567 n, decrement (A. colptr), decrement (A. rowval), A. nzval;
563- check, allowsingular, full_factor, use_fma, fully_preallocated, detect_banded
568+ check, allowsingular, full_factor, use_fma, fully_preallocated,
569+ detect_banded, tol
564570 )
565571end
566572
0 commit comments