PARTONS/NumA++
|
Numerical Analysis C++ routines
|
Represents a two-dimensional array of double. More...
Public Member Functions | |
MatrixD () | |
Default constructor. More... | |
MatrixD (const size_t _rowsNumber, const size_t _columnsNumber, double first_value,...) | |
Creates a matrix with specific dimensions and fills it with given values separated by comma. More... | |
MatrixD (const size_t _rowsNumber, const size_t _columnsNumber) | |
Creates matrix with specific dimensions and fills it with 0. More... | |
MatrixD (const MatrixD &rhs) | |
Copy constructor. More... | |
MatrixD (const VectorD &rhs) | |
VectorD constructor (creates a one-column matrix). More... | |
virtual | ~MatrixD () |
Default destructor. More... | |
void | assign (const size_t _rowsNumber, const size_t _columnsNumber, double value=0.) |
Assigns a new matrix with all coefficients set to value . More... | |
void | setLine (size_t i, const NumA::VectorD &line) |
Sets an existing line of the matrix to new values given by a vector. More... | |
void | addLine (size_t i, const NumA::VectorD &line) |
Adds a new line in the matrix (its dimension is therefore incremented) with the values given by a vector. More... | |
void | appendLine (const NumA::VectorD &line) |
Adds a new line at the end of the matrix (its dimension is therefore incremented) with the values given by a vector. More... | |
NumA::VectorD | getLine (const size_t lineIndex) const |
Extracts a single line from the matrix. More... | |
NumA::VectorD | operator* (const NumA::VectorD &rhs) const |
Matrix vector multiplication. More... | |
NumA::MatrixD | operator* (const NumA::MatrixD &rhs) const |
Matrix-matrix multiplication. More... | |
NumA::MatrixD | operator+ (const NumA::MatrixD &rhs) const |
Matrix addition. More... | |
NumA::MatrixD | operator- (const NumA::MatrixD &rhs) const |
Matrix subtraction. More... | |
NumA::MatrixD | operator* (double rhs) const |
Multiplication of all the coefficients by a scalar. More... | |
NumA::MatrixD | operator+ (double rhs) const |
Addition coefficient by coefficient with a scalar. More... | |
NumA::MatrixD | operator- (double rhs) const |
Subtraction coefficient by coefficient with a scalar. More... | |
NumA::MatrixD | operator/ (double rhs) const |
Division of all the coefficients by a scalar. More... | |
NumA::MatrixD | transpose () const |
Matrix transpose. More... | |
void | update (const size_t i, const size_t j, const double value) |
Update the value at the given indices. More... | |
double & | at (const size_t i, const size_t j) |
Element access. More... | |
const double & | at (const size_t i, const size_t j) const |
Element access. More... | |
std::string | toString () const |
Return a formatted characters string to display matrix's values. More... | |
size_t | cols () const |
size_t | rows () const |
Static Public Member Functions | |
static NumA::MatrixD | Id (unsigned int n) |
Matrix identity. More... | |
Private Attributes | |
std::vector< double > | m_matrix |
A flat std::vector to represent the matrix. More... | |
size_t | m_rowsNumber |
Number of rows. More... | |
size_t | m_columnsNumber |
Number of columns. More... | |
Represents a two-dimensional array of double.
The indices start at 0 up to size
-1.
Examples:
This returns:
NumA::MatrixD::MatrixD | ( | ) |
Default constructor.
Initializes an empty matrix.
NumA::MatrixD::MatrixD | ( | const size_t | _rowsNumber, |
const size_t | _columnsNumber, | ||
double | first_value, | ||
... | |||
) |
Creates a matrix with specific dimensions and fills it with given values separated by comma.
TODO: Write something better?
If the number and type of arguments are not right, UNDEFINED BEHAVIOUR !!! This constructor is very DANGEROUS!!! USE IT RIGHT, OR SCRAP IT ALL AND REWRITE SOMETHING BETTER!
_rowsNumber | : number of rows |
_columnsNumber | : number of columns |
first_value | : first value of the matrix |
NumA::MatrixD::MatrixD | ( | const size_t | _rowsNumber, |
const size_t | _columnsNumber | ||
) |
Creates matrix with specific dimensions and fills it with 0.
_rowsNumber | : number of rows |
_columnsNumber | : number of columns |
NumA::MatrixD::MatrixD | ( | const MatrixD & | rhs | ) |
Copy constructor.
rhs | Matrix to be copied. |
NumA::MatrixD::MatrixD | ( | const VectorD & | rhs | ) |
VectorD constructor (creates a one-column matrix).
rhs | Vector to be converted to a matrix. |
|
virtual |
Default destructor.
void NumA::MatrixD::addLine | ( | size_t | i, |
const NumA::VectorD & | line | ||
) |
Adds a new line in the matrix (its dimension is therefore incremented) with the values given by a vector.
i | Index the row where the line will be inserted. |
line | Vector to copy in the matrix. |
void NumA::MatrixD::appendLine | ( | const NumA::VectorD & | line | ) |
Adds a new line at the end of the matrix (its dimension is therefore incremented) with the values given by a vector.
line | Vector to copy in the matrix. |
void NumA::MatrixD::assign | ( | const size_t | _rowsNumber, |
const size_t | _columnsNumber, | ||
double | value = 0. |
||
) |
Assigns a new matrix with all coefficients set to value
.
_rowsNumber | Number of rows. |
_columnsNumber | Number of columns. |
value | Default value for all the coefficients. |
double & NumA::MatrixD::at | ( | const size_t | i, |
const size_t | j | ||
) |
Element access.
Can be used to set the value of a coefficient.
i | Row index. |
j | Column index. |
const double & NumA::MatrixD::at | ( | const size_t | i, |
const size_t | j | ||
) | const |
Element access.
i | Row index. |
j | Column index. |
size_t NumA::MatrixD::cols | ( | ) | const |
NumA::VectorD NumA::MatrixD::getLine | ( | const size_t | lineIndex | ) | const |
Extracts a single line from the matrix.
lineIndex | Index of the row to be extracted. |
|
static |
Matrix identity.
n | Dimension. |
NumA::MatrixD NumA::MatrixD::operator* | ( | const NumA::MatrixD & | rhs | ) | const |
Matrix-matrix multiplication.
rhs | Matrix. |
NumA::VectorD NumA::MatrixD::operator* | ( | const NumA::VectorD & | rhs | ) | const |
Matrix vector multiplication.
rhs | Vector. |
NumA::MatrixD NumA::MatrixD::operator* | ( | double | rhs | ) | const |
Multiplication of all the coefficients by a scalar.
rhs | Scalar. |
NumA::MatrixD NumA::MatrixD::operator+ | ( | const NumA::MatrixD & | rhs | ) | const |
Matrix addition.
rhs | Matrix. |
NumA::MatrixD NumA::MatrixD::operator+ | ( | double | rhs | ) | const |
Addition coefficient by coefficient with a scalar.
rhs | Scalar. |
NumA::MatrixD NumA::MatrixD::operator- | ( | const NumA::MatrixD & | rhs | ) | const |
Matrix subtraction.
rhs | Matrix. |
NumA::MatrixD NumA::MatrixD::operator- | ( | double | rhs | ) | const |
Subtraction coefficient by coefficient with a scalar.
rhs | Scalar. |
NumA::MatrixD NumA::MatrixD::operator/ | ( | double | rhs | ) | const |
Division of all the coefficients by a scalar.
rhs | Scalar. |
size_t NumA::MatrixD::rows | ( | ) | const |
void NumA::MatrixD::setLine | ( | size_t | i, |
const NumA::VectorD & | line | ||
) |
Sets an existing line of the matrix to new values given by a vector.
i | Index of the line to be modified. |
line | Vector to copy in the matrix. |
std::string NumA::MatrixD::toString | ( | ) | const |
Return a formatted characters string to display matrix's values.
NumA::MatrixD NumA::MatrixD::transpose | ( | ) | const |
Matrix transpose.
void NumA::MatrixD::update | ( | const size_t | i, |
const size_t | j, | ||
const double | value | ||
) |
Update the value at the given indices.
i | Row index. |
j | Column index. |
value | New value for the coefficient. |
|
private |
Number of columns.
|
private |
A flat std::vector to represent the matrix.
|
private |
Number of rows.