Templates -- Meow  204.13.18
A C++ template contains kinds of interesting classes and functions
meow::Matrix< Entry > Class Template Reference

matrix More...

#include "Matrix.h"

Public Types

typedef std::vector< Entry >
::reference 
EntryRef
 
typedef std::vector< Entry >
::const_reference 
EntryRefK
 

Public Member Functions

 Matrix ()
 constructor More...
 
 Matrix (Matrix const &m)
 constructor More...
 
 Matrix (size_t r, size_t c, Entry const &e)
 constructor More...
 
 ~Matrix ()
 destructor More...
 
MatrixcopyFrom (Matrix const &m)
 copy More...
 
MatrixreferenceFrom (Matrix const &m)
 reference More...
 
void reset (size_t r, size_t c, Entry const &e)
 reset the size of the matrix to r x c with entry all be e More...
 
bool valid () const
 Return whether it is a valid matrix. More...
 
size_t rows () const
 Return number of rows. More...
 
size_t cols () const
 Return number of cols. More...
 
size_t size () const
 Return number of rows times number of cols. More...
 
size_t rows (size_t r, Entry const &e)
 resize the matrix such that number of rows become r. More...
 
size_t cols (size_t c, Entry const &e)
 resize the matrix such that number of cols become c More...
 
size_t size (size_t r, size_t c, Entry const &e)
 resize More...
 
Entry entry (size_t r, size_t c) const
 Access the entry at r x c. More...
 
Entry entry (size_t r, size_t c, Entry const &e)
 Change the entry at r x c. More...
 
EntryRef entryGet (size_t r, size_t c)
 Get the entry at r x c. More...
 
void entries (ssize_t rFirst, ssize_t rLast, ssize_t cFirst, ssize_t cLast, Entry const &e)
 Change the entries from rFirst x cFirst to rLast x cLast. More...
 
Matrix subMatrix (size_t rFirst, size_t rLast, size_t cFirst, size_t cLast) const
 Return a rLast-rFirst+1 x cLast-cFirst+1 matrix. More...
 
Matrix row (size_t r) const
 Return the r -th row. More...
 
Matrix col (size_t c) const
 Return the c -th column. More...
 
Matrix positive () const
 return +(*this) More...
 
Matrix negative () const
 return -(*this) More...
 
Matrix add (Matrix const &m) const
 return (*this) + m. More...
 
Matrix sub (Matrix const &m) const
 return (*this) - m. More...
 
Matrix mul (Matrix const &m) const
 return (*this) times m. More...
 
Matrix mul (Entry const &s) const
 return (*this) times s. s is a scalar More...
 
Matrix div (Entry const &s) const
 return (*this) / s. s is a scalar More...
 
Matrix identity () const
 Return a identity matrix with size equal to itself. More...
 
Matrixidentitied ()
 Let itself be an identity matrix. More...
 
Matrixdiagonaled ()
 Let itself be an diagonal form of original itself. More...
 
Matrix diagonal () const
 Return a matrix which is a diangonal form of me. More...
 
Matrix inverse () const
 Return a matrix which is an inverse matrix of (*this) More...
 
Matrixinversed ()
 let itself become itself's inverse matrix More...
 
Matrix transpose () const
 return itself's transpose matrix More...
 
Matrixtransposed ()
 Let itself become itself's transpose matrix. More...
 
Matrix triangular () const
 return a matrix which is the triangular form of (*this) More...
 
Matrixtriangulared ()
 triangluar itself More...
 
Matrixoperator= (Matrix const &m)
 same as copyFrom More...
 
Entry operator() (size_t r, size_t c) const
 same as entry(r,c) More...
 
Entry operator() (size_t r, size_t c, Entry const &e)
 same as entry(r,c,e) More...
 
Matrix operator+ () const
 same as positive() More...
 
Matrix operator- () const
 same as negative() More...
 
Matrix operator+ (Matrix const &m) const
 same as add(m) More...
 
Matrix operator- (Matrix const &m) const
 same as sub(m) More...
 
Matrix operator* (Matrix const &m) const
 same as mul(m) More...
 
Matrix operator* (Entry const &s) const
 same as mul(m) More...
 
Matrix operator/ (Entry const &s) const
 same as div(s) More...
 

Detailed Description

template<class Entry>
class meow::Matrix< Entry >

matrix

Author
cat_leopard

Definition at line 18 of file Matrix.h.

Member Typedef Documentation

template<class Entry>
typedef std::vector<Entry>::reference meow::Matrix< Entry >::EntryRef

Definition at line 20 of file Matrix.h.

template<class Entry>
typedef std::vector<Entry>::const_reference meow::Matrix< Entry >::EntryRefK

Definition at line 21 of file Matrix.h.

Constructor & Destructor Documentation

template<class Entry>
meow::Matrix< Entry >::Matrix ( )
inline

constructor

Create an empty matrix with size 0x0. In other world, create an invalid matrix

Definition at line 56 of file Matrix.h.

template<class Entry>
meow::Matrix< Entry >::Matrix ( Matrix< Entry > const &  m)
inline

constructor

Copy data from another one

Parameters
[in]manother matrix

Definition at line 65 of file Matrix.h.

template<class Entry>
meow::Matrix< Entry >::Matrix ( size_t  r,
size_t  c,
Entry const &  e 
)
inline

constructor

Create an r x c matrix with all entry be e

Parameters
[in]rnumber of rows
[in]cnumber of columns
[in]einital entry

Definition at line 77 of file Matrix.h.

template<class Entry>
meow::Matrix< Entry >::~Matrix ( )
inline

destructor

Definition at line 81 of file Matrix.h.

Member Function Documentation

template<class Entry>
Matrix meow::Matrix< Entry >::add ( Matrix< Entry > const &  m) const
inline

return (*this) + m.

If the size not match, it will return an invalid matrix

Definition at line 285 of file Matrix.h.

template<class Entry>
Matrix meow::Matrix< Entry >::col ( size_t  c) const
inline

Return the c -th column.

Definition at line 263 of file Matrix.h.

template<class Entry>
size_t meow::Matrix< Entry >::cols ( ) const
inline

Return number of cols.

Definition at line 128 of file Matrix.h.

template<class Entry>
size_t meow::Matrix< Entry >::cols ( size_t  c,
Entry const &  e 
)
inline

resize the matrix such that number of cols become c

New created entry will be e

Parameters
[in]cnew number of columns
[in]einital entry
Returns
new number of columns

Definition at line 163 of file Matrix.h.

template<class Entry>
Matrix& meow::Matrix< Entry >::copyFrom ( Matrix< Entry > const &  m)
inline

copy

Copy data from another matrix

Parameters
[in]mmatrix
Returns
*this

Definition at line 91 of file Matrix.h.

template<class Entry>
Matrix meow::Matrix< Entry >::diagonal ( ) const
inline

Return a matrix which is a diangonal form of me.

Definition at line 374 of file Matrix.h.

template<class Entry>
Matrix& meow::Matrix< Entry >::diagonaled ( )
inline

Let itself be an diagonal form of original itself.

Definition at line 361 of file Matrix.h.

template<class Entry>
Matrix meow::Matrix< Entry >::div ( Entry const &  s) const
inline

return (*this) / s. s is a scalar

Definition at line 331 of file Matrix.h.

template<class Entry>
void meow::Matrix< Entry >::entries ( ssize_t  rFirst,
ssize_t  rLast,
ssize_t  cFirst,
ssize_t  cLast,
Entry const &  e 
)
inline

Change the entries from rFirst x cFirst to rLast x cLast.

Parameters
[in]rFirst
[in]rLast
[in]cFirst
[in]cLast
[in]evalue
Returns
void

Definition at line 221 of file Matrix.h.

template<class Entry>
Entry meow::Matrix< Entry >::entry ( size_t  r,
size_t  c 
) const
inline

Access the entry at r x c.

Definition at line 196 of file Matrix.h.

template<class Entry>
Entry meow::Matrix< Entry >::entry ( size_t  r,
size_t  c,
Entry const &  e 
)
inline

Change the entry at r x c.

Definition at line 201 of file Matrix.h.

template<class Entry>
EntryRef meow::Matrix< Entry >::entryGet ( size_t  r,
size_t  c 
)
inline

Get the entry at r x c.

Definition at line 207 of file Matrix.h.

template<class Entry>
Matrix& meow::Matrix< Entry >::identitied ( )
inline

Let itself be an identity matrix.

Our definition of Identity matrix is 1 for entry(i, i) and 0 otherwise.

Definition at line 351 of file Matrix.h.

template<class Entry>
Matrix meow::Matrix< Entry >::identity ( ) const
inline

Return a identity matrix with size equal to itself.

Definition at line 340 of file Matrix.h.

template<class Entry>
Matrix meow::Matrix< Entry >::inverse ( ) const
inline

Return a matrix which is an inverse matrix of (*this)

If inverse matrix doesn't exist, it will return a invalid matrix

Definition at line 385 of file Matrix.h.

template<class Entry>
Matrix& meow::Matrix< Entry >::inversed ( )
inline

let itself become itself's inverse matrix

Definition at line 413 of file Matrix.h.

template<class Entry>
Matrix meow::Matrix< Entry >::mul ( Matrix< Entry > const &  m) const
inline

return (*this) times m.

If the size not match, it will return an invalid matrix

Definition at line 311 of file Matrix.h.

template<class Entry>
Matrix meow::Matrix< Entry >::mul ( Entry const &  s) const
inline

return (*this) times s. s is a scalar

Definition at line 322 of file Matrix.h.

template<class Entry>
Matrix meow::Matrix< Entry >::negative ( ) const
inline

return -(*this)

Definition at line 273 of file Matrix.h.

template<class Entry>
Entry meow::Matrix< Entry >::operator() ( size_t  r,
size_t  c 
) const
inline

same as entry(r,c)

Definition at line 473 of file Matrix.h.

template<class Entry>
Entry meow::Matrix< Entry >::operator() ( size_t  r,
size_t  c,
Entry const &  e 
)
inline

same as entry(r,c,e)

Definition at line 478 of file Matrix.h.

template<class Entry>
Matrix meow::Matrix< Entry >::operator* ( Matrix< Entry > const &  m) const
inline

same as mul(m)

Definition at line 503 of file Matrix.h.

template<class Entry>
Matrix meow::Matrix< Entry >::operator* ( Entry const &  s) const
inline

same as mul(m)

Definition at line 508 of file Matrix.h.

template<class Entry>
Matrix meow::Matrix< Entry >::operator+ ( ) const
inline

same as positive()

Definition at line 483 of file Matrix.h.

template<class Entry>
Matrix meow::Matrix< Entry >::operator+ ( Matrix< Entry > const &  m) const
inline

same as add(m)

Definition at line 493 of file Matrix.h.

template<class Entry>
Matrix meow::Matrix< Entry >::operator- ( ) const
inline

same as negative()

Definition at line 488 of file Matrix.h.

template<class Entry>
Matrix meow::Matrix< Entry >::operator- ( Matrix< Entry > const &  m) const
inline

same as sub(m)

Definition at line 498 of file Matrix.h.

template<class Entry>
Matrix meow::Matrix< Entry >::operator/ ( Entry const &  s) const
inline

same as div(s)

Definition at line 513 of file Matrix.h.

template<class Entry>
Matrix& meow::Matrix< Entry >::operator= ( Matrix< Entry > const &  m)
inline

same as copyFrom

Definition at line 468 of file Matrix.h.

template<class Entry>
Matrix meow::Matrix< Entry >::positive ( ) const
inline

return +(*this)

Definition at line 268 of file Matrix.h.

template<class Entry>
Matrix& meow::Matrix< Entry >::referenceFrom ( Matrix< Entry > const &  m)
inline

reference

Reference itself to another matrix

Parameters
[in]mmatrix
Returns
*this

Definition at line 104 of file Matrix.h.

template<class Entry>
void meow::Matrix< Entry >::reset ( size_t  r,
size_t  c,
Entry const &  e 
)
inline

reset the size of the matrix to r x c with entry all be e

Definition at line 110 of file Matrix.h.

template<class Entry>
Matrix meow::Matrix< Entry >::row ( size_t  r) const
inline

Return the r -th row.

Definition at line 258 of file Matrix.h.

template<class Entry>
size_t meow::Matrix< Entry >::rows ( ) const
inline

Return number of rows.

Definition at line 123 of file Matrix.h.

template<class Entry>
size_t meow::Matrix< Entry >::rows ( size_t  r,
Entry const &  e 
)
inline

resize the matrix such that number of rows become r.

New created entry will be e

Parameters
[in]rnew number of rows
[in]einital entry
Returns
new number of rows

Definition at line 146 of file Matrix.h.

template<class Entry>
size_t meow::Matrix< Entry >::size ( ) const
inline

Return number of rows times number of cols.

Definition at line 133 of file Matrix.h.

template<class Entry>
size_t meow::Matrix< Entry >::size ( size_t  r,
size_t  c,
Entry const &  e 
)
inline

resize

Resize to r x c, with new created entry be e

Parameters
[in]rnumber of rows
[in]cnumber of rows
[in]einital entry
Returns
r * c

Definition at line 189 of file Matrix.h.

template<class Entry>
Matrix meow::Matrix< Entry >::sub ( Matrix< Entry > const &  m) const
inline

return (*this) - m.

If the size not match, it will return an invalid matrix

Definition at line 298 of file Matrix.h.

template<class Entry>
Matrix meow::Matrix< Entry >::subMatrix ( size_t  rFirst,
size_t  rLast,
size_t  cFirst,
size_t  cLast 
) const
inline

Return a rLast-rFirst+1 x cLast-cFirst+1 matrix.

With value be the entries from rFirst x cFirst to rLast x cLast

Parameters
[in]rFirst
[in]rLast
[in]cFirst
[in]cLast
Returns
a matrix

Definition at line 242 of file Matrix.h.

template<class Entry>
Matrix meow::Matrix< Entry >::transpose ( ) const
inline

return itself's transpose matrix

Definition at line 419 of file Matrix.h.

template<class Entry>
Matrix& meow::Matrix< Entry >::transposed ( )
inline

Let itself become itself's transpose matrix.

Definition at line 428 of file Matrix.h.

template<class Entry>
Matrix meow::Matrix< Entry >::triangular ( ) const
inline

return a matrix which is the triangular form of (*this)

Definition at line 434 of file Matrix.h.

template<class Entry>
Matrix& meow::Matrix< Entry >::triangulared ( )
inline

triangluar itself

Definition at line 441 of file Matrix.h.

template<class Entry>
bool meow::Matrix< Entry >::valid ( ) const
inline

Return whether it is a valid matrix.

Definition at line 118 of file Matrix.h.


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