Peano 4
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 (testInversion);
19}
20
21
24
25
27 // Test is obviously buggy. The pivot values are doubles but the test uses
28 // them as integer in line 57.
29/*
30 Matrix<4,4,double> A;
31 assignList(A) =
32 5.0, 2.0, 3.0, 1.0,
33 6.0, 3.0, 6.0, 1.0,
34 3.0, 2.0, 5.0, 4.0,
35 4.0, 1.0, 2.0, 1.0;
36 Matrix<4,4,double> Acopy(A);
37 Vector<4,double> pivots;
38 lu(A,pivots);
39 Matrix<4,4,double> L(A);
40 for (int i=0; i < 4; i++){
41 L(i,i) = 1.0;
42 for (int j=i+1; j < 4; j++){
43 L(i,j) = 0.0;
44 }
45 }
46 Matrix<4,4,double> R(A);
47 for (int j=0; j < 4; j++){
48 for (int i=j+1; i < 4; i++){
49 R(i,j) = 0.0;
50 }
51 }
52 A = L * R;
53 for (int i=0; i < 4; i++){
54 for (int j=0; j < 4; j++){
55 double temp = Acopy(i,j);
56 Acopy(i,j) = Acopy(pivots(i),j);
57 Acopy(pivots(i),j) = temp;
58 }
59 }
60*/
61}
62
64 #ifdef UseLapack
65
66 // checking if Lapack correctly configured. Invert
67 // a diagonal matrix.
68
70 1,0,0,0,0,
71 0,2,0,0,0,
72 0,0,3,0,0,
73 0,0,0,4,0,
74 0,0,0,0,5
75 };
76
77 Matrix<5,5,double> AInverted = {
78 1,0,0,0,0,
79 0,1./2,0,0,0,
80 0,0,1./3,0,0,
81 0,0,0,1./4,0,
82 0,0,0,0,1./5
83 };
84
85 validateEquals( invert(A), AInverted );
86
87 #endif
88}
#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:31
virtual void run()
This routine is triggered by the TestCaseCollection.
Matrix< 2, 2, Scalar > invert(const Matrix< 2, 2, Scalar > &R)