@@ -76,28 +76,26 @@ adjoint(F::LU) = Adjoint(F)
76
76
transpose (F:: LU ) = Transpose (F)
77
77
78
78
# StridedMatrix
79
- function lu! (A:: StridedMatrix{T} , pivot:: Symbol = :rowmax ; check:: Bool = true ) where {T<: BlasFloat }
80
- if pivot === :none
81
- return generic_lufact! (A, pivot; check = check)
82
- elseif pivot === :rowmax
83
- lpt = LAPACK. getrf! (A)
84
- check && checknonsingular (lpt[3 ])
85
- return LU {T,typeof(A)} (lpt[1 ], lpt[2 ], lpt[3 ])
86
- else
87
- throw (ArgumentError (" only `:rowmax` and `:none` are supported as `pivot` argument but you supplied `$pivot `" ))
88
- end
79
+ lu! (A:: StridedMatrix{<:BlasFloat} ; check:: Bool = true ) = lu! (A, RowMax (); check= check)
80
+ function lu! (A:: StridedMatrix{T} , :: RowMax ; check:: Bool = true ) where {T<: BlasFloat }
81
+ lpt = LAPACK. getrf! (A)
82
+ check && checknonsingular (lpt[3 ])
83
+ return LU {T,typeof(A)} (lpt[1 ], lpt[2 ], lpt[3 ])
89
84
end
90
- function lu! (A:: HermOrSym , pivot:: Symbol = :rowmax ; check:: Bool = true )
85
+ function lu! (A:: StridedMatrix{<:BlasFloat} , pivot:: NoPivot ; check:: Bool = true )
86
+ return generic_lufact! (A, pivot; check = check)
87
+ end
88
+ function lu! (A:: HermOrSym , pivot:: PivotingStrategy = RowMax (); check:: Bool = true )
91
89
copytri! (A. data, A. uplo, isa (A, Hermitian))
92
90
lu! (A. data, pivot; check = check)
93
91
end
94
92
# for backward compatibility
95
93
# TODO : remove towards Julia v2
96
- @deprecate lu! (A:: Union{StridedMatrix,HermOrSym,Tridiagonal} , :: Val{true} ; check:: Bool = true ) lu! (A, :rowmax ; check= check)
97
- @deprecate lu! (A:: Union{StridedMatrix,HermOrSym,Tridiagonal} , :: Val{false} ; check:: Bool = true ) lu! (A, :none ; check= check)
94
+ @deprecate lu! (A:: Union{StridedMatrix,HermOrSym,Tridiagonal} , :: Val{true} ; check:: Bool = true ) lu! (A, RowMax () ; check= check)
95
+ @deprecate lu! (A:: Union{StridedMatrix,HermOrSym,Tridiagonal} , :: Val{false} ; check:: Bool = true ) lu! (A, NoPivot () ; check= check)
98
96
99
97
"""
100
- lu!(A, pivot = :rowmax ; check = true) -> LU
98
+ lu!(A, pivot = RowMax() ; check = true) -> LU
101
99
102
100
`lu!` is the same as [`lu`](@ref), but saves space by overwriting the
103
101
input `A`, instead of creating a copy. An [`InexactError`](@ref)
@@ -133,26 +131,26 @@ Stacktrace:
133
131
[...]
134
132
```
135
133
"""
136
- lu! (A:: StridedMatrix , pivot:: Symbol = :rowmax ; check:: Bool = true ) =
134
+ lu! (A:: StridedMatrix , pivot:: PivotingStrategy = RowMax () ; check:: Bool = true ) =
137
135
generic_lufact! (A, pivot; check = check)
138
- function generic_lufact! (A:: StridedMatrix{T} , pivot = :rowmax ; check:: Bool = true ) where T
139
- # Check arguments
140
- if pivot != = :rowmax && pivot != = :none
141
- throw (ArgumentError (" only `rowmax` and `none` are supported as `pivot` argument but you supplied `$pivot `" ))
142
- end
143
-
136
+ function generic_lufact! (A:: StridedMatrix{T} , pivot:: PivotingStrategy = RowMax ();
137
+ check:: Bool = true ) where {T}
144
138
# Extract values
145
139
m, n = size (A)
146
140
minmn = min (m,n)
147
141
142
+ if pivot != = RowMax () && pivot != = NoPivot ()
143
+ throw (ArgumentError (" only `RowMax()` and `NoPivot()` are supported as `pivot` argument but you supplied `$pivot `" ))
144
+ end
145
+
148
146
# Initialize variables
149
147
info = 0
150
148
ipiv = Vector {BlasInt} (undef, minmn)
151
149
@inbounds begin
152
150
for k = 1 : minmn
153
151
# find index max
154
152
kp = k
155
- if pivot === :rowmax && k < m
153
+ if pivot === RowMax () && k < m
156
154
amax = abs (A[k, k])
157
155
for i = k+ 1 : m
158
156
absi = abs (A[i,k])
213
211
214
212
# for all other types we must promote to a type which is stable under division
215
213
"""
216
- lu(A, pivot = :rowmax ; check = true) -> F::LU
214
+ lu(A, pivot = RowMax() ; check = true) -> F::LU
217
215
218
216
Compute the LU factorization of `A`.
219
217
@@ -224,7 +222,7 @@ validity (via [`issuccess`](@ref)) lies with the user.
224
222
In most cases, if `A` is a subtype `S` of `AbstractMatrix{T}` with an element
225
223
type `T` supporting `+`, `-`, `*` and `/`, the return type is `LU{T,S{T}}`. If
226
224
pivoting is chosen (default) the element type should also support [`abs`](@ref) and
227
- [`<`](@ref). Pivoting can be turned off by passing `pivot = :none `.
225
+ [`<`](@ref). Pivoting can be turned off by passing `pivot = NoPivot() `.
228
226
229
227
The individual components of the factorization `F` can be accessed via [`getproperty`](@ref):
230
228
@@ -280,13 +278,13 @@ julia> l == F.L && u == F.U && p == F.p
280
278
true
281
279
```
282
280
"""
283
- function lu (A:: AbstractMatrix{T} , pivot:: Symbol = :rowmax ; check:: Bool = true ) where {T}
281
+ function lu (A:: AbstractMatrix{T} , pivot:: PivotingStrategy = RowMax () ; check:: Bool = true ) where {T}
284
282
S = lutype (T)
285
283
lu! (copy_oftype (A, S), pivot; check = check)
286
284
end
287
285
# TODO : remove for Julia v2.0
288
- @deprecate lu (A:: AbstractMatrix , :: Val{true} ; check:: Bool = true ) lu (A, :rowmax ; check= check)
289
- @deprecate lu (A:: AbstractMatrix , :: Val{false} ; check:: Bool = true ) lu (A, :none ; check= check)
286
+ @deprecate lu (A:: AbstractMatrix , :: Val{true} ; check:: Bool = true ) lu (A, RowMax () ; check= check)
287
+ @deprecate lu (A:: AbstractMatrix , :: Val{false} ; check:: Bool = true ) lu (A, NoPivot () ; check= check)
290
288
291
289
292
290
lu (S:: LU ) = S
@@ -497,13 +495,12 @@ inv(A::LU{<:BlasFloat,<:StridedMatrix}) = inv!(copy(A))
497
495
# Tridiagonal
498
496
499
497
# See dgttrf.f
500
- function lu! (A:: Tridiagonal{T,V} , pivot:: Symbol = :rowmax ; check:: Bool = true ) where {T,V}
498
+ function lu! (A:: Tridiagonal{T,V} , pivot:: PivotingStrategy = RowMax () ; check:: Bool = true ) where {T,V}
501
499
# Extract values
502
500
n = size (A, 1 )
503
501
504
- # Check arguments
505
- if pivot != = :rowmax && pivot != = :none
506
- throw (ArgumentError (" only `:row` and `:none` are supported as `pivot` argument but you supplied `$pivot `" ))
502
+ if pivot != = RowMax () && pivot != = NoPivot ()
503
+ throw (ArgumentError (" only `RowMax()` and `NoPivot()` are supported as `pivot` argument but you supplied `$pivot `" ))
507
504
end
508
505
509
506
# Initialize variables
@@ -523,7 +520,7 @@ function lu!(A::Tridiagonal{T,V}, pivot::Symbol = :rowmax; check::Bool = true) w
523
520
end
524
521
for i = 1 : n- 2
525
522
# pivot or not?
526
- if pivot === :none || abs (d[i]) >= abs (dl[i])
523
+ if pivot === NoPivot () || abs (d[i]) >= abs (dl[i])
527
524
# No interchange
528
525
if d[i] != 0
529
526
fact = dl[i]/ d[i]
@@ -546,7 +543,7 @@ function lu!(A::Tridiagonal{T,V}, pivot::Symbol = :rowmax; check::Bool = true) w
546
543
end
547
544
if n > 1
548
545
i = n- 1
549
- if pivot === :none || abs (d[i]) >= abs (dl[i])
546
+ if pivot === NoPivot () || abs (d[i]) >= abs (dl[i])
550
547
if d[i] != 0
551
548
fact = dl[i]/ d[i]
552
549
dl[i] = fact
0 commit comments