17#include "LanczosTypedefs.h"
19#ifndef IS_REAL_FUNCTION
20#define IS_REAL_FUNCTION
21inline double isReal (
double x) {
return x;}
22inline double isReal (std::complex<double> x) {
return x.real();}
25#ifndef CONJ_IF_COMPLEX
26#define CONJ_IF_COMPLEX
28inline std::complex<double>
conjIfcomplex (std::complex<double> x) {
return conj(x);}
31#define EIGEN_INITIALIZE_MATRICES_BY_ZERO
33#ifndef SPIN_INDEX_ENUM
34#define SPIN_INDEX_ENUM
45 assert(sigma==
UP or sigma==
DN);
46 return (sigma==
UP) ?
DN :
UP;
52 if (sigma==
UP) {s <<
"ā";}
53 else if (sigma==
DN) {s <<
"ā";}
54 else if (sigma==
NOSPIN) {s <<
"āÆ";}
55 else if (sigma==
UPDN) {s <<
"ā
";}
60enum SPINOP_LABEL {
SX,
SY,
iSY,
SZ,
SP,
SM,
QZ,
QP,
QM,
QPZ,
QMZ};
64 if (Sa==
SX) {s <<
"Sx";}
65 else if (Sa==
SY) {s <<
"Sy";}
66 else if (Sa==
iSY) {s <<
"iSy";}
67 else if (Sa==
SZ) {s <<
"Sz";}
68 else if (Sa==
SP) {s <<
"S+";}
69 else if (Sa==
SM) {s <<
"S-";}
70 else if (Sa==
QZ) {s <<
"Qz";}
71 else if (Sa==
QP) {s <<
"Q+";}
72 else if (Sa==
QM) {s <<
"Q-";}
73 else if (Sa==
QPZ) {s <<
"Q+z";}
74 else if (Sa==
QMZ) {s <<
"Q-z";}
82 if (STR==
NOSTRING) {s <<
"NOSTRING";}
83 else if (STR==
STRINGX) {s <<
"STRINGX";}
84 else if (STR==
STRINGY) {s <<
"STRINGY";}
85 else if (STR==
STRINGZ) {s <<
"STRINGZ";}
101 else if (mf==
HUBBARD) {s <<
"HUBBARD";}
102 else if (mf==
KONDO) {s <<
"KONDO";}
103 else if (mf==
SPINLESS) {s <<
"SPINLESS";}
116 if (l==Sym::KIND::S) {s <<
"S";}
117 if (l==Sym::KIND::Salt) {s <<
"Salt";}
118 else if (l==Sym::KIND::T) {s <<
"T";}
119 else if (l==Sym::KIND::N) {s <<
"N";}
120 else if (l==Sym::KIND::M) {s <<
"M";}
121 else if (l==Sym::KIND::Nup) {s <<
"Nā";}
122 else if (l==Sym::KIND::Ndn) {s <<
"Nā";}
123 else if (l==Sym::KIND::Nparity) {s <<
"P";}
124 else if (l==Sym::KIND::K) {s <<
"K";}
136 if (sublat==
A) {s <<
"A";}
137 else if (sublat==
B) {s <<
"B";}
143 return (sublat==
A)?
B:
A;
148 for (
size_t i=0; i<hopping.rows(); ++i)
149 for (
size_t j=0; j<hopping.cols(); ++j)
151 if (hopping(i,j)!=0.)
153 if (G[i]==G[j]) lout <<
"sublattice error: G[" << i <<
"]=" << G[i] <<
", G[" << j <<
"]=" << G[j] << endl;
154 assert(G[i]!=G[j] and
"Sublattice check");
157 lout <<
"Sublattice check passed!" << endl;
170 if (boundary==
BC::OPEN) {s <<
"open";}
176#include <Eigen/Dense>
177#include <Eigen/SparseCore>
180#ifndef EIGEN_DEFAULT_SPARSE_INDEX_TYPE
181#define EIGEN_DEFAULT_SPARSE_INDEX_TYPE int
183using namespace Eigen;
184typedef SparseMatrix<double,ColMajor,EIGEN_DEFAULT_SPARSE_INDEX_TYPE>
SparseMatrixXd;
187template<
typename Operator,
typename Scalar>
190 std::vector<std::tuple<std::size_t, std::vector<Operator>, Scalar>>
data;
192 template<
typename OtherOperator>
193 void push_back(
const std::tuple<std::size_t, std::vector<OtherOperator>, Scalar> & elem)
195 if( std::abs(std::get<2>(elem) ) != 0 )
197 std::vector<Operator> plainOps;
198 for (
auto & op: std::get<1>(elem)) {plainOps.push_back(op.template plain<typename OtherOperator::Scalar>());}
199 std::tuple<std::size_t, std::vector<Operator>, Scalar> plainElem;
200 std::get<0>(plainElem) = std::get<0>(elem);
201 std::get<1>(plainElem) = plainOps;
202 std::get<2>(plainElem) = std::get<2>(elem);
203 data.push_back(plainElem);
207 void push_back(
const std::tuple<std::size_t, std::vector<Operator>, Scalar> & elem) {
if( std::abs(std::get<2>(elem) ) != 0 ) {
data.push_back(elem);}}
209 std::tuple<std::size_t, std::vector<Operator>, Scalar>
operator[] ( std::size_t i )
const {
return data[i];}
210 std::tuple<std::size_t, std::vector<Operator>, Scalar>&
operator[] ( std::size_t i ) {
return data[i];}
217 for (
size_t i=0; i<
size(); i++)
219 std::vector<OtherOperator> otherOps(std::get<1>(
data[i]).
size());
220 for (
size_t j=0; j<std::get<1>(
data[i]).size(); j++) {otherOps[j] = std::get<1>(
data[i]).at(j).template cast<typename OtherOperator::Scalar>();}
352 #ifndef DMRG_CONTROL_DEFAULT_MIN_NSV
353 #define DMRG_CONTROL_DEFAULT_MIN_NSV 0
359 static double eps_svd (
size_t i) {
return 1e-14;}
370 constexpr static ::LANCZOS::REORTHO::OPTION
REORTHO = LANCZOS::REORTHO::FULL;
373 constexpr static size_t dimK = 500ul;
473template<
typename Symmetry,
typename Scalar>
479 :
s1(s[0]),
s2(s[1]),
s3(s[2]),
s4(s[3]),
s1s3(s[4]),
s2s4(s[5]),
qmerge13(qm[0]),
qmerge24(qm[1]),
k12(k[0]),
k34(k[1]),
qOp(qOp_),
cgc9(cgc9_)
void sublattice_check(const ArrayXXd &hopping, const vector< SUB_LATTICE > &G)
#define DMRG_CONTROL_DEFAULT_MIN_NSV
double conjIfcomplex(double x)
std::istream & operator>>(std::istream &str, DMRG::VERBOSITY::OPTION &VERB)
SPIN_INDEX operator!(const SPIN_INDEX sigma)
SparseMatrix< std::complex< double >, ColMajor, EIGEN_DEFAULT_SPARSE_INDEX_TYPE > SparseMatrixXcd
SparseMatrix< double, ColMajor, EIGEN_DEFAULT_SPARSE_INDEX_TYPE > SparseMatrixXd
SUB_LATTICE flip_sublattice(SUB_LATTICE sublat)
SPINOP_LABEL STRING_TO_SPINOP(STRING STR)
std::ostream & operator<<(std::ostream &s, SPIN_INDEX sigma)
#define EIGEN_DEFAULT_SPARSE_INDEX_TYPE
std::ostream & operator<<(std::ostream &s, VMPS::DIRECTION::OPTION DIR)
std::array< qarray< Nq >, 2 > qarray2
static constexpr double tol_eigval_Lanczos
static constexpr bool CALC_S_ON_EXIT
static double Mincr_rel(size_t i)
static size_t Mincr_abs(size_t i)
static double eps_svd(size_t i)
static constexpr double tol_state
static constexpr size_t Minit
static constexpr double tol_state_Lanczos
static constexpr DMRG::CONVTEST::OPTION CONVTEST
static constexpr DMRG::DIRECTION::OPTION INITDIR
static void doSomething(size_t i)
static constexpr char saveName[]
static DMRG::ITERATION::OPTION iteration(size_t i)
static double max_alpha_rsvd(size_t i)
static constexpr double falphamin
static constexpr double tol_eigval
static constexpr int Qinit
static constexpr size_t Mlimit
static constexpr double falphamax
static double min_alpha_rsvd(size_t i)
static size_t Mincr_per(size_t i)
static constexpr size_t savePeriod
static constexpr ::LANCZOS::REORTHO::OPTION REORTHO
static double eps_truncWeight(size_t i)
static constexpr size_t max_halfsweeps
static constexpr size_t min_halfsweeps
static size_t min_Nsv(size_t i)
static constexpr bool CALC_ERR_ON_EXIT
static constexpr size_t dimK
static int max_Nrich(size_t i)
function< double(size_t)> eps_svd
function< double(size_t)> eps_truncWeight
function< int(size_t)> max_Nrich
function< size_t(size_t)> Mincr_per
function< size_t(size_t)> Mincr_abs
function< double(size_t)> max_alpha_rsvd
function< size_t(size_t)> min_Nsv
function< void(size_t)> doSomething
function< DMRG::ITERATION::OPTION(size_t)> iteration
function< double(size_t)> Mincr_rel
function< double(size_t)> min_alpha_rsvd
DMRG::DIRECTION::OPTION INITDIR
::LANCZOS::REORTHO::OPTION REORTHO
void push_back(const std::tuple< std::size_t, std::vector< Operator >, Scalar > &elem)
PushType< OtherOperator, OtherScalar > cast()
std::vector< std::tuple< std::size_t, std::vector< Operator >, Scalar > > data
void push_back(const std::tuple< std::size_t, std::vector< OtherOperator >, Scalar > &elem)
std::tuple< std::size_t, std::vector< Operator >, Scalar > operator[](std::size_t i) const
qarray< Symmetry::Nq > qmerge13
qarray< Symmetry::Nq > qmerge24
qarray< Symmetry::Nq > qOp
TwoSiteData(std::array< size_t, 6 > s, qarray2< Symmetry::Nq > qm, std::array< size_t, 2 > k, qarray< Symmetry::Nq > qOp_, Scalar cgc9_)