43 TPM trace_constr(L,N);
47 trace_constr(0,i,i) = 1;
49 E.push_back(trace_constr);
54 trace_constr(0,i) = 1;
56 E.push_back(std::move(trace_constr));
57 e.push_back(N*(N/2.0-1));
60 TPM trace_constr(L,N);
67 E.push_back(std::move(trace_constr));
71 E.insert(
E.end(), std::make_move_iterator(doci_constr.begin()), std::make_move_iterator(doci_constr.end()));
73 assert(
E.size() == 1+
L);
152 output <<
"first print the constraint matrices:";
156 for(
int i = 0;i < lineq_p.
gnr();++i)
158 output <<
"constraint nr :" << i << std::endl;
161 output << lineq_p.
gE(i);
166 output <<
"the desired values are:" << std::endl;
169 for(
int i = 0;i < lineq_p.
gnr();++i)
170 output << i <<
"\t" << lineq_p.
ge(i) << std::endl;
184 for(
int i = 0;i <
gnr();++i)
185 for(
int j = i;j <
gnr();++j)
186 S(i,j) = S(j,i) =
E[i].ddot(
E[j]);
199 for(
int i=0;i<
gnr();++i)
201 TPM ortho_constr(
L,
N);
204 double tmp_e_ortho = 0;
206 for(
int j = 0;j<
gnr();++j)
208 ortho_constr.
daxpy(S(i,j),
E[j]);
209 tmp_e_ortho += S(i,j) *
e[j];
212 E_ortho.push_back(std::move(ortho_constr));
213 e_ortho.push_back(tmp_e_ortho);
247 for(
int i = 0;i <
gnr();++i)
253 u_0.push_back(std::move(tmp));
256 assert(
u_0.size() ==
E.size());
267 for(
int i = 0;i <
gnr();++i)
268 for(
int j = i;j <
gnr();++j)
269 S(i,j) = S(j,i) =
u_0[i].ddot(
u_0[j]);
280 for(
int i=0;i<
gnr();++i)
282 SUP ortho_constr(
L,
N);
285 for(
int j = 0;j<
gnr();++j)
288 u_0_ortho.push_back(std::move(ortho_constr));
323 for(
int i = 0;i <
gnr();++i)
325 std::cout <<
"constrain " << i <<
" gives " << tpm.
ddot(
gE(i)) <<
" = " <<
ge(i);
326 double tmp = fabs(tpm.
ddot(
gE(i)) -
ge(i));
327 std::cout << ((tmp>1
e-10) ?
"\tFAILED" :
"") << std::endl;
void daxpy(double, const SUP &)
std::vector< double > e
pointer of doubles, will contain the values of the projections. (the desired equalities) ...
std::vector< TPM > E
double pointer to TPM object, will contain the linear equality constraints
std::vector< SUP > u_0_ortho
will contain the orthogonalized matrices that span u^0 space
double ge_ortho(int) const
double ddot(const Container &) const
std::ostream & operator<<(std::ostream &output, const doci2DM::BlockStructure< MyBlockType > &blocks_p)
std::vector< SUP > u_0
will contain the matrices that span u^0 space
int gdimVector(int) const
std::vector< TPM > E_ortho
orthogonalized constraints, these will be hidden from the public.
Lineq(int L, int N, bool=false)
void check(const TPM &tpm) const
const SUP & gu_0(int) const
const TPM & gE(int) const
Container & daxpy(double alpha, const Container &)
const SUP & gu_0_ortho(int) const
int gdimMatrix(int) const
const TPM & gE_ortho(int) const
std::vector< double > e_ortho
the values accompanying the orthogonalized constraints
std::vector< TPM > DOCI_constrains() const