VMPS++
Loading...
Searching...
No Matches
DmrgLinearAlgebra.h File Reference

Detailed Description

External functions to manipulate Mps and Mpo objects.

Definition in file DmrgLinearAlgebra.h.

#include "Stopwatch.h"
#include "Mps.h"
#include "Mpo.h"
#include "solvers/MpsCompressor.h"
#include "ParamHandler.h"
Include dependency graph for DmrgLinearAlgebra.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define OXV_EXACT_INIT_M   100
 

Functions

template<typename Symmetry , typename Scalar >
Scalar dot (const Mps< Symmetry, Scalar > &Vbra, const Mps< Symmetry, Scalar > &Vket)
 
template<typename Symmetry , typename Scalar >
Scalar dot_hetero (const Mps< Symmetry, Scalar > &Vbra, const Mps< Symmetry, Scalar > &Vket, int Ncellshift=0)
 
template<typename Symmetry , typename Scalar >
void swap (Mps< Symmetry, Scalar > &V1, Mps< Symmetry, Scalar > &V2)
 
template<typename Symmetry , typename MpoScalar , typename Scalar >
Array< Scalar, Dynamic, 1 > matrix_element (int iL, int iR, const Mps< Symmetry, Scalar > &Vbra, const Mpo< Symmetry, MpoScalar > &O, const Mps< Symmetry, Scalar > &Vket, size_t power_of_O=1)
 
template<typename Symmetry , typename Scalar >
Array< Scalar, Dynamic, 1 > dot_green (const Mps< Symmetry, Scalar > &V1, const Mps< Symmetry, Scalar > &V2)
 
template<typename Symmetry , typename MpoScalar , typename Scalar >
Scalar avg (const Mps< Symmetry, Scalar > &Vbra, const Mpo< Symmetry, MpoScalar > &O, const Mps< Symmetry, Scalar > &Vket, size_t power_of_O=1ul, DMRG::DIRECTION::OPTION DIR=DMRG::DIRECTION::RIGHT, DMRG::VERBOSITY::OPTION CHOSEN_VERBOSITY=DMRG::VERBOSITY::SILENT)
 
template<typename Symmetry , typename MpoScalar , typename Scalar >
Scalar avg_hetero (const Mps< Symmetry, Scalar > &Vbra, const Mpo< Symmetry, MpoScalar > &O, const Mps< Symmetry, Scalar > &Vket, bool USE_BOUNDARY=false, size_t usePower=1ul, const qarray< Symmetry::Nq > &Qmid=Symmetry::qvacuum())
 
template<typename Symmetry , typename MpoScalar , typename Scalar >
Scalar avg (const Mps< Symmetry, Scalar > &Vbra, const Mpo< Symmetry, MpoScalar > &O1, const Mpo< Symmetry, MpoScalar > &O2, const Mps< Symmetry, Scalar > &Vket, typename Symmetry::qType Qtarget=Symmetry::qvacuum(), size_t usePower1=1, size_t usePower2=1, bool WARN=true, DMRG::VERBOSITY::OPTION CHOSEN_VERBOSITY=DMRG::VERBOSITY::SILENT)
 
template<typename Symmetry , typename MpoScalar , typename Scalar >
Scalar avg (const Mps< Symmetry, Scalar > &Vbra, const vector< Mpo< Symmetry, MpoScalar > > &O, const Mps< Symmetry, Scalar > &Vket, size_t usePower=1ul, DMRG::DIRECTION::OPTION DIR=DMRG::DIRECTION::LEFT, DMRG::VERBOSITY::OPTION CHOSEN_VERBOSITY=DMRG::VERBOSITY::SILENT)
 
template<typename Symmetry , typename MpoScalar , typename Scalar >
Scalar avg (const Mps< Symmetry, Scalar > &Vbra, const vector< Mpo< Symmetry, MpoScalar > > &O1, const vector< Mpo< Symmetry, MpoScalar > > &O2, const Mps< Symmetry, Scalar > &Vket, typename Symmetry::qType Qtarget=Symmetry::qvacuum(), size_t usePower1=1ul, size_t usePower2=1ul, bool WARN=true, DMRG::VERBOSITY::OPTION CHOSEN_VERBOSITY=DMRG::VERBOSITY::SILENT)
 
template<typename Symmetry , typename MpoScalar , typename Scalar >
void HxV (const Mpo< Symmetry, MpoScalar > &H, const Mps< Symmetry, Scalar > &Vin, Mps< Symmetry, Scalar > &Vout, bool VERBOSE=true, double tol_compr=1e-4, int Mincr=100, int Mlimit=10000, int max_halfsweeps=100)
 
template<typename Symmetry , typename MpoScalar , typename Scalar >
void HxV (const Mpo< Symmetry, MpoScalar > &H, Mps< Symmetry, Scalar > &Vinout, bool VERBOSE=true, double tol_compr=1e-4, int Mincr=100, int Mlimit=10000, int max_halfsweeps=100)
 
template<typename Symmetry , typename MpoScalar , typename Scalar >
void polyIter (const Mpo< Symmetry, MpoScalar > &H, const Mps< Symmetry, Scalar > &Vin1, double polyB, const Mps< Symmetry, Scalar > &Vin2, Mps< Symmetry, Scalar > &Vout, bool VERBOSE=true)
 
template<typename Symmetry , typename Scalar , typename OtherScalar >
void addScale (const OtherScalar alpha, const Mps< Symmetry, Scalar > &Vin, Mps< Symmetry, Scalar > &Vout, DMRG::VERBOSITY::OPTION VERBOSITY=DMRG::VERBOSITY::SILENT)
 
template<typename Symmetry , typename MpoScalar , typename Scalar >
void OxV (const Mpo< Symmetry, MpoScalar > &H, const Mpo< Symmetry, MpoScalar > &Hdag, const Mps< Symmetry, Scalar > &Vin, Mps< Symmetry, Scalar > &Vout, bool VERBOSE=true, double tol_compr=1e-4, int Mincr=100, int Mlimit=10000, int max_halfsweeps=100, int min_halfsweeps=1, bool MEASURE_DISTANCE=true)
 
template<typename Symmetry , typename MpoScalar , typename Scalar >
void OxV (const Mpo< Symmetry, MpoScalar > &H, const Mpo< Symmetry, MpoScalar > &Hdag, Mps< Symmetry, Scalar > &Vinout, bool VERBOSE=true, double tol_compr=1e-4, int Mincr=100, int Mlimit=10000, int max_halfsweeps=100, int min_halfsweeps=1, bool MEASURE_DISTANCE=true)
 
template<typename Symmetry , typename MpoScalar , typename Scalar >
void OxV_exact (const Mpo< Symmetry, MpoScalar > &O, const Mps< Symmetry, Scalar > &Vin, Mps< Symmetry, Scalar > &Vout, double tol_compr=1e-7, DMRG::VERBOSITY::OPTION VERBOSITY=DMRG::VERBOSITY::HALFSWEEPWISE, int max_halfsweeps=200, int min_halfsweeps=1, int Minit=-1, DMRG::BROOM::OPTION BROOMOPTION=DMRG::BROOM::QR)
 
template<typename Symmetry , typename MpoScalar , typename Scalar >
void OxV_exact (const Mpo< Symmetry, MpoScalar > &O, Mps< Symmetry, Scalar > &Vinout, double tol_compr=1e-7, DMRG::VERBOSITY::OPTION VERBOSITY=DMRG::VERBOSITY::HALFSWEEPWISE, int max_halfsweeps=200, int min_halfsweeps=1, int Minit=-1, DMRG::BROOM::OPTION BROOMOPTION=DMRG::BROOM::QR)
 
template<typename Hamiltonian , typename Scalar >
Hamiltonian sum (const Hamiltonian &H1, const Hamiltonian &H2, DMRG::VERBOSITY::OPTION VERBOSITY=DMRG::VERBOSITY::SILENT)
 
template<typename Hamiltonian , typename Scalar >
Hamiltonian prod (const Hamiltonian &H1, const Hamiltonian &H2, const qarray< Hamiltonian::Symmetry::Nq > &Qtot=Hamiltonian::Symmetry::qvacuum(), DMRG::VERBOSITY::OPTION VERBOSITY=DMRG::VERBOSITY::SILENT)
 
template<typename Symmetry , typename Scalar = double>
Mpo< Symmetry, Scalar > sum (const Mpo< Symmetry, Scalar > &H1, const Mpo< Symmetry, Scalar > &H2, DMRG::VERBOSITY::OPTION VERBOSITY=DMRG::VERBOSITY::SILENT)
 
template<typename Symmetry , typename Scalar = double>
Mpo< Symmetry, Scalar > diff (const Mpo< Symmetry, Scalar > &H1, const Mpo< Symmetry, Scalar > &H2, DMRG::VERBOSITY::OPTION VERBOSITY=DMRG::VERBOSITY::SILENT)
 
template<typename Symmetry , typename Scalar = double>
Mpo< Symmetry, Scalar > prod (const Mpo< Symmetry, Scalar > &H1, const Mpo< Symmetry, Scalar > &H2, const qarray< Symmetry::Nq > &Qtot=Symmetry::qvacuum(), DMRG::VERBOSITY::OPTION VERBOSITY=DMRG::VERBOSITY::SILENT)
 
template<typename Symmetry , typename MpsScalar = double, typename MpoScalar = double>
void OvecxV (const std::vector< Mpo< Symmetry, MpoScalar > > &Os, Mps< Symmetry, MpsScalar > &v_in, std::size_t Minit_in=0ul, std::size_t Mincr=100ul, std::size_t Mlimit=10000ul, double tol_compr=1e-5, std::size_t max_halfsweeps=24ul, std::size_t min_halfsweeps=1ul)
 

Macro Definition Documentation

◆ OXV_EXACT_INIT_M

#define OXV_EXACT_INIT_M   100

Definition at line 5 of file DmrgLinearAlgebra.h.

Function Documentation

◆ addScale()

template<typename Symmetry , typename Scalar , typename OtherScalar >
void addScale ( const OtherScalar  alpha,
const Mps< Symmetry, Scalar > &  Vin,
Mps< Symmetry, Scalar > &  Vout,
DMRG::VERBOSITY::OPTION  VERBOSITY = DMRG::VERBOSITY::SILENT 
)

Definition at line 570 of file DmrgLinearAlgebra.h.

◆ avg() [1/4]

template<typename Symmetry , typename MpoScalar , typename Scalar >
Scalar avg ( const Mps< Symmetry, Scalar > &  Vbra,
const Mpo< Symmetry, MpoScalar > &  O,
const Mps< Symmetry, Scalar > &  Vket,
size_t  power_of_O = 1ul,
DMRG::DIRECTION::OPTION  DIR = DMRG::DIRECTION::RIGHT,
DMRG::VERBOSITY::OPTION  CHOSEN_VERBOSITY = DMRG::VERBOSITY::SILENT 
)

Calculates the expectation value $\left<\Psi_{bra}|O|\Psi_{ket}\right>$

Parameters
Vbra: input $\left<\Psi_{bra}\right|$
O: input Mpo
Vket: input $\left|\Psi_{ket}\right>$
USE_SQUARE: If true, uses the square of O stored in O itself. Call Mpo::check_SQUARE() first to see whether it was calculated.
DIR: whether to contract going left or right (should obviously make no difference, useful for testing purposes)

Definition at line 149 of file DmrgLinearAlgebra.h.

◆ avg() [2/4]

template<typename Symmetry , typename MpoScalar , typename Scalar >
Scalar avg ( const Mps< Symmetry, Scalar > &  Vbra,
const Mpo< Symmetry, MpoScalar > &  O1,
const Mpo< Symmetry, MpoScalar > &  O2,
const Mps< Symmetry, Scalar > &  Vket,
typename Symmetry::qType  Qtarget = Symmetry::qvacuum(),
size_t  usePower1 = 1,
size_t  usePower2 = 1,
bool  WARN = true,
DMRG::VERBOSITY::OPTION  CHOSEN_VERBOSITY = DMRG::VERBOSITY::SILENT 
)

Calculates the expectation value $\left<\Psi_{bra}|O_{1}O_{2}|\Psi_{ket}\right>$ Only a left-to-right contraction is implemented.

Parameters
Vbra: input $\left<\Psi_{bra}\right|$
O1: input Mpo
O2: input Mpo
Vket: input $\left|\Psi_{ket}\right>$
Qtarget: The quantum number of the product of $O_1\cdot O_2$. For abelian symmetries simply O1.Qtarget()+O2.Qtarget()

Definition at line 365 of file DmrgLinearAlgebra.h.

◆ avg() [3/4]

template<typename Symmetry , typename MpoScalar , typename Scalar >
Scalar avg ( const Mps< Symmetry, Scalar > &  Vbra,
const vector< Mpo< Symmetry, MpoScalar > > &  O,
const Mps< Symmetry, Scalar > &  Vket,
size_t  usePower = 1ul,
DMRG::DIRECTION::OPTION  DIR = DMRG::DIRECTION::LEFT,
DMRG::VERBOSITY::OPTION  CHOSEN_VERBOSITY = DMRG::VERBOSITY::SILENT 
)

Definition at line 457 of file DmrgLinearAlgebra.h.

◆ avg() [4/4]

template<typename Symmetry , typename MpoScalar , typename Scalar >
Scalar avg ( const Mps< Symmetry, Scalar > &  Vbra,
const vector< Mpo< Symmetry, MpoScalar > > &  O1,
const vector< Mpo< Symmetry, MpoScalar > > &  O2,
const Mps< Symmetry, Scalar > &  Vket,
typename Symmetry::qType  Qtarget = Symmetry::qvacuum(),
size_t  usePower1 = 1ul,
size_t  usePower2 = 1ul,
bool  WARN = true,
DMRG::VERBOSITY::OPTION  CHOSEN_VERBOSITY = DMRG::VERBOSITY::SILENT 
)

Definition at line 473 of file DmrgLinearAlgebra.h.

◆ avg_hetero()

template<typename Symmetry , typename MpoScalar , typename Scalar >
Scalar avg_hetero ( const Mps< Symmetry, Scalar > &  Vbra,
const Mpo< Symmetry, MpoScalar > &  O,
const Mps< Symmetry, Scalar > &  Vket,
bool  USE_BOUNDARY = false,
size_t  usePower = 1ul,
const qarray< Symmetry::Nq > &  Qmid = Symmetry::qvacuum() 
)

Definition at line 287 of file DmrgLinearAlgebra.h.

◆ diff()

template<typename Symmetry , typename Scalar = double>
Mpo< Symmetry, Scalar > diff ( const Mpo< Symmetry, Scalar > &  H1,
const Mpo< Symmetry, Scalar > &  H2,
DMRG::VERBOSITY::OPTION  VERBOSITY = DMRG::VERBOSITY::SILENT 
)

Definition at line 914 of file DmrgLinearAlgebra.h.

◆ dot()

template<typename Symmetry , typename Scalar >
Scalar dot ( const Mps< Symmetry, Scalar > &  Vbra,
const Mps< Symmetry, Scalar > &  Vket 
)

Calculates the scalar product $\left<\Psi_{bra}|\Psi_{ket}\right>$.

Parameters
Vbra: input $\left<\Psi_{bra}\right|$
Vket: input $\left|\Psi_{ket}\right>$

Definition at line 24 of file DmrgLinearAlgebra.h.

◆ dot_green()

template<typename Symmetry , typename Scalar >
Array< Scalar, Dynamic, 1 > dot_green ( const Mps< Symmetry, Scalar > &  V1,
const Mps< Symmetry, Scalar > &  V2 
)

Definition at line 121 of file DmrgLinearAlgebra.h.

◆ dot_hetero()

template<typename Symmetry , typename Scalar >
Scalar dot_hetero ( const Mps< Symmetry, Scalar > &  Vbra,
const Mps< Symmetry, Scalar > &  Vket,
int  Ncellshift = 0 
)

Calculates the scalar product $\left<\Psi_{bra}|\Psi_{ket}\right>$ for a heterogenic MPS.

Parameters
Vbra: input $\left<\Psi_{bra}\right|$
Vket: input $\left|\Psi_{ket}\right>$
Ncellshift: Shift Vbra by this many unit cells (negative=left-shift, positive=right-shift).

Definition at line 36 of file DmrgLinearAlgebra.h.

◆ HxV() [1/2]

template<typename Symmetry , typename MpoScalar , typename Scalar >
void HxV ( const Mpo< Symmetry, MpoScalar > &  H,
const Mps< Symmetry, Scalar > &  Vin,
Mps< Symmetry, Scalar > &  Vout,
bool  VERBOSE = true,
double  tol_compr = 1e-4,
int  Mincr = 100,
int  Mlimit = 10000,
int  max_halfsweeps = 100 
)

Apply an Mpo to an Mps $\left|\Psi_{out}\right> = H \left|\Psi_{in}\right>$ by using the zip-up algorithm (Stoudenmire, White 2010).

Parameters
H: input Hamiltonian
Vin: input $\left|\Psi_{in}\right>$
Vout: output $\left|\Psi_{out}\right>$
VERBOSE: print info if true

Definition at line 500 of file DmrgLinearAlgebra.h.

◆ HxV() [2/2]

template<typename Symmetry , typename MpoScalar , typename Scalar >
void HxV ( const Mpo< Symmetry, MpoScalar > &  H,
Mps< Symmetry, Scalar > &  Vinout,
bool  VERBOSE = true,
double  tol_compr = 1e-4,
int  Mincr = 100,
int  Mlimit = 10000,
int  max_halfsweeps = 100 
)

Definition at line 531 of file DmrgLinearAlgebra.h.

◆ matrix_element()

template<typename Symmetry , typename MpoScalar , typename Scalar >
Array< Scalar, Dynamic, 1 > matrix_element ( int  iL,
int  iR,
const Mps< Symmetry, Scalar > &  Vbra,
const Mpo< Symmetry, MpoScalar > &  O,
const Mps< Symmetry, Scalar > &  Vket,
size_t  power_of_O = 1 
)

Definition at line 71 of file DmrgLinearAlgebra.h.

◆ OvecxV()

template<typename Symmetry , typename MpsScalar = double, typename MpoScalar = double>
void OvecxV ( const std::vector< Mpo< Symmetry, MpoScalar > > &  Os,
Mps< Symmetry, MpsScalar > &  v_in,
std::size_t  Minit_in = 0ul,
std::size_t  Mincr = 100ul,
std::size_t  Mlimit = 10000ul,
double  tol_compr = 1e-5,
std::size_t  max_halfsweeps = 24ul,
std::size_t  min_halfsweeps = 1ul 
)

Definition at line 954 of file DmrgLinearAlgebra.h.

◆ OxV() [1/2]

template<typename Symmetry , typename MpoScalar , typename Scalar >
void OxV ( const Mpo< Symmetry, MpoScalar > &  H,
const Mpo< Symmetry, MpoScalar > &  Hdag,
const Mps< Symmetry, Scalar > &  Vin,
Mps< Symmetry, Scalar > &  Vout,
bool  VERBOSE = true,
double  tol_compr = 1e-4,
int  Mincr = 100,
int  Mlimit = 10000,
int  max_halfsweeps = 100,
int  min_halfsweeps = 1,
bool  MEASURE_DISTANCE = true 
)

Definition at line 593 of file DmrgLinearAlgebra.h.

◆ OxV() [2/2]

template<typename Symmetry , typename MpoScalar , typename Scalar >
void OxV ( const Mpo< Symmetry, MpoScalar > &  H,
const Mpo< Symmetry, MpoScalar > &  Hdag,
Mps< Symmetry, Scalar > &  Vinout,
bool  VERBOSE = true,
double  tol_compr = 1e-4,
int  Mincr = 100,
int  Mlimit = 10000,
int  max_halfsweeps = 100,
int  min_halfsweeps = 1,
bool  MEASURE_DISTANCE = true 
)

Definition at line 622 of file DmrgLinearAlgebra.h.

◆ OxV_exact() [1/2]

template<typename Symmetry , typename MpoScalar , typename Scalar >
void OxV_exact ( const Mpo< Symmetry, MpoScalar > &  O,
const Mps< Symmetry, Scalar > &  Vin,
Mps< Symmetry, Scalar > &  Vout,
double  tol_compr = 1e-7,
DMRG::VERBOSITY::OPTION  VERBOSITY = DMRG::VERBOSITY::HALFSWEEPWISE,
int  max_halfsweeps = 200,
int  min_halfsweeps = 1,
int  Minit = -1,
DMRG::BROOM::OPTION  BROOMOPTION = DMRG::BROOM::QR 
)

Performs an exact MPO-MPS product.

Parameters
O: input MPO
Vin: input MPS
Vout: output MPS
tol_compr: if $tol_compr < 1$, compresses the result with this tolerance
VERBOSITY: verbosity level, which is also passed on to the MpsCompressor class

Definition at line 722 of file DmrgLinearAlgebra.h.

◆ OxV_exact() [2/2]

template<typename Symmetry , typename MpoScalar , typename Scalar >
void OxV_exact ( const Mpo< Symmetry, MpoScalar > &  O,
Mps< Symmetry, Scalar > &  Vinout,
double  tol_compr = 1e-7,
DMRG::VERBOSITY::OPTION  VERBOSITY = DMRG::VERBOSITY::HALFSWEEPWISE,
int  max_halfsweeps = 200,
int  min_halfsweeps = 1,
int  Minit = -1,
DMRG::BROOM::OPTION  BROOMOPTION = DMRG::BROOM::QR 
)

Definition at line 855 of file DmrgLinearAlgebra.h.

◆ polyIter()

template<typename Symmetry , typename MpoScalar , typename Scalar >
void polyIter ( const Mpo< Symmetry, MpoScalar > &  H,
const Mps< Symmetry, Scalar > &  Vin1,
double  polyB,
const Mps< Symmetry, Scalar > &  Vin2,
Mps< Symmetry, Scalar > &  Vout,
bool  VERBOSE = true 
)

Performs an orthogonal polynomial iteration step $\left|\Psi_{out}\right> = \cdot H \left|\Psi_{in,1}\right> - 
B \left|\Psi_{in,2}\right>$ as needed in the polynomial recursion relation $P_n = (C_n x - A_n) P_{n-1} - B_n P_{n-2}$.

Warning
The Hamiltonian is assumed to be rescaled by C_n and A_n already.
Parameters
H: input Hamiltonian
Vin1: input Mps $\left|T_{n-1}\right>$
polyB: the coefficient before the subtracted vector
Vin2: input Mps $\left|T_{n-2}\right>$
Vout: output Mps $\left|T_{n}\right>$
VERBOSE: print info if true

Definition at line 550 of file DmrgLinearAlgebra.h.

◆ prod() [1/2]

template<typename Hamiltonian , typename Scalar >
Hamiltonian prod ( const Hamiltonian &  H1,
const Hamiltonian &  H2,
const qarray< Hamiltonian::Symmetry::Nq > &  Qtot = Hamiltonian::Symmetry::qvacuum(),
DMRG::VERBOSITY::OPTION  VERBOSITY = DMRG::VERBOSITY::SILENT 
)

Definition at line 880 of file DmrgLinearAlgebra.h.

◆ prod() [2/2]

template<typename Symmetry , typename Scalar = double>
Mpo< Symmetry, Scalar > prod ( const Mpo< Symmetry, Scalar > &  H1,
const Mpo< Symmetry, Scalar > &  H2,
const qarray< Symmetry::Nq > &  Qtot = Symmetry::qvacuum(),
DMRG::VERBOSITY::OPTION  VERBOSITY = DMRG::VERBOSITY::SILENT 
)

Definition at line 942 of file DmrgLinearAlgebra.h.

◆ sum() [1/2]

template<typename Hamiltonian , typename Scalar >
Hamiltonian sum ( const Hamiltonian &  H1,
const Hamiltonian &  H2,
DMRG::VERBOSITY::OPTION  VERBOSITY = DMRG::VERBOSITY::SILENT 
)

Definition at line 866 of file DmrgLinearAlgebra.h.

◆ sum() [2/2]

template<typename Symmetry , typename Scalar = double>
Mpo< Symmetry, Scalar > sum ( const Mpo< Symmetry, Scalar > &  H1,
const Mpo< Symmetry, Scalar > &  H2,
DMRG::VERBOSITY::OPTION  VERBOSITY = DMRG::VERBOSITY::SILENT 
)

Definition at line 894 of file DmrgLinearAlgebra.h.

◆ swap()

template<typename Symmetry , typename Scalar >
void swap ( Mps< Symmetry, Scalar > &  V1,
Mps< Symmetry, Scalar > &  V2 
)

Swaps two Mps.

Definition at line 65 of file DmrgLinearAlgebra.h.