MyraMath
rcholesky2_constructors


Source: tests/multifrontal/rcholesky/rcholesky2_constructors.cpp

1 // ========================================================================= //
2 // This file is part of MyraMath, copyright (c) 2014-2019 by Ryan A Chilton //
3 // and distributed by MyraCore, LLC. See LICENSE.txt for license terms. //
4 // ========================================================================= //
5 
11 // Containers.
13 #include <myramath/dense/Vector.h>
18 
19 // Algorithms.
21 #include <myramath/sparse/gemv.h>
23 
24 // Solver under test.
26 
27 // Reporting.
28 #include <tests/myratest.h>
29 
30 using namespace myra;
31 
32 ADD_TEST("rcholesky2_constructors","[multifrontal][parallel]")
33  {
34  typedef double Precision;
35  // Make laplacian matrix A.
36  int I = 64;
37  int J = 64;
38  int N = I*J;
39  SparseMatrix<Precision> A = laplacian2<Precision>(I,J);
40  // Define solver options.
41  typedef SparseRCholeskySolver<Precision> Solver;
42  typedef ::multifrontal::Options Options;
43  Options options = Options::create().set_blocksize(16).set_globsize(4).set_nthreads(1);
44  // Three construction options ..
45  Permutation perm = bisect2(I,J);
46  Solver solver1(A,options); // .. factor A, using internal reorder()'ing
47  Solver solver2(A,perm,options); // .. factor A, using caller-provided ordering
48  Solver solver3(A,solver1.tree(),options); // .. factor A, reusing symbolic factorization
49  // Make random b and three solution vectors.
50  auto b = Vector<Precision>::random(N);
51  auto x1 = b;
52  auto x2 = b;
53  auto x3 = b;
54  // Solve system using each solver.
55  solver1.solve(x1.column());
56  solver2.solve(x2.column());
57  solver3.solve(x3.column());
58  // Check residuals.
59  Precision error1 = euclidean(A*x1-b);
60  Precision error2 = euclidean(A*x2-b);
61  Precision error3 = euclidean(A*x3-b);
62  myra::out() << "|A*x1-b| = " << error1 << std::endl;
63  myra::out() << "|A*x2-b| = " << error2 << std::endl;
64  myra::out() << "|A*x3-b| = " << error3 << std::endl;
65  }
66 
Routines for computing euclidean norm of a Vector/VectorRange, or normalizing a Vector/VectorRange to...
Represents a Permutation matrix, used to reorder rows/columns/etc of various numeric containers...
Definition: Permutation.h:34
Interface class for representing subranges of dense Vector&#39;s.
General purpose compressed-sparse-column (CSC) container.
static Vector< Number > random(int N)
Generates a random Vector of specified size.
Definition: Vector.cpp:276
Definition: syntax.dox:1
Various utility functions/classes related to scalar Number types.
Signatures for sparse matrix * dense vector multiplies. All delegate to gemm() under the hood...
Sparse direct solver suitable for real symmetric positive definite systems.
Container for either a column vector or row vector (depends upon the usage context) ...
Aggregates a (perm, iperm, swaps) triple into a vocabulary type.
Sparse direct solver suitable for real symmetric positive definite systems.
Definition: SparseRCholeskySolver.h:61
void solve(const Range &B, char side='L', char op='N') const
Solves op(A)*X=B or X*op(A)=B, overwrites B with X.
Definition: RLDLTSolver.cpp:53
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.
Range/Iterator types associated with SparseMatrix.


Results: [PASS]

|A*x1-b| = 1.02357e-14
|A*x2-b| = 1.01954e-14
|A*x3-b| = 1.02611e-14


Go back to Summary of /test programs.