19 #ifndef matrix_array_MATRIX_H
20 #define matrix_array_MATRIX_H
22 #include "./Interpolation/linear.h"
23 #include "./Interpolation/spline.h"
24 #include "./Interpolation/polilinear.h"
25 #include "./Interpolation/polint.h"
26 #include "./Interpolation/ratint.h"
27 #include "./Interpolation/akima.h"
31 #include "../Exceptions/error.h"
56 void AllocateMemory(
int x_size );
59 inline T& operator[](
int i);
60 inline T& operator[](
int i)
const;
61 inline T& operator()(
int x);
62 inline T&
Value (
int x) {
return operator()(x); }
67 inline const Matrix1D& operator+()
const {
return *
this; }
68 inline const Matrix1D operator-()
const {
return ((*
this)*(-1)); }
72 inline Matrix1D& operator= (
const T val);
93 inline Matrix1D operator* (
const T Val)
const;
94 inline Matrix1D operator/ (
const T Val)
const;
102 inline T norm ()
const;
109 void Spline(
Matrix1D<T> &old_function,
Matrix1D<T> &old_grid,
Matrix1D<T> &new_grid,
double lb,
double ub,
double lin_spline_coef = 0,
double max_second_der = 0);
114 void Spline2(
Matrix1D<T> &old_function,
Matrix1D<T> &old_grid,
Matrix1D<T> &new_grid,
double lb,
double ub,
double lin_spline_coef = 0,
double max_second_der = 0);
121 void writeToFile(
string filename);
122 void writeToFile(
string filename,
Matrix1D<T> &grid_x);
123 void readFromFile(
string filename);
124 void readFromFile(
string filename,
Matrix1D<T> &grid_x);
143 Matrix2D() { initialized =
false; };
148 void AllocateMemory(
int size_x,
int size_y);
153 inline T* operator[](
int i)
const {
return matrix_array[i]; }
154 inline T&
operator()(
int x,
int y) {
return matrix_array[0][x*size_y + y]; }
155 inline T&
Value (
int x,
int y) {
return operator()(x, y); }
159 inline const Matrix2D& operator+()
const {
return *
this; }
160 inline const Matrix2D operator-()
const {
return ((*
this)*(-1)); }
164 inline Matrix2D& operator= (
const T val);
183 inline Matrix2D operator* (
const T Val)
const;
184 inline Matrix2D operator/ (
const T Val)
const;
198 inline int index1d(
int x,
int y)
const;
201 void writeToFile(
string filename);
203 void readFromFile(
string filename);
227 Matrix3D(
int size_x,
int size_y,
int size_z );
230 void AllocateMemory(
int size_x,
int size_y,
int size_z);
233 inline T** operator[] (
int i);
234 inline T** operator[] (
int i)
const {
return matrix_array[i]; }
235 inline T& operator() (
int x,
int y,
int z);
236 inline T&
Value (
int x,
int y,
int z) {
return operator()(x, y, z); }
242 inline Matrix3D& operator= (
const T Val);
245 inline const Matrix3D& operator+()
const {
return *
this; }
246 inline const Matrix3D operator-()
const {
return ((*
this)*(-1)); }
252 inline Matrix3D& operator*= (
const T Val);
253 inline Matrix3D& operator/= (
const T Val);
254 inline Matrix3D& operator+= (
const T Val);
255 inline Matrix3D& operator-= (
const T Val);
265 inline Matrix3D operator* (
const T Val)
const;
266 inline Matrix3D operator/ (
const T Val)
const;
274 void writeToFile(
string filename);
275 void writeToFile(
string filename,
277 void readFromFile(
string filename);
278 void readFromFile(
string filename,
284 inline int index1d(
int x,
int y,
int z);
303 typedef map <int , Matrix1D<double> > DiagMatrix;
314 int x_size, y_size, total_size;
321 CalculationMatrix(
int x_size,
int y_size = 1,
int z_size = 1,
int n_of_diags = 1);
325 void Initialize(
int x_size,
int y_size = 1,
int z_size = 1,
int n_of_diags = 1);
328 int index1d(
int x,
int y = 0,
int z = 0);
331 void writeToFile(
string filename);
bool initialized
Flag, equal true if initialized.
Definition: Matrix.h:138
int size_y
size x, size_y
Definition: Matrix.h:139
Matrix3D< T > & MatrixArray()
Return pointer to the instance of the class.
Definition: Matrix.h:237
Matrix3D()
Default constructor. Do nothing.
Definition: Matrix.h:225
string name
name of the Matrix
Definition: Matrix.h:47
bool initialized
Flag, equal true if initialized.
Definition: Matrix.h:45
Matrix2D< T > & MatrixArray()
Return pointer to the instance of the class.
Definition: Matrix.h:156
string change_ind
Variables useful for changes tracking (store here time when changed)
Definition: Matrix.h:316
T * operator[](int i)
Return the i-th pointer to 1d-array. Next [j] can be applied, so we have regular [i][j].
Definition: Matrix.h:152
bool initialized
Flag, equal true if initialized.
Definition: Matrix.h:219
string name
name of the Matrix
Definition: Matrix.h:221
This matrix calculates the diagonal values and index given parameters for x, y, and z...
Definition: Matrix.h:310
one dimensional matrix class
Definition: Matrix.h:41
string change_ind
Variables useful for tracking of changes (time of change can be stored here)
Definition: Matrix.h:282
Matrix1D< T > & MatrixArray()
Return pointer to the instance of the class.
Definition: Matrix.h:63
T * matrix_array
Array to keep the values.
Definition: Matrix.h:43
T & Value(int x)
Return the (x,y) value of matrix.
Definition: Matrix.h:62
T * MatrixArrayPointer()
Return pointer to the instance of the class.
Definition: Matrix.h:64
T & Value(int x, int y, int z)
Return the (x,y,z) value of matrix.
Definition: Matrix.h:236
double T(double alpha)
Function for bounce time.
Definition: variousFunctions.cpp:32
three dimensional matrix class
Definition: Matrix.h:212
two dimensional matrix class
Definition: Matrix.h:132
string name
name of the Matrix
Definition: Matrix.h:140
T & Value(int x, int y)
Return the (x,y) value of matrix.
Definition: Matrix.h:155
T & operator()(int x, int y)
Return the (x,y)-th value of matrix.
Definition: Matrix.h:154
int size_x
size x
Definition: Matrix.h:46
int size_z
size x, size y, size z
Definition: Matrix.h:220