34 #include <tests/myratest.h>    41 template<
class Precision> 
void test_real(
int X, 
int Y, Precision tolerance)
    43   myra::out() << typestring<Precision>() << std::endl;
    46   auto A = laplacian2<Precision>(X,Y);
    52     auto m = make_IdentityAction<Precision>(N);
    53     auto a = make_GemmAction(A);
    55     auto result = pcg(m,a,b,x,tolerance);
    56     Precision error = euclidean(A*x-b) / euclidean(b);
    57     myra::out() << 
"  No preconditioner:" << std::endl;    
    58     myra::out() << 
"  |Ax-b| = " << error << std::endl;
    59     myra::out() << 
"  iteration count = " << result.history.size() << std::endl;
    61     REQUIRE(error < tolerance);
    67     auto a = make_GemmAction(A);
    69     auto result = pcg(m,a,b,x,tolerance);
    70     Precision error = euclidean(A*x-b) / euclidean(b);
    71     myra::out() << 
"  IC preconditioner:" << std::endl;
    72     myra::out() << 
"  |Ax-b| = " << error << std::endl;
    73     myra::out() << 
"  iteration count = " << result.history.size() << std::endl;    
    75     REQUIRE(error < tolerance);
    80 template<
class Precision> 
void test_complex(
int X, 
int Y, Precision tolerance)
    82   typedef std::complex<Precision> Number;
    83   myra::out() << typestring<Number>() << std::endl;
    86   auto A = laplacian2<Number>(X,Y);
    93     auto m = make_IdentityAction<Number>(N);
    94     auto a = make_GemmAction(A);
    96     auto result = pcg(m,a,b,x,tolerance);
    97     Precision error = euclidean(A*x-b) / euclidean(b);
    98     myra::out() << 
"  No preconditioner:" << std::endl;    
    99     myra::out() << 
"  |Ax-b| = " << error << std::endl;
   100     myra::out() << 
"  iteration count = " << result.history.size() << std::endl;
   102     REQUIRE(error < tolerance);
   108     auto a = make_GemmAction(A);
   110     auto result = pcg(m,a,b,x,tolerance);
   111     Precision error = euclidean(A*x-b) / euclidean(b);
   112     myra::out() << 
"  No preconditioner:" << std::endl;    
   113     myra::out() << 
"  |Ax-b| = " << error << std::endl;
   114     myra::out() << 
"  iteration count = " << result.history.size() << std::endl;
   116     REQUIRE(error < tolerance);
   122 ADD_TEST(
"pcg",
"[iterative]")
   124   test_real<NumberS>(20,20,1.0e-4f);  
   125   test_real<NumberD>(20,20,1.0e-8);
   126   test_complex<NumberS>(20,20,1.0e-4f);
   127   test_complex<NumberD>(20,20,1.0e-8);
 Routines for computing euclidean norm of a Vector/VectorRange, or normalizing a Vector/VectorRange to...
Interface class for representing subranges of dense Vector's. 
Applies the "Action" of a linear operator, b := A*x, used in iterative solution algorithms. 
General purpose compressed-sparse-column (CSC) container. 
static Vector< Number > random(int N)
Generates a random Vector of specified size. 
Definition: Vector.cpp:276
An Action that is just the identity operator. 
Definition: stlprint.h:32
Action< typename ReflectNumber< Solver >::type > make_SolveAction(const Solver &solver, char op='N')
Free function for making SolveAction's. 
Definition: SolveAction.h:67
Routines for printing the contents of various std::container's to a std::ostream using operator <<...
Various utility functions/classes related to scalar Number types. 
Signatures for sparse matrix * dense vector multiplies. All delegate to gemm() under the hood...
static Vector< Number > zeros(int N)
Generates a zeros Vector of specified size. 
Definition: Vector.cpp:280
Linear system solution via conjugate gradients (symmetric positive definite action A) ...
Container for either a column vector or row vector (depends upon the usage context) ...
Adapts a class with a .solve() method into an Action. 
An Action for multiplying by a dense Matrix or SparseMatrix using gemm(). 
Incompletely factors A ~= L*L', presents approximate solve() method. 
Definition: ICholeskySolver.h:28
Helper routines for reordering/filling 2D structured grids. Used by many unit tests. 
Applies random phase shifts to a complex square SparseMatrix. 
Incomplete Cholesky preconditioner. Presents a solve() function, but it's only approximate. 
Range/Iterator types associated with SparseMatrix.