Open glennmoy opened 4 years ago
Thanks for the issue. Don't have time to fix this right now but if you make a PR I can review it
No problem - I'm deep diving into the package as we speak to figure out how to fix it. I'll post a PR if I manage to but just wanted to open the issue first :)
I think the sub-block types are being defined as Symmetric
Yeah, i think that right: the blocks are being converted to the same type T
as the input array. But that doesn't make sense for "structured" array types (like Symmetric
).
The errors we hit are
convert(T, block)
: for most structured array type convert(T, ::Array)
is not defined (MethodError
)T(block)
, it may nevertheless error: e.g. trying to convert a non-square matrix to Symmetric
throws a DimensionMismatch
I guess we need a different approach for handling Structured matrix types? Store the blocks as Matrix
es?
But I might be missing something, as i'd have expected the working with Structured matrix types as input would have come up before (but maybe not). And i'm not too familiar with the BlockArrays 😊
It looks like the issue is that it is assuming the storage type is the same as the array type:
Probably best to default to Array
so change this to something like:
...
block_arr = _BlockArray(Array{_block_typeof(arr),N}, baxes)
...
_block_typeof(::AbstractArray{T,N}) where {T,N} = Array{T,N}
_block_typeof(A::AbstractSparseArray) = typeof(A)
The problem is not resolved by defining
Base.convert(::Type{Symmetric}, x::Array{Float64, 2})
.I believe the problem is the non-commutativity of
Symmetric
andBlockArray
methods. Specifically, I think the sub-block types are being defined asSymmetric
in this line and thensetindex!
complains when it tries to assign anArray{T, 2}
to the blocks.At least that's my educated guess. Folks more familiar with what those functions do will know more.