#include <barray2d.h>
Inheritance diagram for PLib::Basic2DArray< T >:
Public Member Functions | |
int | rows () const |
int | cols () const |
Basic2DArray () | |
Basic2DArray (const int r, const int c) | |
Basic2DArray (const Basic2DArray< T > &f2) | |
Basic2DArray (T *p, const int r, const int c) | |
virtual | ~Basic2DArray () |
Basic2DArray< T > & | operator= (const Basic2DArray< T > &f2) |
void | resize (const int nr, const int nc) |
void | resize (const Basic2DArray< T > &A) |
void | resizeKeep (const int nr, const int nc) |
void | reset (const T val=0.0) |
T | operator= (const T val) |
T * | operator[] (const int i) |
T * | operator[] (const int i) const |
T & | operator() (const int i, const int j) |
T | operator() (const int i, const int j) const |
void | io_elem_width (int w) |
void | io_by_rows () |
void | io_by_columns () |
ostream & | print (ostream &os) const |
T & | elem (const int i, const int j) |
T | elem (const int i, const int j) const |
template<> | |
ostream & | print (ostream &os) const |
Protected Member Functions | |
void | init (const int r=1, const int c=1) |
Protected Attributes | |
int | by_columns |
int | width |
int | rz |
int | cz |
T * | m |
T ** | vm |
int | created |
Friends | |
istream & | operator>> (istream &is, Basic2DArray< T > &ary) |
ostream & | operator<< (ostream &os, const Basic2DArray< T > &ary) |
This is a basis array class for two dimensionnal storage and retrieval.
PLib::Basic2DArray< T >::Basic2DArray | ( | ) |
constructor
Constructs an array of size (0,0).
PLib::Basic2DArray< T >::Basic2DArray | ( | const int | r, | |
const int | c | |||
) |
constructor with the size specified
Constructs an array of size (r,c).
r | the number of rows | |
c | the number of columns |
PLib::Basic2DArray< T >::Basic2DArray | ( | const Basic2DArray< T > & | a | ) |
PLib::Basic2DArray< T >::Basic2DArray | ( | T * | p, | |
const int | r, | |||
const int | c | |||
) |
constructor from memory
Constructs a matrix from memory. No memory is allocated for this new basic2DArray and the memory will not be deallocated when the destructor is called. You are responsible for cleaning up the memory you allocated.
p | the memory pointer | |
r | the number of rows | |
c | the number of columns |
PLib::Basic2DArray< T >::~Basic2DArray | ( | ) | [virtual] |
destructor
Destructor
int PLib::Basic2DArray< T >::rows | ( | ) | const [inline] |
< The number or rows
int PLib::Basic2DArray< T >::cols | ( | ) | const [inline] |
< The number of columns
Basic2DArray< T > & PLib::Basic2DArray< T >::operator= | ( | const Basic2DArray< T > & | a | ) |
assignment operator
Assignment operator
a | the Basic2DArray to copy from |
void PLib::Basic2DArray< T >::resize | ( | const int | nr, | |
const int | nc | |||
) |
a destructive resize of the matrix dimensions
Changes the matrix dimensions and intialize it to 0.
nr | the new number of rows | |
nc | the new number of columns |
Reimplemented in PLib::LUMatrix< T >.
void PLib::Basic2DArray< T >::reset | ( | const T | v = 0.0 |
) |
reset all values of the 2D array to v
Reset all values of the 2D array to v
v | resets the elements of the 2D array to this value |
T PLib::Basic2DArray< T >::operator= | ( | const T | val | ) | [inline] |
val | resets every elements to val |
T* PLib::Basic2DArray< T >::operator[] | ( | const int | i | ) | [inline] |
i | returns a pointer to the start of a row i |
T* PLib::Basic2DArray< T >::operator[] | ( | const int | i | ) | const [inline] |
< returns a pointer to the start of a row \ i
T& PLib::Basic2DArray< T >::operator() | ( | const int | i, | |
const int | j | |||
) | [inline] |
j | calls elem(i,j) |
T PLib::Basic2DArray< T >::operator() | ( | const int | i, | |
const int | j | |||
) | const [inline] |
< calls elem(i,j)
void PLib::Basic2DArray< T >::io_elem_width | ( | int | w | ) | [inline] |
w | width of an element in output streams |
ostream & PLib::Basic2DArray< T >::print | ( | ostream & | os | ) | const |
writes a 2D array to an ostream Writes a matrix to an ostream
os | the output stream |
void PLib::Basic2DArray< T >::init | ( | const int | r = 1 , |
|
const int | c = 1 | |||
) | [inline, protected] |
c | Calls a global function to perform the initialization, necessary to overcome some template problems |
istream& operator>> | ( | istream & | is, | |
Basic2DArray< T > & | ary | |||
) | [friend] |
reads a 2D arra from an istream
Reads a matrix from an istream
is | the input stream | |
a | the 2D array to initialize |
ostream& operator<< | ( | ostream & | os, | |
const Basic2DArray< T > & | ary | |||
) | [friend] |
writes a 2D array to an ostream
os | the output stream a the 2D array to output |
int PLib::Basic2DArray< T >::by_columns [protected] |
If the output is done by columns.
int PLib::Basic2DArray< T >::width [protected] |
the size of the output columns
int PLib::Basic2DArray< T >::rz [protected] |
the number of rows
int PLib::Basic2DArray< T >::cz [protected] |
the number of columns
T* PLib::Basic2DArray< T >::m [protected] |
the memory is allocated here
T** PLib::Basic2DArray< T >::vm [protected] |
for referencing, vm[i][j] is faster than m[i+cols*j]
int PLib::Basic2DArray< T >::created [protected] |