Xped
Loading...
Searching...
No Matches
Mps.hpp
Go to the documentation of this file.
1#ifndef MPS_H_
2#define MPS_H_
3
6
7namespace Xped {
8
9template <typename TL, typename TR, typename TC>
11{
12 TL Al;
13 TR Ar;
14 TC Ac;
15};
16
17namespace DMRG {
18enum class BROOM
19{
20 SVD = 0,
21 QR = 1
22};
23}
24
25template <typename Scalar_, typename Symmetry_>
26class Mps
27{
28public:
29 typedef Symmetry_ Symmetry;
30 typedef Scalar_ Scalar;
32 typedef typename Symmetry::qType qType;
34 typedef typename ALType::TensorType TensorType;
35 typedef typename ALType::MatrixType MatrixType;
36 typedef typename ALType::VectorType VectorType;
38
39 constexpr static std::size_t Nq = Symmetry::Nq;
40
41 Mps() {}
42 Mps(std::size_t L);
43 // : N_sites(L)
44 // {
45 // resizeArrays();
46 // }
47 Mps(std::size_t L,
48 const std::vector<Qbasis<Symmetry, 1>>& qloc_in,
49 const qType& Qtarget_in = Symmetry::qvacuum(),
50 std::size_t Mmax_in = 10,
51 std::size_t Nqmax_in = 10,
52 std::size_t seed = 0ul);
53 // : N_sites(L)
54 // {
55 // Qtarget.push_back(Qtarget_in);
56 // resizeArrays();
57 // qloc = qloc_in;
58 // gen_maxBasis();
59 // gen_auxBasis(Mmax_in, Nqmax_in);
60 // for(size_t l = 0; l < N_sites; l++) {
61 // A.Ac[l] = Xped<Scalar, 2, 1, Symmetry>({{inBasis(l), locBasis(l)}}, {{outBasis(l)}});
62 // A.Ac[l].setRandom();
63 // }
64 // }
65
66 std::size_t length() const { return N_sites; }
67
68 Qbasis<Symmetry, 1> inBasis(std::size_t l) const
69 {
70 assert(l < N_sites);
71 return qaux[l];
72 }
73 Qbasis<Symmetry, 1> outBasis(std::size_t l) const
74 {
75 assert(l < N_sites);
76 return qaux[l + 1];
77 }
78 Qbasis<Symmetry, 1> locBasis(std::size_t l) const
79 {
80 assert(l < N_sites);
81 return qloc[l];
82 }
83 Qbasis<Symmetry, 1> auxBasis(std::size_t l) const
84 {
85 assert(l < N_sites + 1);
86 return qaux[l];
87 }
88
89 void leftSweepStep(const std::size_t loc, const DMRG::BROOM& broom, const bool DISCARD_U = false);
90 void rightSweepStep(const std::size_t loc, const DMRG::BROOM& broom, const bool DISCARD_V = false);
91
92 // private:
93 std::size_t N_sites;
94 std::vector<qType> Qtarget;
95
96 GaugeTriple<std::vector<ALType>, std::vector<ARType>, std::vector<ALType>> A; // A[Mps::GAUGE::L/R/C][l]
97
98 std::vector<Qbasis<Symmetry, 1>> qaux;
99 std::vector<Qbasis<Symmetry, 1>> qloc;
100
101 // std::vector<std::unordered_map<qType, std::size_t> > qranges; //set of possible values for quantum numbers at site l
102 std::vector<Qbasis<Symmetry, 1>> maxBasis; // set of possible values for quantum numbers at site l
103
104 std::size_t max_Nsv = 10000, min_Nsv = 0;
106 std::vector<std::map<qType, VectorType>> SVspec;
108 std::vector<RealScalar> truncWeight;
109
111 std::vector<RealScalar> S;
112
113 void gen_maxBasis();
114
115 void gen_auxBasis(const std::size_t Mmax, const std::size_t Nqmax);
116
117 void resizeArrays();
118 // {
119 // A.Ac.resize(N_sites);
120 // qaux.resize(N_sites + 1);
121 // maxBasis.resize(N_sites + 1);
122 // qloc.resize(N_sites);
123 // SVspec.resize(N_sites);
124 // truncWeight.resize(N_sites);
125 // S.resize(N_sites);
126 // }
127};
128
129} // namespace Xped
130
131#ifndef XPED_COMPILED_LIB
132# include "MPS/Mps.cpp"
133#endif
134
135#endif
Definition: Mps.hpp:27
std::size_t N_sites
Definition: Mps.hpp:93
void resizeArrays()
Definition: Mps.cpp:45
std::vector< qType > Qtarget
Definition: Mps.hpp:94
std::vector< std::map< qType, VectorType > > SVspec
Definition: Mps.hpp:106
std::vector< Qbasis< Symmetry, 1 > > qaux
Definition: Mps.hpp:98
static constexpr std::size_t Nq
Definition: Mps.hpp:39
GaugeTriple< std::vector< ALType >, std::vector< ARType >, std::vector< ALType > > A
Definition: Mps.hpp:96
std::vector< Qbasis< Symmetry, 1 > > qloc
Definition: Mps.hpp:99
Symmetry::qType qType
Definition: Mps.hpp:32
Qbasis< Symmetry, 1 > locBasis(std::size_t l) const
Definition: Mps.hpp:78
Symmetry_ Symmetry
Definition: Mps.hpp:29
Mps()
Definition: Mps.hpp:41
void leftSweepStep(const std::size_t loc, const DMRG::BROOM &broom, const bool DISCARD_U=false)
Definition: Mps.cpp:182
RealScalar eps_svd
Definition: Mps.hpp:105
Tensor< Scalar, 1, 2, Symmetry > ARType
Definition: Mps.hpp:37
ScalarTraits< Scalar >::Real RealScalar
Definition: Mps.hpp:31
ALType::MatrixType MatrixType
Definition: Mps.hpp:35
void gen_maxBasis()
Definition: Mps.cpp:57
std::vector< Qbasis< Symmetry, 1 > > maxBasis
Definition: Mps.hpp:102
std::vector< RealScalar > truncWeight
Definition: Mps.hpp:108
ALType::VectorType VectorType
Definition: Mps.hpp:36
ALType::TensorType TensorType
Definition: Mps.hpp:34
Tensor< Scalar, 2, 1, Symmetry > ALType
Definition: Mps.hpp:33
std::size_t length() const
Definition: Mps.hpp:66
Qbasis< Symmetry, 1 > outBasis(std::size_t l) const
Definition: Mps.hpp:73
Qbasis< Symmetry, 1 > inBasis(std::size_t l) const
Definition: Mps.hpp:68
Scalar_ Scalar
Definition: Mps.hpp:30
Qbasis< Symmetry, 1 > auxBasis(std::size_t l) const
Definition: Mps.hpp:83
std::vector< RealScalar > S
Definition: Mps.hpp:111
void gen_auxBasis(const std::size_t Mmax, const std::size_t Nqmax)
Definition: Mps.cpp:80
std::size_t min_Nsv
Definition: Mps.hpp:104
std::size_t max_Nsv
Definition: Mps.hpp:104
void rightSweepStep(const std::size_t loc, const DMRG::BROOM &broom, const bool DISCARD_V=false)
Definition: Mps.cpp:204
Definition: Qbasis.hpp:39
Definition: Tensor.hpp:40
BROOM
Definition: Mps.hpp:19
Definition: bench.cpp:62
Definition: Mps.hpp:11
TL Al
Definition: Mps.hpp:12
TC Ac
Definition: Mps.hpp:14
TR Ar
Definition: Mps.hpp:13
Definition: ScalarTraits.hpp:10