@@ -566,18 +566,34 @@ end
566566# licensed under MIT "Expat".
567567# Specialize a method of `inv` for Matrix{Taylor1{T}}. Simply, avoid pivoting,
568568# since the polynomial field is not an ordered one.
569- function Base. inv (A:: StridedMatrix{Taylor1{T}} ) where T
570- checksquare (A)
571- S = Taylor1{typeof ((one (T)* zero (T) + one (T)* zero (T))/ one (T))}
572- AA = convert (AbstractArray{S}, A)
573- if istriu (AA)
574- Ai = triu! (parent (inv (UpperTriangular (AA))))
575- elseif istril (AA)
576- Ai = tril! (parent (inv (LowerTriangular (AA))))
569+ # function Base.inv(A::StridedMatrix{Taylor1{T}}) where T
570+ # checksquare(A)
571+ # S = Taylor1{typeof((one(T)*zero(T) + one(T)*zero(T))/one(T))}
572+ # AA = convert(AbstractArray{S}, A)
573+ # if istriu(AA)
574+ # Ai = triu!(parent(inv(UpperTriangular(AA))))
575+ # elseif istril(AA)
576+ # Ai = tril!(parent(inv(LowerTriangular(AA))))
577+ # else
578+ # # Do not use pivoting !!
579+ # Ai = inv!(lu(AA, Val(false)))
580+ # Ai = convert(typeof(parent(Ai)), Ai)
581+ # end
582+ # return Ai
583+ # end
584+
585+ # Adapted from (Julia v1.2) stdlib/v1.2/LinearAlgebra/src/lu.jl#240-253
586+ # and (Julia v1.4.0-dev) stdlib/LinearAlgebra/v1.4/src/lu.jl#270-274,
587+ # licensed under MIT "Expat".
588+ # Specialize a method of `lu` for Matrix{Taylor1{T}}, which avoids pivoting,
589+ # since the polynomial field is not an ordered one.
590+ # We can't assume an ordered field so we first try without pivoting
591+ function lu (A:: AbstractMatrix{Taylor1{T}} ; check:: Bool = true ) where T
592+ S = Taylor1{lutype (T)}
593+ F = lu! (copy_oftype (A, S), Val (false ); check = false )
594+ if issuccess (F)
595+ return F
577596 else
578- # Do not use pivoting !!
579- Ai = inv! (lu (AA, Val (false )))
580- Ai = convert (typeof (parent (Ai)), Ai)
597+ return lu! (copy_oftype (A, S), Val (true ); check = check)
581598 end
582- return Ai
583599end
0 commit comments