RDKit: RDNumeric::Matrix< TYPE > Class Template Reference

| RDKit Open-source cheminformatics and machine learning.

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
RDNumeric::Matrix< TYPE > Class Template Reference

A matrix class for general, non-square matrices. More...

`#include <Matrix.h>`

Inheritance diagram for RDNumeric::Matrix< TYPE >:

## Public Types
typedef boost::shared_array< TYPE > | DATA_SPTR

## Public Member Functions
| Matrix (unsigned int nRows, unsigned int nCols)
| Initialize with a size. More...
| Matrix (unsigned int nRows, unsigned int nCols, TYPE val)
| Initialize with a size and default value. More...
| Matrix (unsigned int nRows, unsigned int nCols, DATA_SPTR data)
| Initialize from a pointer. More...
| Matrix (const Matrix< TYPE > &other)
| copy constructor More...
virtual | ~Matrix ()
unsigned int | numRows () const
| returns the number of rows More...
unsigned int | numCols () const
| returns the number of columns More...
unsigned int | getDataSize () const
virtual TYPE | getVal (unsigned int i, unsigned int j) const
| returns a particular element of the matrix More...
virtual void | setVal (unsigned int i, unsigned int j, TYPE val)
| sets a particular element of the matrix More...
virtual void | getRow (unsigned int i, Vector< TYPE > &row) const
| returns a copy of a row of the matrix More...
virtual void | getCol (unsigned int i, Vector< TYPE > &col) const
| returns a copy of a column of the matrix More...
TYPE * | getData ()
| returns a pointer to our data array More...
const TYPE * | getData () const
| returns a const pointer to our data array More...
Matrix< TYPE > & | assign (const Matrix< TYPE > &other)
| Copy operator. More...
virtual Matrix< TYPE > & | operator+= (const Matrix< TYPE > &other)
| Matrix addition. More...
virtual Matrix< TYPE > & | operator-= (const Matrix< TYPE > &other)
| Matrix subtraction. More...
virtual Matrix< TYPE > & | operator*= (TYPE scale)
| Multiplication by a scalar. More...
virtual Matrix< TYPE > & | operator/= (TYPE scale)
| division by a scalar More...
virtual Matrix< TYPE > & | transpose (Matrix< TYPE > &transpose) const
| copies the transpose of this Matrix into another, returns the result More...

## Protected Member Functions
| Matrix ()

## Protected Attributes
unsigned int | d_nRows
unsigned int | d_nCols
unsigned int | d_dataSize
DATA_SPTR | d_data

## Detailed Description

### template<class TYPE>
class RDNumeric::Matrix< TYPE >

A matrix class for general, non-square matrices.

Definition at line 28 of file Matrix.h.

## Member Typedef Documentation

template<class TYPE>

typedef boost::shared_array<TYPE> RDNumeric::Matrix< TYPE >::DATA_SPTR

Definition at line 30 of file Matrix.h.

## Constructor & Destructor Documentation

template<class TYPE>

RDNumeric::Matrix< TYPE >::Matrix | ( | unsigned int | nRows,
|  | unsigned int | nCols
| ) |  |
| inline

Initialize with a size.

Definition at line 33 of file Matrix.h.

template<class TYPE>

RDNumeric::Matrix< TYPE >::Matrix | ( | unsigned int | nRows,
|  | unsigned int | nCols,
|  | TYPE | val
| ) |  |
| inline

Initialize with a size and default value.

Definition at line 41 of file Matrix.h.

template<class TYPE>

RDNumeric::Matrix< TYPE >::Matrix | ( | unsigned int | nRows,
|  | unsigned int | nCols,
|  | DATA_SPTR | data
| ) |  |
| 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 56 of file Matrix.h.

template<class TYPE>

RDNumeric::Matrix< TYPE >::Matrix | ( | const Matrix< TYPE > & | other | ) |
| inline

copy constructor

We make a copy of the other vector's data.

Definition at line 64 of file Matrix.h.

template<class TYPE>

virtual RDNumeric::Matrix< TYPE >::~Matrix | ( |  | ) |
| inlinevirtual

Definition at line 75 of file Matrix.h.

template<class TYPE>

RDNumeric::Matrix< TYPE >::Matrix | ( |  | ) |
| inlineprotected

Definition at line 231 of file Matrix.h.

## Member Function Documentation

template<class TYPE>

Matrix<TYPE>& RDNumeric::Matrix< TYPE >::assign | ( | const Matrix< TYPE > & | other | ) |
| inline

Copy operator.

We make a copy of the other Matrix's data.

Definition at line 136 of file Matrix.h.

template<class TYPE>

virtual void RDNumeric::Matrix< TYPE >::getCol | ( | unsigned int | i,
|  | Vector< TYPE > & | col
| ) |  | const
| inlinevirtual

returns a copy of a column of the matrix

Definition at line 114 of file Matrix.h.

template<class TYPE>

TYPE* RDNumeric::Matrix< TYPE >::getData | ( |  | ) |
| inline

returns a pointer to our data array

Definition at line 127 of file Matrix.h.

Referenced by RDNumeric::Matrix< double >::assign(), RDNumeric::Matrix< double >::Matrix(), RDNumeric::multiply(), RDNumeric::SquareMatrix< double >::operator*=(), RDNumeric::Matrix< double >::operator+=(), RDNumeric::Matrix< double >::operator-=(), and RDNumeric::Matrix< double >::transpose().

template<class TYPE>

const TYPE* RDNumeric::Matrix< TYPE >::getData | ( |  | ) | const
| inline

returns a const pointer to our data array

Definition at line 130 of file Matrix.h.

template<class TYPE>

unsigned int RDNumeric::Matrix< TYPE >::getDataSize | ( |  | ) | const
| inline

Definition at line 83 of file Matrix.h.

template<class TYPE>

virtual void RDNumeric::Matrix< TYPE >::getRow | ( | unsigned int | i,
|  | Vector< TYPE > & | row
| ) |  | const
| inlinevirtual

returns a copy of a row of the matrix

Definition at line 103 of file Matrix.h.

template<class TYPE>

virtual TYPE RDNumeric::Matrix< TYPE >::getVal | ( | unsigned int | i,
|  | unsigned int | j
| ) |  | const
| inlinevirtual

returns a particular element of the matrix

Definition at line 86 of file Matrix.h.

Referenced by operator<<().

template<class TYPE>

unsigned int RDNumeric::Matrix< TYPE >::numCols | ( |  | ) | const
| inline

returns the number of columns

Definition at line 81 of file Matrix.h.

Referenced by RDNumeric::Matrix< double >::assign(), RDNumeric::multiply(), RDNumeric::Matrix< double >::operator+=(), RDNumeric::Matrix< double >::operator-=(), operator<<(), and RDNumeric::Matrix< double >::transpose().

template<class TYPE>

unsigned int RDNumeric::Matrix< TYPE >::numRows | ( |  | ) | const
| inline

returns the number of rows

Definition at line 78 of file Matrix.h.

Referenced by RDNumeric::Matrix< double >::assign(), RDNumeric::multiply(), RDNumeric::SquareMatrix< double >::operator*=(), RDNumeric::Matrix< double >::operator+=(), RDNumeric::Matrix< double >::operator-=(), operator<<(), and RDNumeric::Matrix< double >::transpose().

template<class TYPE>

virtual Matrix<TYPE>& RDNumeric::Matrix< TYPE >::operator*= | ( | TYPE | scale | ) |
| inlinevirtual

Multiplication by a scalar.

Reimplemented in RDNumeric::SquareMatrix< TYPE >, and RDNumeric::SquareMatrix< double >.

Definition at line 183 of file Matrix.h.

Referenced by RDNumeric::SquareMatrix< double >::operator*=().

template<class TYPE>

virtual Matrix<TYPE>& RDNumeric::Matrix< TYPE >::operator+= | ( | const Matrix< TYPE > & | other | ) |
| inlinevirtual

Matrix addition.

Perform a element by element addition of other Matrix to this Matrix

Definition at line 151 of file Matrix.h.

template<class TYPE>

virtual Matrix<TYPE>& RDNumeric::Matrix< TYPE >::operator-= | ( | const Matrix< TYPE > & | other | ) |
| inlinevirtual

Matrix subtraction.

Perform a element by element subtraction of other Matrix from this Matrix

Definition at line 168 of file Matrix.h.

template<class TYPE>

virtual Matrix<TYPE>& RDNumeric::Matrix< TYPE >::operator/= | ( | TYPE | scale | ) |
| inlinevirtual

division by a scalar

Definition at line 193 of file Matrix.h.

template<class TYPE>

virtual void RDNumeric::Matrix< TYPE >::setVal | ( | unsigned int | i,
|  | unsigned int | j,
|  | TYPE | val
| ) |  |
| inlinevirtual

sets a particular element of the matrix

Definition at line 94 of file Matrix.h.

template<class TYPE>

virtual Matrix<TYPE>& RDNumeric::Matrix< TYPE >::transpose | ( | Matrix< TYPE > & | transpose | ) | const
| inlinevirtual

copies the transpose of this Matrix into another, returns the result

Parameters

  transpose | the Matrix to store the results

Returns
  the transpose of this matrix. This is just a reference to the argument.

Definition at line 210 of file Matrix.h.

Referenced by RDNumeric::Matrix< double >::transpose().

## Member Data Documentation

template<class TYPE>

DATA_SPTR RDNumeric::Matrix< TYPE >::d_data
| protected

Definition at line 235 of file Matrix.h.

Referenced by RDNumeric::Matrix< double >::assign(), RDNumeric::Matrix< double >::getCol(), RDNumeric::Matrix< double >::getData(), RDNumeric::Matrix< double >::getRow(), RDNumeric::Matrix< double >::getVal(), RDNumeric::Matrix< double >::Matrix(), RDNumeric::SquareMatrix< double >::operator*=(), RDNumeric::Matrix< double >::operator*=(), RDNumeric::Matrix< double >::operator+=(), RDNumeric::Matrix< double >::operator-=(), RDNumeric::Matrix< double >::operator/=(), RDNumeric::Matrix< double >::setVal(), RDNumeric::Matrix< double >::transpose(), and RDNumeric::SquareMatrix< double >::transposeInplace().

template<class TYPE>

unsigned int RDNumeric::Matrix< TYPE >::d_dataSize
| protected

Definition at line 234 of file Matrix.h.

Referenced by RDNumeric::Matrix< double >::assign(), RDNumeric::Matrix< double >::getDataSize(), RDNumeric::Matrix< double >::Matrix(), RDNumeric::SquareMatrix< double >::operator*=(), RDNumeric::Matrix< double >::operator*=(), RDNumeric::Matrix< double >::operator+=(), RDNumeric::Matrix< double >::operator-=(), and RDNumeric::Matrix< double >::operator/=().

template<class TYPE>

unsigned int RDNumeric::Matrix< TYPE >::d_nCols
| protected

Definition at line 233 of file Matrix.h.

Referenced by RDNumeric::Matrix< double >::assign(), RDNumeric::Matrix< double >::getCol(), RDNumeric::Matrix< double >::getRow(), RDNumeric::Matrix< double >::getVal(), RDNumeric::Matrix< double >::numCols(), RDNumeric::SquareMatrix< double >::operator*=(), RDNumeric::Matrix< double >::operator+=(), RDNumeric::Matrix< double >::operator-=(), RDNumeric::Matrix< double >::setVal(), RDNumeric::Matrix< double >::transpose(), and RDNumeric::SquareMatrix< double >::transposeInplace().

template<class TYPE>

unsigned int RDNumeric::Matrix< TYPE >::d_nRows
| protected

Definition at line 231 of file Matrix.h.

Referenced by RDNumeric::Matrix< double >::assign(), RDNumeric::Matrix< double >::getCol(), RDNumeric::Matrix< double >::getRow(), RDNumeric::Matrix< double >::getVal(), RDNumeric::Matrix< double >::numRows(), RDNumeric::SquareMatrix< double >::operator*=(), RDNumeric::Matrix< double >::operator+=(), RDNumeric::Matrix< double >::operator-=(), RDNumeric::Matrix< double >::setVal(), RDNumeric::Matrix< double >::transpose(), and RDNumeric::SquareMatrix< double >::transposeInplace().

The documentation for this class was generated from the following file:

- Matrix.h