RDKit
Open-source cheminformatics and machine learning.
|
A matrix class for general, non-square matrices. More...
#include <Matrix.h>
Public Types | |
typedef boost::shared_array< TYPE > | DATA_SPTR |
Public Member Functions | |
Matrix (unsigned int nRows, unsigned int nCols) | |
Initialize with a size. | |
Matrix (unsigned int nRows, unsigned int nCols, TYPE val) | |
Initialize with a size and default value. | |
Matrix (unsigned int nRows, unsigned int nCols, DATA_SPTR data) | |
Initialize from a pointer. | |
Matrix (const Matrix< TYPE > &other) | |
copy constructor | |
virtual | ~Matrix () |
unsigned int | numRows () const |
returns the number of rows | |
unsigned int | numCols () const |
returns the number of columns | |
unsigned int | getDataSize () const |
virtual TYPE | getVal (unsigned int i, unsigned int j) const |
returns a particular element of the matrix | |
virtual void | setVal (unsigned int i, unsigned int j, TYPE val) |
sets a particular element of the matrix | |
virtual void | getRow (unsigned int i, Vector< TYPE > &row) const |
returns a copy of a row of the matrix | |
virtual void | getCol (unsigned int i, Vector< TYPE > &col) const |
returns a copy of a column of the matrix | |
TYPE * | getData () |
returns a pointer to our data array | |
const TYPE * | getData () const |
returns a const pointer to our data array | |
Matrix< TYPE > & | assign (const Matrix< TYPE > &other) |
Copy operator. | |
virtual Matrix< TYPE > & | operator+= (const Matrix< TYPE > &other) |
Matrix addition. | |
virtual Matrix< TYPE > & | operator-= (const Matrix< TYPE > &other) |
Matrix subtraction. | |
virtual Matrix< TYPE > & | operator*= (TYPE scale) |
Multiplication by a scalar. | |
virtual Matrix< TYPE > & | operator/= (TYPE scale) |
division by a scalar | |
virtual Matrix< TYPE > & | transpose (Matrix< TYPE > &transpose) const |
copies the transpose of this Matrix into another, returns the result | |
Protected Member Functions | |
Matrix () | |
Protected Attributes | |
unsigned int | d_nRows {0} |
unsigned int | d_nCols {0} |
unsigned int | d_dataSize {0} |
DATA_SPTR | d_data |
A matrix class for general, non-square matrices.
typedef boost::shared_array<TYPE> RDNumeric::Matrix< TYPE >::DATA_SPTR |
|
inline |
Initialize with a size.
Definition at line 34 of file Matrix.h.
References RDNumeric::Matrix< TYPE >::d_data, and RDNumeric::Matrix< TYPE >::d_dataSize.
|
inline |
Initialize with a size and default value.
Definition at line 42 of file Matrix.h.
References RDNumeric::Matrix< TYPE >::d_data, and RDNumeric::Matrix< TYPE >::d_dataSize.
|
inline |
Initialize from a pointer.
NOTE: this does not take ownership of the data, if you delete the data externally, this Matrix will be sad.
Definition at line 57 of file Matrix.h.
References RDNumeric::Matrix< TYPE >::d_data.
|
inline |
copy constructor
We make a copy of the other vector's data.
Definition at line 65 of file Matrix.h.
References RDNumeric::Matrix< TYPE >::d_data, RDNumeric::Matrix< TYPE >::d_dataSize, and RDNumeric::Matrix< TYPE >::getData().
|
inlinevirtual |
|
inlineprotected |
|
inline |
Copy operator.
We make a copy of the other Matrix's data.
Definition at line 137 of file Matrix.h.
References RDNumeric::Matrix< TYPE >::d_data, RDNumeric::Matrix< TYPE >::d_dataSize, RDNumeric::Matrix< TYPE >::d_nCols, RDNumeric::Matrix< TYPE >::d_nRows, RDNumeric::Matrix< TYPE >::getData(), RDNumeric::Matrix< TYPE >::numCols(), RDNumeric::Matrix< TYPE >::numRows(), and PRECONDITION.
|
inlinevirtual |
returns a copy of a column of the matrix
Definition at line 115 of file Matrix.h.
References RDNumeric::Matrix< TYPE >::d_data, RDNumeric::Matrix< TYPE >::d_nCols, RDNumeric::Matrix< TYPE >::d_nRows, RDNumeric::Vector< TYPE >::getData(), PRECONDITION, and RDNumeric::Vector< TYPE >::size().
|
inline |
returns a pointer to our data array
Definition at line 128 of file Matrix.h.
References RDNumeric::Matrix< TYPE >::d_data.
Referenced by RDNumeric::Matrix< TYPE >::assign(), RDNumeric::Matrix< TYPE >::Matrix(), RDNumeric::multiply(), RDNumeric::multiply(), RDNumeric::SquareMatrix< TYPE >::operator*=(), RDNumeric::Matrix< TYPE >::operator+=(), and RDNumeric::Matrix< TYPE >::operator-=().
|
inline |
returns a const pointer to our data array
Definition at line 131 of file Matrix.h.
References RDNumeric::Matrix< TYPE >::d_data.
|
inline |
Definition at line 84 of file Matrix.h.
References RDNumeric::Matrix< TYPE >::d_dataSize.
|
inlinevirtual |
returns a copy of a row of the matrix
Definition at line 104 of file Matrix.h.
References RDNumeric::Matrix< TYPE >::d_data, RDNumeric::Matrix< TYPE >::d_nCols, RDNumeric::Matrix< TYPE >::d_nRows, RDNumeric::Vector< TYPE >::getData(), PRECONDITION, and RDNumeric::Vector< TYPE >::size().
|
inlinevirtual |
returns a particular element of the matrix
Definition at line 87 of file Matrix.h.
References RDNumeric::Matrix< TYPE >::d_data, RDNumeric::Matrix< TYPE >::d_nCols, RDNumeric::Matrix< TYPE >::d_nRows, and PRECONDITION.
Referenced by operator<<().
|
inline |
returns the number of columns
Definition at line 82 of file Matrix.h.
References RDNumeric::Matrix< TYPE >::d_nCols.
Referenced by RDNumeric::Matrix< TYPE >::assign(), RDNumeric::multiply(), RDNumeric::multiply(), RDNumeric::Matrix< TYPE >::operator+=(), RDNumeric::Matrix< TYPE >::operator-=(), and operator<<().
|
inline |
returns the number of rows
Definition at line 79 of file Matrix.h.
References RDNumeric::Matrix< TYPE >::d_nRows.
Referenced by RDNumeric::Matrix< TYPE >::assign(), RDNumeric::multiply(), RDNumeric::multiply(), RDNumeric::SquareMatrix< TYPE >::operator*=(), RDNumeric::Matrix< TYPE >::operator+=(), RDNumeric::Matrix< TYPE >::operator-=(), and operator<<().
|
inlinevirtual |
Multiplication by a scalar.
Reimplemented in RDNumeric::SquareMatrix< TYPE >.
Definition at line 184 of file Matrix.h.
References RDNumeric::Matrix< TYPE >::d_data, and RDNumeric::Matrix< TYPE >::d_dataSize.
Referenced by RDNumeric::SquareMatrix< TYPE >::operator*=().
|
inlinevirtual |
Matrix addition.
Perform a element by element addition of other Matrix to this Matrix
Definition at line 152 of file Matrix.h.
References RDNumeric::Matrix< TYPE >::d_data, RDNumeric::Matrix< TYPE >::d_dataSize, RDNumeric::Matrix< TYPE >::d_nCols, RDNumeric::Matrix< TYPE >::d_nRows, RDNumeric::Matrix< TYPE >::getData(), RDNumeric::Matrix< TYPE >::numCols(), RDNumeric::Matrix< TYPE >::numRows(), and PRECONDITION.
|
inlinevirtual |
Matrix subtraction.
Perform a element by element subtraction of other Matrix from this Matrix
Definition at line 169 of file Matrix.h.
References RDNumeric::Matrix< TYPE >::d_data, RDNumeric::Matrix< TYPE >::d_dataSize, RDNumeric::Matrix< TYPE >::d_nCols, RDNumeric::Matrix< TYPE >::d_nRows, RDNumeric::Matrix< TYPE >::getData(), RDNumeric::Matrix< TYPE >::numCols(), RDNumeric::Matrix< TYPE >::numRows(), and PRECONDITION.
|
inlinevirtual |
division by a scalar
Definition at line 194 of file Matrix.h.
References RDNumeric::Matrix< TYPE >::d_data, and RDNumeric::Matrix< TYPE >::d_dataSize.
|
inlinevirtual |
sets a particular element of the matrix
Definition at line 95 of file Matrix.h.
References RDNumeric::Matrix< TYPE >::d_data, RDNumeric::Matrix< TYPE >::d_nCols, RDNumeric::Matrix< TYPE >::d_nRows, and PRECONDITION.
|
inlinevirtual |
copies the transpose of this Matrix into another, returns the result
transpose | the Matrix to store the results |
Definition at line 211 of file Matrix.h.
References RDNumeric::Matrix< TYPE >::d_data, RDNumeric::Matrix< TYPE >::d_nCols, RDNumeric::Matrix< TYPE >::d_nRows, PRECONDITION, and RDNumeric::Matrix< TYPE >::transpose().
Referenced by RDNumeric::Matrix< TYPE >::transpose().
|
protected |
Definition at line 236 of file Matrix.h.
Referenced by RDNumeric::Matrix< TYPE >::assign(), RDNumeric::Matrix< TYPE >::getCol(), RDNumeric::Matrix< TYPE >::getData(), RDNumeric::Matrix< TYPE >::getData(), RDNumeric::Matrix< TYPE >::getRow(), RDNumeric::Matrix< TYPE >::getVal(), RDNumeric::Matrix< TYPE >::Matrix(), RDNumeric::Matrix< TYPE >::Matrix(), RDNumeric::Matrix< TYPE >::Matrix(), RDNumeric::Matrix< TYPE >::Matrix(), RDNumeric::SquareMatrix< TYPE >::operator*=(), RDNumeric::Matrix< TYPE >::operator*=(), RDNumeric::Matrix< TYPE >::operator+=(), RDNumeric::Matrix< TYPE >::operator-=(), RDNumeric::Matrix< TYPE >::operator/=(), RDNumeric::Matrix< TYPE >::setVal(), RDNumeric::Matrix< TYPE >::transpose(), and RDNumeric::SquareMatrix< TYPE >::transposeInplace().
|
protected |
Definition at line 235 of file Matrix.h.
Referenced by RDNumeric::Matrix< TYPE >::assign(), RDNumeric::Matrix< TYPE >::getDataSize(), RDNumeric::Matrix< TYPE >::Matrix(), RDNumeric::Matrix< TYPE >::Matrix(), RDNumeric::Matrix< TYPE >::Matrix(), RDNumeric::SquareMatrix< TYPE >::operator*=(), RDNumeric::Matrix< TYPE >::operator*=(), RDNumeric::Matrix< TYPE >::operator+=(), RDNumeric::Matrix< TYPE >::operator-=(), and RDNumeric::Matrix< TYPE >::operator/=().
|
protected |
Definition at line 234 of file Matrix.h.
Referenced by RDNumeric::Matrix< TYPE >::assign(), RDNumeric::Matrix< TYPE >::getCol(), RDNumeric::Matrix< TYPE >::getRow(), RDNumeric::Matrix< TYPE >::getVal(), RDNumeric::Matrix< TYPE >::numCols(), RDNumeric::SquareMatrix< TYPE >::operator*=(), RDNumeric::Matrix< TYPE >::operator+=(), RDNumeric::Matrix< TYPE >::operator-=(), RDNumeric::Matrix< TYPE >::setVal(), RDNumeric::Matrix< TYPE >::transpose(), and RDNumeric::SquareMatrix< TYPE >::transposeInplace().
|
protected |
Definition at line 233 of file Matrix.h.
Referenced by RDNumeric::Matrix< TYPE >::assign(), RDNumeric::Matrix< TYPE >::getCol(), RDNumeric::Matrix< TYPE >::getRow(), RDNumeric::Matrix< TYPE >::getVal(), RDNumeric::Matrix< TYPE >::numRows(), RDNumeric::SquareMatrix< TYPE >::operator*=(), RDNumeric::Matrix< TYPE >::operator+=(), RDNumeric::Matrix< TYPE >::operator-=(), RDNumeric::Matrix< TYPE >::setVal(), RDNumeric::Matrix< TYPE >::transpose(), and RDNumeric::SquareMatrix< TYPE >::transposeInplace().