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

Question/request: How to create a BlockArray from an array of blocks? #62

Closed
tkf opened this issue Nov 27, 2018 · 1 comment · Fixed by #68
Closed

Question/request: How to create a BlockArray from an array of blocks? #62

tkf opened this issue Nov 27, 2018 · 1 comment · Fixed by #68

Comments

@tkf
Copy link
Member

tkf commented Nov 27, 2018

In #61 (comment) I wrote

using BlockArrays

function blocks_to_vector(blocks)
    R = eltype(blocks)
    T = eltype(R)
    @assert R <: AbstractVector
    ba = BlockArray{T, 1, R}(undef_blocks, size.(blocks, 1))
    ba.blocks .= blocks
    return ba
end

using FillArrays
x = blocks_to_vector([Fill(111.0, 4), Fill(222.0, 3)])

to create a BlockVector from a vector of blocks.

I first thought this was awkward and I was missing an API to do this but after finding #30 (comment) I started to think that there was no API to do this. Is it correct? If so, does it make sense to add an API for this?

(Note: #40 looks somewhat relevant)

@dlfivefifty
Copy link
Member

Yes that appears to be missing. The natural syntax is _BlockArray(blocks), but that has the problem of not being a public API.

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

Successfully merging a pull request may close this issue.

2 participants