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
3
#include "
LUDecompositionTest.h
"
4
#include "
tarch/la/LUDecomposition.h
"
5
#include "
tarch/la/Matrix.h
"
6
#include "
tarch/la/Vector.h
"
7
8
9
10
tarch::la::tests::LUDecompositionTest::LUDecompositionTest
():
11
TestCase (
"tarch::la::LUDecompositionTest"
) {
12
}
13
14
15
void
tarch::la::tests::LUDecompositionTest::run
() {
16
testMethod
(testLUNoPivoting);
17
testMethod
(testLU);
18
testMethod
(testInversion0 );
19
testMethod
(testInversion1 );
20
}
21
22
23
void
tarch::la::tests::LUDecompositionTest::testLUNoPivoting
() {
24
}
25
26
27
void
tarch::la::tests::LUDecompositionTest::testLU
() {
28
// Test is obviously buggy. The pivot values are doubles but the test uses
29
// them as integer in line 57.
30
Matrix<2,2,double>
A = {
31
4.0, 3.0,
32
6.0, 3.0
33
};
34
Matrix<2,2,double>
LU = {
35
4.0, 3.0,
36
1.5, -1.5
37
};
38
39
tarch::la::lu
(A);
40
41
validateEquals
( A, LU );
42
}
43
44
45
void
tarch::la::tests::LUDecompositionTest::testInversion0
(){
46
// checking if Lapack correctly configured. Invert
47
// a diagonal matrix.
48
49
Matrix<5,5,double>
A = {
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
69
void
tarch::la::tests::LUDecompositionTest::testInversion1
(){
70
// checking if Lapack correctly configured. Invert
71
// a diagonal matrix.
72
73
Matrix<2,2,double>
A = {
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
}
LUDecompositionTest.h
LUDecomposition.h
Matrix.h
testMethod
#define testMethod(name)
Run a test method and check for errors.
Definition
TestMacros.h:24
validateEquals
#define validateEquals(actualValue, validValue)
Definition
TestMacros.h:299
Vector.h
tarch::la::Matrix
Static (i.e.
Definition
Matrix.h:42
tarch::la::tests::LUDecompositionTest::run
virtual void run()
This routine is triggered by the TestCaseCollection.
Definition
LUDecompositionTest.cpp:15
tarch::la::tests::LUDecompositionTest::testLUNoPivoting
void testLUNoPivoting()
Definition
LUDecompositionTest.cpp:23
tarch::la::tests::LUDecompositionTest::testLU
void testLU()
Definition
LUDecompositionTest.cpp:27
tarch::la::tests::LUDecompositionTest::testInversion1
void testInversion1()
Definition
LUDecompositionTest.cpp:69
tarch::la::tests::LUDecompositionTest::testInversion0
void testInversion0()
Definition
LUDecompositionTest.cpp:45
tarch::la::tests::LUDecompositionTest::LUDecompositionTest
LUDecompositionTest()
Constructor.
Definition
LUDecompositionTest.cpp:10
tarch::la::invert
Matrix< Rows, Rows, Scalar > invert(const Matrix< Rows, Rows, Scalar > &M)
Invert matrix with LU decomposition.
tarch::la::lu
void lu(Matrix< Rows, Rows, Scalar > &A, Vector< Rows, int > &pivots)
Performs an in-situ LU-decomposition of the square matrix A.
Definition
LUDecomposition.cpph:21
src
tarch
la
tests
LUDecompositionTest.cpp
Generated on Fri Apr 11 2025 10:18:06 for Peano by
1.10.0