-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Description
I am performing tests with the DescriptorSystems with versions of Julia starting with 1.2. The tests with Julia 1.2 fail with a message saying
MethodError: no method matching rdiv!(::Array{Float64,2}, ::LinearAlgebra.LU{Float64,Array{Float64,2}})
I reproduced the error message after I reinstalled version 1.2 and performed the following sequence:
using LinearAlgebra
a = rand(3,3);
b = rand(3,3);
F = lu(a);
ldiv!(F,b);
rdiv!(b,F);
ERROR: MethodError: no method matching rdiv!(::Array{Float64,2}, ::LU{Float64,Array{Float64,2}})
All other versions of Julia starting with 1.3 are working at this point. I wonder if this is an error or rdiv! is not implemented for factorizations such as LU or QR (I was able to find the code only for ldiv!, but rdiv! is documented). Compat.jl also does not provide a solution.
The missing code (taken from version 1.6) is:
function rdiv!(A::StridedVecOrMat, B::LU{<:Any,<:StridedMatrix})
rdiv!(rdiv!(A, UpperTriangular(B.factors)), UnitLowerTriangular(B.factors))
_apply_inverse_ipiv_cols!(B, A)
end
_apply_inverse_ipiv_cols!(A::LU, B::StridedVecOrMat) = _ipiv_cols!(A, length(A.ipiv) : -1 : 1, B)
function _ipiv_cols!(A::LU, order::OrdinalRange, B::StridedVecOrMat)
for i = order
if i != A.ipiv[i]
_swap_cols!(B, i, A.ipiv[i])
end
end
B
end
function _swap_cols!(B::StridedVector, i::Integer, j::Integer)
_swap_rows!(B, i, j)
end
function _swap_cols!(B::StridedMatrix, i::Integer, j::Integer)
for row = 1 : size(B, 1)
B[row,i], B[row,j] = B[row,j], B[row,i]
end
B
end
The overloaded code for rdiv! works apparently in version 1.2 too:
julia> rdiv!(a,lu(a))
3×3 Array{Float64,2}:
1.0 0.0 3.21456e-16
0.0 1.0 0.0
0.0 0.0 1.0
Metadata
Metadata
Assignees
Labels
No labels