Skip to content

Commit f663d05

Browse files
committed
use do block
1 parent 4057fe8 commit f663d05

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/fusiontensor/linear_algebra_interface.jl

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,18 @@ end
4444
function LinearAlgebra.norm(ft::FusionTensor)
4545
m = data_matrix(ft)
4646
row_sectors = blocklabels(matrix_row_axis(ft))
47-
n2 = sum(
48-
quantum_dimension(row_sectors[Int(first(Tuple(b)))]) * norm(m[b])^2 for
49-
b in eachblockstoredindex(m);
50-
init=zero(real(eltype(ft))),
51-
)
47+
n2 = sum(eachblockstoredindex(m); init=zero(real(eltype(ft)))) do b
48+
return quantum_dimension(row_sectors[Int(first(Tuple(b)))]) * norm(m[b])^2
49+
end
5250
return sqrt(n2)
5351
end
5452

5553
function LinearAlgebra.tr(ft::FusionTensor)
5654
m = data_matrix(ft)
5755
row_sectors = blocklabels(matrix_row_axis(ft))
58-
return sum(
59-
quantum_dimension(row_sectors[Int(first(Tuple(b)))]) * tr(m[b]) for
60-
b in eachblockstoredindex(m);
61-
init=zero(eltype(ft)),
62-
)
56+
return sum(eachblockstoredindex(m); init=zero(eltype(ft))) do b
57+
return quantum_dimension(row_sectors[Int(first(Tuple(b)))]) * tr(m[b])
58+
end
6359
end
6460

6561
function LinearAlgebra.qr(ft::FusionTensor)

0 commit comments

Comments
 (0)