76 int nc =
min(2 * nroot, nroot + 8);
112 for (
int i = 1; i <= nn; i++ ) {
114 w.
at(i) = b.
at(i, i) / a.
at(i, i);
120 for (
int j = 2; j <= nc; j++ ) {
122 for (
int i = 1; i <= nn; i++ ) {
123 if ( fabs( w.
at(i) ) >= rt ) {
124 rt = fabs( w.
at(i) );
131 for (
int i = 1; i <= nn; i++ ) {
143# ifdef DETAILED_REPORT
144 OOFEM_LOG_INFO(
"SubspaceIteration :: solveYourselfAt: Degrees of freedom invoked by initial vectors :\n");
146 OOFEM_LOG_INFO(
"SubspaceIteration :: solveYourselfAt: initial vectors for iteration:\n");
155 for (
int nite = 0; ; ++nite ) {
156# ifdef DETAILED_REPORT
157 printf(
"SubspaceIteration :: solveYourselfAt: Iteration loop no. %d\n", nite);
162 for (
int j = 1; j <= nc; j++ ) {
165 solver->solve(a, f, tt);
167 for (
int i = j; i <= nc; i++ ) {
169 for (
int k = 1; k <= nn; k++ ) {
170 art += r.
at(k, i) * tt.
at(k);
180#ifdef DETAILED_REPORT
181 OOFEM_LOG_INFO(
"SubspaceIteration :: solveYourselfAt: Printing projection matrix ar\n");
185 for (
int j = 1; j <= nc; j++ ) {
189 for (
int i = j; i <= nc; i++ ) {
191 for (
int k = 1; k <= nn; k++ ) {
192 brt += r.
at(k, i) * temp.
at(k);
202#ifdef DETAILED_REPORT
203 OOFEM_LOG_INFO(
"SubspaceIteration :: solveYourselfAt: Printing projection matrix br\n");
210 mtd.
solve(ar, br, eigv, vec);
221 for (
int i = 1;i <= nc; i++ ) {
226 for (
int i = 1;i <= nc; i++ )
227 for (
int j = 1; j <= nc;j++ )
232 for (
int i = 0;i <
nitem; i++ ) {
237 x.beProductOf(arinv, z);
239 for (
int j = 1;j <= nc; j++ ) {
241 for (k = 1; k<= nc; k++) w.
at(j) += zz.at(k,j) * x.at(k,j);
244 z.beProductOf (br, x);
246 for (
int j = 1;j <= nc; j++ ) {
248 for (
int k = 1; k<= nc; k++ ) c += z.at(k,j) * x.at(k,j);
254 for (
int j = 1;j <= nc; j++ ) {
255 if (fabs((ww.at(j)-w.
at(j))/w.
at(j))< rtol) ac++;
263 for (
int j = 1;j <= nc;j++ ) {
264 for (
int k = 1; k<= nc; k++ ) tt.
at(k) = x.at(k,j);
266 for (
int ii = 1;ii < j; ii++ ) {
268 for (
int k = 1; k<= nc; k++ ) c += x.at(k,ii) * t.
at(k);
269 for (
int k = 1; k<= nc; k++ ) x.at(k,j) -= x.at(k,ii) * c;
271 for (
int k = 1; k<= nc; k++) tt.
at(k) = x.at(k,j);
274 for (
int k = 1; k<= nc; k++) c += x.at(k,j)*t.
at(k);
275 for (
int k = 1; k<= nc; k++) x.at(k,j) /= sqrt(c);
298 for (
int i = 1; i <= nc1; i++ ) {
299 if ( fabs( eigv.
at(i + 1) ) < fabs( eigv.
at(i) ) ) {
301 std::swap(eigv.
at(i), eigv.
at(i + 1));
302 for (
int k = 1; k <= nc; k++ ) {
303 std::swap(vec.
at(k, i), vec.
at(k, i + 1));
309# ifdef DETAILED_REPORT
310 OOFEM_LOG_INFO(
"SubspaceIteration :: solveYourselfAt: current eigen values of reduced problem \n");
312 OOFEM_LOG_INFO(
"SubspaceIteration :: solveYourselfAt: current eigen vectors of reduced problem \n");
318 for (
int i = 1; i <= nn; i++ ) {
319 for (
int j = 1; j <= nc; j++ ) {
320 tt.
at(j) = r.
at(i, j);
323 for (
int k = 1; k <= nc; k++ ) {
325 for (
int j = 1; j <= nc; j++ ) {
326 rt += tt.
at(j) * vec.
at(j, k);
336 for (
int i = 1; i <= nc; i++ ) {
337 double dif = ( eigv.
at(i) - d.
at(i) );
338 rtolv.
at(i) = fabs( dif / eigv.
at(i) );
341# ifdef DETAILED_REPORT
342 OOFEM_LOG_INFO(
"SubspaceIteration :: solveYourselfAt: Reached precision of eigenvalues:\n");
345 for (
int i = 1; i <= nroot; i++ ) {
346 if ( rtolv.
at(i) > rtol ) {
351 OOFEM_LOG_INFO(
"SubspaceIteration :: solveYourselfAt: Convergence reached for RTOL=%20.15f\n", rtol);
355 if ( nite >=
nitem ) {
356 OOFEM_WARNING(
"SubspaceIteration :: solveYourselfAt: Convergence not reached in %d iteration - using current values",
nitem);
368 for (
int j = 1; j <= nc; j++ ) {
380 for (
int i = 1; i <= nroot; i++ ) {
381 _eigv.
at(i) = eigv.
at(i);
382 for (
int j = 1; j <= nn; j++ ) {
383 _r.
at(j, i) = r.
at(j, i);
#define REGISTER_GeneralizedEigenValueSolver(class, type)
void beColumnOf(const FloatMatrix &mat, int col)
virtual void printYourself() const
void zero()
Zeroes all coefficients of receiver.
void beProductOf(const FloatMatrix &aMatrix, const FloatArray &anArray)
void resize(Index rows, Index cols)
void setColumn(const FloatArray &src, int c)
void zero()
Zeroes all coefficient of receiver.
bool beInverseOf(const FloatMatrix &src)
*Prints matrix to stdout Useful for debugging void printYourself() const
double at(std::size_t i, std::size_t j) const
ConvergedReason solve(FloatMatrix &K, FloatMatrix &M, FloatArray &w, FloatMatrix &x)
Domain * domain
Pointer to domain.
EngngModel * engngModel
Pointer to engineering model.
SparseGeneralEigenValueSystemNM(Domain *d, EngngModel *m)
Constructor.
virtual double & at(int i, int j)=0
Returns coefficient at position (i,j).
virtual SparseMtrx * factorized()
virtual FloatArray * backSubstitutionWith(FloatArray &y) const
int giveNumberOfColumns() const
Returns number of columns of receiver.
virtual void times(const FloatArray &x, FloatArray &answer) const
int nitem
Max number of iterations.
#define OOFEM_WARNING(...)
#define OOFEM_LOG_INFO(...)
FloatArrayF< N > min(const FloatArrayF< N > &a, const FloatArrayF< N > &b)
ClassFactory & GiveClassFactory()