ITADN

Feature request: `reinterpret` blocked sparse matrix to wider data type

#646Closedluke-kiernan 创建于 2025-08-29
L
luke-kiernancommented
If I have a `SparseMatrixCSC{Float64}` of dimensions `(2n, m)` whose structurally nonzero elements always occur in vertical pairs `(2i-1, j)` and `(2i, j)`, then I should be able to `reinterpret` it to sparse matrix with element type `ComplexF64` and dimensions `(n,m)`. Moreover, I should be able to get the `rowvals` and `nzrange` of the `reinterpret` object, with the usual disclaimer of "don't modify this." Aside: I'm surprised by the lack of cooperation between the`reinterpret` operation and sparse matrices. This throws an error, when I'd expect it to simply return `reinterpret(Float64, nonzeros(A))`: ```julia using SparseArrays A = sprand(ComplexF64, 10, 10, 0.3) B = reinterpret(Float64, A) nonzeros(B) ``` Is there a reason for this?
关闭于 2025-09-02 3 条评论