Peano 4
Loading...
Searching...
No Matches
MatrixVectorTest.cpp
Go to the documentation of this file.
1#include "MatrixVectorTest.h"
2#include "tarch/la/Matrix.h"
4#include "tarch/la/Vector.h"
7#include <string>
8#include <sstream>
9
10
11
12
14 TestCase ("tarch::la::MatrixVectorTest") {
15}
16
17
19 testMethod (testMultiplication);
20 testMethod (testForwardSubstitution);
21 testMethod (testBackSubstitution);
22 testMethod (testSolveSystem3x3);
23}
24
25
28 Vector<2,int> vector;
29 matrix = {1, 2, 3, 4};
30 vector = {1, 2};
31
32 Vector<2,int> result(0);
33 result = multiply(matrix, vector);
34 validateEquals (result[0], 5);
35 validateEquals (result[1], 11);
36
37}
38
41
42
45
46
48// Matrix<3,3,double> matrix;
49// assignList(matrix) = 1.0, 2.0, 3.0,
50// 4.0, 5.0, 6.0,
51// 2.0, 3.0, 2.0;
52// Vector<3,double> rhs;
53// rhs = 1.0, 2.0, 3.0;
54// Vector<3,double> x(0.0);
55//
56// rhs = solve(matrix, rhs, x);
57// validateNumericalEquals (x(0), -1.166666666666667);
58// validateNumericalEquals (x(1), 2.333333333333333);
59// validateNumericalEquals (x(2), -0.833333333333333);
60//
61// assignList(matrix) = 0.0, 1.0, 0.0,
62// 0.0, 0.0, 1.0,
63// 1.0, 1.0, 1.0;
64// rhs = 0.5, 0.5, 1.0;
65// x = 0.0;
66//
67// rhs = solveSystem3x3 (matrix, rhs, x);
68// validateNumericalEquals (x(0), 0.0);
69// validateNumericalEquals (x(1), 0.5);
70// validateNumericalEquals (x(2), 0.5);
71}
And from this we can write down f$ nabla phi_i nabla phi_i dx but since we are constructing matrix let s investigate the f$ our matrix elements will nabla phi_i dx f By this will be a sparse matrix
#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.
void testMultiplication()
Tests methods from MatrixVectorOperations.h.
Matrix< Rows, Cols, Scalar > multiply(const Matrix< Rows, X, Scalar > &lhs, const Matrix< X, Cols, Scalar > &rhs)
Performs a matrix x matrix multiplication.
Simple vector class.
Definition Vector.h:134