#include <SMatrix.h>
Inheritance diagram for SMatrix:
Public Member Functions | |
SMatrix (const dword nrows=1, const dword ncols=1) | |
constructor | |
SMatrix (const dword nrows, const dword ncols, const double s) | |
constructor with initialization | |
SMatrix (const SMatrix &m) | |
Copy constructor. | |
SMatrix (const vuColourN &col) | |
Create from vuColour without alpha. | |
SMatrix (const vuMatrix &m) | |
Create from vuMatrix. | |
SMatrix (dword nrows, dword ncols, const double *data) | |
Create from a double*. | |
SMatrix (dword nrows, dword ncols, const float *data) | |
Create from a float*. | |
SMatrix (const linalg::Matrix &m) | |
Create from linalg::Matrix. | |
SMatrix (const linalg::Vector &m) | |
Create from linalg::Vector. | |
SMatrix (const coool::DensMatrix< double > &m) | |
Create from coool::Matrix. | |
SMatrix (const coool::Vector< double > &m) | |
Create from coool::Vector. | |
~SMatrix () | |
destructor | |
SMatrix & | operator= (const SMatrix &m) |
Assigns a matrix to the instance. | |
SMatrix & | operator= (const double s) |
Assigns a constant scalar to all elements. | |
SMatrix & | operator= (const float *fdata) |
Assigns from float array. | |
SMatrix & | operator= (const double *fdata) |
Assigns from double array. | |
SMatrix & | operator= (const vuMatrix &m) |
Assigns a matrix to the instance. | |
SMatrix & | operator= (const linalg::Matrix &m) |
Assigns a linalg::Matrix to the instance. | |
SMatrix & | operator= (const coool::DensMatrix< double > &m) |
Assigns a coool:DensMatrix to the instance. | |
operator linalg::Matrix () const | |
convert to a linalg::Matrix | |
operator coool::DensMatrix () const | |
convert to a coool::DensMatrix<double> | |
double * | operator[] (unsigned int index) |
The access operator. | |
const double * | operator[] (unsigned int index) const |
The const access operator. | |
double * | getData (void) |
Returns the data pointer. | |
double const * | getData (void) const |
void | resize (dword nrows, dword ncols) |
Resizes the matrix. | |
dword | getNCols () const |
returns number of rows | |
dword | getNRows () const |
returns number of rows | |
SMatrix & | makeIdentity (void) |
Makes the matrix an identity matrix and returns a reference. | |
SMatrix & | makeZero (void) |
sets all elements of the matrix to zero | |
SMatrix & | makeDiag (const SVector &diag) |
sets diagonal elements from vector diag | |
SMatrix & | makeToeplitz (const SVector &v, bool symmetric=false) |
creates a Toeplitz matrix using the elements of v as diagonal elements | |
SMatrix & | insert (const SMatrix &m, dword i=0, dword j=0) |
inserts the contents of another matrix at a certain position | |
SMatrix | horizCat (const SMatrix &m) const |
horizontal concatenation of another matrix, rows must match | |
SMatrix | vertCat (const SMatrix &m) const |
vertical concatenation with another matrix, columns must match | |
double | norm () const |
returns euclidic norm | |
double | norm2 () const |
returns squared 2 euclidic norm | |
SMatrix | operator+ (const SMatrix &m) const |
Returns the addition of the two matrices.. | |
SMatrix | operator- (const SMatrix &m) const |
Returns the difference of the two matrices.. | |
SMatrix | operator * (const SMatrix &m) const |
Returns the product of the two matrices. | |
SMatrix | operator * (double s) const |
Returns the product of the instance with a scalar. | |
SMatrix & | operator+= (const SMatrix &m) |
Adds a matrix to the instance. | |
SMatrix & | operator-= (const SMatrix &m) |
Subtracts a matrix from the instance. | |
SMatrix & | operator *= (const SMatrix &m) |
Multiplies the instance by a matrix. | |
SMatrix & | operator *= (double s) |
Multiplies the instance by a scalar. | |
Protected Attributes | |
dword | m_NRows |
number of rows and columns | |
dword | m_NCols |
number of rows and columns | |
double * | m_Data |
pointer to the two dimensional double array | |
Private Member Functions | |
void | init (dword nrows, dword ncols) |
allocating memory and setting m_NRows and m_NCols | |
void | free () |
release the allocated memory | |
Friends | |
SMatrix | operator * (double s, const SMatrix &m) |
Multiplies a scalar by a matrix. | |
ostream & | operator<< (ostream &os, const SMatrix &A) |
istream & | operator>> (istream &is, SMatrix &A) |
Unlike vuMatrix this class can be of arbitrary format. It's meant to act as converter to the matrix classes provided by the COOOL and the LinAlg package.
This implementation is really inefficient, because there is a lot of memory copying and allocation going on. But it's ok for the stuff done in SOptimize. To see how a matrix class is really done, look at MTL (http://www.osl.iu.edu/research/mtl) or the one provided in LinAlg.
The positions and sizes are written as rows first and then columns.
Definition at line 29 of file SMatrix.h.
|
constructor
Definition at line 30 of file SMatrix.cpp. References init(). |
Here is the call graph for this function:
|
constructor with initialization
Definition at line 35 of file SMatrix.cpp. References init(), and operator=(). |
Here is the call graph for this function:
|
Copy constructor.
Definition at line 72 of file SMatrix.cpp. References init(), m_NCols, m_NRows, and operator=(). |
Here is the call graph for this function:
|
Create from vuColour without alpha.
Definition at line 93 of file SMatrix.cpp. References dword, vuColourN::getData(), init(), and vuColourN::nComponents(). |
Here is the call graph for this function:
|
Create from vuMatrix.
Definition at line 105 of file SMatrix.cpp. |
Here is the call graph for this function:
|
Create from a double*.
Definition at line 86 of file SMatrix.cpp. References data, init(), and operator=(). |
Here is the call graph for this function:
|
Create from a float*.
Definition at line 79 of file SMatrix.cpp. References data, init(), and operator=(). |
Here is the call graph for this function:
|
Create from linalg::Matrix.
Definition at line 117 of file SMatrix.cpp. References init(), linalg::DimSpec::q_col_lwb(), linalg::DimSpec::q_col_upb(), linalg::DimSpec::q_row_lwb(), and linalg::DimSpec::q_row_upb(). |
Here is the call graph for this function:
|
Create from linalg::Vector.
Definition at line 132 of file SMatrix.cpp. References init(), linalg::Vector::q_lwb(), and linalg::Vector::q_upb(). |
Here is the call graph for this function:
|
Create from coool::Matrix.
Definition at line 144 of file SMatrix.cpp. |
Here is the call graph for this function:
|
Create from coool::Vector.
Definition at line 157 of file SMatrix.cpp. |
Here is the call graph for this function:
|
destructor
Definition at line 57 of file SMatrix.cpp. References free(). |
Here is the call graph for this function:
|
release the allocated memory
Definition at line 49 of file SMatrix.cpp. References m_Data, m_NCols, and m_NRows. Referenced by resize(), and ~SMatrix(). |
|
Definition at line 242 of file SMatrix.cpp. |
|
Returns the data pointer. Same as calling operator[0]. Definition at line 237 of file SMatrix.cpp. Referenced by makeDiag(), and makeToeplitz(). |
|
returns number of rows
Definition at line 101 of file SMatrix.h. References dword. Referenced by SOptimizer::minimize(), and SVector::SVector(). |
|
returns number of rows
Definition at line 103 of file SMatrix.h. References dword. Referenced by SOptimizer::minimize(). |
|
horizontal concatenation of another matrix, rows must match
Definition at line 370 of file SMatrix.cpp. References checkNRows, insert(), m_NCols, and m_NRows. |
Here is the call graph for this function:
|
allocating memory and setting m_NRows and m_NCols
Definition at line 41 of file SMatrix.cpp. |
|
inserts the contents of another matrix at a certain position
Definition at line 356 of file SMatrix.cpp. References dword, m_Data, m_NCols, and m_NRows. Referenced by horizCat(), SOptimizer::minimize(), and vertCat(). |
|
sets diagonal elements from vector diag
Definition at line 307 of file SMatrix.cpp. References dword, getData(), m_NCols, m_NRows, makeZero(), and min. |
Here is the call graph for this function:
|
Makes the matrix an identity matrix and returns a reference.
Definition at line 288 of file SMatrix.cpp. References dword, m_NCols, m_NRows, makeZero(), and min. |
Here is the call graph for this function:
|
creates a Toeplitz matrix using the elements of v as diagonal elements
Definition at line 321 of file SMatrix.cpp. References dword, getData(), SVector::getSize(), m_Data, m_NCols, m_NRows, makeZero(), and min. |
Here is the call graph for this function:
|
sets all elements of the matrix to zero
Definition at line 300 of file SMatrix.cpp. References operator=(). Referenced by makeDiag(), makeIdentity(), and makeToeplitz(). |
Here is the call graph for this function:
|
returns euclidic norm
Definition at line 282 of file SMatrix.cpp. References norm2(). Referenced by SOptimizer::minimize(). |
Here is the call graph for this function:
|
returns squared 2 euclidic norm
Definition at line 272 of file SMatrix.cpp. References dword, m_NRows, and res. Referenced by norm(). |
|
Returns the product of the instance with a scalar.
Definition at line 435 of file SMatrix.cpp. References res. |
|
Returns the product of the two matrices.
Definition at line 414 of file SMatrix.cpp. |
|
Multiplies the instance by a scalar.
Definition at line 501 of file SMatrix.cpp. |
|
Multiplies the instance by a matrix.
Definition at line 480 of file SMatrix.cpp. |
|
convert to a coool::DensMatrix<double>
Definition at line 260 of file SMatrix.cpp. |
|
convert to a linalg::Matrix
Definition at line 248 of file SMatrix.cpp. References m_NCols, m_NRows, linalg::DimSpec::q_col_lwb(), linalg::DimSpec::q_col_upb(), linalg::DimSpec::q_row_lwb(), and linalg::DimSpec::q_row_upb(). |
Here is the call graph for this function:
|
Returns the addition of the two matrices..
Definition at line 396 of file SMatrix.cpp. |
|
Adds a matrix to the instance.
Definition at line 448 of file SMatrix.cpp. |
|
Returns the difference of the two matrices..
Definition at line 405 of file SMatrix.cpp. |
|
Subtracts a matrix from the instance.
Definition at line 464 of file SMatrix.cpp. |
|
Assigns a coool:DensMatrix to the instance.
|
|
Assigns a linalg::Matrix to the instance.
|
|
Assigns a matrix to the instance.
|
|
Assigns from double array.
Definition at line 208 of file SMatrix.cpp. |
|
Assigns from float array.
Definition at line 195 of file SMatrix.cpp. |
|
Assigns a constant scalar to all elements.
Definition at line 183 of file SMatrix.cpp. |
|
Assigns a matrix to the instance.
Definition at line 169 of file SMatrix.cpp. References dword, m_Data, m_NCols, m_NRows, and resize(). Referenced by makeZero(), and SMatrix(). |
Here is the call graph for this function:
|
The const access operator.
Definition at line 228 of file SMatrix.cpp. References m_Data. |
|
The access operator. To make it nice we could return a vector here, but therefore we'd need to reuse the memory (like LinAlg Matrix). Definition at line 221 of file SMatrix.cpp. References m_Data. |
|
Resizes the matrix. No changes are made if the current dimensions aggree with the parameters. Attention: The elements are not initialized. So call makeZero() on your own. This function does pretty much the same as destroying the class and creating a new one. Definition at line 62 of file SMatrix.cpp. References free(), init(), m_NCols, and m_NRows. Referenced by operator=(). |
Here is the call graph for this function:
|
vertical concatenation with another matrix, columns must match
Definition at line 383 of file SMatrix.cpp. References checkNCols, insert(), m_NCols, and m_NRows. |
Here is the call graph for this function:
|
Multiplies a scalar by a matrix.
Definition at line 442 of file SMatrix.cpp. |
|
Definition at line 512 of file SMatrix.cpp. |
|
Definition at line 525 of file SMatrix.cpp. |
|
pointer to the two dimensional double array
Definition at line 170 of file SMatrix.h. Referenced by free(), init(), insert(), makeToeplitz(), operator *(), operator *=(), operator+=(), operator-=(), operator<<(), operator=(), operator>>(), and operator[](). |
|
number of rows and columns
Definition at line 168 of file SMatrix.h. Referenced by free(), horizCat(), init(), insert(), makeDiag(), makeIdentity(), makeToeplitz(), operator *(), operator *=(), operator coool::DensMatrix(), operator linalg::Matrix(), operator<<(), operator=(), operator>>(), resize(), SMatrix(), and vertCat(). |
|
number of rows and columns
Definition at line 168 of file SMatrix.h. Referenced by free(), horizCat(), init(), insert(), makeDiag(), makeIdentity(), makeToeplitz(), norm2(), operator *(), operator *=(), operator coool::DensMatrix(), operator linalg::Matrix(), operator+=(), operator-=(), operator<<(), operator=(), operator>>(), resize(), SMatrix(), and vertCat(). |