@@ -49,21 +49,22 @@ function MatrixAlgebraKit.initialize_output(
4949 :: typeof (svd_compact!), A:: AbstractBlockSparseMatrix , alg:: BlockPermutedDiagonalAlgorithm
5050)
5151 bm, bn = blocksize (A)
52- bmn = min ( bm, bn)
52+ ( bmn, mindim) = findmin (( bm, bn) )
5353
5454 brows = eachblockaxis (axes (A, 1 ))
5555 bcols = eachblockaxis (axes (A, 2 ))
5656 u_axes = similar (brows, bmn)
57- v_axes = similar (brows , bmn)
57+ v_axes = similar (bcols , bmn)
5858
5959 # fill in values for blocks that are present
6060 bIs = collect (eachblockstoredindex (A))
6161 browIs = Int .(first .(Tuple .(bIs)))
6262 bcolIs = Int .(last .(Tuple .(bIs)))
6363 for bI in eachblockstoredindex (A)
6464 row, col = Int .(Tuple (bI))
65- u_axes[col] = infimum (brows[row], bcols[col])
66- v_axes[col] = infimum (bcols[col], brows[row])
65+ dim = (row, col)[mindim]
66+ u_axes[dim] = infimum (brows[row], bcols[col])
67+ v_axes[dim] = infimum (bcols[col], brows[row])
6768 end
6869
6970 # fill in values for blocks that aren't present, pairing them in order of occurence
@@ -83,9 +84,10 @@ function MatrixAlgebraKit.initialize_output(
8384 # allocate output
8485 for bI in eachblockstoredindex (A)
8586 brow, bcol = Tuple (bI)
87+ bdim = (brow, bcol)[mindim]
8688 block = @view! (A[bI])
8789 block_alg = block_algorithm (alg, block)
88- U[brow, bcol ], S[bcol, bcol ], Vt[bcol , bcol] = MatrixAlgebraKit. initialize_output (
90+ U[brow, bdim ], S[bdim, bdim ], Vt[bdim , bcol] = MatrixAlgebraKit. initialize_output (
8991 svd_compact!, block, block_alg
9092 )
9193 end
0 commit comments