Simple matrix class.
More...
#include <RMatrix.h>
List of all members.
Public Member Functions |
| void | clear () |
| | Deletes the elements of this matrix and resets the matrix size to 0/0.
|
| double | get (int r, int c) const |
| RMatrix | getAppended (const RMatrix &v) const |
| | Appends matrix v to the right side of this matrix and returns the new matrix.
|
| int | getCols () const |
| RMatrix | getInverse () const |
| int | getRows () const |
| RMatrix | getTransposed () const |
| void | init (int r, int c) |
| | Initializes the matrix for the given size and resets all elements to 0.
|
| bool | isValid () const |
| RMatrix | multiplyWith (const RMatrix &w) const |
| RMatrix | operator* (const RMatrix &other) const |
| | Multiplies two matrices.
|
| RMatrix | operator*= (double f) |
| | Multiplies all elements of this matrix with the given factor and returns this matrix.
|
| RMatrix & | operator= (const RMatrix &other) |
| | Assignment operator.
|
| bool | operator== (const RMatrix &other) const |
| | Comparison.
|
| double * | operator[] (int i) |
| void | print () const |
| void | printRow (int r) const |
| void | reset () |
| | Resets all elements to 0.
|
| | RMatrix () |
| | Creates and empty matrix (zero columns and zero rows).
|
| | RMatrix (int r, int c) |
| | Creates a matrix with r rows and c columns.
|
| | RMatrix (const RMatrix &other) |
| | Copy constructor.
|
| bool | rref () |
| | Changes this matrix into its rref.
|
| void | set (int r, int c, double v) |
| | Sets the element at the given row/column to the given value v.
|
| void | set2x3 (double a11, double a12, double a13, double a21, double a22, double a23) |
| | Sets the dimension of this matrix to 2x3 and the elements to the given elements.
|
| void | set3x1 (double a11, double a21, double a31) |
| | Sets the dimension of this matrix to 3x1 and the elements to the given elements.
|
| void | set3x3 (double a11, double a12, double a13, double a21, double a22, double a23, double a31, double a32, double a33) |
| | Sets the dimension of this matrix to 3x3 and the elements to the given elements.
|
| | ~RMatrix () |
| | Deletes the matrix.
|
Static Public Member Functions |
| static RMatrix | create2x3 (double a11, double a12, double a13, double a21, double a22, double a23) |
| static RMatrix | create3x1 (double a11, double a21, double a31) |
| static RMatrix | create3x3 (double a11, double a12, double a13, double a21, double a22, double a23, double a31, double a32, double a33) |
| static RMatrix | createIdentity (int size) |
| static RMatrix | createIdentity2x2 () |
| static RMatrix | createIdentity3x3 () |
Protected Member Functions |
| void | addRow (int r, double factor, int r2) |
| | Adds to row r factor times row r2.
|
| int | getPivotCol (int r) |
| int | getPivotRow (int startRow) |
| void | multiplyRow (int r, double factor) |
| | Multiplies row r with factor.
|
| bool | ref (int startRow) |
| | Changes this matrix into its ref.
|
| void | swapRows (int r1, int r2) |
| | Swaps the given two rows.
|
Private Attributes |
| int | cols |
| double ** | m |
| int | rows |
Detailed Description
Simple matrix class.
- Copyable:
- Script wrappers of this class should pass objects by reference.
Constructor & Destructor Documentation
Creates and empty matrix (zero columns and zero rows).
| RMatrix::RMatrix |
( |
int |
r, |
|
|
int |
c |
|
) |
| |
Creates a matrix with r rows and c columns.
All elements are reset to 0.
- Parameters:
-
| r | number of rows |
| c | number of columns |
| RMatrix::RMatrix |
( |
const RMatrix & |
other | ) |
|
Member Function Documentation
| void RMatrix::addRow |
( |
int |
r, |
|
|
double |
factor, |
|
|
int |
r2 |
|
) |
| |
|
protected |
Adds to row r factor times row r2.
- Parameters:
-
| r | the row |
| r2 | the row 2 |
| factor | The factor to apply to r2 before it is added to row r. |
Deletes the elements of this matrix and resets the matrix size to 0/0.
| RMatrix RMatrix::create2x3 |
( |
double |
a11, |
|
|
double |
a12, |
|
|
double |
a13, |
|
|
double |
a21, |
|
|
double |
a22, |
|
|
double |
a23 |
|
) |
| |
|
static |
- Returns:
- A matrix with 2 rows and 3 columns:
| RMatrix RMatrix::create3x1 |
( |
double |
a11, |
|
|
double |
a21, |
|
|
double |
a31 |
|
) |
| |
|
static |
- Returns:
- A matrix with 3 rows and 1 column (vector):
| RMatrix RMatrix::create3x3 |
( |
double |
a11, |
|
|
double |
a12, |
|
|
double |
a13, |
|
|
double |
a21, |
|
|
double |
a22, |
|
|
double |
a23, |
|
|
double |
a31, |
|
|
double |
a32, |
|
|
double |
a33 |
|
) |
| |
|
static |
- Returns:
- A matrix with 3 rows and 3 columns:
| RMatrix RMatrix::createIdentity |
( |
int |
size | ) |
|
|
static |
- Returns:
- An identity matrix with
size rows and size columns:
| RMatrix RMatrix::createIdentity2x2 |
( |
| ) |
|
|
static |
- Returns:
- An identity matrix with 2 rows and 2 columns:
| RMatrix RMatrix::createIdentity3x3 |
( |
| ) |
|
|
static |
- Returns:
- An identity matrix with 3 rows and 3 columns:
| double RMatrix::get |
( |
int |
r, |
|
|
int |
c |
|
) |
| const |
- Parameters:
-
- Returns:
- The element at the given row/column.
Appends matrix v to the right side of this matrix and returns the new matrix.
This matrix is not affected.
- Parameters:
-
| v | the matrix to append to this matrix |
| int RMatrix::getCols |
( |
| ) |
const |
|
inline |
- Returns:
- Number of columns of this matrix.
| RMatrix RMatrix::getInverse |
( |
| ) |
const |
- Returns:
- The inverse matrix of this matrix
or an empty matrix if this matrix is not invertible.
| int RMatrix::getPivotCol |
( |
int |
r | ) |
|
|
protected |
- Parameters:
-
- Returns:
- The pivot column of the given matrix row
r.
| int RMatrix::getPivotRow |
( |
int |
startRow | ) |
|
|
protected |
- Parameters:
-
- Returns:
- The pivot row of this matrix, starting with the given row
startRow.
| int RMatrix::getRows |
( |
| ) |
const |
|
inline |
- Returns:
- Number of rows of this matrix.
| RMatrix RMatrix::getTransposed |
( |
| ) |
const |
- Returns:
- The transposed matrix
. This matrix is not affected.
| void RMatrix::init |
( |
int |
r, |
|
|
int |
c |
|
) |
| |
Initializes the matrix for the given size and resets all elements to 0.
| bool RMatrix::isValid |
( |
| ) |
const |
- Returns:
- True if this matrix is a valid matrix (more than 0 columns and rows).
| void RMatrix::multiplyRow |
( |
int |
r, |
|
|
double |
factor |
|
) |
| |
|
protected |
Multiplies row r with factor.
- Parameters:
-
| r | the row |
| factor | the factor to apply to the row |
- Returns:
This matrix is not affected.
| RMatrix RMatrix::operator*= |
( |
double |
f | ) |
|
Multiplies all elements of this matrix with the given factor and returns this matrix.
| bool RMatrix::operator== |
( |
const RMatrix & |
other | ) |
const |
Comparison.
All elements of the matrix as well as the matrix dimensions have to match for the two matrices to be equal.
| double* RMatrix::operator[] |
( |
int |
i | ) |
|
| void RMatrix::print |
( |
| ) |
const |
| void RMatrix::printRow |
( |
int |
r | ) |
const |
| bool RMatrix::ref |
( |
int |
startRow | ) |
|
|
protected |
Changes this matrix into its ref.
- Returns:
- True on success.
Resets all elements to 0.
| void RMatrix::set |
( |
int |
r, |
|
|
int |
c, |
|
|
double |
v |
|
) |
| |
Sets the element at the given row/column to the given value v.
- Parameters:
-
| r | the row |
| c | the column |
| v | the new value at the given row / column position |
| void RMatrix::set2x3 |
( |
double |
a11, |
|
|
double |
a12, |
|
|
double |
a13, |
|
|
double |
a21, |
|
|
double |
a22, |
|
|
double |
a23 |
|
) |
| |
Sets the dimension of this matrix to 2x3 and the elements to the given elements.
| void RMatrix::set3x1 |
( |
double |
a11, |
|
|
double |
a21, |
|
|
double |
a31 |
|
) |
| |
Sets the dimension of this matrix to 3x1 and the elements to the given elements.
| void RMatrix::set3x3 |
( |
double |
a11, |
|
|
double |
a12, |
|
|
double |
a13, |
|
|
double |
a21, |
|
|
double |
a22, |
|
|
double |
a23, |
|
|
double |
a31, |
|
|
double |
a32, |
|
|
double |
a33 |
|
) |
| |
Sets the dimension of this matrix to 3x3 and the elements to the given elements.
| void RMatrix::swapRows |
( |
int |
r1, |
|
|
int |
r2 |
|
) |
| |
|
protected |
Swaps the given two rows.
- Parameters:
-
Member Data Documentation
The documentation for this class was generated from the following files: