Main Page   Class Hierarchy   Compound List   File List   Compound Members  

PLib::Basic2DArray Class Template Reference

A basic templated array class in two dimensions. More...

#include <barray2d.h>

Inheritance diagram for PLib::Basic2DArray:

PLib::Matrix PLib::LUMatrix PLib::MatrixImage PLib::MatrixRT List of all members.

Public Methods

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)
operator= (const T val)
T * operator[] (const int i)
T * operator[] (const int i) const
T & operator() (const int i, const int j)
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)
elem (const int i, const int j) const

Protected Methods

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)

Detailed Description

template<class T>
class PLib::Basic2DArray< T >

A basic templated array class in two dimensions.

This is a basis array class for two dimensionnal storage and retrieval.

Author:
Philippe Lavoie
Date:
4 Oct. 1996

Definition at line 165 of file barray2d.h.


Constructor & Destructor Documentation

template<class T>
PLib::Basic2DArray< T >::Basic2DArray  
 

constructor.

Constructs an array of size (0,0).

Author:
Philippe Lavoie
Date:
24 January 1997

Definition at line 126 of file barray2d.cpp.

References by_columns, created, init, m, vm, and width.

template<class T>
PLib::Basic2DArray< T >::Basic2DArray const int    r,
const int    c
 

constructor with the size specified.

Constructs an array of size (r,c).

Parameters:
r  the number of rows
c  the number of columns
Author:
Philippe Lavoie
Date:
24 January 1997

Definition at line 147 of file barray2d.cpp.

References by_columns, created, init, m, vm, and width.

template<class T>
PLib::Basic2DArray< T >::Basic2DArray const Basic2DArray< T > &    a
 

copy constructor.

Copy constructor

Parameters:
a  the Basic2DArray to copy from
Author:
Philippe Lavoie
Date:
24 January 1997

Definition at line 206 of file barray2d.cpp.

References by_columns, created, init, m, and width.

template<class T>
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.

Parameters:
p  the memory pointer
r  the number of rows
c  the number of columns
Warning:
Do not access the basic2DArray once you delete the memory segment used by the matrix since it now points to a dead memory location.
Author:
Philippe Lavoie
Date:
24 January 1997

Definition at line 177 of file barray2d.cpp.

References by_columns, created, cz, m, rz, vm, and width.

template<class T>
PLib::Basic2DArray< T >::~Basic2DArray   [virtual]
 

destructor.

Destructor

Author:
Philippe Lavoie
Date:
24 January 1997

Definition at line 271 of file barray2d.cpp.

References created, m, and vm.


Member Function Documentation

template<class T>
void PLib::Basic2DArray< T >::init const int    r = 1,
const int    c = 1
[inline, protected]
 

Parameters:
c  Calls a global function to perform the initialization, necessary to overcome some template problems

Definition at line 246 of file barray2d.h.

Referenced by Basic2DArray, PLib::Matrix::norm, and resize.

template<class T>
void PLib::Basic2DArray< T >::io_elem_width int    w [inline]
 

Parameters:
w  width of an element in output streams

Definition at line 199 of file barray2d.h.

template<class T>
T& PLib::Basic2DArray< T >::operator() const int    i,
const int    j
[inline]
 

Parameters:
j  calls elem(i,j)

Definition at line 194 of file barray2d.h.

Referenced by PLib::MatrixImage::drawLine, and PLib::MatrixImage::drawPoint.

template<class T>
T PLib::Basic2DArray< T >::operator= const T    val [inline]
 

Parameters:
val  resets every elements to val

Definition at line 186 of file barray2d.h.

template<class T>
Basic2DArray< T > & PLib::Basic2DArray< T >::operator= const Basic2DArray< T > &    a
 

assignment operator.

Assignment operator

Parameters:
a  the Basic2DArray to copy from
Returns:
a reference to itself
Author:
Philippe Lavoie
Date:
24 January 1997

Definition at line 237 of file barray2d.cpp.

References by_columns, cols, m, resize, rows, and width.

template<class T>
T* PLib::Basic2DArray< T >::operator[] const int    i [inline]
 

Parameters:
i  returns a pointer to the start of a row i

Definition at line 189 of file barray2d.h.

template<class T>
ostream & PLib::Basic2DArray< T >::print ostream &    os const
 

writes a 2D array to an ostream Writes a matrix to an ostream.

Parameters:
os  the output stream
Returns:
Warning:
Author:
Philippe Lavoie
Date:
24 January 1997

Definition at line 541 of file barray2d.cpp.

References cols, rows, and width.

template<class 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

Parameters:
v  resets the elements of the 2D array to this value
Author:
Philippe Lavoie
Date:
24 January 1997

Definition at line 408 of file barray2d.cpp.

References cols, m, and rows.

Referenced by PLib::MatrixRT::MatrixRT, PLib::NurbsSurface::movePoint, PLib::MatrixRT::scale, and PLib::MatrixRT::translate.

template<class T>
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.

Parameters:
nr  the new number of rows
nc  the new number of columns
Author:
Philippe Lavoie
Date:
24 January 1997

Reimplemented in PLib::LUMatrix.

Definition at line 292 of file barray2d.cpp.

References cols, created, init, m, rows, and vm.

Referenced by PLib::NurbsCurve::drawAaImg, PLib::NurbsSurface::movePoint, PLib::Matrix::operator=, operator=, PLib::Matrix::read, and PLib::NurbsSurface::sweep.


Friends And Related Function Documentation

template<class T>
ostream& operator<< ostream &    os,
const Basic2DArray< T > &    ary
[friend]
 

writes a 2D array to an ostream.

Parameters:
os  the output stream a the 2D array to output
Returns:
Warning:
Author:
Philippe Lavoie
Date:
24 January 1997

Definition at line 578 of file barray2d.cpp.

template<class T>
istream& operator>> istream &    is,
Basic2DArray< T > &    ary
[friend]
 

reads a 2D arra from an istream.

Reads a matrix from an istream

Parameters:
is  the input stream
a  the 2D array to initialize
Author:
Philippe Lavoie
Date:
24 January 1997

Definition at line 513 of file barray2d.cpp.


The documentation for this class was generated from the following files:
Generated on Tue Jun 24 13:26:59 2003 for NURBS++ by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002