diff --git a/src/spaces/cartesianspace.jl b/src/spaces/cartesianspace.jl index 9f927dac..90fbef30 100644 --- a/src/spaces/cartesianspace.jl +++ b/src/spaces/cartesianspace.jl @@ -8,7 +8,7 @@ vector space that is implicitly assumed in most of matrix algebra. struct CartesianSpace <: EuclideanSpace{ℝ} d::Int end -CartesianSpace(d::Integer; dual = false) = CartesianSpace(Int(d)) +CartesianSpace(d::Integer = 0; dual = false) = CartesianSpace(Int(d)) Base.getindex(::RealNumbers) = CartesianSpace Base.getindex(::RealNumbers, d::Int) = CartesianSpace(d) diff --git a/src/spaces/complexspace.jl b/src/spaces/complexspace.jl index aa5f7e02..6dfc0972 100644 --- a/src/spaces/complexspace.jl +++ b/src/spaces/complexspace.jl @@ -9,7 +9,7 @@ struct ComplexSpace <: EuclideanSpace{ℂ} d::Int dual::Bool end -ComplexSpace(d::Integer; dual = false) = ComplexSpace(Int(d), dual) +ComplexSpace(d::Integer = 0; dual = false) = ComplexSpace(Int(d), dual) # convenience constructor Base.:^(::ComplexNumbers, d::Int) = ComplexSpace(d) diff --git a/src/spaces/generalspace.jl b/src/spaces/generalspace.jl index 17bb3c38..32f45c10 100644 --- a/src/spaces/generalspace.jl +++ b/src/spaces/generalspace.jl @@ -19,7 +19,7 @@ struct GeneralSpace{𝕜} <: ElementarySpace{𝕜} end end end -GeneralSpace{𝕜}(d::Int; dual::Bool = false, conj::Bool = false) where {𝕜} = +GeneralSpace{𝕜}(d::Int = 0; dual::Bool = false, conj::Bool = false) where {𝕜} = GeneralSpace{𝕜}(d, dual, conj) dim(V::GeneralSpace) = V.d diff --git a/src/spaces/representationspace.jl b/src/spaces/representationspace.jl index f0a386e0..7a95ab72 100644 --- a/src/spaces/representationspace.jl +++ b/src/spaces/representationspace.jl @@ -103,12 +103,13 @@ Base.getindex(::ComplexNumbers, d1::Pair{G,Int}, dims::Pair{G,Int}...) where {G< # Corresponding methods: # properties dim(V::GenericRepresentationSpace) = - mapreduce(c->dim(c)*V.dims[c], +, keys(V.dims); init = 0) + mapreduce(c->dim(c)*V.dims[c], +, keys(V.dims); init = zero(dim(one(sectortype(V))))) dim(V::GenericRepresentationSpace{G}, c::G) where {G<:Sector} = get(V.dims, isdual(V) ? dual(c) : c, 0) dim(V::FiniteRepresentationSpace{G}) where {G<:Sector} = - reduce(+, dc*dim(c) for (dc,c) in zip(V.dims, values(G)); init = 0) + reduce(+, dc*dim(c) for (dc,c) in zip(V.dims, values(G)); + init = zero(dim(one(sectortype(V))))) dim(V::FiniteRepresentationSpace{G}, c::G) where {G<:Sector} = V.dims[findindex(values(G), isdual(V) ? dual(c) : c)] diff --git a/test/tensors.jl b/test/tensors.jl index 4045797c..b5599832 100644 --- a/test/tensors.jl +++ b/test/tensors.jl @@ -275,19 +275,19 @@ for (G,V) in ((Trivial, Vtr), (ℤ₂, Vℤ₂), (ℤ₃, Vℤ₃), (U₁, VU₁ @test N*N' ≈ id(codomain(N)) end @testset "rightorth with $alg" for alg in (TensorKit.RQ(), TensorKit.RQpos(), TensorKit.LQ(), TensorKit.LQpos(), TensorKit.Polar(), TensorKit.SVD(), TensorKit.SDD()) - L, Q = @inferred rightorth(t; alg = alg) - @test L == t - @test dim(Q) == dim(R) == 0 + L, Q = @inferred rightorth(copy(t'); alg = alg) + @test Q == t' + @test dim(Q) == dim(L) == 0 end @testset "rightnull with $alg" for alg in (TensorKit.LQ(), TensorKit.SVD(), TensorKit.SDD()) - M = @inferred rightnull(t; alg = alg) + M = @inferred rightnull(copy(t'); alg = alg) @test M*M' ≈ id(codomain(M)) @test M'*M ≈ id(domain(M)) end @testset "tsvd with $alg" for alg in (TensorKit.SVD(), TensorKit.SDD()) U, S, V = @inferred tsvd(t; alg = alg) @test U == t - @test dim(Q) == dim(R) == dim(V) + @test dim(U) == dim(S) == dim(V) end end