MyraMath
Public Types | Public Member Functions | Static Public Member Functions | List of all members
myra::Matrix< Number > Class Template Reference

Tabulates an IxJ matrix. Allows random access, has column major layout to be compatible with BLAS/LAPACK. More...

#include <Matrix.h>

Public Types

typedef std::pair< MatrixRange< Number >, MatrixRange< Number > > Pair
 Useful typedefs.
 
typedef std::pair< CMatrixRange< Number >, CMatrixRange< Number > > CPair
 

Public Member Functions

 Matrix ()
 Default constructor, makes size 0x0 empty Matrix.
 
 Matrix (const Expression< 2, Number > &e)
 Constructs a Matrix from an Expression.
 
 Matrix (const Matrix &that)
 Copy constructor.
 
void swap (Matrix &that)
 Member swap.
 
 Matrix (Matrix &&that)
 Move constructor, default construct and swap idiom.
 
Matrix< Number > & operator= (Matrix that)
 Copy-assignment operator, copy construct and swap idiom.
 
 Matrix (const CMatrixRange< Number > &that)
 Constructs from a MatrixRange (same size, values copied).
 
 Matrix (InputStream &in)
 InputStream constructor, complements write(OutputStream) method.
 
void write (OutputStream &out) const
 Writes to OutputStream, complements InputStream constructor.
 
const Matrix< Number > & add_const () const
 Returns const reference to *this.
 
 ~Matrix ()
 Releases internal resources.
 
std::pair< int, int > size () const
 Size inspector.
 
uint64_t n_words () const
 Storage requirements.
 
template<class Functor >
void transform (const Functor &f)
 Overwrites every A(i,j) in this Matrix with f(A(i,j)).
 
template<class Functor >
void transform_triangle (const Functor &f, char uplo)
 Overwrites every A(i,j) in the 'U'pper or 'L'ower triangle of this Matrix with f(A(i,j)).
 
template<class Functor >
void transform_diagonal (const Functor &f)
 Overwrites every A(ij,ij) on the diagonal of this Matrix with f(A(ij,ij)).
 
void operator*= (Number alpha)
 Scales this *= alpha.
 
void operator/= (Number alpha)
 Scales this /= alpha.
 
Matrix< Number > operator- ()
 Unary minus (sign negation).
 
 Matrix (int I, int J)
 Constructs a Matrix of size IxJ, filled with Number(0)
 
 Matrix (std::pair< int, int > IJ)
 Constructs a Matrix of size IxJ, filled with Number(0)
 
CMatrixRange< Number > range () const
 Explicit conversion, returns a MatrixRange over all of *this.
 
MatrixRange< Number > range ()
 Explicit conversion, returns a MatrixRange over all of *this.
 
 operator const CMatrixRange< Number > () const
 Implicit conversion into a MatrixRange.
 
 operator const MatrixRange< Number > ()
 Implicit conversion into a MatrixRange.
 
CMatrixRange< Number > window (int i0, int i1, int j0, int j1) const
 Returns a MatrixRange over this(i0:i1,j0:j1)
 
MatrixRange< Number > window (int i0, int i1, int j0, int j1)
 Returns a MatrixRange over this(i0:i1,j0:j1)
 
Array2< CMatrixRange< Number > > windows (const intCRange &i, const intCRange &j) const
 Tile rows and columns using given sizes.
 
Array2< MatrixRange< Number > > windows (const intCRange &i, const intCRange &j)
 Tile rows and columns using given sizes.
 
CVectorRange< Number > vector (int j) const
 Returns the j'th column as a VectorRange.
 
VectorRange< Number > vector (int j)
 Returns the j'th column as a VectorRange.
 
const Number & operator() (int i, int j) const
 Random accessor/mutator.
 
Number & operator() (int i, int j)
 Random accessor/mutator.
 
const Number & at (int i, int j) const
 Bounds checked random accessor/mutator.
 
Number & at (int i, int j)
 Bounds checked random accessor/mutator.
 
CMatrixRange< Number > row (int i) const
 Returns a MatrixRange over this(i,:)
 
MatrixRange< Number > row (int i)
 Returns a MatrixRange over this(i,:)
 
CMatrixRange< Number > rows (int i0, int i1) const
 Returns a MatrixRange over this(i0:i1,:)
 
MatrixRange< Number > rows (int i0, int i1)
 Returns a MatrixRange over this(i0:i1,:)
 
Array1< CMatrixRange< Number > > rows (const intCRange &i) const
 Returns {this.rows(0:i0,:), this.rows(i0:i0+i1,:), ...}, tiling by rows.
 
Array1< MatrixRange< Number > > rows (const intCRange &i)
 Returns {this.rows(0:i0,:), this.rows(i0:i0+i1,:), ...}, tiling by rows.
 
CMatrixRange< Number > top (int i) const
 Returns a MatrixRange over the i topmost rows, this(0:i,:)
 
MatrixRange< Number > top (int i)
 Returns a MatrixRange over the i topmost rows, this(0:i,:)
 
CMatrixRange< Number > cut_top (int i) const
 Returns a MatrixRange that cuts the i topmost rows, this(i:I,:)
 
MatrixRange< Number > cut_top (int i)
 Returns a MatrixRange that cuts the i topmost rows, this(i:I,:)
 
CPair split_top (int i) const
 Splits by rows, returns [this->top(i), this->cut_top(i)].
 
Pair split_top (int i)
 Splits by rows, returns [this->top(i), this->cut_top(i)].
 
CMatrixRange< Number > bottom (int i) const
 Returns a MatrixRange over the i bottommost rows, this(I-i:I,:)
 
MatrixRange< Number > bottom (int i)
 Returns a MatrixRange over the i bottommost rows, this(I-i:I,:)
 
CMatrixRange< Number > cut_bottom (int i) const
 Returns a MatrixRange that cuts the i bottommost rows, this(0:I-i,:)
 
MatrixRange< Number > cut_bottom (int i)
 Returns a MatrixRange that cuts the i bottommost rows, this(0:I-i,:)
 
CPair split_bottom (int i) const
 Splits by rows, returns [this->cut_bottom(i), this->bottom(i)].
 
Pair split_bottom (int i)
 Splits by rows, returns [this->cut_bottom(i), this->bottom(i)].
 
CMatrixRange< Number > column (int j) const
 Returns a MatrixRange over this(:,j)
 
MatrixRange< Number > column (int j)
 Returns a MatrixRange over this(:,j)
 
CMatrixRange< Number > columns (int j0, int j1) const
 Returns a MatrixRange over this(:,j0:j1)
 
MatrixRange< Number > columns (int j0, int j1)
 Returns a MatrixRange over this(:,j0:j1)
 
Array1< CMatrixRange< Number > > columns (const intCRange &j) const
 Returns {this.columns(:,0:j0), this.columns(:,j0:j0+j1), ...}, tiling by columns.
 
Array1< MatrixRange< Number > > columns (const intCRange &j)
 Returns {this.columns(:,0:j0), this.columns(:,j0:j0+j1), ...}, tiling by columns.
 
CMatrixRange< Number > left (int j) const
 Returns a MatrixRange over the j leftmost columns, this(:,0:j)
 
MatrixRange< Number > left (int j)
 Returns a MatrixRange over the j leftmost columns, this(:,0:j)
 
CMatrixRange< Number > cut_left (int j) const
 Returns a MatrixRange that cuts the j leftmost columns, this(:,j:J)
 
MatrixRange< Number > cut_left (int j)
 Returns a MatrixRange that cuts the j leftmost columns, this(:,j:J)
 
CPair split_left (int j) const
 Splits by columns, returns [this->left(j), this->cut_left(j)].
 
Pair split_left (int j)
 Splits by columns, returns [this->left(j), this->cut_left(j)].
 
CMatrixRange< Number > right (int j) const
 Returns a MatrixRange over the j rightmost columns, this(:,J-j:J)
 
MatrixRange< Number > right (int j)
 Returns a MatrixRange over the j rightmost columns, this(:,J-j:J)
 
CMatrixRange< Number > cut_right (int j) const
 Returns a MatrixRange that cuts the j rightmost columns, this(:,0:J-j)
 
MatrixRange< Number > cut_right (int j)
 Returns a MatrixRange that cuts the j rightmost columns, this(:,0:J-j)
 
CPair split_right (int j) const
 Splits by columns, returns [this->cut_right(j), this->right(j)].
 
Pair split_right (int j)
 Splits by columns, returns [this->cut_right(j), this->right(j)].
 
Matrix< Number > & operator= (const CMatrixRange< Number > &that)
 Assigns this = that.
 
Matrix< Number > & operator= (const Expression< 2, Number > &that)
 Assigns this = that.
 
void assign (const CMatrixRange< Number > &that)
 Like operator =, but does not reallocate/resize. Requires matching sizes.
 
void assign (const CMatrixRange< Number > &that, char op)
 Like operator =, but does not reallocate/resize. Requires matching sizes.
 
void assign (const Expression< 2, Number > &that)
 Like operator =, but does not reallocate/resize. Requires matching sizes.
 
void operator+= (const CMatrixRange< Number > &that)
 Adds this += that.
 
void operator+= (const Expression< 2, Number > &that)
 Adds this += that.
 
void operator-= (const CMatrixRange< Number > &that)
 Subtracts this -= that.
 
void operator-= (const Expression< 2, Number > &that)
 Subtracts this -= that.
 

Static Public Member Functions

static Matrix< Number > identity (int IJ)
 Generates an identity Matrix of specified size.
 
static Matrix< Number > random (int I, int J)
 Generates a random Matrix of specified size.
 
static Matrix< Number > zeros (int I, int J)
 Generates a zeros Matrix of specified size.
 
static Matrix< Number > ones (int I, int J)
 Generates a ones Matrix of specified size.
 
static Matrix< Number > fill (int I, int J, Number c)
 Generates a Matrix of specified size filled with constant c.
 
static Matrix< Number > fill_cmajor (int I, int J, std::initializer_list< Number > list)
 Generates a Matrix of specified size, filled from a std::initializer_list.
 
static Matrix< Number > fill_rmajor (int I, int J, std::initializer_list< Number > list)
 
static Matrix< Number > evaluate (const Expression< 2, Number > &e)
 Generates a Matrix by evaluating an arity-2 Expression of Number.
 

Detailed Description

template<class Number>
class myra::Matrix< Number >

Tabulates an IxJ matrix. Allows random access, has column major layout to be compatible with BLAS/LAPACK.


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