-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathSymmetric.h
61 lines (45 loc) · 1.78 KB
/
Symmetric.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
#pragma once
#include "Matrix.h"
template <class T>
class Symmetric: public Matrix<T>
{
// This class stores the top half of the symmetric matrix only
public:
// Constructor
Symmetric(int rows, int cols, bool preallocate);
// Constructor where user preallocates memory
Symmetric(int rows, int cols, T* values_ptr);
// destructor
virtual ~Symmetric();
// turns dense matrix into symmetric format
// "this" is the input, symm matrix to write to
// input variable is the dense matrix to be transformed
virtual void dense2symm(const Matrix<T> &sdense_mat);
// turns symmetric matrix into dense format
// "this" is the input, symm matrix to be transformed
// input variable is the dense matrix to write to
virtual void symm2dense(Matrix<T> &dense_mat);
// Prints matrix in a symmetric fashion.
// The user expierience is the same as for
// the parent class.
virtual void printMatrix();
// The memory allocated to b is assumed to be
// of size to store as many values as the amount
// columns of this matrix. This Matrix and b need
// to be of same datatype.
// The memory for x must be allocated BEFORE
// calling this function.
// A(this) * b = x
virtual void matVecMult(T* &b, T* x);
// matrix dimensions of this and mat_right
// must be suitable for matrix multiplication
//void matMatMult(Symmetric<T> &mat_right, Symmetric<T> &output);
// Linear Solver using SOR method
// The function will iterate until reaching
// the absolut tolerance specified = sqrt(res1^2 + res2^2 + ...)
// Where the residual res = b - A * x
// or until reaching 10000 iterations
// A(this)*x = b
virtual void SOR(T *b, T *x, double omega, double atol);
int len = -1;
};