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

Should BlockArray(arr::AbstractArray{T,N},..) always create a BlockArray{T,N,Array{T}}? #40

Open
dlfivefifty opened this issue Nov 26, 2017 · 2 comments

Comments

@dlfivefifty
Copy link
Member

At the moment BlockArray(arr::AbstractArray{T,N},..) creates a BlockArray{T,N,typeof(arr)}. However, for many types subarrays are not of the same type (e.g., Diagonal). I think it is safer to always convert to Array.

The one argument I can see is that it might be nice for BlockArray(::SparseVector) to automatically use sparse data storage.

Another option is to look into whether the type of sub-blocks can be inferred automatically.

@KristofferC
Copy link
Collaborator

Hm, we should probably to some type promotion then. Is typejoin the correct function?

@dlfivefifty
Copy link
Member Author

dlfivefifty commented Nov 27, 2017

No I don't think so. In the case of N = 1 this could be done by comprehension:

[arr[globalrange(block_sizes, K)] for K=1:nblocks(block_sizes,1)]

should automatically infer the correct type (SparseVector if arr is a SparseVector, otherwise normally Vector).

I'm not sure how to do comprehension via generated functions though.

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