66 int nc =
min(2 * nroot, nroot + 8);
70 std :: vector< FloatArray > z(nc, nn), zz(nc, nn), x(nc, nn);
75 for (
int j = 0; j < nc; j++ ) {
81 for (
int i = 1; i <= nn; i++ ) {
82 ad.at(i) = fabs(a.
at(i, i));
83 bd.
at(i) = fabs(b.
at(i, i));
87 std :: sort(order.begin(), order.end(), [&ad, &bd](
int a,
int b) {
return bd.
at(a) * ad.at(b) > bd.
at(b) * ad.at(a); });
88 for (
int i = 0; i < nc; i++ ) {
89 x[i].at(order[i]) = 1.0;
91 ww.at(i + 1) = z[i].dotProduct(x[i]);
97 for ( it = 0; it <
nitem; it++ ) {
99 for (
int j = 0; j < nc; j++ ) {
104 for (
int j = 0; j < nc; j++ ) {
105 solver->
solve(a, z[j], x[j]);
109 for (
int j = 0; j < nc; j++ ) {
110 w.at(j + 1) = zz[j].dotProduct(x[j]);
113 for (
int j = 0; j < nc; j++ ) {
117 for (
int j = 0; j < nc; j++ ) {
118 w.at(j + 1) /= z[j].dotProduct(x[j]);
123 for (
int j = 1; j <= nc; j++ ) {
124 if ( fabs( ww.at(j) - w.at(j) ) <= fabs( w.at(j) * rtol ) ) {
135 for (
int j = 0; j < nc; j++ ) {
140 for (
int ii = 0; ii < j; ii++ ) {
141 x[j].add( -x[ii].dotProduct(t), x[ii] );
145 x[j].times( 1.0 / sqrt( x[j].dotProduct(t) ) );
153 for (
int j = 0; j < nc; j++ ) {
165 for (
int i = 1; i <= nroot; i++ ) {
166 _eigv.
at(i) = w.at(order.
at(i));
171 OOFEM_LOG_INFO(
"InverseIt info: convergence reached in %d iterations\n", it);
173 OOFEM_WARNING(
"convergence not reached after %d iterations\n", it);
void enumerate(int maxVal)
Resizes receiver and enumerates from 1 to the maximum value given.
virtual NM_Status solve(SparseMtrx &A, FloatArray &b, FloatArray &x)=0
Solves the given sparse linear system of equations .
#define NM_Success
Numerical method exited with success.
InverseIteration(Domain *d, EngngModel *m)
Base class for all matrices stored in sparse format.
double & at(int i)
Coefficient access function.
This base class is an abstraction for all numerical methods solving sparse linear system of equations...
std::vector< int >::iterator end()
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...
Class implementing an array of integers.
int & at(int i)
Coefficient access function.
void sort(IntArray &arry, operation op)
Sorts the receiver using quicksort algorithm.
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 .
REGISTER_GeneralizedEigenValueSolver(InverseIteration, GES_InverseIt)
Domain * domain
Pointer to domain.
#define OOFEM_LOG_INFO(...)
ClassFactory & GiveClassFactory()
This function must be used by all code that run at link time to ensure that the classFactory is const...
Class representing vector of real numbers.
SparseLinearSystemNM * createSparseLinSolver(LinSystSolverType st, Domain *d, EngngModel *m)
Creates new instance of SparseLinearSystemNM corresponding to given type.
Implementation of matrix containing floating point numbers.
void resize(int rows, int cols)
Checks size of receiver towards requested bounds.
void setColumn(const FloatArray &src, int c)
Sets the values of the matrix in specified column.
int giveNumberOfColumns() const
Returns number of columns of receiver.
std::vector< int >::iterator begin()
int min(int i, int j)
Returns smaller value from two given decimals.
virtual ~InverseIteration()
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.
This base class is an abstraction for all numerical methods solving sparse linear system of equations...
EngngModel * engngModel
Pointer to engineering model.
#define OOFEM_WARNING(...)
void resize(int s)
Resizes receiver towards requested size.