Array< T, 3 > Class Template Reference

#include <noblitz.h>

Collaboration diagram for Array< T, 3 >:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 Array ()
 Array (const Array< T, 3 > &a)
 ~Array ()
T & operator() (const int &i, const int &j, const int &k)
const T & operator() (const int &i, const int &j, const int &k) const
T & operator[] (const int &i)
const T & operator[] (const int &i) const
Array< T, 3 > operator* (const real &d) const
Array< T, 3 > operator- (const Array< T, 3 > &a) const
Array< T, 3 > & operator-= (const Array< T, 3 > &a)
Array< T, 3 > operator+ (const Array< T, 3 > &a) const
Array< T, 3 > & operator*= (const real &d)
Array< T, 3 > & operator+= (const Array< T, 3 > &a)
VarShape< 3 > & shape ()
void resize (const int &ni, const int &nj, const int &nk)
const VarShape< 3 > & shape () const
Array< T, 3 > & operator= (const Array< T, 3 > &a)
Array< T, 3 > & operator= (const real &d)

Private Attributes

T *** array
T * the_array
VarShape< 3 > s


Detailed Description

template<class T>
class Array< T, 3 >

Definition at line 43 of file noblitz.h.


Constructor & Destructor Documentation

template<class T>
Array< T, 3 >::Array (  )  [inline]

Definition at line 50 of file noblitz.h.

00050           {
00051     for (int i=0; i<3; i++)
00052       shape()[i]=0;
00053   }

template<class T>
Array< T, 3 >::Array ( const Array< T, 3 > &  a  )  [inline]

Definition at line 55 of file noblitz.h.

00055                              {
00056     const int ni = a.shape()[0];
00057     const int nj = a.shape()[1];
00058     const int nk = a.shape()[2];
00059 
00060     resize(ni,nj,nk);
00061 
00062     for (int i=0; i<ni*nj*nk; i++)
00063       the_array[i] = a.the_array[i];
00064   }

template<class T>
Array< T, 3 >::~Array (  )  [inline]

Definition at line 66 of file noblitz.h.

00066            {
00067     if (shape()[0]>0) {
00068       for (int i=0; i<shape()[0]; i++)
00069         delete[] array[i];
00070       delete [] array;
00071       delete [] the_array;
00072     }
00073   }


Member Function Documentation

template<class T>
T& Array< T, 3 >::operator() ( const int &  i,
const int &  j,
const int &  k 
) [inline]

Definition at line 75 of file noblitz.h.

00075                                                                  {
00076     return array[i][j][k];
00077   }

template<class T>
const T& Array< T, 3 >::operator() ( const int &  i,
const int &  j,
const int &  k 
) const [inline]

Definition at line 79 of file noblitz.h.

00079                                                                              {
00080     return array[i][j][k];
00081   }

template<class T>
T& Array< T, 3 >::operator[] ( const int &  i  )  [inline]

Definition at line 83 of file noblitz.h.

00083                                      {
00084     return the_array[i];
00085   }

template<class T>
const T& Array< T, 3 >::operator[] ( const int &  i  )  const [inline]

Definition at line 87 of file noblitz.h.

00087                                                  {
00088     return the_array[i];
00089   }

template<class T>
Array<T,3> Array< T, 3 >::operator* ( const real &  d  )  const [inline]

Definition at line 91 of file noblitz.h.

00091                                                    {
00092     Array<T,3> a;
00093     a.resize(shape()[0],shape()[1],shape()[2]);
00094 
00095     for (int i=0; i<shape()[0]*shape()[1]*shape()[2]; i++)
00096           a.the_array[i] = the_array[i]*d;
00097 
00098     return a;
00099   }

template<class T>
Array<T,3> Array< T, 3 >::operator- ( const Array< T, 3 > &  a  )  const [inline]

Definition at line 101 of file noblitz.h.

00101                                                          {
00102     assert((shape()[0]==a.shape()[0])
00103            &&(shape()[1]==a.shape()[1])
00104            &&(shape()[2]==a.shape()[2]));
00105 
00106     Array<T,3> temp;
00107     temp.resize(shape()[0],shape()[1],shape()[2]);
00108     for (int i=0; i<shape()[0]*shape()[1]*shape()[2]; i++) {
00109       temp.the_array[i]
00110         = the_array[i] - a.the_array[i];
00111     }
00112     return temp;
00113   }

template<class T>
Array<T,3>& Array< T, 3 >::operator-= ( const Array< T, 3 > &  a  )  [inline]

Definition at line 115 of file noblitz.h.

00115                                                      {
00116     assert((shape()[0]==a.shape()[0])
00117            &&(shape()[1]==a.shape()[1])
00118            &&(shape()[2]==a.shape()[2]));
00119 
00120     for (int i=0; i<shape()[0]*shape()[1]*shape()[2]; i++){
00121       the_array[i] -= a.the_array[i];
00122     }
00123     return *this;
00124   }

template<class T>
Array<T,3> Array< T, 3 >::operator+ ( const Array< T, 3 > &  a  )  const [inline]

Definition at line 126 of file noblitz.h.

00126                                                          {
00127     assert((shape()[0]==a.shape()[0])
00128            &&(shape()[1]==a.shape()[1])
00129            &&(shape()[2]==a.shape()[2]));
00130 
00131     Array<T,3> temp;
00132     temp.resize(shape()[0],shape()[1],shape()[2]);
00133     for (int i=0; i<shape()[0]*shape()[1]*shape()[2]; i++) {
00134       temp.the_array[i] 
00135         = the_array[i] + a.the_array[i];
00136     }
00137     return temp;
00138   }

template<class T>
Array<T,3>& Array< T, 3 >::operator*= ( const real &  d  )  [inline]

Definition at line 140 of file noblitz.h.

00140                                                {
00141 
00142     for (int i=0; i<shape()[0]*shape()[1]*shape()[2]; i++) {
00143       the_array[i] *= d;
00144     }
00145     return *this;
00146   }

template<class T>
Array<T,3>& Array< T, 3 >::operator+= ( const Array< T, 3 > &  a  )  [inline]

Definition at line 148 of file noblitz.h.

00148                                                      {
00149     assert((shape()[0]==a.shape()[0])
00150            &&(shape()[1]==a.shape()[1])
00151            &&(shape()[2]==a.shape()[2]));
00152 
00153     for (int i=0; i<shape()[0]*shape()[1]*shape()[2]; i++) {
00154       the_array[i] += a.the_array[i];
00155     }
00156     return *this;
00157   }

template<class T>
VarShape<3>& Array< T, 3 >::shape (  )  [inline]

Definition at line 159 of file noblitz.h.

00159                               {
00160     return s;
00161   }

template<class T>
void Array< T, 3 >::resize ( const int &  ni,
const int &  nj,
const int &  nk 
) [inline]

Definition at line 163 of file noblitz.h.

00163                                                                   {
00164     if ((ni != shape()[0])&&(nj != shape()[1])&&(nk != shape()[2])) {
00165 
00166       // clean memory.
00167       if (shape()[0] > 0) {
00168         for (int i=0; i<shape()[0]; i++)
00169           if (shape()[1] > 0) {
00170             delete [] array[i];
00171           }
00172         delete [] array;
00173         delete [] the_array;
00174       }
00175 
00176       shape()[0] = ni;
00177       shape()[1] = nj;
00178       shape()[2] = nk;
00179       array = new T**[ni];
00180 
00181       the_array = new T[ni*nj*nk];
00182 
00183       for (int i=0; i<ni; i++)
00184         array[i] = new T*[nj];
00185       for (int i=0; i<ni; i++)
00186         for (int j=0; j<nj; j++)
00187           array[i][j]  = &the_array[i*nj*nk + j*nk];
00188     }
00189   }

template<class T>
const VarShape<3>& Array< T, 3 >::shape (  )  const [inline]

Definition at line 191 of file noblitz.h.

00191                                           {
00192     return s;
00193   }

template<class T>
Array<T,3>& Array< T, 3 >::operator= ( const Array< T, 3 > &  a  )  [inline]

Definition at line 195 of file noblitz.h.

00195                                                     {
00196 
00197     if (this != &a) { // if Vectors are the same one don't do anythings
00198       resize(a.shape()[0], a.shape()[1], a.shape()[2]);
00199       for (int i=0; i<a.shape()[0]*shape()[1]*shape()[2]; i++)
00200         the_array[i] = a.the_array[i];
00201     }
00202 
00203     return *this;
00204   }

template<class T>
Array<T,3>& Array< T, 3 >::operator= ( const real &  d  )  [inline]

Definition at line 207 of file noblitz.h.

00207                                               {
00208     for (int i=0; i<shape()[0]*shape()[1]*shape()[2]; i++)
00209       the_array[i] = d;
00210 
00211     return *this;
00212   }


Member Data Documentation

template<class T>
T*** Array< T, 3 >::array [private]

Definition at line 45 of file noblitz.h.

template<class T>
T* Array< T, 3 >::the_array [private]

Definition at line 46 of file noblitz.h.

template<class T>
VarShape<3> Array< T, 3 >::s [private]

Definition at line 47 of file noblitz.h.


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

Generated on Wed Nov 19 00:04:01 2008 for FreeFEM3D (aka ff3d) by  doxygen 1.5.6