-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMatrix.h
115 lines (92 loc) · 3.05 KB
/
Matrix.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#ifndef Matrix_h
#define Matrix_h
#include "global.h"
using namespace std;
/** \brief Matrix manipulation class
Class for matrix manipulation (like inverting, calculating determinants, etc.)
© Copyright 2010 TU Berlin - Christoph Tavan. All Rights Reserved.
\author Christoph Tavan TU Berlin
\author $LastChangedBy$
\date 2010-12-27
\date $LastChangedDate$
\version $Rev$ \sa
**/
class Matrix {
public:
Matrix();
/** \brief Determinant of a matrix
Computes and returns the determinant of an m x m Matrix A.
\author Christoph Tavan TU Berlin
\date 2010-12-25
\param vector m x m Matrix A
\return my_rational Value of the determinant
\sa
**/
my_rational det(vector< vector< my_rational > > A);
/** \brief Transpose matrix
Transpose matrix A and write the transposed matrix to At.
\author Christoph Tavan TU Berlin
\date 2010-12-25
\param vector m x m Matrix A
\param vector Resulting m x m Matrix At
\return void
\sa
**/
void transpose(vector< vector< my_rational > > A, vector< vector< my_rational > > At);
/** \brief Matrix multiplication
Multiply matrix A with matrix B and write result to matrix R.
\author Christoph Tavan TU Berlin
\date 2010-12-25
\param vector m x m Matrix A
\param vector m x m Matrix B
\param Resulting m x m Matrix R = A . B
\return void
\sa
**/
void multiply(vector< vector< my_rational > > A, vector< vector< my_rational > > B, vector< vector< my_rational > > R);
/** \brief Invert matrix
Compute the inverse of matrix A and write it into Ai.
\author Christoph Tavan TU Berlin
\date 2010-12-25
\param vector m x m Matrix A
\param vector m x m Matrix Ai
\return void
\sa
**/
void inverse(vector< vector< my_rational > > A, vector< vector< my_rational > > Ai);
/** \brief Perform pivot operation
Perform a pivot operation on the given pivot-element ij (indices starting at 0)
\author Christoph Tavan TU Berlin
\date 2010-12-25
\param vector Final m x n Matrix B after pivoting
\param vector Initial m x n Matrix A
\param int i Row-index of pivot element
\param int j Column-index of pivot element
\return void
\sa
**/
static void pivot(vector< vector< my_rational > >& B, const vector< vector< my_rational > >& A, const int& i, const int& j);
/** \brief Subtract row j from row i
Subtracts row j of input matrix A from row i. The input matrix is manipulated directly.
\author Christoph Tavan TU Berlin
\date 2010-12-27
\param vector m x n Matrix A
\param int i Row-index of first row
\param int j Row-index of second row
\return void
\sa
**/
static void row_subtract(vector< vector< my_rational > >& A, const int& i, const int& j);
/** \brief Append vector x to matrix A
Appends vector x to matrix A and writes the result to matrix B: B = A|x
\author Christoph Tavan TU Berlin
\date 2011-01-11
\param vector Resulting matrix B
\param vector Initial matrix A
\param vector Column-vector to be appended to A
\return void
\sa
**/
static void append_vec(vector< vector< my_rational > >& B, const vector< vector< my_rational > >& A, const vector< my_rational >& x);
};
#endif