27 #ifndef MAQUIS_DMRG_COHERENT_INIT_H
28 #define MAQUIS_DMRG_COHERENT_INIT_H
34 #include <boost/tuple/tuple.hpp>
36 template <
class SymmGroup>
37 double coherent_weight(std::vector<double>
const& coeff, std::vector<boost::tuple<typename SymmGroup::charge, size_t> >
const& state)
39 using std::exp;
using std::sqrt;
using std::pow;
40 using boost::math::factorial;
43 for (
int p=0; p<state.size(); ++p) {
44 int n = boost::get<1>(state[p]);
45 w *= pow(coeff[p], n) *
sqrt(factorial<double>(n)) / factorial<double>(n);
50 template <
class Matrix,
class SymmGroup>
52 typename SymmGroup::charge initc=SymmGroup::IdentityCharge)
54 typedef typename SymmGroup::charge charge;
55 typedef boost::tuple<charge, size_t> local_state;
57 size_t L = coeff.size();
65 std::vector<local_state>
const& state = *it;
66 double weight = coherent_weight<SymmGroup>(coeff, state);
68 mps = state_mps<Matrix>(state, phys);
71 mps =
join(mps, state_mps<Matrix>(state, phys), prev_weight, weight);
73 mps =
join(mps, state_mps<Matrix>(state, phys), 1., weight);
83 template <
class Matrix,
class SymmGroup>
86 assert(phys.
size() == 1);
89 typedef typename SymmGroup::charge charge;
91 using std::exp;
using std::sqrt;
using std::pow;
92 using boost::math::factorial;
94 size_t L = coeff.size();
97 trivial_i.
insert(std::make_pair(SymmGroup::IdentityCharge, 1));
100 for (
int p=0; p<L; ++p) {
102 Matrix m(phys[s].second, 1, 0.);
103 for (
int ss=0; ss<phys[s].second; ++ss) {
104 m(ss, 0) = pow(coeff[p], ss) *
sqrt(factorial<double>(ss)) / factorial<double>(ss);
107 block.
insert_block(m, SymmGroup::IdentityCharge, SymmGroup::IdentityCharge);
118 template <
class Matrix,
class SymmGroup>
121 typedef typename SymmGroup::charge charge;
122 typedef boost::tuple<charge, size_t> local_state;
124 size_t L = coeff.size();
130 for (boost::tie(it1,end1)=
basis_sector_iterators(L, phys_psi, SymmGroup::IdentityCharge); it1!=end1; ++it1)
131 for (boost::tie(it2,end2)=
basis_sector_iterators(L, phys_psi, SymmGroup::IdentityCharge); it2!=end2; ++it2)
133 std::vector<local_state>
const& state1 = *it1;
134 std::vector<local_state>
const& state2 = *it2;
135 std::vector<local_state> state_rho(L);
137 for (
int p=0; p<L; ++p) {
138 boost::get<0>(state_rho[p]) = SymmGroup::IdentityCharge;
139 boost::get<1>(state_rho[p]) = boost::get<1>(state1[p])*phys_psi.
size_of_block(boost::get<0>(state2[p])) + boost::get<1>(state2[p]);
142 double weight = coherent_weight<SymmGroup>(coeff, state1)*coherent_weight<SymmGroup>(coeff, state2);
144 mps = state_mps<Matrix>(state_rho, phys_rho);
147 mps =
join(mps, state_mps<Matrix>(state_rho, phys_rho), prev_weight, weight);
149 mps =
join(mps, state_mps<Matrix>(state_rho, phys_rho), 1., weight);
153 prev_weight = weight;
159 template <
class Matrix,
class SymmGroup>
162 assert(phys_psi.
size() == 1);
165 typedef typename SymmGroup::charge charge;
167 using std::exp;
using std::sqrt;
using std::pow;
168 using boost::math::factorial;
170 size_t L = coeff.size();
173 trivial_i.
insert(std::make_pair(SymmGroup::IdentityCharge, 1));
176 for (
int p=0; p<L; ++p) {
178 Matrix m(phys_rho[s].second, 1, 0.);
179 for (
int ss1=0; ss1<phys_psi[s].second; ++ss1)
180 for (
int ss2=0; ss2<phys_psi[s].second; ++ss2) {
181 m(ss1*phys_psi[s].second+ss2, 0) = pow(coeff[p], ss1) *
sqrt(factorial<double>(ss1)) / factorial<double>(ss1);
182 m(ss1*phys_psi[s].second+ss2, 0) *= pow(coeff[p], ss2) *
sqrt(factorial<double>(ss2)) / factorial<double>(ss2);
185 block.
insert_block(m, SymmGroup::IdentityCharge, SymmGroup::IdentityCharge);
declaration of the MPS class (vector of MPSTensor)
MPS< Matrix, SymmGroup > coherent_init(std::vector< double > const &coeff, Index< SymmGroup > const &phys)
std::pair< basis_sector_iterator_< SymmGroup >, basis_sector_iterator_< SymmGroup > > basis_sector_iterators(size_t L, Index< SymmGroup > const &phys, typename SymmGroup::charge initc=SymmGroup::IdentityCharge)
convert a basis state into MPS
size_type insert_block(Matrix const &, charge, charge)
std::size_t size_of_block(charge c) const
MPS< Matrix, SymmGroup > coherent_init_dm_join(std::vector< double > const &coeff, Index< SymmGroup > const &phys_psi, Index< SymmGroup > const &phys_rho)
block_matrix< Matrix, SymmGroup > sqrt(block_matrix< Matrix, SymmGroup > m)
MPS< Matrix, SymmGroup > coherent_init_dm(std::vector< double > const &coeff, Index< SymmGroup > const &phys_psi, Index< SymmGroup > const &phys_rho)
MPS< Matrix, SymmGroup > coherent_init_join(std::vector< double > const &coeff, Index< SymmGroup > const &phys, typename SymmGroup::charge initc=SymmGroup::IdentityCharge)
double coherent_weight(std::vector< double > const &coeff, std::vector< boost::tuple< typename SymmGroup::charge, size_t > > const &state)
std::size_t insert(std::pair< charge, std::size_t > const &x)
block_matrix< Matrix, SymmGroup > & data()
MPSTensor< Matrix, SymmGroup > join(MPSTensor< Matrix, SymmGroup > const &m1, MPSTensor< Matrix, SymmGroup > const &m2, boundary_flag_t boundary_f=no_boundary_f)
iterators through all allowed sectors in the system