19 #ifndef matrix_array_MATRIX_H
20 #define matrix_array_MATRIX_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); }
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);
146 Matrix2D() { initialized =
false; };
151 void AllocateMemory(
int size_x,
int size_y);
157 inline T&
operator()(
int x,
int y) {
return matrix_array[0][x*size_y + y]; }
158 inline T&
Value (
int x,
int y) {
return operator()(x, y); }
167 inline Matrix2D& operator= (
const T val);
186 inline Matrix2D operator* (
const T Val)
const;
187 inline Matrix2D operator/ (
const T Val)
const;
201 inline int index1d(
int x,
int y)
const;
204 void writeToFile(
string filename);
206 void readFromFile(
string filename);
224 int size_x, size_y, size_z;
234 Matrix3D(
int size_x,
int size_y,
int size_z );
237 void AllocateMemory(
int size_x,
int size_y,
int size_z);
240 inline T** operator[] (
int i);
241 inline T** operator[] (
int i)
const {
return matrix_array[i]; }
242 inline T& operator() (
int x,
int y,
int z);
243 inline T&
Value (
int x,
int y,
int z) {
return operator()(x, y, z); }
249 inline Matrix3D& operator= (
const T Val);
259 inline Matrix3D& operator*= (
const T Val);
260 inline Matrix3D& operator/= (
const T Val);
261 inline Matrix3D& operator+= (
const T Val);
262 inline Matrix3D& operator-= (
const T Val);
272 inline Matrix3D operator* (
const T Val)
const;
273 inline Matrix3D operator/ (
const T Val)
const;
281 void writeToFile(
string filename);
282 void writeToFile(
string filename,
284 void readFromFile(
string filename);
285 void readFromFile(
string filename,
291 inline int index1d(
int x,
int y,
int z);
341 CalculationMatrix(
int x_size,
int y_size = 1,
int z_size = 1,
int n_of_diags = 1);
345 void Initialize(
int x_size,
int y_size = 1,
int z_size = 1,
int n_of_diags = 1);
348 int index1d(
int x,
int y = 0,
int z = 0);
351 void writeToFile(
string filename);
bool initialized
Flag, equal true if initialized.
Matrix3D< T > & MatrixArray()
Return pointer to the instance of the class.
const Matrix3D & operator+() const
Return itself as positive version of values.
Matrix3D()
Default constructor. Do nothing.
const Matrix3D operator-() const
Return negative version of values.
string name
name of the Matrix
const Matrix1D operator-() const
Return negative version of values.
double max(double v1, double v2)
Return maximum.
bool initialized
Flag, equal true if initialized.
Matrix2D< T > & MatrixArray()
Return pointer to the instance of the class.
string change_ind
Variables useful for changes tracking (store here time when changed)
T * operator[](int i)
Return the i-th pointer to 1d-array. Next [j] can be applied, so we have regular [i][j].
bool initialized
Flag, equal true if initialized.
map< int, Matrix1D< double > > DiagMatrix
string name
name of the Matrix
T * operator[](int i) const
Return the i-th pointer to 1d-array as const.
This matrix calculates the diagonal values and index given parameters for x, y, and z...
one dimensional matrix class
string change_ind
Variables useful for tracking of changes (time of change can be stored here)
const Matrix2D & operator+() const
Return itself as positive version of values.
Matrix1D< T > & MatrixArray()
Return pointer to the instance of the class.
This method of storage for matrices is convenient for diagonal (spread) matrices. Stored as map (diag...
const Matrix2D operator-() const
Return negative version of values.
T & Value(int x)
Return the (x,y) value of matrix.
T * MatrixArrayPointer()
Return pointer to the instance of the class.
T & Value(int x, int y, int z)
Return the (x,y,z) value of matrix.
T * matrix_array
Array to keep the values.
double T(double alpha)
Function for bounce time.
three dimensional matrix class
two dimensional matrix class
string name
name of the Matrix
T & Value(int x, int y)
Return the (x,y) value of matrix.
T & operator()(int x, int y)
Return the (x,y)-th value of matrix.
const Matrix1D & operator+() const
Return itself as positive version of values.
bool initialized
Flag, equal true if initialized.