MyraMath
zldlt2_mixed


Source: tests/multifrontal/zldlt/zldlt2_mixed.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.
22 #include <myramath/sparse/phasor.h>
23 #include <myramath/sparse/gemm.h>
24 #include <myramath/sparse/gemv.h>
26 
27 // Solver under test.
29 
30 // Details for setting up refinement.
34 
35 // Reporting.
37 #include <tests/myratest.h>
38 
39 using namespace myra;
40 using namespace myra_stlprint;
41 
42 ADD_TEST("zldlt2_mixed","[multifrontal][parallel]")
43  {
44  // Define problem size.
45  int I = 64;
46  int J = 64;
47  int N = I*J;
48  // Make laplacian matrix A in double precision, shift to make it indefinite.
49  SparseMatrix<NumberZ> A = laplacian2<NumberZ>(I,J);
50  for (int n = 0; n < N; ++n)
51  A(n,n) -= 5.5;
52  phasor_symmetric(A);
53  // Factor A = L*D*L' in float precision.
54  SparseZLDLTSolver<float> solver(lower_precision(A));
55  // Make random b and x.
56  auto b = Vector<NumberZ>::random(N);
57  auto x = Vector<NumberZ>::zeros(N);
58  x = b;
59  // Solve A*x = b with mixed_refine(), using the single precision solver as a preconditioner.
60  auto history = mixed_refine( make_GemmAction(A), make_SolveAction(solver), x, 1.0e-12, 20);
61  double error = frobenius(A*x-b);
62  myra::out() << " error = " << error << std::endl;
63  myra::out() << " history = " << history << std::endl;
64  REQUIRE(error < 1.0e-10);
65  }
66 
Sparse direct solver suitable for complex symmetric systems.
Definition: SparseZLDLTSolver.h:61
Interface class for representing subranges of dense Vector&#39;s.
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.
Sparse direct solver suitable for complex symmetric systems.
Routines for copying and lowering the precision of a SparseMatrix.
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
Definition: stlprint.h:32
Action< typename ReflectNumber< Solver >::type > make_SolveAction(const Solver &solver, char op='N')
Free function for making SolveAction&#39;s.
Definition: SolveAction.h:67
Routines for printing the contents of various std::container&#39;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...
Like refine(), but uses a low-precision M to solve/refine a high-precision A.
static Vector< Number > zeros(int N)
Generates a zeros Vector of specified size.
Definition: Vector.cpp:280
Container for either a column vector or row vector (depends upon the usage context) ...
Aggregates a (perm, iperm, swaps) triple into a vocabulary type.
Adapts a class with a .solve() method into an Action.
An Action for multiplying by a dense Matrix or SparseMatrix using gemm().
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.
Applies random phase shifts to a complex square SparseMatrix.
Range/Iterator types associated with SparseMatrix.


Results: [PASS]

error = 1.08688e-12
history = [ 0.00593523 2.506e-05 9.60908e-08 5.32913e-10 5.11736e-12 2.09337e-14 ] (6)


Go back to Summary of /test programs.