@@ -4,25 +4,6 @@ import MatrixAlgebraKit as MAK
44
55# Type piracy for defining the MAK rules on BlockArrays!
66# -----------------------------------------------------
7-
8- const BlockBlasMat{T <: MAK.BlasFloat } = BlockMatrix{T}
9-
10- function MatrixAlgebraKit. zero! (A:: BlockBlasMat )
11- for bj in blockaxes (A, 2 ), bi in blockaxes (A, 1 )
12- a = view (A, bi, bj)
13- MAK. zero! (a)
14- end
15- return A
16- end
17-
18- function MatrixAlgebraKit. one! (A:: BlockBlasMat )
19- for bj in blockaxes (A, 2 ), bi in blockaxes (A, 1 )
20- a = view (A, bi, bj)
21- bi == bj ? MAK. one! (a) : MAK. zero! (a)
22- end
23- return A
24- end
25-
267for f in
278 [
289 :svd_compact , :svd_full , :svd_vals ,
@@ -44,7 +25,7 @@ for f! in (
4425 )
4526 @eval function MAK. $f! (t:: AbstractBlockTensorMap , F, alg:: AbstractAlgorithm )
4627 TensorKit. foreachblock (t, F... ) do _, (tblock, Fblocks... )
47- Fblocks′ = MAK.$ f! (Array ( tblock), alg)
28+ Fblocks′ = MAK.$ f! (copy_dense! ( similar (tblock, size (tblock)), tblock), alg)
4829 # deal with the case where the output is not in-place
4930 for (b′, b) in zip (Fblocks′, Fblocks)
5031 b === b′ || copy! (b, b′)
@@ -63,7 +44,7 @@ for f! in (
6344 )
6445 @eval function MAK. $f! (t:: AbstractBlockTensorMap , N, alg:: AbstractAlgorithm )
6546 TensorKit. foreachblock (t, N) do _, (tblock, Nblock)
66- Nblock′ = MAK.$ f! (Array ( tblock), alg)
47+ Nblock′ = MAK.$ f! (copy_dense! ( similar (tblock, size (tblock)), tblock), alg)
6748 # deal with the case where the output is not the same as the input
6849 Nblock === Nblock′ || copy! (Nblock, Nblock′)
6950 return nothing
@@ -144,15 +125,15 @@ end
144125function MAK. initialize_output (:: typeof (eigh_full!), t:: AbstractBlockTensorMap , :: AbstractAlgorithm )
145126 V_D = ⊕ (fuse (domain (t)))
146127 T = real (scalartype (t))
147- D = DiagonalTensorMap {T} (undef , V_D)
128+ D = TK . similar_diagonal (t, T , V_D)
148129 V = dense_similar (t, codomain (t) ← V_D)
149130 return D, V
150131end
151132
152133function MAK. initialize_output (:: typeof (eig_full!), t:: AbstractBlockTensorMap , :: AbstractAlgorithm )
153134 V_D = ⊕ (fuse (domain (t)))
154135 Tc = complex (scalartype (t))
155- D = DiagonalTensorMap {Tc} (undef , V_D)
136+ D = TK . similar_diagonal (t, Tc , V_D)
156137 V = dense_similar (t, Tc, codomain (t) ← V_D)
157138 return D, V
158139end
168149function MAK. initialize_output (:: typeof (svd_compact!), t:: AbstractBlockTensorMap , :: AbstractAlgorithm )
169150 V_cod = V_dom = infimum (fuse (codomain (t)), fuse (domain (t)))
170151 U = dense_similar (t, codomain (t) ← V_cod)
171- S = DiagonalTensorMap { real(scalartype(t))} (undef , V_cod)
152+ S = TK . similar_diagonal (t, real (scalartype (t)), V_cod)
172153 Vᴴ = dense_similar (t, V_dom ← domain (t))
173154 return U, S, Vᴴ
174155end
0 commit comments