Skip to content

Commit d7e11e2

Browse files
authored
Merge pull request #13 from Jutho/tensorkit-0.13
Tensorkit v0.13
2 parents d136b39 + 6ec6779 commit d7e11e2

File tree

6 files changed

+36
-53
lines changed

6 files changed

+36
-53
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,14 @@ jobs:
2121
fail-fast: false
2222
matrix:
2323
version:
24-
- '1.6' # LTS version
24+
- 'lts' # LTS version
2525
- '1' # automatically expands to the latest stable 1.x release of Julia
2626
os:
2727
- ubuntu-latest
2828
- macOS-latest
2929
- windows-latest
3030
arch:
3131
- x64
32-
# - x86
33-
# exclude:
34-
# - os: macOS-latest
35-
# arch: x86
3632
steps:
3733
- uses: actions/checkout@v4
3834
- uses: julia-actions/setup-julia@v2

Project.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
name = "TensorKitManifolds"
22
uuid = "11fa318c-39cb-4a83-b1ed-cdc7ba1e3684"
33
authors = ["Jutho Haegeman <[email protected]>", "Markus Hauru <[email protected]>"]
4-
version = "0.7"
4+
version = "0.7.1"
55

66
[deps]
77
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
88
TensorKit = "07d1fe3e-3e46-537d-9eac-e9e13d0d4cec"
99

1010
[compat]
11-
TensorKit = "0.12.1"
12-
julia = "1.6"
11+
TensorKit = "0.13"
12+
julia = "1.10"
1313

1414
[extras]
1515
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

src/grassmann.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ mutable struct GrassmannTangent{T<:AbstractTensorMap,
2222
U::Union{Nothing,TU}
2323
S::Union{Nothing,TS}
2424
V::Union{Nothing,TV}
25-
function GrassmannTangent(W::AbstractTensorMap{S,N₁,N₂},
26-
Z::AbstractTensorMap{S,N₁,N₂}) where {S,N₁,N₂}
25+
function GrassmannTangent(W::AbstractTensorMap{TT₁,S,N₁,N₂},
26+
Z::AbstractTensorMap{TT₂,S,N₁,N₂}) where {TT₁,TT₂,S,N₁,N₂}
2727
T = typeof(W)
2828
TT = promote_type(float(scalartype(W)), scalartype(Z))
2929
M = similarstoragetype(W, TT)

src/stiefel.jl

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -167,26 +167,18 @@ function stiefelexp(W::AbstractTensorMap,
167167
A::AbstractTensorMap,
168168
Z::AbstractTensorMap,
169169
α::Real)
170-
S = spacetype(W)
171-
G = sectortype(W)
172-
Wdata′ = TensorKit.SectorDict{G,storagetype(W)}()
173-
Qdata = TensorKit.SectorDict{G,storagetype(W)}()
174-
Qdata′ = TensorKit.SectorDict{G,storagetype(W)}()
175-
Rdata′ = TensorKit.SectorDict{G,storagetype(W)}()
176-
dims = TensorKit.SectorDict{G,Int}()
177-
for c in blocksectors(W)
178-
w′, q, q′, r′ = _stiefelexp(block(W, c), block(A, c), block(Z, c), α)
179-
Wdata′[c] = w′
180-
Qdata[c] = q
181-
Qdata′[c] = q′
182-
Rdata′[c] = r′
183-
dims[c] = size(q, 2)
170+
V = fuse(domain(W))
171+
W′ = similar(W)
172+
Q = similar(W, codomain(W) V)
173+
Q′ = similar(Q)
174+
R′ = similar(W, V domain(W))
175+
for (c, b) in blocks(W)
176+
w′, q, q′, r′ = _stiefelexp(b, block(A, c), block(Z, c), α)
177+
copy!(block(W′, c), w′)
178+
copy!(block(Q, c), q)
179+
copy!(block(Q′, c), q′)
180+
copy!(block(R′, c), r′)
184181
end
185-
V = S(dims)
186-
W′ = TensorMap(Wdata′, space(W))
187-
Q = TensorMap(Qdata, codomain(W) V)
188-
Q′ = TensorMap(Qdata′, codomain(W) V)
189-
R′ = TensorMap(Rdata′, V domain(W))
190182
return W′, Q, Q′, R′
191183
end
192184

@@ -201,18 +193,13 @@ end
201193
function invretract_exp(Wold::AbstractTensorMap, Wnew::AbstractTensorMap;
202194
tol=scalareps(Wold)^(2 / 3))
203195
space(Wold) == space(Wnew) || throw(SectorMismatch())
204-
205-
S = spacetype(Wold)
206-
G = sectortype(Wold)
207-
Adata = TensorKit.SectorDict{G,storagetype(Wold)}()
208-
Zdata = TensorKit.SectorDict{G,storagetype(Wold)}()
209-
for c in blocksectors(Wold)
210-
a, q, r = _stiefellog(block(Wold, c), block(Wnew, c); tol=tol)
211-
Adata[c] = a
212-
Zdata[c] = q * r
196+
A = similar(Wold, domain(Wold) domain(Wold))
197+
Z = similar(Wold, space(Wold))
198+
for (c, b) in blocks(Wold)
199+
a, q, r = _stiefellog(b, block(Wnew, c); tol)
200+
copy!(block(A, c), a)
201+
mul!(block(Z, c), q, r)
213202
end
214-
A = TensorMap(Adata, domain(Wold) domain(Wold))
215-
Z = TensorMap(Zdata, space(Wold))
216203
return StiefelTangent(Wold, A, Z)
217204
end
218205

src/unitary.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import ..TensorKitManifolds: base, checkbase, inner, retract, transport, transpo
1111
struct UnitaryTangent{T<:AbstractTensorMap,TA<:AbstractTensorMap}
1212
W::T
1313
A::TA
14-
function UnitaryTangent(W::AbstractTensorMap{S,N₁,N₂},
15-
A::AbstractTensorMap{S,N₂,N₂}) where {S,N₁,N₂}
14+
function UnitaryTangent(W::AbstractTensorMap{T₁,S,N₁,N₂},
15+
A::AbstractTensorMap{T₂,S,N₂,N₂}) where {T₁,T₂,S,N₁,N₂}
1616
T = typeof(W)
1717
TA = typeof(A)
1818
return new{T,TA}(W, A)

test/runtests.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ const α = 0.75
88

99
@testset "Grassmann with space $V" for V in spaces
1010
for T in (Float64,)
11-
W, = leftorth(TensorMap(randn, T, V * V * V, V * V); alg=Polar())
12-
X = TensorMap(randn, T, space(W))
13-
Y = TensorMap(randn, T, space(W))
11+
W, = leftorth(randn(T, V * V * V, V * V); alg=Polar())
12+
X = randn(T, space(W))
13+
Y = randn(T, space(W))
1414
Δ = @inferred Grassmann.project(X, W)
1515
Θ = Grassmann.project(Y, W)
1616
γ = randn(T)
@@ -42,7 +42,7 @@ const α = 0.75
4242
@test Grassmann.inner(W2, Δ2, Θ2) Grassmann.inner(W, Δ, Θ)
4343
@test Grassmann.inner(W2, Ξ2, Θ2) Grassmann.inner(W, Ξ, Θ)
4444

45-
Wend = TensorMap(randhaar, T, codomain(W), domain(W))
45+
Wend = randisometry(T, codomain(W), domain(W))
4646
Δ3, V = Grassmann.invretract(W, Wend)
4747
@test Wend retract(W, Δ3, 1)[1] * V
4848
U = Grassmann.relativegauge(W, Wend)
@@ -53,9 +53,9 @@ end
5353

5454
@testset "Stiefel with space $V" for V in spaces
5555
for T in (Float64, ComplexF64)
56-
W = TensorMap(randhaar, T, V * V * V, V * V)
57-
X = TensorMap(randn, T, space(W))
58-
Y = TensorMap(randn, T, space(W))
56+
W = randisometry(T, V * V * V, V * V)
57+
X = randn(T, space(W))
58+
Y = randn(T, space(W))
5959
Δ = @inferred Stiefel.project_euclidean(X, W)
6060
Θ = Stiefel.project_canonical(Y, W)
6161
γ = rand()
@@ -116,17 +116,17 @@ end
116116
@test Stiefel.inner_canonical(W2, Δ2, Θ2) Stiefel.inner_canonical(W, Δ, Θ)
117117
@test Stiefel.inner_canonical(W2, Ξ2, Θ2) Stiefel.inner_canonical(W, Ξ, Θ)
118118

119-
W3 = projectisometric!(W + 1e-1 * TensorMap(rand, T, codomain(W), domain(W)))
119+
W3 = projectisometric!(W + 1e-1 * rand(T, codomain(W), domain(W)))
120120
Δ3 = Stiefel.invretract(W, W3)
121121
@test W3 retract(W, Δ3, 1)[1]
122122
end
123123
end
124124

125125
@testset "Unitary with space $V" for V in spaces
126126
for T in (Float64, ComplexF64)
127-
W, = leftorth(TensorMap(randn, T, V * V * V, V * V); alg=Polar())
128-
X = TensorMap(randn, T, space(W))
129-
Y = TensorMap(randn, T, space(W))
127+
W, = leftorth(randn(T, V * V * V, V * V); alg=Polar())
128+
X = randn(T, space(W))
129+
Y = randn(T, space(W))
130130
Δ = @inferred Unitary.project(X, W)
131131
Θ = Unitary.project(Y, W)
132132
γ = randn()

0 commit comments

Comments
 (0)