28 #if !defined(SLR_HEADER) 40 template<
bool MultByS,
bool SwapXY>
62 onDisk(0), inMemory(1) {
69 VarVector() : v(NULL), fName(NULL), nvar(0), onDisk(0), inMemory(1) {}
73 : v(NULL), fName(NULL), nvar(0), onDisk(0), inMemory(1) {
74 setFromFull(nbast, nocc, full_mat);
94 int size()
const {
return nvar; }
95 void print(
const char *comment = NULL) {
96 if(comment) puts(comment);
97 for(
int i=0; i<nvar*2; i++) printf(
"%15.10f\n", (
double)v[i]);
99 void setFromFull(
int nbast,
int nocc,
const ergo_real *full_mat);
100 void setFull(
int nbast,
int nocc,
ergo_real *full_mat)
const;
104 for(
int i=0; i<2*nvar; i++) v[i] = scalar;
109 if(
this == &b)
return *
this;
115 memcpy(v, b.
v, 2*nvar*
sizeof(v[0]));
122 if (&proxy.
vec ==
this)
123 throw "VarVector self-assignment not-implemented";
124 if(nvar != proxy.
vec.nvar) {
126 nvar = proxy.
vec.nvar;
130 for(
int i=0; i<2*nvar; i++)
137 if (&proxy.
vec ==
this)
138 throw "VarVector self-assignment not-implemented";
139 if(nvar != proxy.
vec.nvar) {
141 nvar = proxy.
vec.nvar;
144 for(
int i=0; i<nvar; i++) {
153 void load(
const char* tmpdir);
155 void save(
const char* tmpdir);
157 void release(
const char* tmpdir);
186 nVecs(0), nAllocated(0), diskMode(false) {
187 if(nSize) setSize(nSize);
190 void setSize(
int sz);
192 int size()
const {
return nVecs; }
206 virtual void getOper(
ergo_real *result) = 0;
228 void expand(
int newSize);
243 if(fdiag)
delete fdiag;
262 virtual ergo_real getPreconditionerShift(
int i)
const = 0;
265 virtual void increaseSubspaceLimit(
int newSize);
273 static const int MVEC = 200;
335 :
LRSolver(nbast, nocc, fock_matrix, s), frequency(freq),
343 virtual void increaseSubspaceLimit(
int newSize);
365 :
LRSolver(nbast, nocc, NULL, NULL),
367 nStates(n), nConverged(0), last_ev(NULL) {
368 ritzVals[0] = setE2diag(nbast, nocc, fock_matrix, overlap);
369 for(
int i=1; i<n; i++) ritzVals[i] = ritzVals[0];
372 if(last_ev)
delete last_ev;
377 return ritzVals[nConverged+i];
382 virtual void increaseSubspaceLimit(
int newSize);
int size() const
Definition: slr.h:192
VarVector(const VarVector &a)
Definition: slr.h:61
ergo_real * last_ev
most recent eigenvectors in the reduced space
Definition: slr.h:360
ergo_real operator*(const VarVector &a, const VarVector &b)
Definition: slr.cc:97
EigenSolver(int nbast, int nocc, const ergo_real *fock_matrix, const ergo_real *overlap, int n)
Definition: slr.h:362
double ergo_real
Definition: realtype.h:53
int nAllocated
Definition: slr.h:182
Iterative Set Of Linear Equations solver, extending the generic LRSolver.
Definition: slr.h:325
ergo_real & operator[](int j) const
Definition: slr.h:218
RowProxy(ergo_real *r)
Definition: slr.h:217
int size() const
Definition: slr.h:94
ergo_real * mat
Definition: slr.h:212
Linear Response iterative solver using a variant of the Davidson method.
Definition: slr.h:235
void setDiskMode(bool x)
Definition: slr.h:194
E2Evaluator interface provides a way to perform a linear transformation of supplied transition densit...
Definition: slr.h:169
const VarVector & vec
Definition: slr.h:43
virtual ~OneElOperator()
Definition: slr.h:207
unsigned inMemory
valid representation in memory
Definition: slr.h:59
VarVector & operator=(const VarVectorProxyOp< false, false > &proxy)
Definition: slr.h:121
ergo_real * rhsSub
RHS vector projected onto subspace.
Definition: slr.h:346
VarVectorProxyOp(const VarVector &a, ergo_real s=1.0)
Definition: slr.h:45
VarVectorCollection Avects
vects and Avects members store the trial vectors and their transformed versions.
Definition: slr.h:313
unsigned currentAge
Definition: slr.h:180
ergo_real * ritzVals
recent ritz values in the subspace.
Definition: slr.h:356
template based proxy object that uses bool-valued policies to perform the assignments.
Definition: slr.h:41
VarVectorCollection(int nSize=0)
Definition: slr.h:185
ergo_real & operator[](int i)
Definition: slr.h:102
Vector of variables parametrising the solution to the linear response equations.
Definition: slr.h:52
VarVector & operator=(ergo_real scalar)
Definition: slr.h:103
int nVecs
Definition: slr.h:181
ergo_real scalar
Definition: slr.h:44
SetOfEqSolver(int nbast, int nocc, const ergo_real *fock_matrix, const ergo_real *s, ergo_real freq)
Creates the set-of-equations solver.
Definition: slr.h:331
virtual ~SetOfEqSolver()
Definition: slr.h:338
Iterative Eigenvalue solver, extending the generic LRSolver.
Definition: slr.h:355
~SmallMatrix()
Definition: slr.h:224
a collection of vectors, usually handled at once.
Definition: slr.h:177
ergo_real * cmo
the MO coefficients.
Definition: slr.h:316
VarVector & operator=(const VarVectorProxyOp< false, true > &proxy)
Definition: slr.h:136
unsigned onDisk
valid representation on disk
Definition: slr.h:58
ergo_real xTimesRHS
Definition: slr.h:349
ergo_real getFreq(int i) const
Definition: slr.h:384
const RowProxy operator[](int i)
Definition: slr.h:225
VarVector(int nbast, int nocc, const ergo_real *full_mat)
Creates a vector from a full matrix.
Definition: slr.h:72
ergo_real * toprow
Definition: slr.h:216
void print(const char *comment=NULL)
Definition: slr.h:95
ergo_real frequency
frequency for which the SOE is to be solved.
Definition: slr.h:326
~VarVector()
Definition: slr.h:77
SmallMatrix(int sz)
Definition: slr.h:223
ergo_real * x() const
return the X part of the vector.
Definition: slr.h:84
a class implementing dynamic resized two dimensional arrays.
Definition: slr.h:211
char * fName
Present in secondary storage (i.e.
Definition: slr.h:55
ergo_real * transMoms2
most recent SQUARED transition moments.
Definition: slr.h:357
VarVector rhs
RHS of the SOE.
Definition: slr.h:327
int maxSubspaceSize
current subspace size limit.
Definition: slr.h:271
Abstract interface to a one electron operator.
Definition: slr.h:204
int nsize
Definition: slr.h:213
void setSize(int n)
Definition: slr.h:87
static const char * tmpdir
Definition: slr.h:199
int nStates
number of excited states to compute
Definition: slr.h:358
ergo_real convThreshold
iterative method convergence threshold
Definition: slr.h:270
virtual ergo_real getPreconditionerShift(int i) const
returns the preconditioning shift.
Definition: slr.h:376
int subspaceSize
current subspace size
Definition: slr.h:275
ergo_real * fdiag
the eigenvalues of the Fock matrix.
Definition: slr.h:314
SmallMatrix sSub
S[2] matrix projected onto subspace.
Definition: slr.h:277
int nConverged
number of already converged eigenvalues
Definition: slr.h:359
VarVector e2diag
approximation to the diagonal of E2 operator
Definition: slr.h:274
bool getDiskMode() const
Definition: slr.h:193
bool diskMode
Definition: slr.h:183
VarVector & operator=(const VarVector &b)
Definition: slr.h:108
ergo_real getTransitionMoment2(int i) const
Definition: slr.h:388
SmallMatrix eSub
E[2] matrix projected onto subspace.
Definition: slr.h:276
VarVector()
Definition: slr.h:69
int nvar
nvar := nocc*nvirt.
Definition: slr.h:57
virtual ergo_real getPreconditionerShift(int) const
returns the preconditioning shift.
Definition: slr.h:339
const ergo_real & operator[](int i) const
Definition: slr.h:101
ergo_real * v
vector coefficients
Definition: slr.h:53
VarVectorCollection vects
base vectors
Definition: slr.h:305
int nbast
number of basis functions
Definition: slr.h:303
int nocc
number of occupied orbitals
Definition: slr.h:304
unsigned * ages
Definition: slr.h:179
virtual ~E2Evaluator()
Definition: slr.h:172
ergo_real * xSub
solution vector projected onto subspace
Definition: slr.h:278
ergo_real * y() const
returns the Y part.
Definition: slr.h:85
virtual ~EigenSolver()
Definition: slr.h:371
virtual ~LRSolver()
Definition: slr.h:241
VarVector * vecs
Definition: slr.h:178