VMPS++
Loading...
Searching...
No Matches
Biped< Symmetry, MatrixType_ > Struct Template Reference

Detailed Description

template<typename Symmetry, typename MatrixType_>
struct Biped< Symmetry, MatrixType_ >

Tensor with two legs and quantum number blocks. One could have used a general tensor, but the special case of two legs is hardcoded to preserve the sanity of the programmer. For the general tensor see Multipede.

Template Parameters
Symmetry: A class providing all relevant functions and infos that are determined by the Symmetry. Click here for more information.
MatrixType: MatrixXd or MatrixXcd

Definition at line 63 of file Biped.h.

#include <Biped.h>

Public Types

typedef MatrixType_ MatrixType
 

Public Member Functions

 Biped ()
 
std::string formatted () const
 
std::string print (const bool SHOW_MATRICES=false, const std::size_t precision=3) const
 
std::string print_dict () const
 
double memory (MEMUNIT memunit=GB) const
 
double overhead (MEMUNIT memunit=MB) const
 
Scalar trace () const
 
template<typename expScalar >
Biped< Symmetry, MatrixType_ > exp (const expScalar x) const
 
template<typename OtherMatrixType >
void outerResize (const Biped< Symmetry, OtherMatrixType > Brhs)
 
template<typename OtherMatrixType >
Biped< Symmetry, OtherMatrixType > cast () const
 
void shift_Qin (const qarray< Symmetry::Nq > &Q)
 
void clear ()
 
void setZero ()
 
void setRandom ()
 
void setVacuum ()
 
void setTarget (qType Qtot)
 
void setTarget (vector< qType > Qmulti)
 
void setIdentity (const Qbasis< Symmetry > &base1, const Qbasis< Symmetry > &base2, qType Q=Symmetry::qvacuum())
 
void setRandom (const Qbasis< Symmetry > &base1, const Qbasis< Symmetry > &base2, qType Q=Symmetry::qvacuum())
 
void setZero (const Qbasis< Symmetry > &base1, const Qbasis< Symmetry > &base2, qType Q=Symmetry::qvacuum())
 
Biped< Symmetry, MatrixType_ > cleaned () const
 
Biped< Symmetry, MatrixType_ > sorted () const
 
Biped< Symmetry, MatrixType_ > adjoint () const
 
Biped< Symmetry, MatrixType_ > transpose () const
 
Biped< Symmetry, MatrixType_ > conjugate () const
 
Biped< Symmetry, MatrixType_ > adjustQN (const size_t number_cells)
 
void cholesky (Biped< Symmetry, MatrixType > &res) const
 
template<typename EpsScalar >
tuple< Biped< Symmetry, MatrixType_ >, Biped< Symmetry, MatrixType_ >, Biped< Symmetry, MatrixType_ > > truncateSVD (size_t minKeep, size_t maxKeep, EpsScalar eps_svd, double &truncWeight, double &entropy, map< qarray< Symmetry::Nq >, Eigen::ArrayXd > &SVspec, bool PRESERVE_MULTIPLETS=true, bool RETURN_SPEC=true) const
 
template<typename EpsScalar >
tuple< Biped< Symmetry, MatrixType_ >, Biped< Symmetry, MatrixType_ >, Biped< Symmetry, MatrixType_ > > truncateSVD (size_t minKeep, size_t maxKeep, EpsScalar eps_svd, double &truncWeight, bool PRESERVE_MULTIPLETS=true) const
 
pair< Biped< Symmetry, MatrixType_ >, Biped< Symmetry, MatrixType_ > > QR (bool RETURN_LQ=false, bool MAKE_UNIQUE=false) const
 
Biped< Symmetry, MatrixType_ > & operator+= (const Biped< Symmetry, MatrixType_ > &Arhs)
 
void addScale (const Scalar &factor, const Biped< Symmetry, MatrixType_ > &Mrhs, BLOCK_POSITION BP=SAME_PLACE)
 
void addScale_extend (const Scalar &factor, const Biped< Symmetry, MatrixType_ > &Mrhs)
 
Biped< Symmetry, MatrixType_ > contract (const Biped< Symmetry, MatrixType_ > &A, const contract::MODE MODE=contract::MODE::UNITY) const
 
void push_back (qType qin, qType qout, const MatrixType_ &M)
 
void push_back (std::array< qType, 2 > quple, const MatrixType_ &M)
 
void try_push_back (std::array< qType, 2 > quple, const MatrixType_ &M)
 
void try_push_back (qType qin, qType qout, const MatrixType_ &M)
 
void create_block (std::array< qType, 2 > quple)
 
void try_create_block (std::array< qType, 2 > quple)
 

Private Types

typedef Symmetry::qType qType
 
typedef Eigen::Index Index
 
typedef MatrixType_::Scalar Scalar
 
std::size_t dim
 
std::vector< qTypein
 
std::vector< qTypeout
 
std::vector< MatrixType_ > block
 
std::size_t size () const
 
void plusplus ()
 
std::unordered_map< std::array< qType, 2 >, std::size_t > dict
 
Eigen::VectorXi rows (bool FULL=false) const
 
Eigen::VectorXi cols (bool FULL=false) const
 
double operatorNorm (bool COLWISE=true) const
 
double norm () const
 
Eigen::VectorXd squaredNorm () const
 

Member Typedef Documentation

◆ Index

template<typename Symmetry , typename MatrixType_ >
typedef Eigen::Index Biped< Symmetry, MatrixType_ >::Index
private

Definition at line 67 of file Biped.h.

◆ MatrixType

template<typename Symmetry , typename MatrixType_ >
typedef MatrixType_ Biped< Symmetry, MatrixType_ >::MatrixType

Definition at line 69 of file Biped.h.

◆ qType

template<typename Symmetry , typename MatrixType_ >
typedef Symmetry::qType Biped< Symmetry, MatrixType_ >::qType
private

Definition at line 66 of file Biped.h.

◆ Scalar

template<typename Symmetry , typename MatrixType_ >
typedef MatrixType_::Scalar Biped< Symmetry, MatrixType_ >::Scalar
private

Definition at line 71 of file Biped.h.

Constructor & Destructor Documentation

◆ Biped()

template<typename Symmetry , typename MatrixType_ >
Biped< Symmetry, MatrixType_ >::Biped ( )
inline

Definition at line 75 of file Biped.h.

Member Function Documentation

◆ addScale()

template<typename Symmetry , typename MatrixType_ >
void Biped< Symmetry, MatrixType_ >::addScale ( const Scalar factor,
const Biped< Symmetry, MatrixType_ > &  Mrhs,
BLOCK_POSITION  POS = SAME_PLACE 
)

Adds two Bipeds block- and coefficient-wise.

Definition at line 1294 of file Biped.h.

◆ addScale_extend()

template<typename Symmetry , typename MatrixType_ >
void Biped< Symmetry, MatrixType_ >::addScale_extend ( const Scalar factor,
const Biped< Symmetry, MatrixType_ > &  Mrhs 
)

Adds two Bipeds block- and coefficient-wise. Extends the result if the block sizes don't match.

Definition at line 1366 of file Biped.h.

◆ adjoint()

template<typename Symmetry , typename MatrixType_ >
Biped< Symmetry, MatrixType_ > Biped< Symmetry, MatrixType_ >::adjoint

Returns the adjoint tensor where all the block matrices are adjoint and the quantum number arrows are flipped: in $\to$ out and vice versa.

Definition at line 629 of file Biped.h.

◆ adjustQN()

template<typename Symmetry , typename MatrixType_ >
Biped< Symmetry, MatrixType_ > Biped< Symmetry, MatrixType_ >::adjustQN ( const size_t  number_cells)

This functions transforms all quantum numbers in Biped::in and Biped::out by $q \rightarrow q * N_{cells}$. It is used for avg(Umps V, Mpo O, Umps V) in VumpsLinearAlgebra.h when O.length() > V.length(). In this case the quantum numbers in the Bipeds are transformed in correspondence with V.length() and this is incompatible with the quantum numbers in O.length() which are transformed in correspondence to O.length().

Parameters
number_cells: $N_{cells}$

Definition at line 710 of file Biped.h.

◆ cast()

template<typename Symmetry , typename MatrixType_ >
template<typename OtherMatrixType >
Biped< Symmetry, OtherMatrixType > Biped< Symmetry, MatrixType_ >::cast ( ) const
inline

Definition at line 268 of file Biped.h.

◆ cholesky()

template<typename Symmetry , typename MatrixType_ >
void Biped< Symmetry, MatrixType_ >::cholesky ( Biped< Symmetry, MatrixType > &  res) const

Returns the adjoint tensor where all the block matrices are adjoint and the quantum number arrows are flipped: in $\to$ out and vice versa.

Definition at line 728 of file Biped.h.

◆ cleaned()

template<typename Symmetry , typename MatrixType_ >
Biped< Symmetry, MatrixType_ > Biped< Symmetry, MatrixType_ >::cleaned

Returns the adjoint tensor where all the block matrices are adjoint and the quantum number arrows are flipped: in $\to$ out and vice versa.

Definition at line 596 of file Biped.h.

◆ clear()

template<typename Symmetry , typename MatrixType_ >
void Biped< Symmetry, MatrixType_ >::clear

Deletes the contents of in, out, block, dict.

Definition at line 324 of file Biped.h.

◆ cols()

template<typename Symmetry , typename MatrixType_ >
Eigen::VectorXi Biped< Symmetry, MatrixType_ >::cols ( bool  FULL = false) const

Returns an Eigen vector of size dim containing all Matrix cols for every block nu.

Definition at line 465 of file Biped.h.

◆ conjugate()

template<typename Symmetry , typename MatrixType_ >
Biped< Symmetry, MatrixType_ > Biped< Symmetry, MatrixType_ >::conjugate

Returns the adjoint tensor where all the block matrices are adjoint and the quantum number arrows are flipped: in $\to$ out and vice versa.

Definition at line 681 of file Biped.h.

◆ contract()

template<typename Symmetry , typename MatrixType_ >
Biped< Symmetry, MatrixType_ > Biped< Symmetry, MatrixType_ >::contract ( const Biped< Symmetry, MatrixType_ > &  A,
const contract::MODE  MODE = contract::MODE::UNITY 
) const

This functions perform a contraction of this and A, which is a standard Matrix multiplication in this case.

Parameters
A: other Biped which is contracted together with this.
MODE

Definition at line 975 of file Biped.h.

◆ create_block()

template<typename Symmetry , typename MatrixType_ >
void Biped< Symmetry, MatrixType_ >::create_block ( std::array< qType, 2 >  quple)

Adds a new block to the tensor specified by the incoming quantum number qin and the outgoing quantum number qout.

Warning
Does not check whether the block for these quantum numbers already exists.

Definition at line 568 of file Biped.h.

◆ exp()

template<typename Symmetry , typename MatrixType_ >
template<typename expScalar >
Biped< Symmetry, MatrixType_ > Biped< Symmetry, MatrixType_ >::exp ( const expScalar  x) const

Definition at line 1068 of file Biped.h.

◆ formatted()

template<typename Symmetry , typename MatrixType_ >
std::string Biped< Symmetry, MatrixType_ >::formatted

Prints the whole tensor, formatting the quantum numbers

Definition at line 1119 of file Biped.h.

◆ memory()

template<typename Symmetry , typename MatrixType_ >
double Biped< Symmetry, MatrixType_ >::memory ( MEMUNIT  memunit = GB) const

Calculates the (theoretically) allocated memory (note: by default in GB).

Definition at line 1097 of file Biped.h.

◆ norm()

template<typename Symmetry , typename MatrixType_ >
double Biped< Symmetry, MatrixType_ >::norm

Returns the total Frobenius norm of the Biped. This is equivalent to std::sqrt(squaredNorm().sum()).

Definition at line 509 of file Biped.h.

◆ operator+=()

template<typename Symmetry , typename MatrixType_ >
Biped< Symmetry, MatrixType_ > & Biped< Symmetry, MatrixType_ >::operator+= ( const Biped< Symmetry, MatrixType_ > &  Arhs)

Adds another tensor to the current one. If quantum numbers match, the block is updated (block rows and columns must match), otherwise a new block is created.

Definition at line 948 of file Biped.h.

◆ operatorNorm()

template<typename Symmetry , typename MatrixType_ >
double Biped< Symmetry, MatrixType_ >::operatorNorm ( bool  COLWISE = true) const

Returns the total operator norm of the Biped. This norm is 1 for Identity Bipeds, whether the following two are not.

Definition at line 493 of file Biped.h.

◆ outerResize()

template<typename Symmetry , typename MatrixType_ >
template<typename OtherMatrixType >
void Biped< Symmetry, MatrixType_ >::outerResize ( const Biped< Symmetry, OtherMatrixType >  Brhs)
inline

Definition at line 258 of file Biped.h.

◆ overhead()

template<typename Symmetry , typename MatrixType_ >
double Biped< Symmetry, MatrixType_ >::overhead ( MEMUNIT  memunit = MB) const

Calculates the (theoretical) additional memory associated with the subspace blocks (note: by default in MB).

Definition at line 1109 of file Biped.h.

◆ plusplus()

template<typename Symmetry , typename MatrixType_ >
void Biped< Symmetry, MatrixType_ >::plusplus ( )
inline

Convenience access to the amount of blocks. Equal to either of the following: in.size(), out.size(), block.size()

Definition at line 84 of file Biped.h.

◆ print()

template<typename Symmetry , typename MatrixType_ >
std::string Biped< Symmetry, MatrixType_ >::print ( const bool  SHOW_MATRICES = false,
const std::size_t  precision = 3 
) const

Function to print the full Biped

Parameters
SHOW_MATRICES: if true, all the block-matrices are printed.
precision: precision for the tensor components

Definition at line 1136 of file Biped.h.

◆ print_dict()

template<typename Symmetry , typename MatrixType_ >
string Biped< Symmetry, MatrixType_ >::print_dict

Prints Biped<Symmetry,MatrixType>::dict into a string.

Definition at line 1085 of file Biped.h.

◆ push_back() [1/2]

template<typename Symmetry , typename MatrixType_ >
void Biped< Symmetry, MatrixType_ >::push_back ( qType  qin,
qType  qout,
const MatrixType_ &  M 
)

Adds a new block to the tensor specified by the incoming quantum number qin and the outgoing quantum number qout.

Warning
Does not check whether the block for these quantum numbers already exists.

Definition at line 528 of file Biped.h.

◆ push_back() [2/2]

template<typename Symmetry , typename MatrixType_ >
void Biped< Symmetry, MatrixType_ >::push_back ( std::array< qType, 2 >  quple,
const MatrixType_ &  M 
)

Adds a new block to the tensor specified by the 2-array of quantum numbers quple. The ordering convention is: in, out.

Warning
Does not check whether the block for these quantum numbers already exists.

Definition at line 535 of file Biped.h.

◆ QR()

template<typename Symmetry , typename MatrixType_ >
pair< Biped< Symmetry, MatrixType_ >, Biped< Symmetry, MatrixType_ > > Biped< Symmetry, MatrixType_ >::QR ( bool  RETURN_LQ = false,
bool  MAKE_UNIQUE = false 
) const

Returns the adjoint tensor where all the block matrices are adjoint and the quantum number arrows are flipped: in $\to$ out and vice versa.

Definition at line 900 of file Biped.h.

◆ rows()

template<typename Symmetry , typename MatrixType_ >
Eigen::VectorXi Biped< Symmetry, MatrixType_ >::rows ( bool  FULL = false) const

Returns an Eigen vector of size dim containing all Matrix rows for every block nu.

Definition at line 438 of file Biped.h.

◆ setIdentity()

template<typename Symmetry , typename MatrixType_ >
void Biped< Symmetry, MatrixType_ >::setIdentity ( const Qbasis< Symmetry > &  base1,
const Qbasis< Symmetry > &  base2,
qType  Q = Symmetry::qvacuum() 
)

Deletes the contents of in, out, block, dict.

Definition at line 357 of file Biped.h.

◆ setRandom() [1/2]

template<typename Symmetry , typename MatrixType_ >
void Biped< Symmetry, MatrixType_ >::setRandom

Sets all matrices in Biped<Symmetry,MatrixType>::block to random values, preserving the rows and columns.

Definition at line 342 of file Biped.h.

◆ setRandom() [2/2]

template<typename Symmetry , typename MatrixType_ >
void Biped< Symmetry, MatrixType_ >::setRandom ( const Qbasis< Symmetry > &  base1,
const Qbasis< Symmetry > &  base2,
qType  Q = Symmetry::qvacuum() 
)

Deletes the contents of in, out, block, dict.

Definition at line 374 of file Biped.h.

◆ setTarget() [1/2]

template<typename Symmetry , typename MatrixType_ >
void Biped< Symmetry, MatrixType_ >::setTarget ( qType  Qtot)

Creates a single block of size 1x1 containing 1 and the corresponding quantum numbers to Qtot (both in & out). Needed in for the transfer matrix from the last site in overlap calculations.

Definition at line 415 of file Biped.h.

◆ setTarget() [2/2]

template<typename Symmetry , typename MatrixType_ >
void Biped< Symmetry, MatrixType_ >::setTarget ( vector< qType Qmulti)

Deletes the contents of in, out, block, dict.

Definition at line 425 of file Biped.h.

◆ setVacuum()

template<typename Symmetry , typename MatrixType_ >
void Biped< Symmetry, MatrixType_ >::setVacuum

Creates a single block of size 1x1 containing 1 and the corresponding quantum numbers to the vacuum (both in & out). Needed in for the transfer matrix to the first site in overlap calculations.

Definition at line 349 of file Biped.h.

◆ setZero() [1/2]

template<typename Symmetry , typename MatrixType_ >
void Biped< Symmetry, MatrixType_ >::setZero

Sets all matrices in Biped<Symmetry,MatrixType>::block to zero, preserving the rows and columns.

Definition at line 335 of file Biped.h.

◆ setZero() [2/2]

template<typename Symmetry , typename MatrixType_ >
void Biped< Symmetry, MatrixType_ >::setZero ( const Qbasis< Symmetry > &  base1,
const Qbasis< Symmetry > &  base2,
qType  Q = Symmetry::qvacuum() 
)

Deletes the contents of in, out, block, dict.

Definition at line 394 of file Biped.h.

◆ shift_Qin()

template<typename Symmetry , typename MatrixType_ >
void Biped< Symmetry, MatrixType_ >::shift_Qin ( const qarray< Symmetry::Nq > &  Q)
inline

Definition at line 281 of file Biped.h.

◆ size()

template<typename Symmetry , typename MatrixType_ >
std::size_t Biped< Symmetry, MatrixType_ >::size ( ) const
inline

Convenience access to the amount of blocks. Equal to either of the following: in.size(), out.size(), block.size()

Definition at line 83 of file Biped.h.

◆ sorted()

template<typename Symmetry , typename MatrixType_ >
Biped< Symmetry, MatrixType_ > Biped< Symmetry, MatrixType_ >::sorted

Returns the adjoint tensor where all the block matrices are adjoint and the quantum number arrows are flipped: in $\to$ out and vice versa.

Definition at line 611 of file Biped.h.

◆ squaredNorm()

template<typename Symmetry , typename MatrixType_ >
Eigen::VectorXd Biped< Symmetry, MatrixType_ >::squaredNorm

Returns an Eigen vector of size dim containing all Frobenius Matrix squared norm for every block nu.

Definition at line 519 of file Biped.h.

◆ trace()

template<typename Symmetry , typename MatrixType_ >
MatrixType_::Scalar Biped< Symmetry, MatrixType_ >::trace

Takes the trace of the Biped. Only useful if this Biped is really a matrix from symmetry perspective (q_in = q_out in all blocks).

Definition at line 935 of file Biped.h.

◆ transpose()

template<typename Symmetry , typename MatrixType_ >
Biped< Symmetry, MatrixType_ > Biped< Symmetry, MatrixType_ >::transpose

Returns the adjoint tensor where all the block matrices are adjoint and the quantum number arrows are flipped: in $\to$ out and vice versa.

Definition at line 655 of file Biped.h.

◆ truncateSVD() [1/2]

template<typename Symmetry , typename MatrixType_ >
template<typename EpsScalar >
tuple< Biped< Symmetry, MatrixType_ >, Biped< Symmetry, MatrixType_ >, Biped< Symmetry, MatrixType_ > > Biped< Symmetry, MatrixType_ >::truncateSVD ( size_t  minKeep,
size_t  maxKeep,
EpsScalar  eps_svd,
double &  truncWeight,
bool  PRESERVE_MULTIPLETS = true 
) const
inline

Returns the adjoint tensor where all the block matrices are adjoint and the quantum number arrows are flipped: in $\to$ out and vice versa.

Definition at line 202 of file Biped.h.

◆ truncateSVD() [2/2]

template<typename Symmetry , typename MatrixType_ >
template<typename EpsScalar >
tuple< Biped< Symmetry, MatrixType_ >, Biped< Symmetry, MatrixType_ >, Biped< Symmetry, MatrixType_ > > Biped< Symmetry, MatrixType_ >::truncateSVD ( size_t  minKeep,
size_t  maxKeep,
EpsScalar  eps_svd,
double &  truncWeight,
double &  entropy,
map< qarray< Symmetry::Nq >, Eigen::ArrayXd > &  SVspec,
bool  PRESERVE_MULTIPLETS = true,
bool  RETURN_SPEC = true 
) const

Returns the adjoint tensor where all the block matrices are adjoint and the quantum number arrows are flipped: in $\to$ out and vice versa.

Definition at line 743 of file Biped.h.

◆ try_create_block()

template<typename Symmetry , typename MatrixType_ >
void Biped< Symmetry, MatrixType_ >::try_create_block ( std::array< qType, 2 >  quple)

Adds a new block to the tensor specified by the incoming quantum number qin and the outgoing quantum number qout.

Warning
Does not check whether the block for these quantum numbers already exists.

Definition at line 581 of file Biped.h.

◆ try_push_back() [1/2]

template<typename Symmetry , typename MatrixType_ >
void Biped< Symmetry, MatrixType_ >::try_push_back ( qType  qin,
qType  qout,
const MatrixType_ &  M 
)

Adds a new block to the tensor specified by the incoming quantum number qin and the outgoing quantum number qout.

Warning
Does not check whether the block for these quantum numbers already exists.

Definition at line 547 of file Biped.h.

◆ try_push_back() [2/2]

template<typename Symmetry , typename MatrixType_ >
void Biped< Symmetry, MatrixType_ >::try_push_back ( std::array< qType, 2 >  quple,
const MatrixType_ &  M 
)

Adds a new block to the tensor specified by the incoming quantum number qin and the outgoing quantum number qout.

Warning
Does not check whether the block for these quantum numbers already exists.

Definition at line 554 of file Biped.h.

Member Data Documentation

◆ block

template<typename Symmetry , typename MatrixType_ >
std::vector<MatrixType_> Biped< Symmetry, MatrixType_ >::block

Vector of quantum number blocks. The matrix block[q] is characterized by the incoming quantum number in[q] and the outgoing quantum number out[q]

Definition at line 96 of file Biped.h.

◆ dict

template<typename Symmetry , typename MatrixType_ >
std::unordered_map<std::array<qType,2>,std::size_t> Biped< Symmetry, MatrixType_ >::dict

Dictionary allowing one to find the index of block for a given array of two quantum numbers qin, qout in $O(1)$ operations without looping over the blocks.

Definition at line 104 of file Biped.h.

◆ dim

template<typename Symmetry , typename MatrixType_ >
std::size_t Biped< Symmetry, MatrixType_ >::dim

Convenience access to the amount of blocks. Equal to either of the following: in.size(), out.size(), block.size()

Definition at line 82 of file Biped.h.

◆ in

template<typename Symmetry , typename MatrixType_ >
std::vector<qType> Biped< Symmetry, MatrixType_ >::in

Vector of all incoming quantum numbers.

Definition at line 87 of file Biped.h.

◆ out

template<typename Symmetry , typename MatrixType_ >
std::vector<qType> Biped< Symmetry, MatrixType_ >::out

Vector of all outgoing quantum numbers.

Definition at line 90 of file Biped.h.


The documentation for this struct was generated from the following file: