ESTER
Evolution STEllaire en Rotation
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Attributes | Friends | List of all members
matrix Class Reference

The matrix class is used to facilitate the work with regular dense matrices. More...

#include <matrix.h>

Public Member Functions

 matrix (int nfil=1, int ncol=1)
 Default matrix constructor. More...
 
 ~matrix ()
 Destructor. More...
 
 matrix (const matrix &)
 Copy constructor. More...
 
int nrows () const
 Returns the number of rows of the matrix. More...
 
int ncols () const
 Returns the columns of rows of the matrix. More...
 
double * data () const
 Returns the pointer to the matrix data. More...
 
matrixdim (int nrow, int ncol)
 Re-dimension the matrix. More...
 
matrixredim (int nrow, int ncol)
 Re-dimension the matrix. More...
 
matrixoperator= (const matrix &)
 Affectation operator. More...
 
double & operator() (int irow, int icol)
 Access matrix's elements. More...
 
double & operator() (int ielem)
 Access matrix's elements. More...
 
const double & operator() (int irow, int icol) const
 Access matrix's elements. More...
 
const double & operator() (int ielem) const
 Access matrix's elements. More...
 
int read (int nrow, int ncol, FILE *fp, char mode='t')
 Reads matrix data from a file. More...
 
int write (FILE *fp=stdout, char mode='t') const
 Saves matrix to a file. More...
 
void write_fmt (const char *fmt, FILE *fp=stdout) const
 Saves matrix to a file with a special format. More...
 
void swap (matrix &)
 Swaps two matrices. More...
 
void zero (int nrows, int ncols)
 Sets the matrix to the nrows x ncols zero matrix. More...
 
void values (double,...)
 Sets the values of the matrix (given in column major order). More...
 
matrix operator+ (const matrix &) const
 Performs matrix addition. More...
 
matrix operator+ (double) const
 
matrix operator- (const matrix &) const
 
matrix operator- (double) const
 
matrix operator* (const matrix &) const
 
matrix operator* (double) const
 
matrix operator/ (const matrix &) const
 
matrix operator/ (double) const
 
matrix operator== (const matrix &) const
 
matrix operator== (double) const
 
matrix operator!= (const matrix &) const
 
matrix operator!= (double) const
 
matrix operator> (const matrix &) const
 
matrix operator> (double) const
 
matrix operator< (const matrix &a) const
 
matrix operator< (double) const
 
matrix operator>= (const matrix &) const
 
matrix operator>= (double) const
 
matrix operator<= (const matrix &a) const
 
matrix operator<= (double) const
 
matrix operator&& (const matrix &) const
 
matrix operator&& (double) const
 
matrix operator|| (const matrix &) const
 
matrix operator|| (double) const
 
matrixoperator+= (const matrix &)
 
matrixoperator-= (const matrix &)
 
matrixoperator*= (const matrix &)
 
matrixoperator/= (const matrix &)
 
matrixoperator+= (double)
 
matrixoperator-= (double)
 
matrixoperator*= (double)
 
matrixoperator/= (double)
 
const matrix row (int irow) const
 
const matrix col (int icol) const
 
const matrix block (int irow1, int irow2, int icol1, int icol2) const
 
const matrix block_step (int irow1, int irow2, int drow, int icol1, int icol2, int dcol) const
 
matrixsetrow (int irow, const matrix &)
 
matrixsetcol (int icol, const matrix &)
 
matrixsetblock (int irow1, int irow2, int icol1, int icol2, const matrix &)
 
matrixsetblock_step (int irow1, int irow2, int drow, int icol1, int icol2, int dcol, const matrix &)
 
matrix concatenate (const matrix &a, int dir=0) const
 
matrix transpose () const
 
matrix fliplr () const
 
matrix flipud () const
 
matrix operator, (const matrix &) const
 
matrix solve (matrix) const
 
matrix inv () const
 

Private Attributes

double * p
 
int nf
 
int nc
 

Friends

class matrix_block_diag
 
matrix operator- (double, const matrix &)
 
matrix operator- (const matrix &)
 
matrix operator/ (double, const matrix &)
 
matrix ones (int nfil, int ncol)
 
matrix zeros (int nfil, int ncol)
 
matrix random_matrix (int nfil, int ncol)
 
matrix eye (int n)
 
matrix vector (double x0, double x1, int n)
 
matrix vector_t (double x0, double x1, int n)
 
double max (const matrix &)
 
double min (const matrix &)
 
double sum (const matrix &)
 
double mean (const matrix &)
 
matrix max (const matrix &, const matrix &)
 
matrix max (const matrix &, double)
 
matrix max (double, const matrix &)
 
matrix min (const matrix &, const matrix &)
 
matrix min (const matrix &, double)
 
matrix min (double, const matrix &)
 
int exist (const matrix &)
 
int isequal (const matrix &, const matrix &)
 
matrix cos (const matrix &)
 
matrix sin (const matrix &)
 
matrix tan (const matrix &)
 
matrix acos (const matrix &)
 
matrix asin (const matrix &)
 
matrix atan (const matrix &)
 
matrix cosh (const matrix &)
 
matrix sinh (const matrix &)
 
matrix tanh (const matrix &)
 
matrix exp (const matrix &)
 
matrix log (const matrix &)
 
matrix log10 (const matrix &)
 
matrix sqrt (const matrix &)
 
matrix abs (const matrix &)
 
matrix floor (const matrix &)
 
matrix ceil (const matrix &)
 
matrix round (const matrix &)
 
matrix atan2 (const matrix &, const matrix &)
 
matrix atan2 (double, const matrix &)
 
matrix atan2 (const matrix &, double)
 
matrix pow (const matrix &, const matrix &)
 
matrix pow (double, const matrix &)
 
matrix pow (const matrix &, double)
 
matrix pow (const matrix &, int)
 

Detailed Description

The matrix class is used to facilitate the work with regular dense matrices.

Constructor & Destructor Documentation

matrix::matrix ( int  nfil = 1,
int  ncol = 1 
)
explicit

Default matrix constructor.

Creates an nfil rows by ncol columns matrix. If nfil and ncol are omitted, defaults are 1.

matrix::~matrix ( )

Destructor.

matrix::matrix ( const matrix a)

Copy constructor.

Creates a new matrix object identical to a.

Member Function Documentation

const matrix matrix::block ( int  irow1,
int  irow2,
int  icol1,
int  icol2 
) const
const matrix matrix::block_step ( int  irow1,
int  irow2,
int  drow,
int  icol1,
int  icol2,
int  dcol 
) const
const matrix matrix::col ( int  icol) const
matrix matrix::concatenate ( const matrix a,
int  dir = 0 
) const

Here is the call graph for this function:

double * matrix::data ( ) const

Returns the pointer to the matrix data.

matrix & matrix::dim ( int  nfil,
int  ncol 
)

Re-dimension the matrix.

Updates the matrix dimension.

Returns
the updated matrix object.
matrix matrix::fliplr ( ) const
matrix matrix::flipud ( ) const
matrix matrix::inv ( ) const

Here is the call graph for this function:

int matrix::ncols ( ) const

Returns the columns of rows of the matrix.

int matrix::nrows ( ) const

Returns the number of rows of the matrix.

matrix matrix::operator!= ( const matrix a) const

Here is the call graph for this function:

matrix matrix::operator!= ( double  n) const
matrix matrix::operator&& ( const matrix a) const

Here is the call graph for this function:

matrix matrix::operator&& ( double  n) const
double & matrix::operator() ( int  irow,
int  icol 
)

Access matrix's elements.

double & matrix::operator() ( int  ielem)

Access matrix's elements.

const double & matrix::operator() ( int  irow,
int  icol 
) const

Access matrix's elements.

const double & matrix::operator() ( int  ielem) const

Access matrix's elements.

matrix matrix::operator* ( const matrix a) const

Here is the call graph for this function:

matrix matrix::operator* ( double  n) const
matrix & matrix::operator*= ( const matrix a)
matrix & matrix::operator*= ( double  n)
matrix matrix::operator+ ( const matrix a) const

Performs matrix addition.

The matrices must be of the same size.

Returns
Result of the element-wise addition of the two matrices.

Here is the call graph for this function:

matrix matrix::operator+ ( double  n) const
matrix & matrix::operator+= ( const matrix a)
matrix & matrix::operator+= ( double  n)
matrix matrix::operator, ( const matrix a) const
matrix matrix::operator- ( const matrix a) const

Here is the call graph for this function:

matrix matrix::operator- ( double  n) const
matrix & matrix::operator-= ( const matrix a)
matrix & matrix::operator-= ( double  n)
matrix matrix::operator/ ( const matrix a) const

Here is the call graph for this function:

matrix matrix::operator/ ( double  n) const
matrix & matrix::operator/= ( const matrix a)
matrix & matrix::operator/= ( double  n)
matrix matrix::operator< ( const matrix a) const
inline
matrix matrix::operator< ( double  n) const
matrix matrix::operator<= ( const matrix a) const
inline
matrix matrix::operator<= ( double  n) const
matrix & matrix::operator= ( const matrix a)

Affectation operator.

Here is the call graph for this function:

matrix matrix::operator== ( const matrix a) const

Here is the call graph for this function:

matrix matrix::operator== ( double  n) const
matrix matrix::operator> ( const matrix a) const

Here is the call graph for this function:

matrix matrix::operator> ( double  n) const
matrix matrix::operator>= ( const matrix a) const

Here is the call graph for this function:

matrix matrix::operator>= ( double  n) const
matrix matrix::operator|| ( const matrix a) const

Here is the call graph for this function:

matrix matrix::operator|| ( double  n) const
int matrix::read ( int  nrow,
int  ncol,
FILE *  fp,
char  mode = 't' 
)

Reads matrix data from a file.

Here is the call graph for this function:

matrix & matrix::redim ( int  nfil,
int  ncol 
)

Re-dimension the matrix.

Updates the matrix dimension. The new full matrix (nfil x ncol) size must match the original matrix size (nrows() x ncols()).

Returns
the updated matrix object.
const matrix matrix::row ( int  irow) const
matrix & matrix::setblock ( int  irow1,
int  irow2,
int  icol1,
int  icol2,
const matrix a 
)
matrix & matrix::setblock_step ( int  irow1,
int  irow2,
int  drow,
int  icol1,
int  icol2,
int  dcol,
const matrix a 
)
matrix & matrix::setcol ( int  icol,
const matrix a 
)
matrix & matrix::setrow ( int  irow,
const matrix a 
)
matrix matrix::solve ( matrix  b) const

Here is the call graph for this function:

void matrix::swap ( matrix a)

Swaps two matrices.

matrix matrix::transpose ( ) const
void matrix::values ( double  x,
  ... 
)

Sets the values of the matrix (given in column major order).

Here is the call graph for this function:

int matrix::write ( FILE *  fp = stdout,
char  mode = 't' 
) const

Saves matrix to a file.

void matrix::write_fmt ( const char *  fmt,
FILE *  fp = stdout 
) const

Saves matrix to a file with a special format.

fmt is the printf format used to save the matrix data to the file.

void matrix::zero ( int  nrows,
int  ncols 
)

Sets the matrix to the nrows x ncols zero matrix.

Here is the call graph for this function:

Friends And Related Function Documentation

matrix abs ( const matrix a)
friend
matrix acos ( const matrix a)
friend
matrix asin ( const matrix a)
friend
matrix atan ( const matrix a)
friend
matrix atan2 ( const matrix a,
const matrix b 
)
friend
matrix atan2 ( double  n,
const matrix a 
)
friend
matrix atan2 ( const matrix a,
double  n 
)
friend
matrix ceil ( const matrix a)
friend
matrix cos ( const matrix a)
friend
matrix cosh ( const matrix a)
friend
int exist ( const matrix a)
friend
matrix exp ( const matrix a)
friend
matrix eye ( int  n)
friend
matrix floor ( const matrix a)
friend
int isequal ( const matrix a,
const matrix b 
)
friend
matrix log ( const matrix a)
friend
matrix log10 ( const matrix a)
friend
friend class matrix_block_diag
friend
double max ( const matrix a)
friend
matrix max ( const matrix a,
const matrix b 
)
friend
matrix max ( const matrix a,
double  n 
)
friend
matrix max ( double  n,
const matrix a 
)
friend
double mean ( const matrix a)
friend
double min ( const matrix a)
friend
matrix min ( const matrix a,
const matrix b 
)
friend
matrix min ( const matrix a,
double  n 
)
friend
matrix min ( double  n,
const matrix a 
)
friend
matrix ones ( int  nfil,
int  ncol 
)
friend
matrix operator- ( double  n,
const matrix a 
)
friend
matrix operator- ( const matrix a)
friend
matrix operator/ ( double  n,
const matrix a 
)
friend
matrix pow ( const matrix a,
const matrix b 
)
friend
matrix pow ( double  n,
const matrix a 
)
friend
matrix pow ( const matrix a,
double  n 
)
friend
matrix pow ( const matrix a,
int  n 
)
friend
matrix random_matrix ( int  nfil,
int  ncol 
)
friend
matrix round ( const matrix a)
friend
matrix sin ( const matrix a)
friend
matrix sinh ( const matrix a)
friend
matrix sqrt ( const matrix a)
friend
double sum ( const matrix a)
friend
matrix tan ( const matrix a)
friend
matrix tanh ( const matrix a)
friend
matrix vector ( double  x0,
double  x1,
int  n 
)
friend
matrix vector_t ( double  x0,
double  x1,
int  n 
)
friend
matrix zeros ( int  nfil,
int  ncol 
)
friend

Member Data Documentation

int matrix::nc
private
int matrix::nf
private
double* matrix::p
private

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