27 #include <tests/myratest.h> 36 void test_Permutation1(
int N)
41 auto A = P.make_SparseMatrix<
double>();
50 double error = frobenius(PX-AX);
51 myra::out() <<
" |PX-AX| = " << error << std::endl;
52 REQUIRE(error < 1.0e-9);
59 double error = frobenius(PtX-AtX);
60 myra::out() <<
" |P'X-A'X| = " << error << std::endl;
61 REQUIRE(error < 1.0e-9);
68 double error = frobenius(XP-XA);
69 myra::out() <<
" |XP-XA| = " << error << std::endl;
70 REQUIRE(error < 1.0e-9);
77 double error = frobenius(XPt-XAt);
78 myra::out() <<
" |XP'-XA'| = " << error << std::endl;
79 REQUIRE(error < 1.0e-9);
85 void test_Permutation2(
int N)
91 auto A = P.make_SparseMatrix<
double>();
100 double error = frobenius(Px-Ax);
101 myra::out() <<
" |Px-Ax| = " << error << std::endl;
102 REQUIRE(error < 1.0e-9);
109 double error = frobenius(Ptx-Atx);
110 myra::out() <<
" |P'x-A'x| = " << error << std::endl;
111 REQUIRE(error < 1.0e-9);
117 void test_Permutation3(
int N)
124 auto A = P.make_SparseMatrix<
double>().make_Matrix();
125 auto B = Q.make_SparseMatrix<
double>().make_Matrix();
127 double error = frobenius( gemm(A,B) - I );
128 myra::out() <<
" |I - P*inverse(P)| = " << error << std::endl;
129 REQUIRE(error < 1.0e-9);
133 void test_Permutation4(
int N)
140 auto PQ = multiply(P,Q);
151 double error = euclidean(x-y);
152 myra::out() <<
" |P*(Q*x) - (P*Q)*x| = " << error << std::endl;
153 REQUIRE(error < 1.0e-9);
158 ADD_TEST(
"Permutation",
"[sparse]")
160 test_Permutation1(20);
161 test_Permutation2(20);
162 test_Permutation3(20);
163 test_Permutation4(20);
Routines for computing euclidean norm of a Vector/VectorRange, or normalizing a Vector/VectorRange to...
Tabulates an IxJ matrix. Allows random access, has column major layout to be compatible with BLAS/LAP...
Definition: bdsqr.h:20
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
General purpose compressed-sparse-column (CSC) container.
static Vector< Number > random(int N)
Generates a random Vector of specified size.
Definition: Vector.cpp:276
static Matrix< Number > identity(int IJ)
Generates an identity Matrix of specified size.
Definition: Matrix.cpp:349
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.
Aggregates a (perm, iperm, swaps) triple into a vocabulary type.
Returns frobenius norm of a SparseMatrix.
static Permutation random(int N)
Generates a random Matrix of specified size.
Definition: Permutation.cpp:188
Variety of routines all for dense Matrix*Matrix multiplies. Delegates to the BLAS.
Interface class for representing subranges of contiguous int's.