MyraMath
lu2_constructors


Source: tests/multifrontal/lu/lu2_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>
20 
21 // Algorithms.
23 #include <myramath/sparse/gemv.h>
25 
26 // Solver under test.
28 
29 // Reporting.
30 #include <tests/myratest.h>
31 
32 using namespace myra;
33 
34 ADD_TEST("lu2_constructors","[multifrontal][parallel]")
35  {
36  typedef double Number;
37  typedef double Precision;
38  // Make laplacian matrix A.
39  int I = 64;
40  int J = 64;
41  int N = I*J;
42  Pattern P = stencil2(I,J);
43  auto A = SparseMatrix<Number>::random(P);
44  // Define solver options.
45  typedef SparseLUSolver<Number> Solver;
46  typedef ::multifrontal::Options Options;
47  Options options = Options::create().set_blocksize(16).set_globsize(4).set_nthreads(1);
48  // Three construction options ..
49  Permutation perm = bisect2(I,J);
50  Solver solver1(A,options); // .. factor A, using internal reorder()'ing
51  Solver solver2(A,perm,options); // .. factor A, using caller-provided ordering
52  Solver solver3(A,solver1.tree(),options); // .. factor A, reusing symbolic factorization
53  // Make random b and three solution vectors.
54  auto b = Vector<Precision>::random(N);
55  auto x1 = b;
56  auto x2 = b;
57  auto x3 = b;
58  // Solve system using each solver.
59  solver1.refine(x1.column());
60  solver2.refine(x2.column());
61  solver3.refine(x3.column());
62  // Check residuals.
63  Precision error1 = euclidean(A*x1-b);
64  Precision error2 = euclidean(A*x2-b);
65  Precision error3 = euclidean(A*x3-b);
66  myra::out() << "|A*x1-b| = " << error1 << std::endl;
67  myra::out() << "|A*x2-b| = " << error2 << std::endl;
68  myra::out() << "|A*x3-b| = " << error3 << std::endl;
69  }
70 
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.
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
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 symmetric-pattern nonsymmetric-value A.
Range/Iterator types associated with Pattern.
Container for either a column vector or row vector (depends upon the usage context) ...
Sparse direct solver suitable for symmetric-pattern nonsymmetric-valued A.
Definition: SparseLUSolver.h:57
Holds the nonzero pattern of a sparse matrix.
Definition: Pattern.h:55
Container class for a sparse nonzero pattern, used in reordering/symbolic analysis.
Aggregates a (perm, iperm, swaps) triple into a vocabulary type.
Helper routines for reordering/filling 2D structured grids. Used by many unit tests.
Range/Iterator types associated with SparseMatrix.


Results: [PASS]

|A*x1-b| = 3.00701e-12
|A*x2-b| = 3.22009e-12
|A*x3-b| = 3.00701e-12


Go back to Summary of /test programs.