Skip to content

Commit a7d2bbb

Browse files
lkdvosKatharine HyattkshyattJutho
authored
MatrixAlgebraKit decompositions (#230)
This PR is part of a large set of changes that alters the backend from `TensorKit.MatrixAlgebra` to `MatrixAlgebraKit` for the factorizations. Concretely, this is achieved through a new submodule `TensorKit.Factorizations` that implements most of the `MatrixAlgebraKit` interface, along with some overloads and reimplementations to be somewhat backwards compatible. ## New features - `foreachblock(f, t::AbstractTensorMap...)` is a new function that is meant to provide a uniform interface to iterate through the blocks of a collection of tensors. The main purpose is to centralize this concept to easily add multithreading over the blocks. In order to break up this PR the actual multithreading implementation is left for a follow-up PR. - Truncated eigenvalue decompositions through `eig_trunc` and `eigh_trunc` - The factorizations can now swap out their backends to select alternate algorithms or implementations. - `ominus` and its unicode variant can now be used to obtain the orthogonal complement of a space, ie if `W = oplus(V1, V2)`, `V2 = ominus(W, V1)`. ## Breaking changes - The `OrthogonalFactorization` structs have been removed, but their constructors are deprecated to obtain equivalent `MatrixAlgebraKit` algorithm structs. - The factorization functions `leftorth`, `rightorth`, `tsvd`, `eig`, `eigh` have been deprecated in favor of the MatrixAlgebraKit variants. - The truncation strategies are now directly inherited from `MatrixAlgebraKit`. This means `truncdim` is replaced by `truncrank`, `trunctol` is replaced by `truncbelow`, and there are deprecation warnings for the old functions. - The `left_orth` and `right_orth` functions will now always output tensors with a single space connecting them, which was not the case for `Polar` decompositions previously. To retrieve the old behavior with `isposdef` `R` factors (equal domain and codomain instead of isomorphic), the functions `left_polar` and `right_polar` can be used. - The `left_orth` and `right_orth` functions will now always have a connecting space with `isdual=false`. This is different from the previous behavior where some `N,1` or `1,N` tensors kept the `isdual` flag on the connecting leg. - There is no more direct call to both permute and factorize in one go. This is mainly because this is incompatible with the distinction between `permute` and `braid`. --------- Co-authored-by: Katharine Hyatt <[email protected]> Co-authored-by: Katharine Hyatt <[email protected]> Co-authored-by: Jutho <[email protected]>
1 parent ec78a85 commit a7d2bbb

35 files changed

+2587
-2485
lines changed

Project.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
name = "TensorKit"
22
uuid = "07d1fe3e-3e46-537d-9eac-e9e13d0d4cec"
33
authors = ["Jutho Haegeman"]
4-
version = "0.14.11"
4+
version = "0.15.0"
55

66
[deps]
77
LRUCache = "8ac3fa9e-de4c-5943-b1dc-09c6b5f20637"
88
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
9+
MatrixAlgebraKit = "6c742aac-3347-4629-af66-fc926824e5e4"
10+
OhMyThreads = "67456a42-1dca-4109-a031-0a68de7e3ad5"
911
PackageExtensionCompat = "65ce6f38-6b18-4e1d-a461-8949797d7930"
1012
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
13+
ScopedValues = "7e506255-f358-4e82-b7e4-beb19740aa63"
1114
Strided = "5e0ebb24-38b0-5f93-81fe-25c709ecae67"
1215
TensorKitSectors = "13a9c161-d5da-41f0-bcbd-e1a08ae0647f"
1316
TensorOperations = "6aa20fa7-93e2-5fca-9bc0-fbd0db3c71a2"
@@ -30,8 +33,11 @@ Combinatorics = "1"
3033
FiniteDifferences = "0.12"
3134
LRUCache = "1.0.2"
3235
LinearAlgebra = "1"
36+
MatrixAlgebraKit = "0.5.0"
37+
OhMyThreads = "0.8.0"
3338
PackageExtensionCompat = "1"
3439
Random = "1"
40+
ScopedValues = "1.3.0"
3541
Strided = "2"
3642
TensorKitSectors = "0.1.4, 0.2"
3743
TensorOperations = "5.1"

docs/Project.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
[deps]
22
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
3+
DocumenterInterLinks = "d12716ef-a0f6-4df4-a9f1-a5a34e75c656"
34
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
45
TensorKit = "07d1fe3e-3e46-537d-9eac-e9e13d0d4cec"
5-
TensorKitSectors = "13a9c161-d5da-41f0-bcbd-e1a08ae0647f"
66

77
[compat]
88
Documenter = "1"
99
Random = "1"
10-
TensorKitSectors = "0.1"

docs/make.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
using Documenter
22
using Random
3-
using TensorKit, TensorKitSectors
3+
using TensorKit
4+
using TensorKit.TensorKitSectors
5+
using TensorKit.MatrixAlgebraKit
6+
using DocumenterInterLinks
7+
8+
links = InterLinks("MatrixAlgebraKit" => "https://quantumkithub.github.io/MatrixAlgebraKit.jl/stable/",
9+
"TensorOperations" => "https://quantumkithub.github.io/TensorOperations.jl/stable/")
410

511
pages = ["Home" => "index.md",
612
"Manual" => ["man/intro.md", "man/tutorial.md", "man/categories.md",
@@ -15,6 +21,7 @@ makedocs(; modules=[TensorKit, TensorKitSectors],
1521
format=Documenter.HTML(; prettyurls=true, mathengine=MathJax(),
1622
assets=["assets/custom.css"]),
1723
pages=pages,
18-
pagesonly=true)
24+
pagesonly=true,
25+
plugins=[links])
1926

2027
deploydocs(; repo="github.com/QuantumKitHub/TensorKit.jl.git", push_preview=true)

docs/src/lib/spaces.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ dual
9090
conj
9191
flip
9292
93+
9394
zero(::ElementarySpace)
9495
oneunit
9596
supremum

docs/src/lib/tensors.md

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -214,26 +214,21 @@ contract!
214214

215215
## `TensorMap` factorizations
216216

217-
The factorisation methods come in two flavors, namely a non-destructive version where you
218-
can specify an additional permutation of the domain and codomain indices before the
219-
factorisation is performed (provided that `sectorstyle(t)` has a symmetric braiding) as
220-
well as a destructive version The non-destructive methods are given first:
217+
The factorisation methods are powered by [MatrixAlgebraKit.jl](https://github.com/QuantumKitHub/MatrixAlgebraKit.jl)
218+
and all follow the same strategy. The idea is that the `TensorMap` is interpreted as a linear
219+
map based on the current partition of indices between `domain` and `codomain`, and then the
220+
entire range of MatrixAlgebraKit functions can be called.
221+
Factorizing a tensor according to a different partition of the indices is possible
222+
by prepending the factorization step with an explicit call to [`permute`](@ref) or [`transpose`](@ref).
221223

222-
```@docs
223-
leftorth
224-
rightorth
225-
leftnull
226-
rightnull
227-
tsvd
228-
eigh
229-
eig
230-
eigen
231-
isposdef
232-
```
224+
For the full list of factorizations, see [Decompositions](@extref MatrixAlgebraKit).
233225

234-
The corresponding destructive methods have an exclamation mark at the end of their name,
235-
and only accept the `TensorMap` object as well as the method-specific algorithm and keyword
236-
arguments.
226+
Additionally, it is possible to obtain truncated versions of some of these factorizations
227+
through the [`MatrixAlgebraKit.TruncationStrategy`](@ref) objects.
237228

229+
The exact truncation strategy can be controlled through the strategies defined in [Truncations](@extref MatrixAlgebraKit),
230+
but for `TensorMap`s there is also the special-purpose scheme:
238231

239-
TODO: document svd truncation types
232+
```@docs
233+
truncspace
234+
```

ext/TensorKitChainRulesCoreExt/TensorKitChainRulesCoreExt.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module TensorKitChainRulesCoreExt
33
using TensorOperations
44
using VectorInterface
55
using TensorKit
6+
using TensorKit: foreachblock
67
using ChainRulesCore
78
using LinearAlgebra
89
using TupleTools
@@ -15,6 +16,5 @@ include("utility.jl")
1516
include("constructors.jl")
1617
include("linalg.jl")
1718
include("tensoroperations.jl")
18-
include("factorizations.jl")
1919

2020
end

0 commit comments

Comments
 (0)