Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "TensorKit"
uuid = "07d1fe3e-3e46-537d-9eac-e9e13d0d4cec"
authors = ["Jutho Haegeman"]
version = "0.15.2"
version = "0.15.3"

[deps]
LRUCache = "8ac3fa9e-de4c-5943-b1dc-09c6b5f20637"
Expand Down
2 changes: 1 addition & 1 deletion src/spaces/gradedspace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ end
function Base.show(io::IO, ::MIME"text/plain", V::GradedSpace)
# print small summary, e.g.: Vect[I](…) of dim d
d = dim(V)
print(io, type_repr(typeof(d)), "(…)")
print(io, type_repr(typeof(V)), "(…)")
isdual(V) && print(io, "'")
print(io, " of dim ", d)

Expand Down
2 changes: 2 additions & 0 deletions src/spaces/homspace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ function dim(W::HomSpace)
return d
end

dims(W::HomSpace) = (dims(codomain(W))..., dims(domain(W))...)

"""
fusiontrees(W::HomSpace)

Expand Down
14 changes: 9 additions & 5 deletions src/spaces/productspace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,14 @@ end

# Corresponding methods
#-----------------------
"""
@doc """
dims(::ProductSpace{S, N}) -> Dims{N} = NTuple{N, Int}
dims(V::HomSpace) -> Dims{length(V)}
dims(t::AbstractTensorMap) -> Dims{numind(t)}

Return the dimensions of the spaces in the tensor product space(s) as a tuple of integers.
""" dims

Return the dimensions of the spaces in the tensor product space as a tuple of integers.
"""
dims(P::ProductSpace) = map(dim, P.spaces)
dim(P::ProductSpace, n::Int) = dim(P.spaces[n])
dim(P::ProductSpace) = prod(dims(P))
Expand All @@ -68,10 +71,11 @@ dual(P::ProductSpace) = ProductSpace(map(dual, reverse(P.spaces)))
function Base.show(io::IO, P::ProductSpace{S}) where {S <: ElementarySpace}
spaces = P.spaces
if length(spaces) == 0
print(io, "ProductSpace{", S, ", 0}")
print(io, "one(", type_repr(S), ")")
return nothing
end
if length(spaces) == 1
print(io, "ProductSpace")
print(io, "")
end
print(io, "(")
for i in 1:length(spaces)
Expand Down
7 changes: 4 additions & 3 deletions src/tensors/abstracttensor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ symmetry. This is also the dimension of the `HomSpace` on which the `TensorMap`
"""
dim(t::AbstractTensorMap) = fusionblockstructure(t).totaldim

dims(t::AbstractTensorMap) = dims(space(t))

"""
blocksectors(t::AbstractTensorMap)

Expand Down Expand Up @@ -461,8 +463,7 @@ end
Base.getindex(t::AbstractTensorMap)
t[]

Return a view into the data of `t` as a `StridedViews.StridedView` of size
`(dims(codomain(t))..., dims(domain(t))...)`.
Return a view into the data of `t` as a `StridedViews.StridedView` of size `dims(t)`.
"""
@inline function Base.getindex(t::AbstractTensorMap)
return t[trivial_fusiontree(t)...]
Expand Down Expand Up @@ -616,7 +617,7 @@ function Base.convert(::Type{Array}, t::AbstractTensorMap)
dom = domain(t)
T = sectorscalartype(I) <: Complex ? complex(scalartype(t)) :
sectorscalartype(I) <: Integer ? scalartype(t) : float(scalartype(t))
A = zeros(T, dims(cod)..., dims(dom)...)
A = zeros(T, dims(t)...)
for (f₁, f₂) in fusiontrees(t)
F = convert(Array, (f₁, f₂))
Aslice = StridedView(A)[axes(cod, f₁.uncoupled)..., axes(dom, f₂.uncoupled)...]
Expand Down
4 changes: 2 additions & 2 deletions src/tensors/tensor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ function TensorMap(
# dimension check
codom = codomain(V)
dom = domain(V)
arraysize = (dims(codom)..., dims(dom)...)
arraysize = dims(V)
matsize = (dim(codom), dim(dom))

if !(size(data) == arraysize || size(data) == matsize)
Expand Down Expand Up @@ -487,7 +487,7 @@ end
@boundscheck begin
sectortype(t) == Trivial || throw(SectorMismatch())
end
return sreshape(StridedView(t.data), (dims(codomain(t))..., dims(domain(t))...))
return sreshape(StridedView(t.data), dims(t))
end

# Show
Expand Down
8 changes: 8 additions & 0 deletions test/symmetries/spaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -452,4 +452,12 @@ end
end
end

@timedtestset "show and friends" begin
V = U1Space(i => 1 for i in 1:3)
@test string(V) == "Rep[U₁](1 => 1, 2 => 1, 3 => 1)"
@test string(V') == "Rep[U₁](1 => 1, 2 => 1, 3 => 1)'"
@test sprint((x, y) -> show(x, MIME"text/plain"(), y), V) == "Rep[U₁](…) of dim 3:\n 1 => 1\n 2 => 1\n 3 => 1"
@test sprint((x, y) -> show(x, MIME"text/plain"(), y), V') == "Rep[U₁](…)' of dim 3:\n 1 => 1\n 2 => 1\n 3 => 1"
end

TensorKit.empty_globalcaches!()
Loading