File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -202,8 +202,21 @@ function LinearAlgebra.lu(A::MtlMatrix{T}; check::Bool = true) where {T<:MtlFloa
202202 return LinearAlgebra. LU (B, p, status)
203203end
204204
205+ function _check_lu_success (info, allowsingular)
206+ if VERSION >= v " 1.11.0-DEV.1535"
207+ if info < 0 # zero pivot error from unpivoted LU
208+ LinearAlgebra. checknozeropivot (- info)
209+ else
210+ allowsingular || LinearAlgebra. checknonsingular (info)
211+ end
212+ else
213+ LinearAlgebra. checknonsingular (info)
214+ end
215+ end
216+
205217# TODO : dispatch on pivot strategy
206- function LinearAlgebra. lu! (A:: MtlMatrix{T} ; check:: Bool = true ) where {T<: MtlFloat }
218+ function LinearAlgebra. lu! (A:: MtlMatrix{T} ;
219+ check:: Bool = true , allowsingular:: Bool = false ) where {T<: MtlFloat }
207220 M,N = size (A)
208221 dev = current_device ()
209222 queue = global_queue (dev)
@@ -238,7 +251,7 @@ function LinearAlgebra.lu!(A::MtlMatrix{T}; check::Bool = true) where {T<:MtlFlo
238251 wait_completed (cmdbuf_lu)
239252
240253 status = convert (LinearAlgebra. BlasInt, Metal. @allowscalar status[])
241- check && checknonsingular (status)
254+ check && _check_lu_success (status, allowsingular )
242255
243256 return LinearAlgebra. LU (A, p, status)
244257end
You can’t perform that action at this time.
0 commit comments