Skip to content

Commit 0f49439

Browse files
committed
use dimscalartype
1 parent dc468ec commit 0f49439

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/tensors/linalg.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,8 @@ function LinearAlgebra.rank(
290290
t::AbstractTensorMap;
291291
atol::Real = 0, rtol::Real = atol > 0 ? 0 : _default_rtol(t)
292292
)
293-
r = 0 * dim(first(allunits(sectortype(t))))
294-
dim(t) == 0 && return r
293+
r = zero(dimscalartype(sectortype(t)))
294+
iszero(dim(t)) && return r
295295
S = MatrixAlgebraKit.svd_vals(t)
296296
tol = max(atol, rtol * maximum(parent(S)))
297297
for (c, b) in pairs(S)
@@ -323,7 +323,7 @@ end
323323
function LinearAlgebra.tr(t::AbstractTensorMap)
324324
domain(t) == codomain(t) ||
325325
throw(SpaceMismatch("Trace of a tensor only exist when domain == codomain"))
326-
s = zero(scalartype(t))
326+
s = zero(scalartype(t)) * zero(dimscalartype(sectortype(t)))
327327
for (c, b) in blocks(t)
328328
s += dim(c) * tr(b)
329329
end

0 commit comments

Comments
 (0)