Skip to content

Commit 0a6fcdb

Browse files
committedDec 17, 2024
some cleanup for v0.14
1 parent c041bfe commit 0a6fcdb

File tree

4 files changed

+38
-2
lines changed

4 files changed

+38
-2
lines changed
 

‎Changelog.md

+17
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,23 @@ Features that are planned to be implemented before the release of v1.0.0, in no
1717

1818
## v0.14
1919

20+
### Use `DiagonalTensorMap` for singular values and eigenvalues
21+
22+
The diagonal (1,1) tensor that contains the singular values or eigenvalues of a tensor
23+
are now explicitly represented as `DiagonalTensorMap` instances.
24+
25+
### New index functionality
26+
There are is new functionality for manipulating the spaces associated with a tensor:
27+
* `flip(t, i)` changes the duality flag of the `i`th index of `t`, in such a way that flipping
28+
a pair of contracted indices in an `@tensor` contraction does not affect the result.
29+
* `insertleftunit(t, i)` and `insertrightunit(t, i)` insert a trivial unit space to the left
30+
or to right of index `i`, whereas `removeunit(t, i)` removes such a trivial unit space.
31+
32+
### SVD truncation change (breaking)
33+
There is a subtle but breaking change in the truncation mechanism in SVD, where now it is
34+
guaranteed that smaller singular values are removed first, irrespective of the (quantum)
35+
dimension of the sector to which they belong
36+
2037
### `DiagonalTensorMap` and `reduceddim`
2138

2239
This adds a `DiagonalTensorMap` type for representing tensor maps in which all of the

‎docs/src/lib/spaces.md

+1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ There are also specific methods for `HomSpace` instances, that are used in deter
113113
the resuling `HomSpace` after applying certain tensor operations.
114114

115115
```@docs
116+
flip(W::HomSpace{S}, I) where {S}
116117
TensorKit.permute(::HomSpace{S}, ::Index2Tuple{N₁,N₂}) where {S,N₁,N₂}
117118
TensorKit.select(::HomSpace{S}, ::Index2Tuple{N₁,N₂}) where {S,N₁,N₂}
118119
TensorKit.compose(::HomSpace{S}, ::HomSpace{S}) where {S}

‎docs/src/lib/tensors.md

+1
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ permute(::AbstractTensorMap, ::Index2Tuple{N₁,N₂}; ::Bool) where {N₁,N₂}
174174
braid(::AbstractTensorMap, ::Index2Tuple, ::IndexTuple; ::Bool)
175175
transpose(::AbstractTensorMap, ::Index2Tuple; ::Bool)
176176
repartition(::AbstractTensorMap, ::Int, ::Int; ::Bool)
177+
flip(t::AbstractTensorMap, I)
177178
twist(::AbstractTensorMap, ::Int; ::Bool)
178179
```
179180

‎src/tensors/vectorinterface.jl

+19-2
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,25 @@ function VectorInterface.inner(tx::AbstractTensorMap, ty::AbstractTensorMap)
102102
InnerProductStyle(tx) === EuclideanInnerProduct() || throw_invalid_innerproduct(:inner)
103103
T = VectorInterface.promote_inner(tx, ty)
104104
s = zero(T)
105-
for c in blocksectors(tx)
106-
s += convert(T, dim(c)) * inner(block(tx, c), block(ty, c))
105+
for ((cx, bx), (cy, by)) in zip(blocks(tx), blocks(ty))
106+
s += convert(T, dim(cx)) * inner(bx, by)
107107
end
108108
return s
109109
end
110+
function VectorInterface.inner(tx::TensorMap, ty::TensorMap)
111+
space(tx) == space(ty) || throw(SpaceMismatch("$(space(tx))$(space(ty))"))
112+
InnerProductStyle(tx) === EuclideanInnerProduct() || throw_invalid_innerproduct(:inner)
113+
if FusionStyle(sectortype(tx)) isa UniqueFusion # all quantum dimensions are one
114+
return inner(tx.data, ty.data)
115+
else
116+
T = VectorInterface.promote_inner(tx, ty)
117+
s = zero(T)
118+
for c in blocksectors(tx)
119+
bx = parent(block(tx, c)) # matrix structure (reshape) does not matter
120+
by = parent(block(ty, c)) # but does lead to slower path in inner
121+
s += convert(T, dim(c)) * inner(bx, by)
122+
end
123+
end
124+
return s
125+
end
126+
# TODO: do we need a fast path for `AdjointTensorMap` instances?

0 commit comments

Comments
 (0)