Public Member Functions | Protected Attributes | Friends
fMat Class Reference

Matrix of generic size. The elements are stored in a one-dimensional array in row-major order. More...

#include <fMatrix.h>

Inheritance diagram for fMat:
Inheritance graph
[legend]

List of all members.

Public Member Functions

int col () const
 Returns the number of columns.
double * data () const
 Returns the pointer to the first element.
void ddiv (const fMat &mat1, const fMat &mat2)
 Element-wise division: ./ operator in MATLAB.
double det (void)
 Computes the determinant.
void dmul (const fMat &mat1, const fMat &mat2)
 Element-wise multiplication: .* operator in MATLAB.
int eig (fVec &wr, fVec &wi)
 Computes the eigenvalues.
int eig (fVec &wr, fVec &wi, fMat &v)
 Computes the eigenvalues and eigenvectors.
int eig (fVec &wr, fVec &wi, fMat &vr, fMat &vi)
 Computes the eigenvalues and eigenvectors.
 fMat ()
 Default constructor.
 fMat (int m, int n, double *ini=0)
 Constructor with size and initial values (optional).
 fMat (int m, int n, double ini)
 Constructor with size and common initial values.
 fMat (const fMat &ini)
 Copy constructor.
 fMat (const fVec &ini)
 Constructor from a vector.
void get_submat (int row_start, int col_start, const fMat &allM)
 Extract a sub-matrix and set to myself.
void identity ()
 Creates an identity matrix (only for square matrices).
int info ()
 Returns the value of m_info.
int inv_porfs (const fMat &)
 inverse of positive-definite, symmetric matrix
int inv_posv (const fMat &)
 inverse of positive-definite, symmetric matrix
int lineq_porfs (const fMat &A, const fMat &b)
 solve linear equation Ax = b, where A is positive-definite, symmetric
int lineq_posv (const fMat &A, const fMat &b)
 solve linear equation Ax = b, where A is positive-definite, symmetric
 operator double * ()
 Converts to an array of double.
double & operator() (int i, int j)
 Returns the (non-constant) reference to the (i,j) element.
double operator() (int i, int j) const
 Returns the value of the (i,j) element.
fMat operator= (const fMat &mat)
 Assignment from a reference matrix.
void operator= (double d)
 Assigns the same value to all elements.
int resize (int i, int j)
 Changes the matrix size.
int row () const
 Returns the number of rows.
void set (double *_d)
 Sets the values from an array.
void set_submat (int row_start, int col_start, const fMat &subM)
 Sets a sub-matrix of myself.
void setinfo (int _info)
 Sets m_info.
int svd (fMat &U, fVec &Sigma, fMat &VT)
 singular value decomposition
void symmetric (char t= 'U')
 Change to symmetric matrix.
void tran (const fMat &mat)
 Sets the transpose of a matrix.
void tran ()
 Transposes a matrix (only for square matrices).
void zero ()
 Creates a zero matrix.
 ~fMat ()
 Destructor.
functions

Operators in function forms (faster).

void set (const fMat &mat)
void neg (const fMat &mat)
void add (const fMat &mat1, const fMat &mat2)
void add (const fMat &mat)
void sub (const fMat &mat1, const fMat &mat2)
void mul (const fMat &mat1, const fMat &mat2)
void mul (double d, const fMat &mat)
void mul (const fMat &mat, double d)
void mul_tran (const fMat &mat1, int trans_first)
void div (const fMat &mat, double d)

Protected Attributes

int m_info
int n_col
int n_row
double * p_data
double temp

Friends

fMat eigs (const fMat &mat, double *w)
 Compute the eigenvalues.
fMat eigs2 (const fMat &mat, double *w)
 Compute the eigenvalues.
int inv_col_replaced (const fMat &P, const fMat &q, const fMat &m2d, fMat &X, fMat &y)
 Computes the inverse when some columns are replaced.
int inv_enlarge (const fMat &m12, const fMat &m21, const fMat &m22, const fMat &P, fMat &X, fMat &y, fMat &z, fMat &w)
 Computes the inverse of an enlarged matrix.
int inv_row_replaced (const fMat &P, const fMat &q, const fMat &m2d, fMat &X, fMat &y)
 Computes the inverse when some rows are replaced.
int inv_shrink (const fMat &P, const fMat &q, const fMat &r, const fMat &s, fMat &X)
 Computes the inverse of a shrinked matrix.
ostream & operator<< (ostream &ost, const fMat &mat)
 Outputs to a stream.
fMat tran (const fMat &mat)
 Returns the transpose of a matrix.

friend

Member function versions.

int inv (const fMat &)
 inverse
int p_inv (const fMat &)
 pseudo inverse
int sr_inv (const fMat &mat, fVec &w_err, fVec &w_norm, double k)
 singularity-robust (SR) inverse
int lineq (const fMat &A, const fMat &b)
 solve linear equation Ax = b
int lineq_sr (const fMat &A, fVec &w_err, fVec &w_norm, double k, const fMat &b)
 solve linear equation Ax = b using SR-inverse
int inv_svd (const fMat &, int lwork=-1)
 inverse
int p_inv_svd (const fMat &, int lwork=-1)
 pseudo inverse
int sr_inv_svd (const fMat &mat, fVec &w_err, fVec &w_norm, double k, int lwork=-1)
 SR-inverse.
int lineq_svd (const fMat &A, const fMat &b, int lwork=-1)
 solve linear equation Ax = b
fMat inv (const fMat &mat)
 inverse
fMat p_inv (const fMat &mat)
 pseudo inverse
fMat sr_inv (const fMat &mat, fVec &w_err, fVec &w_norm, double k)
 singularity-robust (SR) inverse
fMat lineq (const fMat &A, const fMat &b)
 solve linear equation Ax = b
fMat lineq_sr (const fMat &A, fVec &w_err, fVec &w_norm, double k, const fMat &b)
 solve linear equation Ax = b using SR-inverse
fMat inv_svd (const fMat &mat, int lwork)
 inverse
fMat p_inv_svd (const fMat &mat, int lwork)
 pseudo inverse
fMat sr_inv_svd (const fMat &mat, fVec &w_err, fVec &w_norm, double k, int lwork)
 SR-inverse.
fMat lineq_svd (const fMat &A, const fMat &b, int lwork)
 solve linear equation Ax = b

operators

Operators.

void operator+= (const fMat &mat)
void operator-= (const fMat &mat)
void operator*= (double d)
void operator/= (double d)
fMat operator- (const fMat &mat)
fMat operator+ (const fMat &mat1, const fMat &mat2)
fMat operator- (const fMat &mat1, const fMat &mat2)
fMat operator* (const fMat &mat1, const fMat &mat2)
fVec operator* (const fMat &mat, const fVec &vec)
fMat operator* (double d, const fMat &mat)
fMat operator* (const fMat &mat, double d)
fMat operator/ (const fMat &mat, double d)

Detailed Description

Matrix of generic size. The elements are stored in a one-dimensional array in row-major order.

Definition at line 46 of file fMatrix.h.


Constructor & Destructor Documentation

fMat::fMat ( ) [inline]

Default constructor.

Creates an empty matrix with size 0x0.

Definition at line 53 of file fMatrix.h.

fMat::fMat ( int  m,
int  n,
double *  ini = 0 
) [inline]

Constructor with size and initial values (optional).

Creates a matrix with specific size and initial values.

Parameters:
[in]mRow size.
[in]nColumn size.
[in]iniArray of initial values; should have at least mxn elements (optional).

Definition at line 67 of file fMatrix.h.

fMat::fMat ( int  m,
int  n,
double  ini 
) [inline]

Constructor with size and common initial values.

Creates a matrix with specific size and the same initial values.

Parameters:
[in]mRow size.
[in]nColumn size.
[in]iniInitial value for all elements.

Definition at line 87 of file fMatrix.h.

fMat::fMat ( const fMat ini) [inline]

Copy constructor.

Creates a matrix with the same size and elements as the original.

Parameters:
[in]iniThe reference matrix.

Definition at line 102 of file fMatrix.h.

fMat::fMat ( const fVec ini)

Constructor from a vector.

Creates an nx1 matrix from a vector.

Parameters:
[in]iniThe reference vector.

fMat

Definition at line 21 of file fMatrix.cpp.

fMat::~fMat ( ) [inline]

Destructor.

Definition at line 120 of file fMatrix.h.


Member Function Documentation

void fMat::add ( const fMat mat1,
const fMat mat2 
)

Definition at line 1169 of file fMatrix.cpp.

void fMat::add ( const fMat mat)

Definition at line 1180 of file fMatrix.cpp.

int fMat::col ( ) const [inline]

Returns the number of columns.

Definition at line 154 of file fMatrix.h.

double* fMat::data ( ) const [inline]

Returns the pointer to the first element.

Definition at line 193 of file fMatrix.h.

void fMat::ddiv ( const fMat mat1,
const fMat mat2 
)

Element-wise division: ./ operator in MATLAB.

Definition at line 1737 of file fMatrix.cpp.

double fMat::det ( void  )

Computes the determinant.

Definition at line 1785 of file fMatrix.cpp.

void fMat::div ( const fMat mat,
double  d 
)

Definition at line 1428 of file fMatrix.cpp.

void fMat::dmul ( const fMat mat1,
const fMat mat2 
)

Element-wise multiplication: .* operator in MATLAB.

Definition at line 1688 of file fMatrix.cpp.

int fMat::eig ( fVec wr,
fVec wi 
)

Computes the eigenvalues.

Computes the eigenvalues.

Parameters:
[out]wrVector of the real parts.
[out]wiVector of the imaginary parts.

Definition at line 1800 of file fMatrix.cpp.

int fMat::eig ( fVec wr,
fVec wi,
fMat v 
)

Computes the eigenvalues and eigenvectors.

Computes the eigenvalues and eigenvectors.

Parameters:
[out]wrVector of the real parts of the eigenvalues.
[out]wiVector of the imaginary parts of the eigenvlaues.
[out]vEigenvectors.

Definition at line 1819 of file fMatrix.cpp.

int fMat::eig ( fVec wr,
fVec wi,
fMat vr,
fMat vi 
)

Computes the eigenvalues and eigenvectors.

Computes the eigenvalues and eigenvectors.

Parameters:
[out]wrVector of the real parts of the eigenvalues.
[out]wiVector of the imaginary parts of the eigenvlaues.
[out]vrReal parts of the eigenvectors.
[out]viImaginary parts of the eigenvectors.

Definition at line 1840 of file fMatrix.cpp.

void fMat::get_submat ( int  row_start,
int  col_start,
const fMat allM 
)

Extract a sub-matrix and set to myself.

Extracts an n_row x n_col sub-matrix from a large matrix.

Parameters:
[in]row_startFirst row to extract.
[in]col_startFirst column to extract.
[in]allMThe original matrix.

Definition at line 32 of file fMatrix.cpp.

Creates an identity matrix (only for square matrices).

Definition at line 1058 of file fMatrix.cpp.

int fMat::info ( ) [inline]

Returns the value of m_info.

Definition at line 162 of file fMatrix.h.

inverse

inverse of positive-definite, symmetric matrix

Definition at line 780 of file fMatrix.cpp.

inverse of positive-definite, symmetric matrix

Definition at line 757 of file fMatrix.cpp.

int fMat::inv_svd ( const fMat ,
int  lwork = -1 
)

inverse

int fMat::lineq ( const fMat A,
const fMat b 
)

solve linear equation Ax = b

int fMat::lineq_porfs ( const fMat A,
const fMat b 
)

solve linear equation Ax = b, where A is positive-definite, symmetric

Definition at line 772 of file fMatrix.cpp.

int fMat::lineq_posv ( const fMat A,
const fMat b 
)

solve linear equation Ax = b, where A is positive-definite, symmetric

Definition at line 746 of file fMatrix.cpp.

int fMat::lineq_sr ( const fMat A,
fVec w_err,
fVec w_norm,
double  k,
const fMat b 
)

solve linear equation Ax = b using SR-inverse

int fMat::lineq_svd ( const fMat A,
const fMat b,
int  lwork = -1 
)

solve linear equation Ax = b

void fMat::mul ( const fMat mat1,
const fMat mat2 
)

Definition at line 1217 of file fMatrix.cpp.

void fMat::mul ( double  d,
const fMat mat 
)

Definition at line 1116 of file fMatrix.cpp.

void fMat::mul ( const fMat mat,
double  d 
)

Definition at line 1123 of file fMatrix.cpp.

void fMat::mul_tran ( const fMat mat1,
int  trans_first 
)

Definition at line 1241 of file fMatrix.cpp.

void fMat::neg ( const fMat mat)

Definition at line 1081 of file fMatrix.cpp.

fMat::operator double * ( ) [inline]

Converts to an array of double.

Definition at line 197 of file fMatrix.h.

double& fMat::operator() ( int  i,
int  j 
) [inline]

Returns the (non-constant) reference to the (i,j) element.

Definition at line 171 of file fMatrix.h.

double fMat::operator() ( int  i,
int  j 
) const [inline]

Returns the value of the (i,j) element.

Definition at line 177 of file fMatrix.h.

void fMat::operator*= ( double  d)

Reimplemented in fVec.

Definition at line 1110 of file fMatrix.cpp.

void fMat::operator+= ( const fMat mat)

Definition at line 1096 of file fMatrix.cpp.

void fMat::operator-= ( const fMat mat)

Definition at line 1103 of file fMatrix.cpp.

void fMat::operator/= ( double  d)

Reimplemented in fVec.

Definition at line 1146 of file fMatrix.cpp.

fMat fMat::operator= ( const fMat mat)

Assignment from a reference matrix.

Definition at line 1152 of file fMatrix.cpp.

void fMat::operator= ( double  d)

Assigns the same value to all elements.

Reimplemented in fVec.

Definition at line 1163 of file fMatrix.cpp.

pseudo inverse

int fMat::p_inv_svd ( const fMat ,
int  lwork = -1 
)

pseudo inverse

int fMat::resize ( int  i,
int  j 
) [inline]

Changes the matrix size.

Changes the size of the matrix. If the new size is the same as the previous, nothing happens (memory is not re-allocated). The values are not initialized.

Parameters:
[in]iThe new row size.
[in]jThe new column size.
Returns:
0 in success, -1 if some error happens.

Definition at line 133 of file fMatrix.h.

int fMat::row ( ) const [inline]

Returns the number of rows.

Definition at line 158 of file fMatrix.h.

void fMat::set ( double *  _d) [inline]

Sets the values from an array.

Reimplemented in fVec.

Definition at line 187 of file fMatrix.h.

void fMat::set ( const fMat mat)

Definition at line 1074 of file fMatrix.cpp.

void fMat::set_submat ( int  row_start,
int  col_start,
const fMat subM 
)

Sets a sub-matrix of myself.

Sets subM as an subM.n_row x subM.n_col sub-matrix of myself.

Parameters:
[in]row_startFirst row to set.
[in]col_startFirst column to set.
[in]subMThe original matrix.

Definition at line 48 of file fMatrix.cpp.

void fMat::setinfo ( int  _info) [inline]

Sets m_info.

Definition at line 166 of file fMatrix.h.

int fMat::sr_inv ( const fMat mat,
fVec w_err,
fVec w_norm,
double  k 
)

singularity-robust (SR) inverse

int fMat::sr_inv_svd ( const fMat mat,
fVec w_err,
fVec w_norm,
double  k,
int  lwork = -1 
)

SR-inverse.

void fMat::sub ( const fMat mat1,
const fMat mat2 
)

Definition at line 1196 of file fMatrix.cpp.

int fMat::svd ( fMat U,
fVec Sigma,
fMat VT 
)

singular value decomposition

Performs singular-value decomposition (SVD) M = U*S*V^T.

Parameters:
[out]UAn mxm matrix.
[out]SigmaVector of min(m, n) elements containing the diagonal elements of S
[out]VTAn nxn matrix, transpose of V.

Definition at line 733 of file fMatrix.cpp.

void fMat::symmetric ( char  t = 'U')

Change to symmetric matrix.

Creates a symmetric matrix

Parameters:
[in]tCommand- 'A': average, 'U': use upper triangle, 'L': use lower triangle

Definition at line 88 of file fMatrix.cpp.

void fMat::tran ( const fMat mat)

Sets the transpose of a matrix.

Transposes a matrix (only for square matrices).

Definition at line 1040 of file fMatrix.cpp.

void fMat::zero ( ) [inline]

Creates a zero matrix.

Reimplemented in fVec.

Definition at line 249 of file fMatrix.h.


Friends And Related Function Documentation

fMat eigs ( const fMat mat,
double *  w 
) [friend]

Compute the eigenvalues.

Definition at line 1659 of file fMatrix.cpp.

fMat eigs2 ( const fMat mat,
double *  w 
) [friend]

Compute the eigenvalues.

int fMat::inv ( const fMat mat) [friend]

inverse

Definition at line 176 of file fMatrix.cpp.

int inv_col_replaced ( const fMat P,
const fMat q,
const fMat m2d,
fMat X,
fMat y 
) [friend]

Computes the inverse when some columns are replaced.

Computes the inverse when some columns are replaced:

	   | X | = | M1  m2' |-1
	   | y |                

where

	   | P | = | M1  m2 |-1
	   | q |   |        |  

are known

Definition at line 1357 of file fMatrix.cpp.

int inv_enlarge ( const fMat m12,
const fMat m21,
const fMat m22,
const fMat P,
fMat X,
fMat y,
fMat z,
fMat w 
) [friend]

Computes the inverse of an enlarged matrix.

Computes the inverse of an enlarged matrix:

	   | X  y | = | M11  m12 |-1
	   | z  w |   | m21  m22 |  

where M11, m12, m21, m22, and P=M11^{-1} are known

Definition at line 1288 of file fMatrix.cpp.

int inv_row_replaced ( const fMat P,
const fMat q,
const fMat m2d,
fMat X,
fMat y 
) [friend]

Computes the inverse when some rows are replaced.

Computes the inverse when some rows are replaced:

	   | X  y | = | M1  |-1
	   |      |   | m2' |  

where

	   | P  q | = | M1 |-1
	   |      |   | m2 |  

are known

Definition at line 1334 of file fMatrix.cpp.

int inv_shrink ( const fMat P,
const fMat q,
const fMat r,
const fMat s,
fMat X 
) [friend]

Computes the inverse of a shrinked matrix.

Computes the inverse of a shrinked matrix: X = M11^(-1) where

	   | P  q | = | M11 m12 |-1
	   | r  s |   | m21 m22 |  

are known

Definition at line 1318 of file fMatrix.cpp.

int fMat::inv_svd ( const fMat mat,
int  lwork = -1 
) [friend]

inverse

Definition at line 484 of file fMatrix.cpp.

int fMat::lineq ( const fMat A,
const fMat b 
) [friend]

solve linear equation Ax = b

Definition at line 137 of file fMatrix.cpp.

int fMat::lineq_sr ( const fMat A,
fVec w_err,
fVec w_norm,
double  k,
const fMat b 
) [friend]

solve linear equation Ax = b using SR-inverse

Definition at line 930 of file fMatrix.cpp.

int fMat::lineq_svd ( const fMat A,
const fMat b,
int  lwork = -1 
) [friend]

solve linear equation Ax = b

Definition at line 416 of file fMatrix.cpp.

fMat operator* ( const fMat mat1,
const fMat mat2 
) [friend]

Definition at line 1268 of file fMatrix.cpp.

fVec operator* ( const fMat mat,
const fVec vec 
) [friend]

Definition at line 1412 of file fMatrix.cpp.

fMat operator* ( double  d,
const fMat mat 
) [friend]

Definition at line 1130 of file fMatrix.cpp.

fMat operator* ( const fMat mat,
double  d 
) [friend]

Definition at line 1138 of file fMatrix.cpp.

fMat operator+ ( const fMat mat1,
const fMat mat2 
) [friend]

Definition at line 1187 of file fMatrix.cpp.

fMat operator- ( const fMat mat) [friend]

Definition at line 1088 of file fMatrix.cpp.

fMat operator- ( const fMat mat1,
const fMat mat2 
) [friend]

Definition at line 1208 of file fMatrix.cpp.

fMat operator/ ( const fMat mat,
double  d 
) [friend]

Definition at line 1435 of file fMatrix.cpp.

ostream& operator<< ( ostream &  ost,
const fMat mat 
) [friend]

Outputs to a stream.

Definition at line 202 of file fMatrix.h.

int fMat::p_inv ( const fMat mat) [friend]

pseudo inverse

Definition at line 191 of file fMatrix.cpp.

int fMat::p_inv_svd ( const fMat mat,
int  lwork = -1 
) [friend]

pseudo inverse

Definition at line 501 of file fMatrix.cpp.

int fMat::sr_inv ( const fMat mat,
fVec w_err,
fVec w_norm,
double  k 
) [friend]

singularity-robust (SR) inverse

Definition at line 226 of file fMatrix.cpp.

int fMat::sr_inv_svd ( const fMat mat,
fVec w_err,
fVec w_norm,
double  k,
int  lwork = -1 
) [friend]

SR-inverse.

Definition at line 536 of file fMatrix.cpp.

void fMat::tran ( const fMat mat) [friend]

Returns the transpose of a matrix.

Definition at line 1013 of file fMatrix.cpp.


Member Data Documentation

int fMat::m_info [protected]

Definition at line 482 of file fMatrix.h.

int fMat::n_col [protected]

Definition at line 483 of file fMatrix.h.

int fMat::n_row [protected]

Definition at line 484 of file fMatrix.h.

double* fMat::p_data [protected]

Definition at line 480 of file fMatrix.h.

double fMat::temp [protected]

Definition at line 481 of file fMatrix.h.


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


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sun Apr 2 2017 03:43:59