Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BlockDiagonal constructor fails with Vector of BandedMatrices #108

Closed
arbenede opened this issue Jun 27, 2022 · 1 comment
Closed

BlockDiagonal constructor fails with Vector of BandedMatrices #108

arbenede opened this issue Jun 27, 2022 · 1 comment

Comments

@arbenede
Copy link

To make the MWE below work I have to call D = BlockDiagonal([Dbv[1], Dbv[2], Dbv[3]]) instead of D = BlockDiagonal(Dbv):

using BandedMatrices
using BlockDiagonals

ix = [9, 16, 22]
Dbv = []
iold = 0
for i in ix
    Db = BandedMatrix{Float64}(undef, (i-iold-1, i-iold), (0,1))
    Db[band(0)]  .= -1
    Db[band(1)] .=  1
    iold = i
    push!(Dbv, copy(Db))
end
Dbv[1]

8×9 BandedMatrix{Float64} with bandwidths (0, 1):
 -1.0   1.0    ⋅     ⋅     ⋅     ⋅     ⋅     ⋅    ⋅ 
   ⋅   -1.0   1.0    ⋅     ⋅     ⋅     ⋅     ⋅    ⋅ 
   ⋅     ⋅   -1.0   1.0    ⋅     ⋅     ⋅     ⋅    ⋅ 
   ⋅     ⋅     ⋅   -1.0   1.0    ⋅     ⋅     ⋅    ⋅ 
   ⋅     ⋅     ⋅     ⋅   -1.0   1.0    ⋅     ⋅    ⋅ 
   ⋅     ⋅     ⋅     ⋅     ⋅   -1.0   1.0    ⋅    ⋅ 
   ⋅     ⋅     ⋅     ⋅     ⋅     ⋅   -1.0   1.0   ⋅ 
   ⋅     ⋅     ⋅     ⋅     ⋅     ⋅     ⋅   -1.0  1.0
D = BlockDiagonal(Dbv)

MethodError: no method matching BlockDiagonal(::Vector{Any})
Closest candidates are:
  BlockDiagonal(::BlockDiagonal) at ~/.julia/packages/BlockDiagonals/Y9q2S/src/blockdiagonal.jl:20
  BlockDiagonal(::Vector{V}) where {T, V<:AbstractMatrix{T}} at ~/.julia/packages/BlockDiagonals/Y9q2S/src/blockdiagonal.jl:16

Stacktrace:
 [1] top-level scope
   @ In[3]:1
 [2] eval
   @ ./boot.jl:373 [inlined]
 [3] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
   @ Base ./loading.jl:1196
D = BlockDiagonal([Dbv[1], Dbv[2], Dbv[3]])

19×22 BlockDiagonal{Float64, BandedMatrix{Float64, Matrix{Float64}, Base.OneTo{Int64}}}:
 -1.0   1.0   0.0   0.0   0.0   0.0  …   0.0   0.0   0.0   0.0   0.0  0.0
  0.0  -1.0   1.0   0.0   0.0   0.0      0.0   0.0   0.0   0.0   0.0  0.0
  0.0   0.0  -1.0   1.0   0.0   0.0      0.0   0.0   0.0   0.0   0.0  0.0
  0.0   0.0   0.0  -1.0   1.0   0.0      0.0   0.0   0.0   0.0   0.0  0.0
  0.0   0.0   0.0   0.0  -1.0   1.0      0.0   0.0   0.0   0.0   0.0  0.0
  0.0   0.0   0.0   0.0   0.0  -1.0  …   0.0   0.0   0.0   0.0   0.0  0.0
  0.0   0.0   0.0   0.0   0.0   0.0      0.0   0.0   0.0   0.0   0.0  0.0
  0.0   0.0   0.0   0.0   0.0   0.0      0.0   0.0   0.0   0.0   0.0  0.0
  0.0   0.0   0.0   0.0   0.0   0.0      0.0   0.0   0.0   0.0   0.0  0.0
  0.0   0.0   0.0   0.0   0.0   0.0      0.0   0.0   0.0   0.0   0.0  0.0
  0.0   0.0   0.0   0.0   0.0   0.0  …   0.0   0.0   0.0   0.0   0.0  0.0
  0.0   0.0   0.0   0.0   0.0   0.0      0.0   0.0   0.0   0.0   0.0  0.0
  0.0   0.0   0.0   0.0   0.0   0.0      0.0   0.0   0.0   0.0   0.0  0.0
  0.0   0.0   0.0   0.0   0.0   0.0      0.0   0.0   0.0   0.0   0.0  0.0
  0.0   0.0   0.0   0.0   0.0   0.0     -1.0   1.0   0.0   0.0   0.0  0.0
  0.0   0.0   0.0   0.0   0.0   0.0  …   0.0  -1.0   1.0   0.0   0.0  0.0
  0.0   0.0   0.0   0.0   0.0   0.0      0.0   0.0  -1.0   1.0   0.0  0.0
  0.0   0.0   0.0   0.0   0.0   0.0      0.0   0.0   0.0  -1.0   1.0  0.0
  0.0   0.0   0.0   0.0   0.0   0.0      0.0   0.0   0.0   0.0  -1.0  1.0
@mzgubic
Copy link
Collaborator

mzgubic commented Jun 27, 2022

Did you find a solution to this or did you close by mistake?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants