Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tensorkit v0.13 #13

Merged
merged 6 commits into from
Nov 5, 2024
Merged
Changes from 1 commit
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
26 changes: 10 additions & 16 deletions src/stiefel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -167,24 +167,18 @@ function stiefelexp(W::AbstractTensorMap,
A::AbstractTensorMap,
Z::AbstractTensorMap,
α::Real)
S = spacetype(W)
G = sectortype(W)
dims = TensorKit.SectorDict{G,Int}()
generator = Iterators.map(blocks(W)) do (c, b)
V = fuse(domain(W))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's clever 😃 : using functions what they are meant for instead of reimplementing them 👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have my moments 😁

W′ = similar(W)
Q = similar(W, codomain(W) ← V)
Q′ = similar(Q)
R′ = similar(W, V ← domain(W))
for (c, b) in blocks(W)
w′, q, q′, r′ = _stiefelexp(b, block(A, c), block(Z, c), α)
dims[c] = size(q, 2)
return c => (w′, q, q′, r′)
copy!(block(W′, c), w′)
copy!(block(Q, c), q)
copy!(block(Q′, c), q′)
copy!(block(R′, c), r′)
end
wqqr = TensorKit.SectorDict(generator)
Wdata′ = SectorDict(c => w′ for (c, (w′, q, q′, r′)) in wqqr)
Qdata = SectorDict(c => q for (c, (w′, q, q′, r′)) in wqqr)
Qdata′ = SectorDict(c => q′ for (c, (w′, q, q′, r′)) in wqqr)
Rdata′ = SectorDict(c => r′ for (c, (w′, q, q′, r′)) in wqqr)
V = S(dims)
W′ = TensorMap(Wdata′, space(W))
Q = TensorMap(Qdata, codomain(W) ← V)
Q′ = TensorMap(Qdata′, codomain(W) ← V)
R′ = TensorMap(Rdata′, V ← domain(W))
return W′, Q, Q′, R′
end

Expand Down