MyraMath
rldlt2_saddle2


Source: tests/multifrontal/rldlt/rldlt2_saddle2.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>
21 
22 // Algorithms.
24 #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 namespace detail {
35 
36 template<class Precision>
37 void test_saddle2(int N, Precision tolerance)
38  {
39  // Generate a system with saddle point structure, a block diagonal
40  // system with [1 0; 0 1] blocks.
41  PatternBuilder P(2*N,2*N);
42  for (int n = 0; n < N; ++n)
43  {
44  P.insert(2*n+1,2*n);
45  P.insert(2*n,2*n+1);
46  }
47  auto A = SparseMatrix<Precision>::fill(P.make_Pattern(),1);
48  auto perm = Permutation::random(2*N);
49  myra::out() << "A.pattern() = " << A.pattern() << std::endl;
50 
51  typedef multifrontal::Options Options;
52  Options options = Options::create().set_blocksize(1).set_globsize(1).set_nthreads(1);
53  SparseRLDLTSolver<Precision> solver(A,perm,options);
54 
55  // Check A*x = b solution.
56  auto b = Vector<Precision>::random(2*N);
57  auto x = b;
58  solver.solve(x.column());
59  Precision error = euclidean( gemv(A,x) - b );
60  myra::out() << "|A*x-b| = " << error << std::endl;
61  REQUIRE( error < tolerance );
62  }
63 
64 } // namespace detail
65 
66 ADD_TEST("rldlt2_saddle2","[multifrontal]")
67  {
68  ::detail::test_saddle2<float >(20,1.0e-4f);
69  ::detail::test_saddle2<double>(20,1.0e-10);
70  }
Routines for computing euclidean norm of a Vector/VectorRange, or normalizing a Vector/VectorRange to...
Options pack for routines in /multifrontal.
Definition: Options.h:24
Interface class for representing subranges of dense Vector&#39;s.
static SparseMatrix< Number > fill(const PatternRange &P, Number c)
Generates a SparseMatrix with Pattern P, filled with constant c.
Definition: SparseMatrix.cpp:521
Convenience type for building Pattern&#39;s, uses coordinate/couplet format. Note that PatternBuilder may...
Sparse direct solver suitable for real symmetric indefinite systems.
Definition: SparseRLDLTSolver.h:61
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: random.cpp:45
Various utility functions/classes related to scalar Number types.
Signatures for sparse matrix * dense vector multiplies. All delegate to gemm() under the hood...
PatternRange pattern() const
Returns the nonzero Pattern over all of A(:,:)
Definition: SparseMatrix.cpp:221
Range/Iterator types associated with Pattern.
Container for either a column vector or row vector (depends upon the usage context) ...
Like Pattern, but easier to populate via insert()/erase() methods.
Definition: PatternBuilder.h:51
Container class for a sparse nonzero pattern, used in reordering/symbolic analysis.
Aggregates a (perm, iperm, swaps) triple into a vocabulary type.
static Permutation random(int N)
Generates a random Matrix of specified size.
Definition: Permutation.cpp:188
Sparse direct solver suitable for real symmetric indefinite systems.
Range/Iterator types associated with SparseMatrix.


Results: [PASS]

A.pattern() = size 40 by 40 Pattern:
[ - x - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ]
[ x - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ]
[ - - - x - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ]
[ - - x - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ]
[ - - - - - x - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ]
[ - - - - x - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ]
[ - - - - - - - x - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ]
[ - - - - - - x - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ]
[ - - - - - - - - - x - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ]
[ - - - - - - - - x - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ]
[ - - - - - - - - - - - x - - - - - - - - - - - - - - - - - - - - - - - - - - - - ]
[ - - - - - - - - - - x - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ]
[ - - - - - - - - - - - - - x - - - - - - - - - - - - - - - - - - - - - - - - - - ]
[ - - - - - - - - - - - - x - - - - - - - - - - - - - - - - - - - - - - - - - - - ]
[ - - - - - - - - - - - - - - - x - - - - - - - - - - - - - - - - - - - - - - - - ]
[ - - - - - - - - - - - - - - x - - - - - - - - - - - - - - - - - - - - - - - - - ]
[ - - - - - - - - - - - - - - - - - x - - - - - - - - - - - - - - - - - - - - - - ]
[ - - - - - - - - - - - - - - - - x - - - - - - - - - - - - - - - - - - - - - - - ]
[ - - - - - - - - - - - - - - - - - - - x - - - - - - - - - - - - - - - - - - - - ]
[ - - - - - - - - - - - - - - - - - - x - - - - - - - - - - - - - - - - - - - - - ]
[ - - - - - - - - - - - - - - - - - - - - - x - - - - - - - - - - - - - - - - - - ]
[ - - - - - - - - - - - - - - - - - - - - x - - - - - - - - - - - - - - - - - - - ]
[ - - - - - - - - - - - - - - - - - - - - - - - x - - - - - - - - - - - - - - - - ]
[ - - - - - - - - - - - - - - - - - - - - - - x - - - - - - - - - - - - - - - - - ]
[ - - - - - - - - - - - - - - - - - - - - - - - - - x - - - - - - - - - - - - - - ]
[ - - - - - - - - - - - - - - - - - - - - - - - - x - - - - - - - - - - - - - - - ]
[ - - - - - - - - - - - - - - - - - - - - - - - - - - - x - - - - - - - - - - - - ]
[ - - - - - - - - - - - - - - - - - - - - - - - - - - x - - - - - - - - - - - - - ]
[ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - x - - - - - - - - - - ]
[ - - - - - - - - - - - - - - - - - - - - - - - - - - - - x - - - - - - - - - - - ]
[ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - x - - - - - - - - ]
[ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - x - - - - - - - - - ]
[ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - x - - - - - - ]
[ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - x - - - - - - - ]
[ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - x - - - - ]
[ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - x - - - - - ]
[ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - x - - ]
[ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - x - - - ]
[ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - x ]
[ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - x - ]
|A*x-b| = 1.88486e-07
A.pattern() = size 40 by 40 Pattern:
[ - x - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ]
[ x - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ]
[ - - - x - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ]
[ - - x - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ]
[ - - - - - x - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ]
[ - - - - x - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ]
[ - - - - - - - x - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ]
[ - - - - - - x - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ]
[ - - - - - - - - - x - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ]
[ - - - - - - - - x - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ]
[ - - - - - - - - - - - x - - - - - - - - - - - - - - - - - - - - - - - - - - - - ]
[ - - - - - - - - - - x - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ]
[ - - - - - - - - - - - - - x - - - - - - - - - - - - - - - - - - - - - - - - - - ]
[ - - - - - - - - - - - - x - - - - - - - - - - - - - - - - - - - - - - - - - - - ]
[ - - - - - - - - - - - - - - - x - - - - - - - - - - - - - - - - - - - - - - - - ]
[ - - - - - - - - - - - - - - x - - - - - - - - - - - - - - - - - - - - - - - - - ]
[ - - - - - - - - - - - - - - - - - x - - - - - - - - - - - - - - - - - - - - - - ]
[ - - - - - - - - - - - - - - - - x - - - - - - - - - - - - - - - - - - - - - - - ]
[ - - - - - - - - - - - - - - - - - - - x - - - - - - - - - - - - - - - - - - - - ]
[ - - - - - - - - - - - - - - - - - - x - - - - - - - - - - - - - - - - - - - - - ]
[ - - - - - - - - - - - - - - - - - - - - - x - - - - - - - - - - - - - - - - - - ]
[ - - - - - - - - - - - - - - - - - - - - x - - - - - - - - - - - - - - - - - - - ]
[ - - - - - - - - - - - - - - - - - - - - - - - x - - - - - - - - - - - - - - - - ]
[ - - - - - - - - - - - - - - - - - - - - - - x - - - - - - - - - - - - - - - - - ]
[ - - - - - - - - - - - - - - - - - - - - - - - - - x - - - - - - - - - - - - - - ]
[ - - - - - - - - - - - - - - - - - - - - - - - - x - - - - - - - - - - - - - - - ]
[ - - - - - - - - - - - - - - - - - - - - - - - - - - - x - - - - - - - - - - - - ]
[ - - - - - - - - - - - - - - - - - - - - - - - - - - x - - - - - - - - - - - - - ]
[ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - x - - - - - - - - - - ]
[ - - - - - - - - - - - - - - - - - - - - - - - - - - - - x - - - - - - - - - - - ]
[ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - x - - - - - - - - ]
[ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - x - - - - - - - - - ]
[ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - x - - - - - - ]
[ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - x - - - - - - - ]
[ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - x - - - - ]
[ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - x - - - - - ]
[ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - x - - ]
[ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - x - - - ]
[ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - x ]
[ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - x - ]
|A*x-b| = 5.16284e-16


Go back to Summary of /test programs.