@@ -18,15 +18,12 @@ function MatrixAlgebraKit.default_svd_algorithm(A::AbstractBlockSparseMatrix; kw
18
18
return BlockPermutedDiagonalAlgorithm (alg)
19
19
end
20
20
21
- #=
22
- Note: here I'm being generic about the matrix type, which effectively means that I'm making
23
- some assumptions about the output type of the algorithm, ie that this will return
24
- Matrix{T},Diagonal{real(T)},Matrix{T}. In principle this is not guaranteed, although it
25
- should cover most cases. The alternative is to be more specific about the matrix type and
26
- replace the `similar` calls with explicit `BlockSparseArray` constructor calls. In that case
27
- I can simply call `initialize_output` on the input blocks, and take whatever is returned.
28
- We should probably discuss which way to go.
29
- =#
21
+ # TODO : this should be replaced with a more general similar function that can handle setting
22
+ # the blocktype and element type - something like S = similar(A, BlockType(...))
23
+ function _similar_S (A:: AbstractBlockSparseMatrix , s_axis)
24
+ T = real (eltype (A))
25
+ return BlockSparseArray {T,2,Diagonal{T,Vector{T}}} (undef, (s_axis, s_axis))
26
+ end
30
27
31
28
function MatrixAlgebraKit. initialize_output (
32
29
:: typeof (svd_compact!),
@@ -61,8 +58,7 @@ function MatrixAlgebraKit.initialize_output(
61
58
62
59
s_axis = blockedrange (slengths)
63
60
U = similar (A, axes (A, 1 ), s_axis)
64
- Tr = real (eltype (A))
65
- S = BlockSparseArray {Tr,2,Diagonal{Tr,Vector{Tr}}} (undef, (s_axis, s_axis))
61
+ S = _similar_S (A, s_axis)
66
62
Vt = similar (A, s_axis, axes (A, 2 ))
67
63
68
64
# allocate output
0 commit comments