45 #include <tests/myratest.h> 53 template<
class Precision>
void test(
int N,
int K, Precision tolerance)
55 myra::out() << typestring<Precision>() << std::endl;
64 auto action1 = make_SymmAction(A) + make_GemmAction(P)*make_GemmAction(P,
'T');
65 auto action2 = make_TrsmAction(L) * action1 * make_TrsmAction(L,
'T');
67 auto XD = syev(action2.make_Matrix());
68 myra::out() <<
"lambda = " << XD.second << std::endl;
74 auto eye = make_IdentityAction<Precision>(N);
75 trsm_inplace(
'L',
'N',L,b2.column());
77 auto result = gmres(eye,action2,b2,x,tolerance);
78 trsm_inplace(
'L',
'T',L,x.
column());
80 Precision residual = euclidean(action1*x-b) / euclidean(b);
81 myra::out() <<
"residual = " << residual << std::endl;
82 REQUIRE(residual < tolerance*10.0);
84 myra::out() <<
"history = " << result.history << std::endl;
85 REQUIRE(result.history.size() <= K+5);
90 ADD_TEST(
"compose_action1",
"[iterative]")
94 test<NumberD>(100,10,1.0e-10);
Routines for computing euclidean norm of a Vector/VectorRange, or normalizing a Vector/VectorRange to...
Cholesky factorization routines for positive definite matrices.
Interface class for representing subranges of DiagonalMatrix's.
Computes all eigenpairs of real symmetric Matrix.
Interface class for representing subranges of dense Matrix's.
Interface class for representing subranges of dense Vector's.
Applies the "Action" of a linear operator, b := A*x, used in iterative solution algorithms.
static Matrix< Number > random(int I, int J)
Generates a random Matrix of specified size.
Definition: Matrix.cpp:353
An Action for solving by a triangular Matrix, LowerMatrix or SparseMatrix using trsm().
Linear system solution via gmres (for invertible action A)
Range construct for a lower triangular matrix stored in rectangular packed format.
static Vector< Number > random(int N)
Generates a random Vector of specified size.
Definition: Vector.cpp:276
An Action for multiplying by a symmetric dense Matrix. LowerMatrix or SparseMatrix using symm() ...
An Action that is just the identity operator.
Definition: stlprint.h:32
Routines for backsolving by a triangular Matrix or LowerMatrix.
Specialized container for a lower triangular matrix, O(N^2/2) storage. Used by symmetry exploiting ma...
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.
Composes two Action's A and B, yielding an Action that applies (A+B)*X.
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) ...
Composes two Action's A and B, yielding an Action that cascades A*(B*X)
General purpose dense matrix container, O(i*j) storage.
Container for either a column vector or row vector (depends upon the usage context) ...
CMatrixRange< Number > column() const
Returns an Nx1 column-shaped MatrixRange over all of *this.
Definition: Vector.cpp:152
Adapts a class with a .solve() method into an Action.
An Action for multiplying by a dense Matrix or SparseMatrix using gemm().
Container for a diagonal matrix, O(n) storage. Used by SVD, row/column scaling, etc.
Routines for symmetric rank-k updates, a specialized form of Matrix*Matrix multiplication.
double
lambda = size 100 DiagonalMatrix of double: [ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4.10069 5.40528 6.64531 9.39695 13.5439 19.6899 28.7806 91.8219 208.946 2805.82 ]
residual = 6.51755e-14
history = [ 6.10651 0.774494 0.50434 0.418633 0.392986 0.325529 0.224299 0.12668 0.0437848 0.00566803 0.00120244 2.54744e-14 ] (12)