36 #ifndef MAT_PURISTEPINFO 37 #define MAT_PURISTEPINFO 54 template<
typename Treal,
typename Tvector,
typename TdebugPolicy>
57 explicit PuriStepInfo(
int nn = -1,
int noc = -1, Treal eigvalConvCrit = 0.0)
80 return homoLumo_converged || XmX2norm_converged;
151 template<
typename Tmatrix>
185 return homo.length() < accuracyLimit;
192 return lumo.length() < accuracyLimit;
269 template<
typename Treal,
typename Tvector,
typename TdebugPolicy>
280 <<
" n0: "<<psi.
getN0()
281 <<
" n1: "<<psi.
getN1()
291 template<
typename Treal,
typename Tvector,
typename TdebugPolicy>
308 template<
typename Treal,
typename Tvector,
typename TdebugPolicy>
313 homo.intersect(homoInt);
315 lumo.intersect(lumoInt);
319 if (
homo.low() > 0.5 &&
lumo.upp() < 0.5)
343 (tmp + (Treal)1.0) / (Treal)2.0;
345 ((tmp * (Treal)(-1.0)) + (Treal)1.0) / (Treal)2.0;
352 lumo.intersect(lumoTmp);
358 homo.intersect(homoTmp);
365 template<
typename Treal,
typename Tvector,
typename TdebugPolicy>
423 template<
typename Treal,
typename Tvector,
typename TdebugPolicy>
430 return error < 1.0 ? error : (Treal)1.0;
434 template<
typename Treal,
typename Tvector,
typename TdebugPolicy>
440 delta = delta1 > delta0 ? delta1 : delta0;
445 template<
typename Treal,
typename Tvector,
typename TdebugPolicy>
466 template<
typename Treal,
typename Tvector,
typename TdebugPolicy>
468 Treal nnzPerRowX =
nnzX / (Treal)
n;
469 Treal maxAbsErrPerElX2 = getRelPrecision<Treal>() * nnzPerRowX;
Treal getChosenThresh() const
Definition: PuriStepInfo.h:84
void setActualThresh(Treal const thr)
Definition: PuriStepInfo.h:85
Treal traceX
Trace of the matrix X.
Definition: PuriStepInfo.h:207
Definition: PuriStepInfoDebug.h:43
float timeTotal
Definition: PuriStepInfo.h:262
float timeXX2Write
Definition: PuriStepInfo.h:263
Tvector * eigVecPtr
Eigenvector possibly containing the homo or lumo eigenvector.
Definition: PuriStepInfo.h:230
void exchangeInfoWithNext(PuriStepInfo< Treal, Tvector, TdebugPolicy > &next)
Definition: PuriStepInfo.h:367
bool getHomoWasComputed()
Definition: PuriStepInfo.h:196
void checkIntervals(Interval< Treal > const &eigInterval, Interval< Treal > const &homo, Interval< Treal > const &lumo, Interval< Treal > const &XmX2EuclNorm, const char *descriptionString) const
Definition: PuriStepInfoDebug.h:46
void computeExactValues(Tmatrix const &X, Tmatrix const &X2)
Definition: PuriStepInfo.h:152
~PuriStepInfo()
Definition: PuriStepInfo.h:70
Treal low() const
Definition: Interval.h:142
bool homoIsAccuratelyKnown(Treal accuracyLimit) const
Definition: PuriStepInfo.h:181
PuriStepInfo base class for tests.
void setTimeThresh(float t)
Definition: PuriStepInfo.h:164
void improveEigInterval(Interval< Treal > const eInt)
Improve eigenvalue bounds and delta if possible.
Definition: PuriStepInfo.h:436
int correctOccupation
Takes the values: 1 meaning all eigenvalues supposed to go to 1 are larger than 0.5 and all eigenvalues supposed to go to 0 are smaller than 0.5 for sure.
Definition: PuriStepInfo.h:219
static Interval intersect(Interval const &A, Interval const &B)
Definition: Interval.h:51
float timeThresh
Definition: PuriStepInfo.h:259
float timeXmX2Norm
Definition: PuriStepInfo.h:261
void setMemUsageInXmX2Diff(MemUsage::Values &memUsage)
Definition: PuriStepInfo.h:161
float timeXX2Read
Definition: PuriStepInfo.h:264
int getPoly() const
Definition: PuriStepInfo.h:96
bool lumoWasComputed
Flag indicating if lumo was computed.
Definition: PuriStepInfo.h:233
void improveHomoLumo(Interval< Treal > const homoInt, Interval< Treal > const lumoInt)
Definition: PuriStepInfo.h:310
float getTimeXmX2Norm()
Definition: PuriStepInfo.h:175
void increase(Treal const value)
Increases interval with value in both directions.
Definition: Interval.h:131
void setCorrectOccupation()
Set correct occ.
Definition: PuriStepInfo.h:127
#define ASSERTALWAYS(x)
Definition: DebugPolicies.h:83
void setTimeXmX2Norm(float t)
Definition: PuriStepInfo.h:166
Definition: allocate.cc:30
void setEstimatedStepsLeft(int const stepsleft)
Definition: PuriStepInfo.h:87
void setTimeXX2Write(float t)
Definition: PuriStepInfo.h:168
size_t nnzX2
Number of nonzeros in the matrix X2.
Definition: PuriStepInfo.h:248
float getTimeSquare()
Definition: PuriStepInfo.h:174
Treal template_blas_fabs(Treal x)
Definition: Interval.h:44
int n
System size.
Definition: PuriStepInfo.h:204
void setTimeTotal(float t)
Definition: PuriStepInfo.h:167
MemUsage::Values getMemUsageInXmX2Diff()
Definition: PuriStepInfo.h:172
Interval< Treal > const & getLumo() const
Definition: PuriStepInfo.h:118
void invPuriStep(int poly)
Definition: Interval.h:269
Tvector const * getEigVecPtr() const
Definition: PuriStepInfo.h:111
void puriStep(int poly)
Definition: Interval.h:228
MemUsage::Values memUsageInXmX2Diff
Definition: PuriStepInfo.h:258
size_t getNnzX2() const
Definition: PuriStepInfo.h:138
int getEstimatedStepsLeft() const
Definition: PuriStepInfo.h:90
bool getLumoWasComputed()
Definition: PuriStepInfo.h:195
Contains information about the matrix before a purification step and about the step.
Definition: PuriStepInfo.h:55
Treal getTraceX2() const
Definition: PuriStepInfo.h:94
void setChosenThresh(Treal const thr)
Definition: PuriStepInfo.h:83
void checkIntervals(const char *descriptionString) const
Definition: PuriStepInfo.h:147
Interval< Treal > const & getHomo() const
Definition: PuriStepInfo.h:115
MemUsage::Values getMemUsageBeforeTrunc()
Definition: PuriStepInfo.h:171
Treal getActualThresh() const
Definition: PuriStepInfo.h:86
void setTraceX(Treal const trX)
Definition: PuriStepInfo.h:91
void setTimeSquare(float t)
Definition: PuriStepInfo.h:165
Interval< Treal > sqrtInt(Interval< Treal > const &other)
Definition: Interval.h:217
Interval< Treal > homo
Interval containing the homo eigenvalue.
Definition: PuriStepInfo.h:242
int getCorrectOccupation() const
Definition: PuriStepInfo.h:128
MemUsage::Values memUsageBeforeTrunc
Definition: PuriStepInfo.h:257
void setTimeXX2Read(float t)
Definition: PuriStepInfo.h:169
std::ostream & operator<<(std::ostream &s, Interval< Treal > const &in)
Definition: Interval.h:357
float getTimeXX2Write()
Definition: PuriStepInfo.h:177
Treal eigAccLoss
A probable upper bound of the accuracy that is lost in the eigenvalues of X * X because of limited re...
Definition: PuriStepInfo.h:254
static void getMemUsage(Values &values)
Definition: matInclude.cc:127
bool homoWasComputed
Flag indicating if homo was computed.
Definition: PuriStepInfo.h:234
int nocc
Number of occupied orbitals.
Definition: PuriStepInfo.h:205
Treal chosenThresh
Chosen threshold value applied before step.
Definition: PuriStepInfo.h:210
Treal getEigAccLoss() const
Definition: PuriStepInfo.h:140
float timeSquare
Definition: PuriStepInfo.h:260
Interval< Treal > XmX2EuclNorm
Interval containing the euclidean norm ||X-X^2||_2 before step.
Definition: PuriStepInfo.h:226
Treal getDelta() const
Definition: PuriStepInfo.h:144
Treal delta
Largest possible deviation from the [0 1] interval.
Definition: PuriStepInfo.h:218
void setTraceX2(Treal const trX2)
Definition: PuriStepInfo.h:92
float getTimeXX2Read()
Definition: PuriStepInfo.h:178
void setNnzX(size_t const nzX)
Definition: PuriStepInfo.h:135
void computen0n1()
Compute n0 and n1 Called by improveEigInterval.
Definition: PuriStepInfo.h:446
Interval< Treal > getXmX2EuclNorm() const
Definition: PuriStepInfo.h:102
int estimatedStepsLeft
Estimated steps left in purification.
Definition: PuriStepInfo.h:212
Interval< Treal > eigInterval
Interval containing the eigenvalue spectrum.
Definition: PuriStepInfo.h:216
void setPoly()
Definition: PuriStepInfo.h:292
Treal actualThresh
Actual threshold value applied before step.
Definition: PuriStepInfo.h:211
Treal traceX2
Trace of the squared matrix X^2.
Definition: PuriStepInfo.h:208
void setEigVecPtr(Tvector *eigVecPtr_)
Improves homo and lumo bounds if the new ones are better.
Definition: PuriStepInfo.h:107
Treal n0
Lower bound on the number of eigenvalues in [lambdaMin, 0.5].
Definition: PuriStepInfo.h:235
bool converged() const
Definition: PuriStepInfo.h:73
Treal length() const
Returns the length of the interval.
Definition: Interval.h:107
Treal getN1() const
Definition: PuriStepInfo.h:143
void computeExactValues(Tmatrix const &X, Tmatrix const &X2, int const n, int const nocc)
Definition: PuriStepInfoDebug.h:52
Treal getN0() const
Definition: PuriStepInfo.h:142
Interval< Treal > lumo
Interval containing the lumo eigenvalue.
Definition: PuriStepInfo.h:243
bool empty() const
Definition: Interval.h:49
size_t getNnzX() const
Definition: PuriStepInfo.h:136
Definition: matInclude.h:171
Interval< Treal > const & getEigInterval() const
Definition: PuriStepInfo.h:121
Treal eigConvCrit
Tolerated deviation from 0 and 1 of converged eigenvalues.
Definition: PuriStepInfo.h:244
bool lumoIsAccuratelyKnown(Treal accuracyLimit) const
Definition: PuriStepInfo.h:188
float getTimeTotal()
Definition: PuriStepInfo.h:176
void setNnzX2(size_t const nzX2)
Definition: PuriStepInfo.h:137
float getTimeThresh()
Definition: PuriStepInfo.h:173
void computeEigAccLoss()
Computes a probable upper bound of the accuracy that is lost in the eigenvalues of X * X because of l...
Definition: PuriStepInfo.h:467
void setXmX2EuclNorm(Interval< Treal > const XmX2eucl)
Sets XmX2EuclNorm bounds.
Definition: PuriStepInfo.h:98
size_t nnzX
Number of nonzeros in the matrix X.
Definition: PuriStepInfo.h:247
void setMemUsageBeforeTrunc()
Definition: PuriStepInfo.h:158
Treal n1
Lower bound on the number of eigenvalues in [0.5, 1 + delta].
Definition: PuriStepInfo.h:238
Treal template_blas_sqrt(Treal x)
Treal getTraceX() const
Definition: PuriStepInfo.h:93
Treal subspaceError() const
Definition: PuriStepInfo.h:424
int poly
Choice of polynomial 0 for x^2 and 1 for 2 * x - x^2.
Definition: PuriStepInfo.h:209
PuriStepInfo(int nn=-1, int noc=-1, Treal eigvalConvCrit=0.0)
Definition: PuriStepInfo.h:57