You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Matrix multiplication is apparently not currently defined for BlockSkyLineMatrix and BandedMatrix even when dimensions should be compatible (i.e m x n array times n x k array).
Not entirely sure if this belongs in BandedMatrices or BlockBandedMatrices but I tend towards the latter so I'll put this here for now.
Here's a simple snippet that reproduces the error:
using BandedMatrices, BlockBandedMatrices
# generate some simple arrays
function M1(N::Integer)
M = BlockBandedMatrix(Zeros(sum(1:N),N), (1:N,Ones{Int}(N)), (0,0))
for n=1:N
for j=1:n
view(M, Block(n,n))[j,1] = 1.
end
end
return M
end
function M2(N::Integer)
M=BandedMatrix{Float64}(undef, (N, N), (0,1))
for n=1:N-1
M[n,n]=1.
M[n,n+1]=1.
end
M[N,N]=1.
return M
end
# works as intended, 55x10 * 10x10 * 10x1 array gives 55x1 array
N = 10
M1(N)
M2(N)
testvec = Ones(N,1)
M1(N)*(M2(N)*testvec)
# doesn't work:
M1(N)*M2(N)*testvec
# because this doesn't work
M1(N)*M2(N)
# also doesn't work:
M2(sum(1:N))*M1(N)*testvec
#while this does:
M2(sum(1:N))*(M1(N)*testvec)
The text was updated successfully, but these errors were encountered:
Sure, it gives a method error due to ambiguity. The first one I mentioned which doesn't work outputs
M1(N)*M2(N)
ERROR: MethodError: *(::BlockSkylineMatrix{Float64,Fill{Int64,1,Tuple{Base.OneTo{Int64}}},Fill{Int64,1,Tuple{Base.OneTo{Int64}}}}, ::BandedMatrix{Float64,Array{Float64,2},Base.OneTo{Int64}}) is ambiguous. Candidates:
*(A::AbstractArray{T,2} where T, B::BandedMatrices.AbstractBandedMatrix, C...) in BandedMatrices at /home/timon/.julia/packages/LazyArrays/jsu0l/src/linalg/lazymul.jl:20
*(A::BlockBandedMatrices.AbstractBlockBandedMatrix, B::AbstractArray{T,2} where T, C...) in BlockBandedMatrices at /home/timon/.julia/packages/LazyArrays/jsu0l/src/linalg/lazymul.jl:18
Possible fix, define
*(::BlockBandedMatrices.AbstractBlockBandedMatrix, ::BandedMatrices.AbstractBandedMatrix, ::Vararg{Any,N} where N)
More or less the same for M2(sum(1:N))*M1(N)*testvec:
M2(sum(1:N))*M1(N)*testvec
ERROR: MethodError: *(::BandedMatrix{Float64,Array{Float64,2},Base.OneTo{Int64}}, ::BlockSkylineMatrix{Float64,Fill{Int64,1,Tuple{Base.OneTo{Int64}}},Fill{Int64,1,Tuple{Base.OneTo{Int64}}}}, ::Ones{Float64,2,Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}}) is ambiguous. Candidates:
*(A::AbstractArray{T,2} where T, B::BlockBandedMatrices.AbstractBlockBandedMatrix, C...) in BlockBandedMatrices at /home/timon/.julia/packages/LazyArrays/jsu0l/src/linalg/lazymul.jl:20
*(A::BandedMatrices.AbstractBandedMatrix, B::AbstractArray{T,2} where T, C...) in BandedMatrices at /home/timon/.julia/packages/LazyArrays/jsu0l/src/linalg/lazymul.jl:18
Possible fix, define
*(::BandedMatrices.AbstractBandedMatrix, ::BlockBandedMatrices.AbstractBlockBandedMatrix, ::Vararg{Any,N} where N)
Matrix multiplication is apparently not currently defined for BlockSkyLineMatrix and BandedMatrix even when dimensions should be compatible (i.e m x n array times n x k array).
Not entirely sure if this belongs in BandedMatrices or BlockBandedMatrices but I tend towards the latter so I'll put this here for now.
Here's a simple snippet that reproduces the error:
The text was updated successfully, but these errors were encountered: