29 #include <tests/myratest.h> 36 template<
class Precision>
class seidel_Action
41 typedef Precision Number;
45 : At(in_At), tol(in_tol), iter(in_iter) { }
48 std::pair<int,int> size()
const 55 for (
int j = 0; j < B.
J; ++j)
69 template<
class Precision>
class sseidel_Action
74 typedef Precision Number;
78 : At(in_At), tol(in_tol), iter(in_iter) { }
81 std::pair<int,int> size()
const 88 for (
int j = 0; j < B.
J; ++j)
102 template<
class Precision>
void test1(
int I,
int J, Precision tol)
104 auto A = laplacian2<Precision>(I,J);
108 Precision seidel_assymetry = frobenius(S0-transpose(S0));
109 myra::out() <<
"| seidel - seidel'| = " << seidel_assymetry << std::endl;
113 Precision sseidel_assymetry = frobenius(SS0-transpose(SS0));
114 myra::out() <<
"|sseidel - sseidel'| = " << sseidel_assymetry << std::endl;
115 REQUIRE( sseidel_assymetry < tol );
119 template<
class Precision>
class sor_Action
124 typedef Precision Number;
128 : At(in_At), omega(in_omega), tol(in_tol), iter(in_iter) { }
131 std::pair<int,int> size()
const 132 {
return At.size(); }
138 for (
int j = 0; j < B.
J; ++j)
153 template<
class Precision>
class ssor_Action
158 typedef Precision Number;
162 : At(in_At), omega(in_omega), tol(in_tol), iter(in_iter) { }
165 std::pair<int,int> size()
const 166 {
return At.size(); }
172 for (
int j = 0; j < B.
J; ++j)
187 template<
class Precision>
void test2(
int I,
int J, Precision tol)
189 auto A = laplacian2<Precision>(I,J);
190 Precision omega(1.5);
194 Precision sor_assymetry = frobenius(S0-transpose(S0));
195 myra::out() <<
"| sor - sor'| = " << sor_assymetry << std::endl;
199 Precision ssor_assymetry = frobenius(SS0-transpose(SS0));
200 myra::out() <<
"|ssor - ssor'| = " << ssor_assymetry << std::endl;
201 REQUIRE( ssor_assymetry < tol );
207 ADD_TEST(
"sseidel_symmetry",
"[iterative]")
209 test1<float>(20,20,1.0e-5f);
210 test1<double>(20,20,1.0e-12);
213 ADD_TEST(
"ssor_symmetry",
"[iterative]")
215 test2<float>(20,20,1.0e-5f);
216 test2<double>(20,20,1.0e-12);
Action< typename UserClass::Number > make_UserAction(const UserClass &u)
Helper function to adapt some user code (encapsulated in a class) into an Action. ...
Definition: UserAction.h:61
Interface class for representing subranges of dense Matrix's.
Implementations of classical stationary iterations: jacobi(), seidel(), sor() and ssor() ...
Interface class for representing subranges of dense Vector's.
Applies the "Action" of a linear operator, b := A*x, used in iterative solution algorithms.
Routines for computing Frobenius norms of various algebraic containers.
General purpose compressed-sparse-column (CSC) container.
CVectorRange< Number > vector(int j) const
Returns the j'th column as a CVectorRange.
Definition: MatrixRange.cpp:608
Represents a const MatrixRange.
Definition: bothcat.h:22
Adapts user code (encapsulated in a class) into an Action.
Returns a transposed copy of a Matrix. The inplace version only works on a square operand...
Various utility functions/classes related to scalar Number types.
VectorRange< Number > vector(int j) const
Returns the j'th column as a VectorRange.
Definition: MatrixRange.cpp:247
int J
---------— Data members, all public ----------------—
Definition: MatrixRange.h:241
Represents a mutable MatrixRange.
Definition: conjugate.h:26
General purpose dense matrix container, O(i*j) storage.
Represents a const SparseMatrixRange.
Definition: bothcat.h:24
Applies the "Action" of a linear operator, b := A*x.
Definition: Action.h:29
Container for either a column vector or row vector (depends upon the usage context) ...
Matrix< Number > make_Matrix() const
Tabulates *this into a dense Matrix.
Definition: Action.cpp:71
void zero() const
Assigns zero to every entry.
Definition: MatrixRange.cpp:362
Helper routines for reordering/filling 2D structured grids. Used by many unit tests.
Range/Iterator types associated with SparseMatrix.