36 #include <tests/myratest.h>    43 std::vector<int> random_rows(
int I, 
int N)
    45   std::vector<int> answer;
    46   for (
int n = 0; n < N; ++n)
    47     answer.push_back( random_int(0,I) );
    55   int J = Bv.
size().second;
    57   for (
int j = 0; j < J; ++j)
    58     for (
int i = 0; i < Bi.size(); ++i)
    59       B_builder(Bi[i],j) = Bv(i,j);
    60   return B_builder.make_SparseMatrix();
    64 template<
class Precision> 
void test(Precision tolerance)
    75   Precision shift = 5.5;
    76   for (
int n = 0; n < N; ++n)
    81   Options options = Options::create().set_blocksize(4).set_globsize(4).set_nthreads(4);
    94     Precision S_error = frobenius(S1.
make_Matrix(
'T')-S2)/frobenius(S2);
    95     myra::out() << 
"|B'*inv(A)*B [dense] - B'*inv(A)*B [sparse]| = " << S_error << std::endl;
    96     REQUIRE(S_error < tolerance);
   102     auto Bi = random_rows(N,10);
   104     auto B = fill(N,Bi,Bv);
   105     auto S1 = solver.schur(Bi,Bv,options);
   107     auto S2 = gemm(B.make_Matrix(),
'T',gemm(inverse(A.
make_Matrix()),B.make_Matrix()));       
   108     Precision S_error = frobenius(S1.
make_Matrix(
'T')-S2)/frobenius(S2);
   109     myra::out() << 
"|schur(B)-schur(BiBv)| = " << S_error << std::endl;
   110     REQUIRE(S_error < tolerance);
   116     auto Bi = ilinspace(0,N);
   118     Precision S1 = solver.schur(Bi,Bv,options)(0,0);
   123     Precision S2 = dot(Cv.vector(0),Bv.
vector(0));
   124     Precision S_error = std::abs(S1-S2)/std::abs(S2);
   125     myra::out() << 
"|schur(Bi,Bv)-dot(L\\Bv,L\\Bv))| = " << S_error << std::endl;
   126     REQUIRE(S_error < tolerance);
   137     Precision S_error = frobenius(S1-S2)/frobenius(S2);
   138     myra::out() << 
"|C'*inv(A)*D [dense] - C'*inv(A)*D [sparse]| = " << S_error << std::endl;
   139     REQUIRE(S_error < tolerance);
   145     auto Bi = random_rows(N,10);
   147     auto Ci = random_rows(N,10);
   149     auto S1 = solver.schur(Bi,Bv,Ci,Cv,options);
   151     auto B = fill(N,Bi,Bv);
   152     auto C = fill(N,Ci,Cv);
   153     auto S2 = gemm(B.make_Matrix(),
'T',gemm(inverse(A.
make_Matrix()),C.make_Matrix()));   
   154     Precision S_error = frobenius(S1-S2)/frobenius(S2);
   155     myra::out() << 
"|schur(B,C)-schur(BiBv,CiCv)| = " << S_error << std::endl;
   156     REQUIRE(S_error < tolerance);
   161     auto Bi = ilinspace(0,N);
   163     auto Ci = ilinspace(0,N);
   165     Precision S1 = solver.schur(Bi,Bv,Ci,Cv,options)(0,0);
   170     Precision S2 = dot(Bv.
vector(0),Cv.vector(0));
   171     Precision S_error = std::abs(S1-S2)/std::abs(S2);
   172     myra::out() << 
"|schur(Bi,Bv)-dot(L\\Bv,L\\Bv))| = " << S_error << std::endl;
   173     REQUIRE(S_error < tolerance);
   181 ADD_TEST(
"rldlt2_schur",
"[multifrontal][parallel]")
   183   test<double>(1.0e-8);
 Interface class for representing subranges of dense Matrix's. 
Options pack for routines in /multifrontal. 
Definition: Options.h:24
Represents a Permutation matrix, used to reorder rows/columns/etc of various numeric containers...
Definition: Permutation.h:34
Tabulates an IxJ matrix. Allows random access, has column major layout to be compatible with BLAS/LAP...
Definition: bdsqr.h:20
Matrix< Number > make_Matrix(char op='N') const
Accumulates *this onto the lower triangle of a Matrix<Number> 
Definition: LowerMatrix.cpp:152
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
Sparse direct solver suitable for real symmetric indefinite systems. 
Definition: SparseRLDLTSolver.h:61
static SparseMatrix< Number > random(int I, int J, int N)
Generates a random SparseMatrix with size IxJ and (approximately) N nonzeros. 
Definition: SparseMatrix.cpp:493
Reduces a std::vector to its unique entries, and sorts it. 
General purpose compressed-sparse-column (CSC) container. 
Range construct for a lower triangular matrix stored in rectangular packed format. 
void sortunique(std::vector< T > &v)
Reduces a std::vector to its unique entries, and sorts it. 
Definition: sortunique.h:20
Specialized container for a lower triangular matrix, O(N^2/2) storage. Used by symmetry exploiting ma...
Routines for inner products of Vector's / VectorRange's. 
Various utility functions/classes related to scalar Number types. 
Returns a vector of int's, over [min,max) 
General purpose dense matrix container, O(i*j) storage. 
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. 
Convenience type for building SparseMatrix's, uses coordinate/triplet format. 
Definition: SparseMatrix.h:32
std::pair< int, int > size() const
Size inspector. 
Definition: Matrix.cpp:116
Convenience type for building SparseMatrix's, uses coordinate/triplet format. Note that SparseMatrixB...
CVectorRange< Number > vector(int j) const
Returns the j'th column as a VectorRange. 
Definition: Matrix.cpp:154
Sparse direct solver suitable for real symmetric indefinite systems. 
Stores an IxJ matrix A in compressed sparse column format. 
Definition: bothcat.h:23
Helper routines for reordering/filling 2D structured grids. Used by many unit tests. 
Variety of routines all for dense Matrix*Matrix multiplies. Delegates to the BLAS. 
Range/Iterator types associated with SparseMatrix. 
Matrix< Number > make_Matrix() const
Accumulates *this onto a Matrix<Number>. 
Definition: SparseMatrix.cpp:581
Interface class for representing subranges of contiguous int's. 
|B'*inv(A)*B [dense] - B'*inv(A)*B [sparse]| = 2.47397e-14
|schur(B)-schur(BiBv)| = 2.71079e-14
|schur(Bi,Bv)-dot(L\Bv,L\Bv))| = 1.11263e-14
|C'*inv(A)*D [dense] - C'*inv(A)*D [sparse]| = 2.28618e-14
|schur(B,C)-schur(BiBv,CiCv)| = 2.06378e-14
|schur(Bi,Bv)-dot(L\Bv,L\Bv))| = 1.84857e-16