Peano
Loading...
Searching...
No Matches
LUDecompositionTest.cpp
Go to the documentation of this file.
1// This file is part of the Peano project. For conditions of distribution and
2// use, please see the copyright notice at www.peano-framework.org
5#include "tarch/la/Matrix.h"
6#include "tarch/la/Vector.h"
7
8
9
11 TestCase ("tarch::la::LUDecompositionTest") {
12}
13
14
16 testMethod (testLUNoPivoting);
17 testMethod (testLU);
18 testMethod (testInversion0 );
19 testMethod (testInversion1 );
20}
21
22
25
26
28 // Test is obviously buggy. The pivot values are doubles but the test uses
29 // them as integer in line 57.
31 4.0, 3.0,
32 6.0, 3.0
33 };
35 4.0, 3.0,
36 1.5, -1.5
37 };
38
40
41 validateEquals( A, LU );
42}
43
44
46 // checking if Lapack correctly configured. Invert
47 // a diagonal matrix.
48
50 1,0,0,0,0,
51 0,2,0,0,0,
52 0,0,3,0,0,
53 0,0,0,4,0,
54 0,0,0,0,5
55 };
56
57 Matrix<5,5,double> AInverted = {
58 1,0,0,0,0,
59 0,1./2,0,0,0,
60 0,0,1./3,0,0,
61 0,0,0,1./4,0,
62 0,0,0,0,1./5
63 };
64
65 validateEquals( invert(A), AInverted );
66}
67
68
70 // checking if Lapack correctly configured. Invert
71 // a diagonal matrix.
72
74 -1.0, 3.0/2.0,
75 1.0, -1.0
76 };
77
78 Matrix<2,2,double> AInverted = {
79 2, 3,
80 2, 2
81 };
82
83 validateEquals( invert(A), AInverted );
84}
#define testMethod(name)
Run a test method and check for errors.
Definition TestMacros.h:24
#define validateEquals(actualValue, validValue)
Definition TestMacros.h:299
Static (i.e.
Definition Matrix.h:42
virtual void run()
This routine is triggered by the TestCaseCollection.
Matrix< Rows, Rows, Scalar > invert(const Matrix< Rows, Rows, Scalar > &M)
Invert matrix with LU decomposition.
void lu(Matrix< Rows, Rows, Scalar > &A, Vector< Rows, int > &pivots)
Performs an in-situ LU-decomposition of the square matrix A.