40 #include <tests/myratest.h> 47 template<
class Precision>
void test1(
int N, Precision tolerance)
49 myra::out() << typestring<Precision>() << std::endl;
53 auto A = Y*D*inverse(Y);
56 Precision lambda = power(make_GemmAction(A),x,tolerance,200);
59 Precision r_error = euclidean(r);
60 myra::out() <<
" |A*x-x*lambda| = " << r_error << std::endl;
61 REQUIRE(r_error < tolerance);
64 template<
class Precision>
void test2(
int N,
int K, Precision tolerance)
66 myra::out() << typestring<Precision>() << std::endl;
70 auto A = Y*D*inverse(Y);
73 auto Lambda = power(make_GemmAction(A),X,tolerance,200);
76 Precision R_error = frobenius(R);
77 myra::out() <<
" |A*X-X*Lambda| = " << R_error << std::endl;
78 REQUIRE(R_error < tolerance*10);
83 ADD_TEST(
"power1",
"[iterative]")
85 test1<float> (20,1.0e-3f);
86 test1<double>(20,1.0e-5);
89 ADD_TEST(
"power2",
"[iterative]")
91 test2<float> (20,5,1.0e-4f);
92 test2<double>(20,5,1.0e-8);
Applies the power method to extract dominant eigenpair.
Routines for computing euclidean norm of a Vector/VectorRange, or normalizing a Vector/VectorRange to...
Interface class for representing subranges of DiagonalMatrix's.
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.
Variety of routines for mixed dense*sparse or dense*sparse matrix multiplies. The dense*dense case is...
Routines for computing Frobenius norms of various algebraic containers.
static Matrix< Number > random(int I, int J)
Generates a random Matrix of specified size.
Definition: Matrix.cpp:353
Routines for multiplying by a DiagonalMatrix.
static DiagonalMatrix< Number > logspace(Precision x0, Precision x1, int N)
Generates a Vector filled with N Number's logarithmically spaced between (10^x0,10^x1).
General purpose compressed-sparse-column (CSC) container.
Variety of routines all for dense Matrix*Vector multiplies. All just delegate to gemm() ...
static Vector< Number > random(int N)
Generates a random Vector of specified size.
Definition: Vector.cpp:276
Definition: stlprint.h:32
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...
General purpose dense matrix container, O(i*j) storage.
Tabulates a vector of length N, allows random access.
Definition: conjugate.h:21
Container for either a column vector or row vector (depends upon the usage context) ...
Overwrites a LowerMatrix, DiagonalMatrix, or square Matrix with its own inverse. Or, returns it as a copy.
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.
Variety of routines all for dense Matrix*Matrix multiplies. Delegates to the BLAS.
Range/Iterator types associated with SparseMatrix.
Helper routines for reordering/filling 1D structured grids. Used by many unit tests.