We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
dimscalartype
1 parent dc468ec commit 0f49439Copy full SHA for 0f49439
1 file changed
src/tensors/linalg.jl
@@ -290,8 +290,8 @@ function LinearAlgebra.rank(
290
t::AbstractTensorMap;
291
atol::Real = 0, rtol::Real = atol > 0 ? 0 : _default_rtol(t)
292
)
293
- r = 0 * dim(first(allunits(sectortype(t))))
294
- dim(t) == 0 && return r
+ r = zero(dimscalartype(sectortype(t)))
+ iszero(dim(t)) && return r
295
S = MatrixAlgebraKit.svd_vals(t)
296
tol = max(atol, rtol * maximum(parent(S)))
297
for (c, b) in pairs(S)
@@ -323,7 +323,7 @@ end
323
function LinearAlgebra.tr(t::AbstractTensorMap)
324
domain(t) == codomain(t) ||
325
throw(SpaceMismatch("Trace of a tensor only exist when domain == codomain"))
326
- s = zero(scalartype(t))
+ s = zero(scalartype(t)) * zero(dimscalartype(sectortype(t)))
327
for (c, b) in blocks(t)
328
s += dim(c) * tr(b)
329
end
0 commit comments