@@ -76,22 +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:: Union{Val{false}, Val{true}} = Val (true );
80
- check:: Bool = true ) where T<: BlasFloat
81
- if pivot === Val (false )
82
- return generic_lufact! (A, pivot; check = check)
83
- end
79
+ lu! (A:: StridedMatrix{<:BlasFloat} ; check:: Bool = true ) = lu! (A, RowMaximum (); check= check)
80
+ function lu! (A:: StridedMatrix{T} , :: RowMaximum ; check:: Bool = true ) where {T<: BlasFloat }
84
81
lpt = LAPACK. getrf! (A)
85
82
check && checknonsingular (lpt[3 ])
86
83
return LU {T,typeof(A)} (lpt[1 ], lpt[2 ], lpt[3 ])
87
84
end
88
- function lu! (A:: HermOrSym , pivot:: Union{Val{false}, Val{true}} = Val (true ); 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:: Union{RowMaximum,NoPivot} = RowMaximum (); check:: Bool = true )
89
89
copytri! (A. data, A. uplo, isa (A, Hermitian))
90
90
lu! (A. data, pivot; check = check)
91
91
end
92
+ # for backward compatibility
93
+ # TODO : remove towards Julia v2
94
+ @deprecate lu! (A:: Union{StridedMatrix,HermOrSym,Tridiagonal} , :: Val{true} ; check:: Bool = true ) lu! (A, RowMaximum (); check= check)
95
+ @deprecate lu! (A:: Union{StridedMatrix,HermOrSym,Tridiagonal} , :: Val{false} ; check:: Bool = true ) lu! (A, NoPivot (); check= check)
92
96
93
97
"""
94
- lu!(A, pivot=Val(true ); check = true) -> LU
98
+ lu!(A, pivot = RowMaximum( ); check = true) -> LU
95
99
96
100
`lu!` is the same as [`lu`](@ref), but saves space by overwriting the
97
101
input `A`, instead of creating a copy. An [`InexactError`](@ref)
@@ -127,19 +131,22 @@ Stacktrace:
127
131
[...]
128
132
```
129
133
"""
130
- lu! (A:: StridedMatrix , pivot:: Union{Val{false}, Val{true}} = Val ( true ); check:: Bool = true ) =
134
+ lu! (A:: StridedMatrix , pivot:: Union{RowMaximum,NoPivot} = RowMaximum ( ); check:: Bool = true ) =
131
135
generic_lufact! (A, pivot; check = check)
132
- function generic_lufact! (A:: StridedMatrix{T} , :: Val{Pivot} = Val (true );
133
- check:: Bool = true ) where {T,Pivot}
136
+ function generic_lufact! (A:: StridedMatrix{T} , pivot:: Union{RowMaximum,NoPivot} = RowMaximum ();
137
+ check:: Bool = true ) where {T}
138
+ # Extract values
134
139
m, n = size (A)
135
140
minmn = min (m,n)
141
+
142
+ # Initialize variables
136
143
info = 0
137
144
ipiv = Vector {BlasInt} (undef, minmn)
138
145
@inbounds begin
139
146
for k = 1 : minmn
140
147
# find index max
141
148
kp = k
142
- if Pivot && k < m
149
+ if pivot === RowMaximum () && k < m
143
150
amax = abs (A[k, k])
144
151
for i = k+ 1 : m
145
152
absi = abs (A[i,k])
@@ -175,7 +182,7 @@ function generic_lufact!(A::StridedMatrix{T}, ::Val{Pivot} = Val(true);
175
182
end
176
183
end
177
184
end
178
- check && checknonsingular (info, Val {Pivot} () )
185
+ check && checknonsingular (info, pivot )
179
186
return LU {T,typeof(A)} (A, ipiv, convert (BlasInt, info))
180
187
end
181
188
200
207
201
208
# for all other types we must promote to a type which is stable under division
202
209
"""
203
- lu(A, pivot=Val(true ); check = true) -> F::LU
210
+ lu(A, pivot = RowMaximum( ); check = true) -> F::LU
204
211
205
212
Compute the LU factorization of `A`.
206
213
@@ -211,7 +218,7 @@ validity (via [`issuccess`](@ref)) lies with the user.
211
218
In most cases, if `A` is a subtype `S` of `AbstractMatrix{T}` with an element
212
219
type `T` supporting `+`, `-`, `*` and `/`, the return type is `LU{T,S{T}}`. If
213
220
pivoting is chosen (default) the element type should also support [`abs`](@ref) and
214
- [`<`](@ref).
221
+ [`<`](@ref). Pivoting can be turned off by passing `pivot = NoPivot()`.
215
222
216
223
The individual components of the factorization `F` can be accessed via [`getproperty`](@ref):
217
224
@@ -267,11 +274,14 @@ julia> l == F.L && u == F.U && p == F.p
267
274
true
268
275
```
269
276
"""
270
- function lu (A:: AbstractMatrix{T} , pivot:: Union{Val{false}, Val{true}} = Val (true );
271
- check:: Bool = true ) where T
277
+ function lu (A:: AbstractMatrix{T} , pivot:: Union{RowMaximum,NoPivot} = RowMaximum (); check:: Bool = true ) where {T}
272
278
S = lutype (T)
273
279
lu! (copy_oftype (A, S), pivot; check = check)
274
280
end
281
+ # TODO : remove for Julia v2.0
282
+ @deprecate lu (A:: AbstractMatrix , :: Val{true} ; check:: Bool = true ) lu (A, RowMaximum (); check= check)
283
+ @deprecate lu (A:: AbstractMatrix , :: Val{false} ; check:: Bool = true ) lu (A, NoPivot (); check= check)
284
+
275
285
276
286
lu (S:: LU ) = S
277
287
function lu (x:: Number ; check:: Bool = true )
@@ -481,9 +491,11 @@ inv(A::LU{<:BlasFloat,<:StridedMatrix}) = inv!(copy(A))
481
491
# Tridiagonal
482
492
483
493
# See dgttrf.f
484
- function lu! (A:: Tridiagonal{T,V} , pivot:: Union{Val{false}, Val{true}} = Val ( true );
485
- check :: Bool = true ) where {T,V}
494
+ function lu! (A:: Tridiagonal{T,V} , pivot:: Union{RowMaximum,NoPivot} = RowMaximum (); check :: Bool = true ) where {T,V}
495
+ # Extract values
486
496
n = size (A, 1 )
497
+
498
+ # Initialize variables
487
499
info = 0
488
500
ipiv = Vector {BlasInt} (undef, n)
489
501
dl = A. dl
@@ -500,7 +512,7 @@ function lu!(A::Tridiagonal{T,V}, pivot::Union{Val{false}, Val{true}} = Val(true
500
512
end
501
513
for i = 1 : n- 2
502
514
# pivot or not?
503
- if pivot === Val ( false ) || abs (d[i]) >= abs (dl[i])
515
+ if pivot === NoPivot ( ) || abs (d[i]) >= abs (dl[i])
504
516
# No interchange
505
517
if d[i] != 0
506
518
fact = dl[i]/ d[i]
@@ -523,7 +535,7 @@ function lu!(A::Tridiagonal{T,V}, pivot::Union{Val{false}, Val{true}} = Val(true
523
535
end
524
536
if n > 1
525
537
i = n- 1
526
- if pivot === Val ( false ) || abs (d[i]) >= abs (dl[i])
538
+ if pivot === NoPivot ( ) || abs (d[i]) >= abs (dl[i])
527
539
if d[i] != 0
528
540
fact = dl[i]/ d[i]
529
541
dl[i] = fact
0 commit comments