41 MyMatrix(
const std::string& dataTxt );
48 MyMatrix(
const std::vector<dataType>& data,
bool rowVector=
true );
68 return nRows>0 && nCols>0 && data!=
nullptr;
81 return data[ GetOffset(iRow, iCol ) ];
94 data[ GetOffset(iRow, iCol) ] = value;
129 return data[ GetOffset(iRow,iCol) ];
145 return data[ GetOffset(iRow,iCol) ];
308 int nRows=-1,nCols=-1;
311 void AssignMemo(
int i_rows,
int i_cols);
313 inline int GetOffset(
int i_row,
int i_col)
const
315 if (i_row>=0 && i_row<nRows && i_col>=0 && i_col<=nCols)
316 return i_row*nCols+i_col;
317 throw std::runtime_error(
"Matrix error access");
320 void CopyFrom(
const MyMatrix& other);
321 bool ReadFromString(
const char *pt,
int *ptRows =
nullptr,
int *ptCols =
nullptr);
403 return m*(-1)+scalar;
std::istream & operator>>(std::istream &in, MyMatrix &m)
Definition MyMatrix.cpp:372
std::ostream & SetPrecisionAndFormat(std::ostream &out, int nDigits, int nDecimals)
Definition MyMatrix.cpp:363
std::ostream & operator<<(std::ostream &out, const MyMatrix &m)
Definition MyMatrix.cpp:346
double dataType
Datatype to be used with matrixes (.
Definition MyMatrix.h:9
MyMatrix GetSubmatrix(int i_row, int n_rows, int i_col, int n_cols) const
dataType & operator()(int iRow, int iCol)
Obtains a reference to the value at row i, column j of the matrix
Definition MyMatrix.h:128
int GetCols() const
Gets the number of columns in the matrix
Definition MyMatrix.h:113
static MyMatrix Eye(int size)
Create a square diagonal ones matrix (eye)
Definition MyMatrix.cpp:207
MyMatrix & operator=(const MyMatrix &other)
Copy operator: modifies the calling matrix contents to equalize the argument matrix
Definition MyMatrix.cpp:116
dataType Determinant() const
Definition MyMatrix.cpp:168
MyMatrix operator-(dataType scalar) const
Subtraction operator: returns a new matrix result of the subtraction of the scalar to all the element...
Definition MyMatrix.cpp:254
bool IsValid() const
Checks if the matrix contents are valid
Definition MyMatrix.h:67
MyMatrix operator*(dataType scalar, const MyMatrix &m)
Addition operator: returns a new matrix result of the product of the scalar with all the elements of ...
Definition MyMatrix.h:373
MyMatrix operator+(dataType scalar, const MyMatrix &m)
Addition operator: returns a new matrix result of the addition of the scalar with all the elements of...
Definition MyMatrix.h:388
MyMatrix operator/(dataType scalar) const
Division operator: returns a new matrix result of the division of all the elements of the calling mat...
Definition MyMatrix.cpp:270
MyMatrix Adjunct(int i_row, int i_col) const
Definition MyMatrix.cpp:147
MyMatrix DivElByEl(const MyMatrix &other) const
Element by element Division function: returns a new matrix result of the element by element division ...
Definition MyMatrix.cpp:286
MyMatrix operator+(dataType scalar) const
Addition operator: returns a new matrix result of the addition of the scalar to all the elements of t...
Definition MyMatrix.cpp:246
int GetRows() const
Gets the number of rows in the matrix
Definition MyMatrix.h:103
MyMatrix GetCol(int i_col) const
Definition MyMatrix.cpp:194
MyMatrix ProdElByEl(const MyMatrix &other) const
Element by element Product function: returns a new matrix result of the element by element product of...
Definition MyMatrix.cpp:275
~MyMatrix()
Default destructor: removes all memory allocations.
Definition MyMatrix.cpp:107
const dataType & operator()(int iRow, int iCol) const
Obtains a const reference to the value at row i, column j of the matrix
Definition MyMatrix.h:144
MyMatrix Transpose() const
Transpose function: returns a new matrix result of the traspose of the calling matrix.
Definition MyMatrix.cpp:122
bool IsEqual(const MyMatrix &other, double tolerance=1.0e-6) const
Compare function: returns a true boolean if the calling and the argument matrix are 'almost' equal.
Definition MyMatrix.cpp:135
MyMatrix operator*(dataType scalar) const
Product operator: returns a new matrix result of the product of the scalar and all the elements of th...
Definition MyMatrix.cpp:262
MyMatrix operator-(dataType scalar, const MyMatrix &m)
Subtraction operator: returns a new matrix result of the subtraction of the scalar with all the eleme...
Definition MyMatrix.h:402
dataType GetAt(int iRow, int iCol) const
Gets the value at row i, column j of the matrix
Definition MyMatrix.h:80
void SetAt(int iRow, int iCol, dataType value)
Sets the value at row i, column j of the matrix to the specified value
Definition MyMatrix.h:93
MyMatrix()
Default constructor: empty invalid matrix.
Definition MyMatrix.cpp:13
MyMatrix GetRow(int i_row) const
Definition MyMatrix.cpp:182