Tensors¶
This section contains the API documentation for the tensors module.
Symmetry sectors¶
Type hierarchy¶
- class AbstractCharge¶
Abstract base class for objects in a fusion category.
- braidingstyle(a)¶
Trait that describes the braiding style.
- Arguments
a (
AbstractCharge) – input charge- Returns
style (
BraidingStyle) – braiding style of given charge
See also
- conj(a)¶
Compute the dual charge.
- Arguments
a (
AbstractCharge) – input charge- Returns
abar (
AbstractCharge) – conjugate charge such thatone(a)is an element ofa * abar
- fusionstyle(a)¶
Trait that describes the fusion style.
- Arguments
a (
AbstractCharge) – input charge- Returns
style (
FusionStyle) – fusion style of given charge
See also
- mtimes(a, b)¶
Implement the fusion rules.
- Arguments
a, b (
AbstractCharge) – charges to be fused- Returns
c ((1, :)
AbstractCharge) – the unique elements in the decomposition of the tensor product ofaandb
- Fsymbol(a, b, c, d, e, f)¶
Compute the recoupling coefficients.
Usage
F = Fsymbol(a, b, c, d, e, f)computes the isomorphism between the following fusion diagrams:- Arguments
a, b, c (
AbstractCharge) – charges being fusedd (
AbstractCharge) – total chargese (
AbstractCharge) – intermediate charge before recouplingf (
AbstractCharge) – intermediate charge after recoupling
- Returns
F ((:, :, :, :)
double) – recoupling coefficients
- Nsymbol(a, b, c)¶
Compute the fusion multiplicities.
- Arguments
a, b (
AbstractCharge) – charges being fusedc (
AbstractCharge) – resulting charge
- Returns
N (
int) – amount of times c appears in the fusion product of a and b
- one(a)¶
Compute the trivial charge.
- Arguments
a (
AbstractCharge) – input charge- Returns
e (
AbstractCharge) – trivial charge
- fusiontensor(a, b, c)¶
Compute a tensor for the fusion vertex.
Usage
C = fusiontensor(a, b, c)a tensor representation for the following diagram:- Arguments
a, b (
AbstractCharge) – charges being fusedc (
AbstractCharge) – resulting charge
- Returns
C ((:, :, :, :)
double) – fusion tensor
- Rsymbol(a, b, c, inv)¶
Compute the braiding coefficients.
Usage
R = Rsymbol(a, b, c, inv)computes the isomorphism between the following fusion diagrams:- Arguments
a, b (
AbstractCharge) – charges being fusedc (
AbstractCharge) – resulting chargeinv (
logical, optional) – compute inverse braiding coefficient (default false)
- Returns
R ((:, :)
double) – braiding coefficients
- Asymbol(a, b, c)¶
Compute the fusion to splitting coefficient.
Todo
Add diagram.
- Arguments
a, b (
AbstractCharge) – charges being fusedc (
AbstractCharge) – resulting charge
- Returns
A (
double) – fusion to splitting coefficient
- Bsymbol(a, b, c)¶
Compute the splitting to fusion coefficient.
Todo
Add diagram.
- Arguments
a, b (
AbstractCharge) – charges being fusedc (
AbstractCharge) – resulting charge
- Returns
B (
double) – splitting to fusion coefficient
- braidingmatrix(a, b, c, d, e, f, inv)¶
Compute the matrix for general Artin braids.
Todo
Complete docstring.
- flipper(a)¶
Create a matrix-representation of an arrowflip.
Todo
Add diagram and proper definition.
- Arguments
a (
AbstractCharge)- Returns
F ((:, :)
double) – matrix-representation of an arrowflip
- Fmatrix(a, b, c, d, e, f)¶
Compute the full recoupling matrix from
etof.Todo
Add proper definition.
Usage
F = Fmatrix(a, b, c, d, e, f)computes the matrix between all allowed channels.- Arguments
a, b, c (
AbstractCharge) – charges being fusedd (
AbstractCharge) – total chargese ((1, :)
AbstractCharge) – intermediate charges before recouplingf ((1, :)
AbstractCharge) – intermediate charge after recoupling
- Returns
F ((:, :, :, :)
double) – recoupling matrix between all allowed channels
- frobeniusschur(a)¶
Compute the Frobenius-Schur indicator.
- Arguments
a (
AbstractCharge)- Returns
nu (
double) – Frobenius-Schur indicator ofa
- qdim(a)¶
Compute the quantum dimension of a charge.
- Arguments
a (
AbstractCharge)- Returns
d (
double) – quantum dimension ofa
- twist(a)¶
Compute the coefficient obtained by twisting a charge.
Todo
Add diagram and proper definition.
- Arguments
a (
AbstractCharge)- Returns
theta (
double) – twist coefficient ofa
- prod(a, dim)¶
Compute the total fusion product of array of charges along a given axis.
- Arguments
a (
AbstractCharge) – input array of chargesdim (
int) – array dimension along which to take the fusion product, defaults to first non-trivial axis
- Returns
c (
AbstractCharge) – array of total fusion products determined by subsequently multiplying input charges along the given direction
- cumprod(a)¶
Cumulative fusion product of elements.
Todo
Complete docstring.
Usage
Y = cumprod(X)computes the cumulative fusion product along the columns of X.For
FusionStyle.Unique,Yhas the same size asX, which can be an arbitrarily-sized matrix. For other fusion styles,Xshould be a vector, andYis a matrix containing all different combinations.- Arguments
a ((:, :)
AbstractCharge)- Returns
charges (
AbstractCharge) – explanationvertices (type) – explanation
- combvec(X)¶
Create all combinations of vectors.
Todo
Complete docstring.
Usage
Y = combvec(X1, X2, ...)takes any number of inputsX, where eachXihasNicolumns, and returns a matrix ofprod(N)column vectors, where the columns consist of all combinations found by combining one column vector from eachXi.- Arguments
X (
AbstractCharge, repeating) – input charges- Returns
Y (
AbstractCharge) – explanation
See also
combvec()
- class FusionStyle¶
Bases:
uint8The fusion product behaviour of charges.
Enumeration class that encodes the possible behavior for the decomposition of the fusion product of two charges.
Unique: Single unique output.Simple: Multiple unique outputs.Generic: Multiple outputs.
- hasmultiplicity(style)¶
Determine whether a given fusionstyle admits fusion multiplicities.
Returns
trueforFusionStyle.Genericandfalsefor all other styles.
- and(style1, style2)¶
Determine the fusion style for a direct product of charges. This effectively boils down to returning the least specific style.
- Arguments
style1 (
FusionStyle) – fusion style of first charge in direct productstyle2 (
FusionStyle) – fusion style of second charge in direct product
- Returns
style (
FusionStyle) – fusion style of direct product charge
- class BraidingStyle¶
The braiding behaviour of charges.
Enumeration class that encodes the possibilities for the braiding of two charges:
Abelian: Trivial braiding with trivial twist.Bosonic: Symmetric braiding with trivial twist.Fermionic: Symmetric braiding with non-trivial twist.Anyonic: Arbitrary braiding and twist.None: No braiding defined.
- istwistless(style)¶
Determine whether a given braiding style has a trivial twist.
Returns
trueforBraidingStyle.AbelianandBraidingStyle.Bosonicandfalsefor all other styles.
- issymmetric(style)¶
Determine whether a given braiding style is symmetric.
Returns
truefor all styles exceptBraidingStyle.AnyonicandBraidingStyle.None.
- and(a, b)¶
Determine the braiding style for a direct product of charges. This effectively boils down to returning the least specific style.
- Arguments
style1 (
BraidingStyle) – fusion style of first charge in direct productstyle2 (
BraidingStyle) – fusion style of second charge in direct product
- Returns
style (
BraidingStyle) – fusion style of direct product charge
- class ProductCharge(charges)¶
Bases:
src.tensors.charges.AbstractChargeIrreducible representations of a direct product of groups.
- ProductCharge(charges)¶
Construct a product group charge.
Usage
charges = ProductCharge(charges1, charges2, ...)creates an (array of) charges that are representations of the direct product group \(G_1 \otimes G_2 \otimes \dots\).- Arguments
charges1, charges2, … (
AbstractCharge) – charges of the separate groups- Returns
prodcharge (
ProductCharge) – resulting product charge
- cat(dim, varargin)¶
Concatenate charges along a given axis.
- prod(a, dim)¶
Compute the total fusion product of array of charges along a given axis.
- Arguments
a (
ProductCharge) – input array of chargesdim (
int) – array dimension along which to take the fusion product, defaults to first non-trivial axis
- Returns
c (
ProductCharge) – array of total fusion products determined by subsequently multiplying input charges along the given direction
- subsref(prodcharges, s)¶
Overload indexing.
Usage
charges_slice = prodcharges(i1, i2, ...)extracts elements out of the charge array.product_slice = prodcharges{i}separates out the direct product factors.- Arguments
prodcharges (
ProductCharge) – array of product chargess (
substruct) – structure containing indexing data
- Returns
charges_slice (
ProductCharge) – sliced array of product chargesproduct_slice (
AbstractCharge) – array of factor charges
- subsasgn(a, s, b)¶
Overload indexed assignment.
Usage
a = subsasgn(a, substruct('()', subs), b)a(subs{:}) = bAssign array slices.
a = subsasgn(a, substruct('{}', subs), c)a{i} = cAssign to a factor slice.
- Arguments
a (
ProductCharge) – array of charges to assign to.s (
struct) – structure containing indexing data.b (
ProductCharge) – slice to assign.c (
AbstractCharge) – factor to assign.
- Returns
a (
ProductCharge) – assigned array
- Fmatrix(a, b, c, d, e, f)¶
Compute the full recoupling matrix from
etof.See also
Concrete charge types¶
- class Z1¶
Bases:
src.tensors.charges.AbstractChargeTrivial charge.
- class Z2(varargin)¶
Bases:
src.tensors.charges.AbstractCharge,logicalIrreducible representations of \(Z_2\).
This class implements the trivial or sign representations of \(Z_2\), represented using {
false,true} where fusion is given by \(\mathrm{XOR}\), giving the multiplication table:falsetruefalsefalsetruetruetruefalse
- class ZN(N, varargin)¶
Bases:
src.tensors.charges.AbstractCharge,uint8Irreducible representations of \(Z_N\).
This class implements the representations of the cyclic group of order \(N\), represented using unteger labels where fusion is given by addition modulo \(N\).
- Properties
N (
uint8) – integer representation label
- class fZ2¶
Bases:
src.tensors.charges.Z2Fermionic charges, implemented as a graded \(Z_2\) symmetry.
- class U1(varargin)¶
Bases:
src.tensors.charges.AbstractCharge,int16Irreducible representations of \(\mathrm{U}(1)\).
This class represents the representations of \(\mathrm{U}(1)\), labeled using integers where fusion is given by addition.
- class fU1¶
Bases:
src.tensors.charges.U1Fermionic \(\mathrm{U}(1)\) charges.
This is equivalent to representations of \(\mathrm{U}(1) \otimes fZ_2\), but restricted to only allow for the combinations of even with trivial and odd with fermion charges.
- class SU2(varargin)¶
Bases:
src.tensors.charges.AbstractCharge,uint8Irreducible representations of \(\mathrm{SU}(2)\).
This class represents the representations of \(\mathrm{SU}(2)\), represented using
uint8, such that the representative is equal to the quantum dimension. The use of \(uint8\) limits the maximum dimension to 255. The spin label can be recovered as \(s = (j - 1) / 2\).
- class fSU2¶
Bases:
src.tensors.charges.SU2Fermionic \(\mathrm{SU}(2)\) charges, used to represent fermionspin.
This is equivalent to representations of \(\mathrm{SU}(2) \otimes fZ_2\), but restricted to only allow for the combinations of integer with trivial and halfinteger with fermion charges.
- class SUN(varargin)¶
Bases:
src.tensors.charges.AbstractChargeIrreducible representations of the special unitary group \(\mathrm{SU}(N)\).
Todo
Explain irrep labeling and give some references.
- Properties
I ((1, :)
uint8) – integer vector representation label
- class O2(j, s)¶
Bases:
src.tensors.charges.AbstractChargeIrreducible representations of \(\mathrm{O}(2)\).
This class represents the representations of \(\mathrm{O}(2)\), also known as the semi-direct product of \(\mathrm{U}(1)\) and charge conjugation.
The representations are labeled using \((j, s)\), indicating the behaviour of \(\mathrm{U}(1)\) and charge conjugation respectively. This leads to two 1-dimensional representations \((0, 0)\) and \((0, 1)\), and for any non-negative \(j\) a two-dimensional representation \((j, 2)\).
- Properties
j (
uint8) – \(\mathrm{U}(1)\) labels (
uint8) – indicator for type of representation
- class A4(varargin)¶
Bases:
src.tensors.charges.AbstractCharge,uint8Irreducible representations of the alternating group of order 4. This is the group of even permutations on four elements, or of orientation-preserving symmetries of a regular tetrahedron. This is a non-abelian group with multiplicities.
The representations are labeled by the integers 1-4, with degrees [1 1 1 3].
Helper routines¶
- class GtPattern(N, M)¶
Object that represents a pattern devised by Gelfand and Tsetlin, used for enumerating \(\mathrm{SU}(N)\) basis states.
/m_{1,N} m_{2,N} ... m_{N,N}\ | m_{1,N-1} ... m_{N-1,N-1} | M = | ... | | m_{1,2} m_{2,2} | \ m_{1,1} /
These consist of triangular arrangements of integers \(M_{ij}\) with the following property:
\[m_{k,l} \geq m_{k,l-1} \geq m_{k+1,l} \quad \text{for} \quad 1 <= k < l <= N\]They will be represented using arrays of size \(N \times N\), where the elements outside of the triangular region are assumed to be zero.
- get(p, k, l)¶
Access an element in the pattern.
Usage
m = get(pat, k, l)gets the element specified by \(M_{kl}\).m = get(pat, ks, l)gets a row vector of elements in thel’th row.m = get(pat, k, ls)gets a column vector of elements in thek’th column.
- set(p, k, l, val)¶
Set the value of \(M_{kl}\) to
val.
- rowsum(p, l)¶
Compute the sum of row
l.Usage
sigma = rowsum(pat, l)computes \(\sigma_l = \sum_{k=1}^l m_{k, l}\).
- pWeight(p)¶
Compute the p-weight of a pattern.
Usage
w = pWeight(pat)computes the pattern weight \(W(\text{pat}) = (w_1 w_2 ... w_N)\) where \(w_i = \sigma_i - \sigma_{i-1}\).Note
This is an alternative weight definition to the z-weight.
See also
- zWeight(p)¶
Compute the z-weight of a pattern
Usage
w = zWeight(pat)computes the z-weight \(L(\text{pat}) = (l_1 l_2 ... l_N-1)\) where \(l_i = \sigma_l - 1/2(\sigma_{l+1} + \sigma_{l-1})\).Note
This is a generalization of the \(m\)-quantum number for angular momentum.
Fusion trees¶
- class FusionTree(charges, vertices, isdual, rank)¶
Bases:
matlab.mixin.CustomDisplaySplitting and fusion tree pair in canonical form.
- Properties
charges ((:, :)
AbstractCharge) – labels for the edges of the fusion treesvertices ((:, :)
int) – labels for the vertices of the fusion treesisdual ((1, :)
logical) – indicator of duality transform on the external edges.rank ((1, 2)
int) – amount of splitting tree and fusion tree legs.
- FusionTree(charges, vertices, isdual, rank)¶
Usage
f = FusionTree(charges, vertices, isdual, rank)- Arguments
charges ((:, :)
AbstractCharge) – array of charges, where each row represents an allowed fusion channel.vertices ( (, :) :
int) – Array of vertex labels. Must be empty or have the same amount of rows as charges. This is optional if the charges have a fusion style which is multiplicity-free.isdual ((1, :)
logical) – mask that shows the presence of duality transformations.rank ((1, 2)
int) – number of splitting and fusing legs.
- static new(rank, charges, isdual)¶
Generate all allowed fusion trees for a set of external charges.
- Arguments
rank ((1, 2)
int) – number of legs for the splitting and fusion tree.- Repeating Arguments
charges ((1, :)
AbstractCharge) – set of charges for a given legisdual (
logical) – presence of a duality transform
- artinbraid(f, i, inv)¶
Compute the coefficients for braiding a set of two neighbouring strands.
- Arguments
f (
FusionTree) – tree to swapi (
int) –iandi+1are the braided strandsinv (
logical=false) – flag to indicate whether to perform an overcrossing (false) or an undercrossing (true)
- Returns
c ((:, :)
sparse) – matrix of coefficients that transform input to output trees:f(i) --> c(i,j) * f(j)f (
FusionTree) – braided trees in canonical form.
- bendleft(f)¶
Compute the coefficients for bending a fusing leg to a splitting leg.
- Arguments
f (
FusionTree) – tree to bend.- Returns
c ((:, :)
sparse) – matrix of coefficients that transform input to output trees.f(i) --> c(i,j) * f(j)f (
FusionTree) – bent trees in canonical form.
- bendright(f)¶
Compute the coefficients for bending a splitting leg to a fusing leg.
- Arguments
f (
FusionTree) – tree to bend.- Returns
c ((:, :)
sparse) – matrix of coefficients that transform input to output trees.f(i) --> c(i,j) * f(j)f (
FusionTree) – bent trees in canonical form.
- braid(f, p, lvl, rank)¶
Compute the coefficients that bring a braided tree into canonical form.
This is done by reducing the braid into a composition of elementary swaps on neighbouring strands.
- Arguments
f (
FusionTree) – tree to braid.p ((:, :)
int) – permutation indices.lvl ((:, :)
int) – height of the strands, indicating over- and undercrossings.rank (
int(1, 2)) – final number of splitting and fusing legs.
- Returns
c ((:, :)
sparse) – matrix of coefficients that transform input to output trees.f(i) --> c(i,j) * f(j)f (
FusionTree) – braided trees in canonical form.
Todo
Currently this is done by first bending all legs to the splitting tree, this step is not necessary when no splitting legs are braided with fusing legs. Additionally this can be sped up significantly for charges with Abelian braiding style.
- permute(f, p, r)¶
Compute the coefficients that bring a permuted tree into canonical form.
- Arguments
f (
FusionTree) – tree to permute.p ((1, :)
int) – permutation indices.r ((1, 2)
int) – final number of splitting and fusing legs.
- Returns
c ((:, :)
sparse) – matrix of coefficients that transform input to output trees.f(i) --> c(i,j) * f(j)f (
FusionTree) – permuted trees in canonical form.
- repartition(f, newrank)¶
Compute the coefficients that bend legs to a desired rank.
- Arguments
f (
FusionTree) – tree to repartition.newrank ((1, 2)
int) – new rank of the fusion tree.
- Returns
c ((:, :)
sparse) – matrix of coefficients that transform input to output trees.f(i) --> c(i,j) * f(j)f (
FusionTree) – repartitioned trees in canonical form.
- twist(f, i, inv)¶
Compute the coefficients that twist legs.
- Arguments
f (
FusionTree) – tree to repartition.i (
intorlogical) – indices of legs to twist.inv (
logical) – flag to determine inverse twisting.
- Returns
c ((:, :)
sparse) – matrix of coefficients that transform input to output trees.f(i) --> c(i,j) * f(j)f (
FusionTree) – twisted trees in canonical form.
- sort(f)¶
sort - Sort the fusion trees into canonical order. [f, p] = sort(f)
- double(f)¶
Construct a numeric representation of a fusion tree.
- Arguments
f (
FusionTree)- Returns
A (
double) – array representation of a fusion tree.
- fusiontensor(f)¶
Construct an array representation of a fusion tree.
- Arguments
f (
FusionTree) – an array of fusion trees to convert.- Returns
C (
cell) – a cell array containing the array representations off.
Spaces¶
Type hierarchy¶
- class AbstractSpace(dimensions, dual)¶
Abstract structure of a tensor index.
- Properties
dimensions (
intorstruct) – Specification of the internal dimensionsdual (
logical) – Flag to indicate if the space is a dual space
- AbstractSpace(dimensions, dual)¶
Construct an array of vector spaces.
- Repeating Arguments
dimensions (
intorstruct) – a variable which represents the internal dimension of the space.isdual (
logical) – a variable which indicates if a space is dual.
- Returns
spaces (
AbstractSpace) – array of spaces.
- static new(dimensions, dual)¶
Construct a vector space. This is a utility method to be able to access the constructor of a subclass.
- Repeating Arguments
dimensions (
intorstruct) – a variable which represents the internal dimension of the space.dual (
logical) – a variable which indicates if a space is dual.
- Returns
spaces (
AbstractSpace) – array of spaces.
Note
This abstract constructor should be overloaded for every concrete subtype.
- charges(spaces)¶
Compute all charge combinations of a space. If no internal structure is present, this yields an empty result.
- Arguments
spaces ((1, :)
AbstractSpace) – input spaces.- Returns
c ((:, :)
AbstractCharge) – list of charge combinations, where each row is a combination.
- degeneracies(spaces)¶
Compute all degeneracy combinations of a product space.
- Arguments
spaces ((1, :)
AbstractSpace) – input spaces.- Returns
d ((:, :)
int) – list of degeneracy combinations, where each row is an entry.
- dims(spaces)¶
Compute the dimension of the spaces.
- Arguments
spaces ((1, :)
AbstractSpace) – input spaces.- Returns
d ((1, :)
double) – total dimension of each of the input spaces.
- fusiontrees(codomain, domain)¶
Compute all allowed fusiontrees that connect domain and codomain. Only the trivial fusion tree is allowed, so this returns empty.
- Arguments
codomain, domain (
GradedSpace) – input spaces.- Returns
trees (
FusionTree) – list of all allowed fusion trees.
- braidingstyle(codomain, domain)¶
Determine the braiding style of the internal structure of a space.
- Arguments
codomain, domain ((1, :)
AbstractSpace) – input spaces.- Returns
style (
BraidingStyle) – braiding style of the internal structure.
- fusionstyle(codomain, domain)¶
Determine the fusion style of the internal structure of a space.
- Arguments
codomain, domain ((1, :)
AbstractSpace) – input spaces.- Returns
style (
FusionStyle) – fusion style of the internal structure.
- conj(spaces)¶
Compute the element-wise dual space.
- Arguments
spaces ((1, :)
AbstractSpace) – input spaces.- Returns
spaces ((1, :)
AbstractSpace) – dual spaces.
- ctranspose(spaces)¶
Compute the dual space of the product space, found by taking the reverse order of the dual spaces.
- Arguments
spaces ((1, :)
AbstractSpace) – input product space.- Returns
spaces ((1, :)
AbstractSpace) – dual product space.
- mtimes(space1, space2)¶
Fuse two spaces to a single space.
- Arguments
space1, space2 ((1, 1)
AbstractSpace) – input spaces.- Returns
space ((1, 1)
AbstractSpace) – fused space.
- plus(space1, space2)¶
Find the direct sum of two spaces.
- Arguments
space1, space2 ((1, 1)
AbstractSpace) – input spaces.- Returns
space ((1, 1)
AbstractSpace) – direct sum space.
- prod(spaces)¶
Fuse a product space to a single space.
- Arguments
spaces ((1, :)
AbstractSpace) – array of input spaces.- Returns
space ((1, 1)
AbstractSpace) – Fused space which is isomorphic to the input product space.
- sum(spaces)¶
Fuse a list of spaces to the direct sum space.
- Arguments
spaces ((1, :)
AbstractSpace) – array of input spaces.- Returns
space ((1, 1)
AbstractSpace) – direct sum space.
- insertone(spaces, i, dual)¶
Insert a trivial space at a given position.
- Arguments
spaces ((1, :)
AbstractSpace) – array of input spaces.i (
int) – position at which to insert trivial space, defaults to the end.dual (
logical) – indicate if trivial space should be dualized, defaults tofalse.
- Returns
spaces ((1, :)
AbstractSpace) – array of output spaces.
- eq(spaces1, spaces2)¶
Verify if spaces are element-wise equal.
- Arguments
spaces1, spaces2 ((1, :)
AbstractSpace) – input spaces, either of equal size or scalar.- Returns
bools ((1, :)
logical) – flags that indicate if the element spaces are equal.
- istrivial(space)¶
Check whether a space is isomorphic to a trivial space.
- isequal(spaces)¶
Check whether all input spaces are equal. Spaces are considered equal if they are of same size, and are equal element-wise. For convenience, empty spaces are considered equal to any empty object.
Usage
bool = isequal(spaces{:})- Repeating Arguments
spaces ((1, :)
AbstractSpace) – input spaces to compare.- Returns
bool ((1, 1)
logical) – true if all inputs are equal.
- GetMD5_helper(spaces)¶
Helper function for hash algorithm. This converts the space object to a data structure which can be processed by
GetMD5().- Arguments
spaces (
AbstractSpace) – input spaces.- Returns
hashable (
cell) – data which can be accepted byGetMD5().
- disp(spaces)¶
Custom display of spaces.
- class SumSpace(subspaces)¶
Bases:
src.tensors.spaces.AbstractSpaceDirect sum structure for a tensor index.
- SumSpace(subspaces)¶
Construct a direct sum of vector spaces array of vector spaces.
- Repeating Arguments
subspace (
AbstractSpace) – individual subspaces of sum space.- Returns
spaces (
SumSpace) – array of spaces representing a direct sum of vector spaces.
Concrete space types¶
- class CartesianSpace(dimensions, ~)¶
Bases:
src.tensors.spaces.AbstractSpaceTensor index without any internal structure, which is self dual.
- CartesianSpace(dimensions, ~)¶
Construct an array of vector spaces.
- Repeating Arguments
dimensions ((1, 1)
int) – dimension of the vector space.~ (any) – ignored argument for syntax congruency with other spacetypes.
- Returns
spaces (
CartesianSpace) – array of cartesian spaces.
- static new(varargin)¶
Construct a vector space. This is a utility method to be able to access the constructor of a subclass.
Usage
spaces = CartesianSpace.new(dims)spaces = CartesianSpace.new(dimensions, ~, ...)- Arguments
dims ((1, :)
int) – vector of dimensions of all spaces.- Repeating Arguments
dimensions (
struct) – a variable which represents the internal dimension of the space.- Returns
spaces ((1, :)
CartesianSpace) – array of cartesian vector spaces.
- charges(spaces)¶
Compute all charge combinations of a space. No internal structure is present, this yields an empty result.
- Arguments
spaces ((1, :)
CartesianSpace) – input spaces.- Returns
c ((1, :)
Z1) – array of trivial spaces of corresponding length.
- degeneracies(spaces)¶
Compute all degeneracy combinations of a product space.
- Arguments
spaces ((1, :)
CartesianSpace) – input spaces.- Returns
d ((1, :)
int) – list of degeneracy combinations, with 1 element.
- dims(spaces)¶
Compute the dimension of the spaces.
- Arguments
spaces ((1, :)
CartesianSpace) – input spaces.- Returns
d ((1, :)
int) – total dimension of each of the input spaces.
- braidingstyle(~, ~)¶
Determine the braiding style of the internal structure of a space.
- Arguments
codomain, domain ((1, :)
CartesianSpace) – input spaces.- Returns
style (
BraidingStyle) – trivial braiding style,BraidingStyle.Abelian.
- fusionstyle(~, ~)¶
Determine the fusion style of the internal structure of a space.
- Arguments
codomain, domain ((1, :)
CartesianSpace) – input spaces.- Returns
style (
FusionStyle) – fusion style of the internal structure,FusionStyle.Unique.
- conj(spaces)¶
Compute the element-wise dual space, which is equal to itself.
- Arguments
spaces ((1, :)
CartesianSpace) – input spaces.- Returns
spaces ((1, :)
CartesianSpace) – dual spaces.
- mtimes(space, space2)¶
Fuse two spaces to a single space.
- Arguments
space1, space2 ((1, 1)
CartesianSpace) – input spaces.- Returns
space ((1, 1)
CartesianSpace) – fused space.
- prod(spaces, ~)¶
Fuse a product space to a single space.
- Arguments
spaces ((1, :)
CartesianSpace) – array of input spaces.- Returns
space ((1, 1)
CartesianSpace) – fused space which is isomorphic to the input product space.
- eq(spaces1, spaces2)¶
Verify if spaces are element-wise equal.
- Arguments
spaces1, spaces2 ((1, :)
CartesianSpace) – input spaces, either of equal size or scalar.- Returns
bools ((1, :)
logical) – flags that indicate if the element spaces are equal.
- GetMD5_helper(spaces)¶
Helper function for hash algorithm. This converts the space object to a data structure which can be processed by
GetMD5().- Arguments
spaces ((1, :)
CartesianSpace) – input spaces.- Returns
hashable ((1, :)
int) – data which can be accepted byGetMD5().
- class ComplexSpace(dimensions, isdual)¶
Bases:
src.tensors.spaces.AbstractSpaceTensor index without any internal structure, which is not self dual.
- ComplexSpace(dimensions, isdual)¶
Construct an array of vector spaces.
- Repeating Arguments
dimensions ((1, 1)
int) – dimension of the vector space.isdual ((1, 1)
logical) – flag to denote dual spaces.
- Returns
spaces ((1, :)
ComplexSpace) – array of complex spaces.
- static new(dimensions, isdual)¶
Construct a vector space. This is a utility method to be able to access the constructor of a subclass.
- Repeating Arguments
dimensions (
intorstruct) – a variable which represents the internal dimension of the space.isdual (
logical) – a variable which indicates if a space is dual.
- Returns
spaces (
ComplexSpace) – array of spaces.
- charges(spaces)¶
Compute all charge combinations of a space. No internal structure is present, this yields an empty result.
- Arguments
spaces ((1, :)
ComplexSpace) – input spaces.- Returns
c ((1, :)
Z1) – array of trivial spaces of corresponding length.
- degeneracies(spaces)¶
Compute all degeneracy combinations of a product space.
- Arguments
spaces ((1, :)
ComplexSpace) – input spaces.- Returns
d ((1, :)
int) – list of degeneracy combinations, with 1 element.
- dims(spaces)¶
Compute the dimension of the spaces.
- Arguments
spaces ((1, :)
ComplexSpace) – input spaces.- Returns
d ((1, :)
int) – total dimension of each of the input spaces.
- braidingstyle(~, ~)¶
Determine the braiding style of the internal structure of a space.
- Arguments
codomain, domain ((1, :)
ComplexSpace) – input spaces.- Returns
style (
BraidingStyle) – trivial braiding style,BraidingStyle.Abelian.
- fusionstyle(~, ~)¶
Determine the fusion style of the internal structure of a space.
- Arguments
codomain, domain ((1, :)
ComplexSpace) – input spaces.- Returns
style (
FusionStyle) – fusion style of the internal structure,FusionStyle.Unique.
- mtimes(space, space2)¶
Fuse two spaces to a single space.
- Arguments
space1, space2 ((1, 1)
ComplexSpace) – input spaces.- Returns
space ((1, 1)
ComplexSpace) – fused space.
- prod(spaces, isdual)¶
Fuse a product space to a single space.
- Arguments
spaces ((1, :)
ComplexSpace) – Array of input spaces.- Returns
space ((1, 1)
ComplexSpace) – Fused space which is isomorphic to the input product space.
- eq(spaces1, spaces2)¶
Verify if spaces are element-wise equal.
- Arguments
spaces1, spaces2 ((1, :)
ComplexSpace) – input spaces, either of equal size or scalar.- Returns
bools ((1, :)
logical) – flags that indicate if the element spaces are equal.
- GetMD5_helper(spaces)¶
Helper function for hash algorithm. This converts the space object to a data structure which can be processed by
GetMD5().- Arguments
spaces ((1, :)
ComplexSpace) – input spaces.- Returns
hashable ((1, :)
int) – data which can be accepted byGetMD5().
- class GradedSpace(dimensions, dual)¶
Bases:
src.tensors.spaces.AbstractSpaceTensor index structure with internal structure, which is not self dual.
- GradedSpace(dimensions, dual)¶
Construct an array of vector spaces.
- Repeating Arguments
dimensions ((1, 1)
struct) – internal structure of the vector space, with fieldschargesanddegeneracies.dual ((1, 1)
logical) – flag to denote dual spaces.
- Returns
spaces (
GradedSpace) – array of graded spaces.
- static new(varargin)¶
Construct a vector space. This is a utility method to be able to access the constructor of a subclass.
Usage
spaces = GradedSpace.new(charges, degeneracies, dual, ...)spaces = GradedSpace.new(dimensions, dual, ...)- Repeating Arguments
dimensions (
struct) – a variable which represents the internal dimension of the space.charges ((1, :)
AbstractCharge) – charges for the internal structure of the space.degeneracies ((1, :)
int) – degeneracies for the internal structure of the space.dual (
logical) – a variable which indicates if a space is dual.
- Returns
spaces (
GradedSpace) – array of graded spaces.
- charges(spaces)¶
Compute all charge combinations of a product space.
- Arguments
spaces ((1, :)
GradedSpace) – input spaces.- Returns
c ((:, :)
AbstractCharge) – list of charge combinations, where each row represents a possible combination.
- degeneracies(spaces)¶
Compute all degeneracy combinations of a product space.
- Arguments
spaces ((1, :)
GradedSpace) – input spaces.- Returns
d ((:, :)
int) – list of degeneracy combinations, where each row represents a possible combination.
- dims(spaces)¶
Compute the dimension of the spaces.
- Arguments
spaces ((1, :)
GradedSpace) – input spaces.- Returns
d ((1, :)
int) – total dimension of each of the input spaces.
- mtimes(space1, space2)¶
Fuse two spaces to a single space.
- Arguments
space1, space2 ((1, 1)
GradedSpace) – input spaces.- Returns
space ((1, 1)
GradedSpace) – fused space.
- prod(spaces, isdual)¶
Fuse a product space to a single space.
- Arguments
spaces ((1, :)
GradedSpace) – array of input spaces.- Returns
space ((1, 1)
GradedSpace) – fused space which is isomorphic to the input product space.
- eq(spaces1, spaces2)¶
Verify if spaces are element-wise equal.
- Arguments
spaces1, spaces2 ((1, :)
GradedSpace) – input spaces, either of equal size or scalar.- Returns
bools ((1, :)
logical) – flags that indicate if the element spaces are equal.
Convenience constructor wrappers¶
- Z2Space(charges, bonds, isdual)¶
Convenience constructor for \(Z_2\)-graded spaces.
- Arguments
charges ((1, :)
logical-like) – vector of \(Z_2\) charge labels.bonds ((1, :)
int) – degeneracy of each charge.isdual (
logical) – indicate if the space is dual.
- fZ2Space(charges, bonds, isdual)¶
Convenience constructor for \(fZ_2\)-graded spaces.
- Arguments
charges ((1, :)
logical-like) – vector of \(fZ_2\) charge labels.bonds ((1, :)
int) – degeneracy of each charge.isdual (
logical) – indicate if the space is dual.
- U1Space(charges, bonds, isdual)¶
Convenience constructor for \(\mathrm{U}(1)\)-graded spaces.
- Arguments
charges ((1, :)
int-like) – vector of \(\mathrm{U}(1)\) charge labels.bonds ((1, :)
int) – degeneracy of each charge.isdual (
logical) – indicate if the space is dual.
- SU2Space(charges, bonds, isdual)¶
Convenience constructor for \(\mathrm{SU}(2)\)-graded spaces.
- Arguments
charges ((1, :)
int-like) – vector of \(\mathrm{SU}(2)\) charge labels.bonds ((1, :)
int) – degeneracy of each charge.isdual (
logical) – indicate if the space is dual.
Kernels¶
- class AbstractBlock¶
Abstract structure for storing tensor data.
This represents the blocks in the block-diagonal decomposition of a general tensor.
- static new(codomain, domain)¶
Dispatch block type based on codomain and domain.
- Arguments
fun (
function_handle) – initialising function for the tensor data, with signaturedata = fun(dims)where dims is a row vector of dimensions.codomain (
AbstractSpace) – vector of vector spaces that form the codomain.domain (
AbstractSpace) – vector of vector spaces that form the domain.
- Returns
X (
AbstractBlock) – tensor data.
- axpby(a, X, b, Y, p, map)¶
Compute
Y = permute(X, p) .* a + Y .* b. This method is the computationally critical method of this class, thus has special cases for scalar multiplication (a == 0), addition (nargin == 4), and various optimizations whena == 1,b == 0 || b == 1. Additionally, this method should not be called directly as it should not perform any error checks.- Arguments
a (
double) – scalar to multiply with X.X (
AbstractBlock) – list of source blocks.b (
double) – scalar to multiply with Y.Y (
AbstractBlock) – list of destination blocks.p (
int) – permutation vector for X.map ((sparse)
double) – coefficient matrix for permuting X.
- Returns
Y (
AbstractBlock) – Result of computingY = permute(X, p) .* a + Y .* b.
Note
This is an abstract method that should be overloaded for each subtype.
- matrixblocks(b)¶
Extract a list of coupled matrix blocks.
- Arguments
b (
AbstractBlock) – list of input data.- Returns
mblocks (
cell) – list of non-zero coupled matrix blocks, sorted according to its charge.mcharges (
AbstractCharge) – list of coupled charges.
Note
This is an abstract method that should be overloaded for each subtype.
- mul(C, A, B, a, b)¶
Compute
C = (A .* a) * (B .* b). Compute the matrix product of two source tensor structures, and store the result in the destination tensor structure. This method should not perform any error checks.- Arguments
C (
AbstractBlock) – location to store the resultA (
AbstractBlock) – first matrix factorB (
AbstractBlock) – second matrix factora (
double= 1) – first scalar factorb (
double= 1) – second scalar factor
- Returns
C (
AbstractBlock) – Result of computing C = (A .* a) * (B .* b)
Note
This is an abstract method that should be overloaded for each subtype.
- tensorblocks(b)¶
Extract a list of uncoupled tensor blocks.
- Arguments
b (
AbstractBlock) – list of input data.- Returns
tblocks (
cell) – list of non-zero uncoupled tensor blocks, sorted according to the coupled charge and then in column-major order according to the uncoupled charges.
Note
This is an abstract method that should be overloaded for each subtype.
- axpy(a, X, Y, p, map)¶
Compute
Y = permute(X, p) .* a + Y. This method is a convenience method that automatically falls back onY = axpby(a, X, 1, Y, p, map), but can be overloaded if the additional efficiency is desired.- Arguments
a (
double) – scalar to multiply with X.X (
AbstractBlock) – list of source blocks.Y (
AbstractBlock) – list of destination blocks.p (
int) – permutation vector for X.map ((sparse)
double) – coefficient matrix for permuting X.
- Returns
Y (
AbstractBlock) – Result of computingY = permute(X, p) .* a + Y.
- minus(X, Y)¶
Subtraction of
Xand :code`Y`.Usage
Y = minus(X, Y)Y = X - Y- Arguments
X (
AbstractBlock) – first list of input data.Y (
AbstractBlock) – second list of input data.
- Returns
Y (
AbstractBlock) – list of output data.
- plus(X, Y)¶
Addition of
XandY.Usage
Y = plus(X, Y)Y = X + Y- Arguments
X (
AbstractBlock) – first list of input data.Y (
AbstractBlock) – second list of input data.
- Returns
Y (
AbstractBlock) – list of output data.
- times(Y, a)¶
Scalar multiplication of
Yanda.Usage
Y = times(Y, a)Y = Y .* a- Arguments
Y (
AbstractBlock) – list of input data.a (
double) – scalar factor.
- Returns
Y (
AbstractBlock) – list of output data.
- rdivide(Y, a)¶
Scalar division of Y and a.
Usage
Y = rdivide(Y, a)Y = Y ./ a- Arguments
Y (
AbstractBlock) – list of input data.a (
double) – scalar factor.
- Returns
Y (
AbstractBlock) – list of output data.
- uplus(A)¶
Unary plus. Equivalent to making a copy.
Usage
A = uplus(A)A = +A- Arguments
A (
AbstractBlock) – list of input data.- Returns
A (
AbstractBlock) – list of output data.
- uminus(Y)¶
Unary minus. Computes the additive inverse.
Usage
A = uminus(A)A = -A- Arguments
A (
AbstractBlock) – list of input data.- Returns
A (
AbstractBlock) – list of output data.
- underlyingType(X)¶
The scalar type of the tensor.
- Arguments
X (
AbstractBlock) – input block.- Returns
type (
char) – the scalar type of the data, which is one of the following:singleordoublelogicalint8,int16,int32orint64uint8,uint16,uint32oruint64
- ctranspose(X)¶
Adjoint of a tensor.
Usage
X = ctranspose(X)X = X'- Arguments
X (
AbstractBlock) – list of input data.- Returns
X (
AbstractBlock) – list of adjoint output data.
- class TrivialBlock(codomain, domain)¶
Bases:
src.tensors.kernels.AbstractBlockData structure for tensors without symmetry.
Todo
Document properties and behavior.
- class MatrixBlock(codomain, domain)¶
Bases:
src.tensors.kernels.AbstractBlockStructure for storing symmetric tensor data.
This represents the blocks in the block-diagonal decomposition of a tensor defined over graded vector spaces.
Todo
Document properties and behavior.
- class AbelianBlock¶
Bases:
src.tensors.kernels.MatrixBlockStructure for storing symmetric tensor data for an Abelian symmetry.
This represents the blocks in the block-diagonal decomposition of a tensor defined over graded vector spaces corresponding to an Abelian symmetry, allowing for a more efficient multiplication.
Tensors¶
- class AbstractTensor¶
Abstract base class for representing tensors.
See also
- linsolve(A, b, x0, M1, M2, options)¶
Find a solution for a linear system
A(x) = borA * x = b.- Arguments
A (
AbstractTensororfunction_handle) – either a function handle implementing or an object that supports right multiplication.b (
AbstractTensor) – right-hand side of the equation, interpreted as vector.x0 (
AbstractTensor) – optional initial guess for the solution.M1, M2 (
AbstractTensororfunction_handle) – preconditionerM = M1orM = M1 * M2to effectively solve the systemA * inv(M) * y = bwithy = M * x.Mis either a function handle implementing or an object that supports left division.
- Keyword Arguments
Tol (
numeric) – specifies the tolerance of the method, by default this is the square root of eps.Algorithm (
char) – specifies the algorithm used. Can be either one of the following:‘bicgstab’
‘bicgstabl’
‘gmres’
‘pcg’
MaxIter (
int) – Maximum number of iterations.Restart (
int) – For ‘gmres’, amount of iterations after which to restart.Verbosity (
int) – Level of output information, by default nothing is printed if flag is returned, otherwise only warnings are given.0 : no information
1 : information at failure
2 : information at convergence
- Returns
x (
AbstractTensor) – solution vector.flag (
int) – a convergence flag:0 : linsolve converged to the desired tolerance.
1 : linsolve reached the maximum iterations without convergence.
2 : linsolve preconditioner was ill-conditioned.
3 : linsolve stagnated.
4 : one of the scalar quantities calculated became too large or too small.
relres (
numeric) – relative residual, norm(b - A * x) / norm(b).iter (
int) – iteration number at which x was computed.resvec (
numeric) – vector of estimated residual norms at each part of the iteration.
- eigsolve(A, x0, howmany, sigma, options)¶
Find a few eigenvalues and eigenvectors of an operator.
Usage
[V, D, flag] = eigsolve(A, x0, howmany, sigma, kwargs)D = eigsolve(A, x0, ...)- Arguments
A (
AbstractTensororfunction_handle) – A square tensormap interpreted as matrix. A function handle which implements one of the following, depending on sigma:A x, if sigma is 0 or ‘smallestabs’(A - sigma * I) x, if sigma is a nonzero scalarA * x, for all other cases
x0 (
AbstractTensor) – initial guess for the eigenvector. If A is aTensor, this defaults to a random complexTensor, for function handles this is a required argument.howmany (
int) – amount of eigenvalues and eigenvectors that should be computed. By default this is 1, and this should not be larger than the total dimension of A.sigma (
charornumeric) – selector for the eigenvalues, should be either one of the following:‘largestabs’, ‘lm’: default, eigenvalues of largest magnitude
‘largestreal’, ‘lr’: eigenvalues with largest real part
‘largestimag’, ‘li’: eigenvalues with largest imaginary part.
‘smallestabs’, ‘sm’: default, eigenvalues of smallest magnitude
‘smallestreal’, ‘sr’: eigenvalues with smallest real part
‘smallestimag’, ‘si’: eigenvalues with smallest imaginary part.
‘bothendsreal’, ‘be’: both ends, with howmany/2 values with largest and smallest real part respectively.
‘bothendsimag’, ‘li’: both ends, with howmany/2 values with largest and smallest imaginary part respectively.
numeric : eigenvalues closest to sigma.
- Keyword Arguments
Tol (
numeric) – tolerance of the algorithm.Algorithm (
char) – choice of eigensolver algorithm. Currently there is a choice between the use of Matlab’s buitin eigs specified by the identifiers ‘eigs’ or ‘KrylovSchur’, or the use of a custom Arnoldi algorithm specified by the identifier ‘Arnoldi’.MaxIter (
int) – maximum number of iterations, 100 by default.KrylovDim (
int) – number of vectors kept in the Krylov subspace.IsSymmetric (
logical) – flag to speed up the algorithm if the operator is symmetric, false by default.Verbosity (
int) – Level of output information, by default nothing is printed ifflagis returned, otherwise only warnings are given.0 : no information
1 : information at failure
2 : information at convergence
3 : information at every iteration
- Returns
V ((1,
howmany)AbstractTensor) – vector of eigenvectors.D (
numeric) – vector of eigenvalues if only a single output argument is asked, diagonal matrix of eigenvalues otherwise.flag (
int) – ifflag = 0then all eigenvalues are converged, otherwise not.
- distance(A, B)¶
Compute the Euclidean distance between two tensors.
- Arguments
A, B (
AbstractTensor)- Returns
d (
numeric) – Euclidean distance, defined as the norm of the distance.
- decompose_local_operator(H, kwargs)¶
convert a tensor into a product of local operators.
Usage
local_operators = decompose_local_operator(H, kwargs).- Arguments
H (
AbstractTensor) – tensor representing a local operator on N sites.- Keyword Arguments
‘Trunc’ (
cell) – optional truncation method for the decomposition. See alsoTensor.tsvd()
- class Tensor(varargin)¶
Bases:
src.tensors.AbstractTensorBase implementation of a dense tensor array with optional symmetries.
- Properties
codomain – codomain vector space represented as tensor product space.
domain – codomain vector space represented as tensor product space.
var – block sparse representation of tensor data.
Todo
Document all methods.
- Tensor(varargin)¶
Create a tensor object.
Usage
t = Tensor(array)t = Tensor(codomain, domain)- Arguments
array (
numeric) – numeric input array to convert to aTensorcodomain, domain ((1, :)
AbstractSpace) – spaces that define the structure of the output tensor.
- Returns
t (
Tensor) – new tensor object.
- fill_matrix(t, data, charges)¶
Fill the matrix blocks of a tensor.
Usage
t = fill_matrix(t, matrices, charges)t = fill_matrix(t, fun, charges)- Arguments
t (
Tensor) – input tensor to fill into.matrices (
cellornumeric) – list of matrices or single matrix to fill with.fun (
function_handle) – function of signaturefun(dims, charge)to fill with.charges (
AbstractCharge) – optional list of charges to identify the matrix blocks.
- Returns
t (
Tensor) – filled tensor.
- fill_tensor(t, data)¶
Fill the tensor blocks of a tensor.
Usage
t = fill_tensor(t, tensors)t = fill_tensor(t, fun)
- similar(fun, tensors, indices, kwargs)¶
Create a tensor based on the indices of other tensors.
Usage
t = similar(fun, tensors, indices, kwargs)- Arguments
fun (
function_handle) – function to fill the tensor data with. This should have signature based on keyword Mode. If left empty, this defaults to a random complex tensor.- Repeating Arguments
tensors (
Tensor) – input tensors used to copy legs.indices (int) – array of which indices to copy for each input tensor.
- Keyword Arguments
Rank ((1, 2)
int´) -- rank of the output tensor, by default this is :code:`[nspaces(t) 0].Conj (
logical) – flag to indicate whether the space should be equal to the input space, or fit onto the input space. This can be either an array of size(tensors), or a scalar, in which case it applies to all tensors.Mode (
char, ‘tensor’ or ‘matrix’) – method of filling the tensor data. By default this is matrix, where the function should be of signaturefun(dims, charge), for ‘tensor’ this should be of signaturefun(dims, tree).
- Returns
t (
Tensor) – output tensor.
Examples
t = similar([], mpsbar, 1, mpo, 4, mps, 1, 'Conj', true)creates a left mps environment tensor.
- static new(fun, varargin, kwargs)¶
Create a tensor with data using a function handle.
Usage
Tensor.new(fun, dims)Tensor.new(fun, dims, arrows)Tensor.new(fun, codomain, domain)Tensor.new(fun, tensor)Tensor.new(..., 'Rank', r, 'Mode', mode)- Arguments
fun (
function_handle) – function of signaturefun(dims, id)where id is determined by Mode. If this is left empty, the tensor data will be uninitialized.dims (
int) – list of dimensions for non-symmetric tensors.arrows (
logical) – optional list of arrows for tensor legs.tensor (
Tensor) – input tensor to copy structure.
- Repeating Arguments
charges (
cell) – list of charges for each tensor index.degeneracies (
cell) – list of degeneracies for each tensor index.arrow (
logical) – arrow for each tensor index.
- Keyword Arguments
Rank ((1, 2)
int) – rank of the constructed tensor. By default this is[nspaces(t) 0].Mode (
char, ‘matrix’ or ‘tensor’) – method of filling the resulting tensor. When this is ‘matrix’ (default), the function signature isfun(dims, charge), while for ‘tensor’ the signature should befun(dims, tree).
- Returns
t (
Tensor) – output tensor.
- insert_onespace(tsrc, i, dual)¶
Insert a trivial space at position
i.- Arguments
tsrc (
Tensor) – input tensor.i (
int) – position at which to insert trivial space, defaults to the last index.dual (
logical) – indicate whether or not to dualize the trivial space, defaults tofalse.
- embed(tsrc, tdst)¶
Embed a tensor in a different tensor.
- conj(t)¶
Compute the conjugate of a tensor. This is defined as taking an element-wise conjugate, but implemented as taking the adjoint and reversing the order of the indices.
- ctranspose(t)¶
Compute the adjoint of a tensor. This is defined as swapping the codomain and domain, while computing the adjoint of the matrix blocks.
Usage
t = ctranspose(t)t = t'
- dot(t1, t2)¶
Compute the scalar dot product of two tensors. This is defined as the overlap of the two tensors, which therefore must have equal domain and codomain. This function is sesquilinear in its arguments.
- Arguments
t1, t2 (
Tensor) – tensors of equal structure.- Returns
d (
double) – scalar dot product of the two tensors.
- minus(t1, t2)¶
Compute the difference between two tensors.
- mldivide(t1, t2)¶
Left division of tensors.
Usage
t = mldivide(t1, t2)t = t1 t2
- mrdivide(t1, t2)¶
Right division of tensors.
Usage
t = mrdivide(t1, t2)t1 = t1 / t2
- mtimes(A, B)¶
Compose tensors, interpreted as maps from domain to codomain.
Usage
A = mtimes(A, B)A = A * B
- norm(t, p)¶
Compute the matrix p-norm of a tensor.
- Arguments
t (
Tensor) – input tensor, considered as a matrix from domain to codomain.p (1, 2, ‘inf’ or ‘fro’) – type of norm to compute
- Returns
n (
double) – matrix norm of the tensor.
- tpermute(t, p, r)¶
Permute the spaces of a tensor.
- repartition(t, r)¶
Change the rank of a tensor.
- Arguments
t (
Tensor) – input tensor.r ((1, 2)
int) – rank of the output tensor, by default equal to[nspaces(t) 0].
- Returns
t (
Tensor) – repartitioned tensor with desired rank.
- rdivide(t, a)¶
Scalar division of a tensor and a scalar.
Usage
t = rdivide(t, a)t = t ./ a- Arguments
t (
Tensor) – input tensor.a (
numeric) – input scalar.
- Returns
t (
Tensor) – output tensor.
- tensorprod(A, B, dimA, dimB, ca, cb, options)¶
Compute the contraction of two tensors through the selected spaces.
- Arguments
A, B (
Tensor) – input tensors, must satisfyspace(A, dimA) == conj(space(B, dimB)).dimA, dimB ((1, :)
int) – selected indices to contract.
- Keyword Arguments
NumDimensionsA (
int) – number of spaces of A, to satisfy builtin tensorprod syntax.- Returns
C (
Tensorornumeric) – output tensor, with the uncontracted spaces of A as codomain, and the uncontracted spaces of B as domain, or output scalar, if no uncontracted spaces remain.
- times(A, B)¶
Scalar product of a tensor and a scalar.
Usage
t = times(t, a)t = a .* t
- trace(t)¶
Compute the matrix trace of a tensor.
- Arguments
t (
Tensor) – input tensor, considered as a matrix from domain to codomain.- Returns
tr (
double) – matrix trace of the tensor.
- transpose(t, p, r)¶
Compute the transpose of a tensor. This is defined as rotating the domain to the codomain and vice versa, while cyclicly permuting the tensor blocks.
Usage
t = transpose(t, p, rank)t = t.'- Arguments
t (
:Tensor) – input tensor.p ((1, :)
int) – permutation vector, which must be cyclic. By default this is no permutation.r ((1, 2)
int) – rank of the output tensor, by default equal to the rank of the input tensor.
- Returns
t (
Tensor) – transposed output tensor.
- twist(t, i, inv)¶
Twist the spaces of a tensor.
- twistdual(t, i, inv)¶
Twist the spaces of a tensor if they are dual.
- eig(A)¶
Compute the eigenvalues and eigenvectors of a square tensor.
Usage
D = eig(A)[V, D] = eig(A)[V, D, W] = eig(A)
- leftorth(t, p1, p2, alg)¶
Factorize a tensor into an orthonormal basis Q and remainder R, such that
tpermute(t, [p1 p2], [length(p1) length(p2)]) = Q * R.Usage
[Q, R] = leftorth(t, p1, p2, alg)- Arguments
t (
Tensor) – input tensor to factorize.p1, p2 (
int) – partition of left and right indices, by default this is the partition of the input tensor.alg (
charorstring) – selection of algorithms for the decomposition:'qr'produces an upper triangular remainder R'qrpos'corrects the diagonal elements of R to be positive.'ql'produces a lower triangular remainder R'qlpos'corrects the diagonal elements of R to be positive.'polar'produces a Hermitian and positive semidefinite R.'svd'uses a singular value decomposition.
- Returns
- rightorth(t, p1, p2, alg)¶
Factorize a tensor into an orthonormal basis Q and remainder L, such that
tpermute(t, [p1 p2], [length(p1) length(p2)]) = L * Q.Usage
[R, Q] = rightorth(t, p1, p2, alg)- Arguments
t (
Tensor) – input tensor to factorize.p1, p2 (
int) – partition of left and right indices, by default this is the partition of the input tensor.alg (
charorstring) – selection of algorithms for the decomposition:'rq'produces an upper triangular remainder R'rqpos'corrects the diagonal elements of R to be positive.'lq'produces a lower triangular remainder R'lqpos'corrects the diagonal elements of R to be positive.'polar'produces a Hermitian and positive semidefinite R.'svd'uses a singular value decomposition.
- Returns
- leftnull(t, p1, p2, alg, atol)¶
Compute the left nullspace of a tensor, such that
N' * tpermute(t, [p1 p2], [length(p1) length(p2)]) = 0.- Arguments
t (
Tensor) – input tensor to compute the nullspace.p1, p2 (
int) – partition of left and right indices, by default this is the partition of the input tensor.alg (
charorstring) – selection of algorithms for the nullspace:'svd''qr'
- Returns
N (
Tensor) – orthogonal basis for the left nullspace.
- rightnull(t, p1, p2, alg, atol)¶
Compute the right nullspace of a tensor, such that
tpermute(t, [p1 p2], [length(p1) length(p2)]) * N = 0.- Arguments
t (
Tensor) – input tensor to compute the nullspace.p1, p2 (
int) – partition of left and right indices, by default this is the partition of the input tensor.alg (
charorstring) – selection of algorithms for the nullspace:'svd''lq'
- Returns
N (
Tensor) – orthogonal basis for the right nullspace.
- tsvd(t, p1, p2, trunc)¶
Compute the singular value decomposition of a tensor. This computes left and right isometries U and V, and a non-negative diagonal tensor S such that
norm(tpermute(t, [p1 p2], [length(p1) length(p2)]) - U * S * V) = 0Additionally, the dimension of S can be truncated in such a way to minimize this norm, which gives the truncation error eta.Usage
[U, S, V] = tsvd(t, p1, p2)[U, S, V, eta] = tsvd(t, p1, p2, trunc, tol)S = tsvd(t, ...)- Arguments
t (
Tensor) – input tensor.p1, p2 (
int) – partition of left and right indices, by default this is the partition of the input tensor.
- Keyword Arguments
TruncDim (
int) – truncate such that the dim of S is not larger than this value for any given charge.TruncTotalDim (
int) – truncate such that the total dim of S is not larger than this value.TruncBelow (
numeric) – truncate such that there are no singular values below this value.TruncSpace (
AbstractSpace) – truncate such that the space of S is smaller than this value.
- Returns
U, S, V (
Tensor) – left isometry U, non-negative diagonal S and right isometry V that satisfyU * S * V = tpermute(t, [p1 p2], [length(p1) length(p2)]).eta (
numeric) – truncation error.
- expm(t)¶
Compute the matrix exponential of a square tensor. This is done via a scaling and squaring algorithm with a Pade approximation, block-wise.
- inv(t)¶
Compute the matrix inverse of a square tensor, such that
t * inv(t) = I.
- mpower(X, Y)¶
Raise a square tensor to a scalar power, or a scalar to a square tensor power.
Usage
A = x^YA = X^y
- sqrtm(A)¶
Compute the principal square root of a square tensor. This is the unique root for which every eigenvalue has nonnegative real part. If
tis singular, then the result may not exist.
- isposdef(t)¶
Test if a tensor is a positive-definite map. Generally, a Hermitian matrix M is positive-definite if the real number z’ * M * z is positive for every nonzero complex column vector z. This is equivalent to any of the following conditions:
M is Hermitian and all eigenvalues are real and positive.
M is congruent with a diagonal matrix with positive real entries.
There exists an invertible B such that M = B’ * B.
- Arguments
t (
Tensor) – input tensor.- Returns
bool (
logical) – true iftis positive definite.
- isisometry(t, side, tol)¶
Test if a tensor is an isometric map. Generally, a matrix M is left or right isometric if M’ * M = I or M * M’ = I.
- Arguments
t (
Tensor) – input tensor.side (
char) – either ‘left’, ‘right’ or ‘both’ (default).
- Keyword Arguments
AbsTol, RelTol (
numeric) –norm(t * t' - eye(size(t))) < max(AbsTol, RelTol * norm(t)). By defaultAbsTol = 0andRelTol = eps.- Returns
bool (
logical) – true iftis isometric.
- cond(t, p)¶
Condition number with respect to inversion. This is defined as \(||t|| * ||t^{-1}||\) in the p-norm. For well conditioned tensors, the value is near 1.0, while for badly conditioned tensors the value diverges.
- Arguments
t (
Tensor) – input tensor.p (1, 2, inf or ‘fro’) – kind of norm to use. Default is the 2-norm.
- Returns
r (
double) – Condition number.
- vectorize(t, type)¶
Collect all parameters in a vector, weighted to reproduce the correct inner product.
- Arguments
t (
Tensor) – input tensor.type (
char, ‘real’ or ‘complex’) – optionally specify if complex entries should be seen as 1 or 2 parameters. Defaults to ‘complex’, with complex parameters.
- Returns
v (
numeric) – real or complex vector containing the parameters of the tensor.
- devectorize(v, t, type)¶
Collect all parameters from a vector, and insert into a tensor.
- Arguments
v (
numeric) – real or complex vector containing the parameters of the tensor.t (
Tensor) – input tensor.type (
char, ‘real’ or ‘complex’) – optionally specify if complex entries should be seen as 1 or 2 parameters. Defaults to ‘complex’, with complex parameters.
- Returns
t (
Tensor) – output tensor, filled with the parameters.
- double(t)¶
Convert tensor to array of double.
- Arguments
t (
Tensor)- Returns
a (
double)