Back to index

fet  5.18.0
Public Member Functions | Private Attributes
Matrix3D< T > Class Template Reference

#include <matrix.h>

List of all members.

Public Member Functions

 Matrix3D ()
 ~Matrix3D ()
void clear ()
void resize (int _d1, int _d2, int _d3)
T ** operator[] (int i)
T & operator() (int i, int j, int k)

Private Attributes

int d1
int d2
int d3
T *** a
T * content

Detailed Description

template<typename T>
class Matrix3D< T >

Definition at line 34 of file matrix.h.


Constructor & Destructor Documentation

template<typename T >
Matrix3D< T >::Matrix3D ( )

Definition at line 93 of file matrix.h.

{
       d1=d2=d3=-1;
}
template<typename T >
Matrix3D< T >::~Matrix3D ( )

Definition at line 98 of file matrix.h.

{
       this->clear();
}

Member Function Documentation

template<typename T >
void Matrix3D< T >::clear ( )

Definition at line 103 of file matrix.h.

{
       if(d1>=0 || d2>=0 || d3>=0){
              assert(d1>0 && d2>0 && d3>0);
              
              for(int i=0; i<d1; i++)
                     delete[] a[i];
              delete[]a;
              
              delete[] content;
       }
       d1=d2=d3=-1;
}

Here is the caller graph for this function:

template<typename T >
T & Matrix3D< T >::operator() ( int  i,
int  j,
int  k 
) [inline]

Definition at line 146 of file matrix.h.

{
       //return content[i*d2*d3+j*d3+k];
       return content[(i*d2+j)*d3+k];
}
template<typename T >
T ** Matrix3D< T >::operator[] ( int  i) [inline]

Definition at line 141 of file matrix.h.

{
       return a[i];
}
template<typename T >
void Matrix3D< T >::resize ( int  _d1,
int  _d2,
int  _d3 
)

Definition at line 117 of file matrix.h.

{
       if(_d1<=0 || _d2<=0 || _d3<=0){
              this->clear();
              return;
       }
       
       if(d1!=_d1 || d2!=_d2 || d3!=_d3){
              this->clear();
              
              d1=_d1;
              d2=_d2;
              d3=_d3;

              content=new T[d1*d2*d3];
              a=new T**[d1];
              for(int i=0; i<d1; i++){
                     a[i]=new T*[d2];
                     for(int j=0; j<d2; j++)
                            a[i][j]=content+i*d2*d3+j*d3;
              }
       }
}

Here is the caller graph for this function:


Member Data Documentation

template<typename T>
T*** Matrix3D< T >::a [private]

Definition at line 41 of file matrix.h.

template<typename T>
T* Matrix3D< T >::content [private]

Definition at line 42 of file matrix.h.

template<typename T>
int Matrix3D< T >::d1 [private]

Definition at line 37 of file matrix.h.

template<typename T>
int Matrix3D< T >::d2 [private]

Definition at line 38 of file matrix.h.

template<typename T>
int Matrix3D< T >::d3 [private]

Definition at line 39 of file matrix.h.


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