52 #define GJacobi_ZERO_CHECK_TOL 1.e-40 63 double eps, eptola, eptolb, akk, ajj, ab, check, sqch, d1, d2, den, ca, cg, ak, bk, xj, xk;
65 int jm1, kp1, km1, jp1;
83 for (
int i = 1; i <= n; i++ ) {
86 d.
at(i) = a.
at(i, i) / b.
at(i, i);
104 # ifdef DETAILED_REPORT 110 eps = pow(0.01, (
double ) nsweep);
112 for (
int j = 1; j <= nr; j++ ) {
114 for (
int k = jj; k <= n; k++ ) {
115 eptola = ( a.
at(j, k) * a.
at(j, k) ) / ( a.
at(j, j) * a.
at(k, k) );
116 eptolb = ( b.
at(j, k) * b.
at(j, k) ) / ( b.
at(j, j) * b.
at(k, k) );
117 if ( ( eptola < eps ) && ( eptolb < eps ) ) {
124 akk = a.
at(k, k) * b.
at(j, k) - b.
at(k, k) * a.
at(j, k);
125 ajj = a.
at(j, j) * b.
at(j, k) - b.
at(j, j) * a.
at(j, k);
126 ab = a.
at(j, j) * b.
at(k, k) - a.
at(k, k) * b.
at(j, j);
127 check = ( ab * ab + 4.0 * akk * ajj ) / 4.0;
130 }
else if ( check < 0.0 ) {
138 if ( fabs(d2) > fabs(d1) ) {
147 cg = -a.
at(j, k) / a.
at(k, k);
153 if ( ( n - 2 ) != 0 ) {
158 if ( ( jm1 - 1 ) >= 0 ) {
159 for (
int i = 1; i <= jm1; i++ ) {
164 a.
at(i, j) = aj + cg * ak;
165 b.
at(i, j) = bj + cg * bk;
166 a.
at(i, k) = ak + ca * aj;
167 b.
at(i, k) = bk + ca * bj;
171 if ( ( kp1 - n ) <= 0 ) {
172 for (
int i = kp1; i <= n; i++ ) {
177 a.
at(j, i) = aj + cg * ak;
178 b.
at(j, i) = bj + cg * bk;
179 a.
at(k, i) = ak + ca * aj;
180 b.
at(k, i) = bk + ca * bj;
184 if ( ( jp1 - km1 ) <= 0 ) {
185 for (
int i = jp1; i <= km1; i++ ) {
190 a.
at(j, i) = aj + cg * ak;
191 b.
at(j, i) = bj + cg * bk;
192 a.
at(i, k) = ak + ca * aj;
193 b.
at(i, k) = bk + ca * bj;
200 a.
at(k, k) = ak + 2.0 *ca *a.
at(j, k) + ca *ca *a.
at(j, j);
201 b.
at(k, k) = bk + 2.0 *ca *b.
at(j, k) + ca *ca *b.
at(j, j);
202 a.
at(j, j) = a.
at(j, j) + 2.0 *cg *a.
at(j, k) + cg * cg * ak;
203 b.
at(j, j) = b.
at(j, j) + 2.0 *cg *b.
at(j, k) + cg * cg * bk;
209 for (
int i = 1; i <= n; i++ ) {
212 x.
at(i, j) = xj + cg * xk;
213 x.
at(i, k) = xk + ca * xj;
221 #ifdef DETAILED_REPORT 226 for (
int i = 1; i <= n; i++ ) {
230 eigv.
at(i) = a.
at(i, i) / b.
at(i, i);
233 # ifdef DETAILED_REPORT 242 for (
int i = 1; i <= n; i++ ) {
243 double tol =
rtol * d.
at(i);
244 double dif = ( eigv.
at(i) - d.
at(i) );
245 if ( fabs(dif) > tol ) {
254 for (
int j = 1; j <= nr; j++ ) {
256 for (
int k = jj; k <= n; k++ ) {
257 double epsa = ( a.
at(j, k) * a.
at(j, k) ) / ( a.
at(j, j) * a.
at(k, k) );
258 double epsb = ( b.
at(j, k) * b.
at(j, k) ) / ( b.
at(j, j) * b.
at(k, k) );
259 if ( ( epsa < eps ) && ( epsb < eps ) ) {
277 }
while ( nsweep <
nsmax );
280 for (
int i = 1; i <= n; i++ ) {
281 for (
int j = 1; j <= n; j++ ) {
282 a.
at(j, i) = a.
at(i, j);
283 b.
at(j, i) = b.
at(i, j);
287 for (
int j = 1; j <= n; j++ ) {
288 double bb = sqrt( fabs( b.
at(j, j) ) );
289 for (
int k = 1; k <= n; k++ ) {
#define NM_Success
Numerical method exited with success.
#define GJacobi_ZERO_CHECK_TOL
double & at(int i)
Coefficient access function.
This base class is an abstraction for numerical algorithm.
bool isSquare() const
Returns nonzero if receiver is square matrix.
unsigned long NM_Status
Mask defining NumMetod Status; which can be asked after finishing computation by Numerical Method...
#define OOFEM_LOG_DEBUG(...)
GJacobi(Domain *d, EngngModel *m)
double at(int i, int j) const
Coefficient access function.
Class representing vector of real numbers.
Implementation of matrix containing floating point numbers.
void resize(int rows, int cols)
Checks size of receiver towards requested bounds.
virtual void printYourself() const
Print receiver on stdout.
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 beUnitMatrix()
Sets receiver to unity matrix.
Abstract base class representing the "problem" under consideration.
the oofem namespace is to define a context or scope in which all oofem names are defined.
int giveNumberOfRows() const
Returns number of rows of receiver.
void resize(int s)
Resizes receiver towards requested size.