73 int nn, nc1, ij = 0, is;
74 double rt, art, brt, eigvt;
79 int nc =
min(2 * nroot, nroot + 8);
115 for (
int i = 1; i <= nn; i++ ) {
117 w.
at(i) = b.
at(i, i) / a.
at(i, i);
123 for (
int j = 2; j <= nc; j++ ) {
125 for (
int i = 1; i <= nn; i++ ) {
126 if ( fabs( w.
at(i) ) >= rt ) {
127 rt = fabs( w.
at(i) );
134 for (
int i = 1; i <= nn; i++ ) {
146 # ifdef DETAILED_REPORT 147 OOFEM_LOG_INFO(
"SubspaceIteration :: solveYourselfAt: Degrees of freedom invoked by initial vectors :\n");
149 OOFEM_LOG_INFO(
"SubspaceIteration :: solveYourselfAt: initial vectors for iteration:\n");
158 for (
int nite = 0; ; ++nite ) {
159 # ifdef DETAILED_REPORT 160 printf(
"SubspaceIteration :: solveYourselfAt: Iteration loop no. %d\n", nite);
165 for (
int j = 1; j <= nc; j++ ) {
168 solver->solve(a, f, tt);
170 for (
int i = j; i <= nc; i++ ) {
172 for (
int k = 1; k <= nn; k++ ) {
173 art += r.
at(k, i) * tt.
at(k);
183 #ifdef DETAILED_REPORT 184 OOFEM_LOG_INFO(
"SubspaceIteration :: solveYourselfAt: Printing projection matrix ar\n");
188 for (
int j = 1; j <= nc; j++ ) {
192 for (
int i = j; i <= nc; i++ ) {
194 for (
int k = 1; k <= nn; k++ ) {
195 brt += r.
at(k, i) * temp.
at(k);
205 #ifdef DETAILED_REPORT 206 OOFEM_LOG_INFO(
"SubspaceIteration :: solveYourselfAt: Printing projection matrix br\n");
213 mtd.
solve(ar, br, eigv, vec);
224 for (
int i = 1;i <= nc; i++ ) {
229 for (
int i = 1;i <= nc; i++ )
230 for (
int j = 1; j <= nc;j++ )
235 for (
int i = 0;i <
nitem; i++ ) {
240 x.beProductOf(arinv, z);
242 for (
int j = 1;j <= nc; j++ ) {
244 for (k = 1; k<= nc; k++) w.
at(j) += zz.at(k,j) * x.at(k,j);
247 z.beProductOf (br, x);
249 for (
int j = 1;j <= nc; j++ ) {
251 for (
int k = 1; k<= nc; k++ ) c += z.at(k,j) * x.at(k,j);
257 for (
int j = 1;j <= nc; j++ ) {
258 if (fabs((ww.at(j)-w.
at(j))/w.
at(j))< rtol) ac++;
266 for (
int j = 1;j <= nc;j++ ) {
267 for (
int k = 1; k<= nc; k++ ) tt.
at(k) = x.at(k,j);
269 for (
int ii = 1;ii < j; ii++ ) {
271 for (
int k = 1; k<= nc; k++ ) c += x.at(k,ii) * t.
at(k);
272 for (
int k = 1; k<= nc; k++ ) x.at(k,j) -= x.at(k,ii) * c;
274 for (
int k = 1; k<= nc; k++) tt.
at(k) = x.at(k,j);
277 for (
int k = 1; k<= nc; k++) c += x.at(k,j)*t.
at(k);
278 for (
int k = 1; k<= nc; k++) x.at(k,j) /= sqrt(c);
300 for (
int i = 1; i <= nc1; i++ ) {
301 if ( fabs( eigv.
at(i + 1) ) < fabs( eigv.
at(i) ) ) {
303 eigvt = eigv.
at(i + 1);
304 eigv.
at(i + 1) = eigv.
at(i);
306 for (
int k = 1; k <= nc; k++ ) {
307 rt = vec.
at(k, i + 1);
308 vec.
at(k, i + 1) = vec.
at(k, i);
315 # ifdef DETAILED_REPORT 316 OOFEM_LOG_INFO(
"SubspaceIteration :: solveYourselfAt: current eigen values of reduced problem \n");
318 OOFEM_LOG_INFO(
"SubspaceIteration :: solveYourselfAt: current eigen vectors of reduced problem \n");
324 for (
int i = 1; i <= nn; i++ ) {
325 for (
int j = 1; j <= nc; j++ ) {
326 tt.
at(j) = r.
at(i, j);
329 for (
int k = 1; k <= nc; k++ ) {
331 for (
int j = 1; j <= nc; j++ ) {
332 rt += tt.
at(j) * vec.
at(j, k);
342 for (
int i = 1; i <= nc; i++ ) {
343 double dif = ( eigv.
at(i) - d.
at(i) );
344 rtolv.
at(i) = fabs( dif / eigv.
at(i) );
347 # ifdef DETAILED_REPORT 348 OOFEM_LOG_INFO(
"SubspaceIteration :: solveYourselfAt: Reached precision of eigenvalues:\n");
351 for (
int i = 1; i <= nroot; i++ ) {
352 if ( rtolv.
at(i) > rtol ) {
357 OOFEM_LOG_INFO(
"SubspaceIteration :: solveYourselfAt: Convergence reached for RTOL=%20.15f\n", rtol);
360 if ( nite >=
nitem ) {
361 OOFEM_WARNING(
"SubspaceIteration :: solveYourselfAt: Convergence not reached in %d iteration - using current values",
nitem);
372 for (
int j = 1; j <= nc; j++ ) {
384 for (
int i = 1; i <= nroot; i++ ) {
385 _eigv.
at(i) = eigv.
at(i);
386 for (
int j = 1; j <= nn; j++ ) {
387 _r.
at(j, i) = r.
at(j, i);
#define NM_Success
Numerical method exited with success.
Base class for all matrices stored in sparse format.
virtual FloatArray * backSubstitutionWith(FloatArray &y) const
Computes the solution of linear system where A is receiver.
double & at(int i)
Coefficient access function.
virtual NM_Status solve(SparseMtrx &A, SparseMtrx &B, FloatArray &x, FloatMatrix &v, double rtol, int nroot)
Solves the given sparse generalized eigen value system of equations .
virtual double & at(int i, int j)=0
Returns coefficient at position (i,j).
unsigned long NM_Status
Mask defining NumMetod Status; which can be asked after finishing computation by Numerical Method...
void beColumnOf(const FloatMatrix &mat, int col)
Reciever will be set to a given column in a matrix.
REGISTER_GeneralizedEigenValueSolver(InverseIteration, GES_InverseIt)
Domain * domain
Pointer to domain.
virtual ~SubspaceIteration()
#define OOFEM_LOG_INFO(...)
void beProductOf(const FloatMatrix &aMatrix, const FloatArray &anArray)
Receiver becomes the result of the product of aMatrix and anArray.
ClassFactory & GiveClassFactory()
This function must be used by all code that run at link time to ensure that the classFactory is const...
double at(int i, int j) const
Coefficient access function.
This class implements the Generalized Jacobi Eigenvalue Problem Solver.
Class representing vector of real numbers.
Implementation of matrix containing floating point numbers.
SubspaceIteration(Domain *d, EngngModel *m)
void resize(int rows, int cols)
Checks size of receiver towards requested bounds.
virtual void printYourself() const
Print receiver on stdout.
virtual SparseMtrx * factorized()
Returns the receiver factorized.
void zero()
Zeroes all coefficients of receiver.
void setColumn(const FloatArray &src, int c)
Sets the values of the matrix in specified column.
void printYourself() const
Prints matrix to stdout. Useful for debugging.
virtual NM_Status solve(FloatMatrix &K, FloatMatrix &M, FloatArray &w, FloatMatrix &x)
Solves the given sparse generalized eigenvalue system of equations .
void zero()
Zeroes all coefficient of receiver.
int giveNumberOfColumns() const
Returns number of columns of receiver.
int min(int i, int j)
Returns smaller value from two given decimals.
Abstract base class representing the "problem" under consideration.
virtual void times(const FloatArray &x, FloatArray &answer) const
Evaluates .
the oofem namespace is to define a context or scope in which all oofem names are defined.
void beInverseOf(const FloatMatrix &src)
Modifies receiver to become inverse of given parameter.
This base class is an abstraction for all numerical methods solving sparse linear system of equations...
void symmetrized()
Initializes the lower half of the receiver according to the upper half.
EngngModel * engngModel
Pointer to engineering model.
#define OOFEM_WARNING(...)
void resize(int s)
Resizes receiver towards requested size.