Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

EMAN::EMArray< T > Class Template Reference

EMArray -- 1-, 2-, or 3-D array of types T. More...

#include <emarray.h>

Collaboration diagram for EMAN::EMArray< T >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 EMArray (size_t xsize, size_t ysize=1, size_t zsize=1)
 Constructor.
 ~EMArray ()
 Destructor.
void set_array_offsets (const size_t xoff_=0, const size_t yoff_=0, const size_t zoff_=0)
 Set the array offsets.
void set_array_offsets (const vector< int > offsets)
 Set the array offsets using an offset vector.
vector< int > get_array_offsets ()
 Get an integer array containing the array offsets.
T & operator() (const size_t ix, const size_t iy=0, const size_t iz=0)
 Index into the array using Fortran-style indexing:.
int get_xsize () const
int get_ysize () const
int get_zsize () const

Private Member Functions

 EMArray (const EMArray &)
EMArrayoperator= (const EMArray &)

Private Attributes

const size_t nx
const size_t ny
const size_t nz
size_t size
size_t xoff
size_t yoff
size_t zoff
T * array

Detailed Description

template<class T>
class EMAN::EMArray< T >

EMArray -- 1-, 2-, or 3-D array of types T.

Sometimes you need an array of something.

Data is ordered with the first element increasing the fastest.

Definition at line 53 of file emarray.h.


Constructor & Destructor Documentation

template<class T>
EMAN::EMArray< T >::EMArray size_t  xsize,
size_t  ysize = 1,
size_t  zsize = 1
[inline, explicit]
 

Constructor.

Definition at line 56 of file emarray.h.

References nx, and ny.

00057                 : nx(xsize),ny(ysize),nz(zsize),
00058                   xoff(0),yoff(0),zoff(0) {
00059                 size = (size_t)nx*ny*nz;
00060                 array = new T[size];
00061             }

template<class T>
EMAN::EMArray< T >::~EMArray  )  [inline]
 

Destructor.

Definition at line 63 of file emarray.h.

00063 { delete [] array; }

template<class T>
EMAN::EMArray< T >::EMArray const EMArray< T > &   )  [private]
 


Member Function Documentation

template<class T>
vector<int> EMAN::EMArray< T >::get_array_offsets  )  [inline]
 

Get an integer array containing the array offsets.

Definition at line 79 of file emarray.h.

00079                                             {
00080                 vector<int> offsets;
00081                 offsets.push_back(xoff);
00082                 offsets.push_back(yoff);
00083                 offsets.push_back(zoff);
00084                 return offsets;
00085             }

template<class T>
int EMAN::EMArray< T >::get_xsize  )  const [inline]
 

Definition at line 101 of file emarray.h.

00101 { return nx; }

template<class T>
int EMAN::EMArray< T >::get_ysize  )  const [inline]
 

Definition at line 102 of file emarray.h.

00102 { return ny; }

template<class T>
int EMAN::EMArray< T >::get_zsize  )  const [inline]
 

Definition at line 103 of file emarray.h.

00103 { return nz; }

template<class T>
T& EMAN::EMArray< T >::operator() const size_t  ix,
const size_t  iy = 0,
const size_t  iz = 0
[inline]
 

Index into the array using Fortran-style indexing:.

EMArray<double> arr(2,2) // 2-D 2x2 array of doubles arr(0,0) = 1.f;

Definition at line 91 of file emarray.h.

References OutofRangeException.

00092                                              {
00093                 long pos = (ix-xoff) + ((iy-yoff)+(iz-zoff)*ny)*nx;
00094 #ifdef BOUNDS_CHECKING
00095                 if (pos < 0 || pos >= long(size))
00096                     throw OutofRangeException(0, size-1, pos, "emarray");
00097 #endif // BOUNDS_CHECKING
00098                 return *(array + pos);
00099             }

template<class T>
EMArray& EMAN::EMArray< T >::operator= const EMArray< T > &   )  [private]
 

template<class T>
void EMAN::EMArray< T >::set_array_offsets const vector< int >  offsets  )  [inline]
 

Set the array offsets using an offset vector.

This method exists mainly for restoring the original offsets.

Definition at line 75 of file emarray.h.

References set_array_offsets().

00075                                                               {
00076                 set_array_offsets(offsets[0],offsets[1],offsets[2]);
00077             }

template<class T>
void EMAN::EMArray< T >::set_array_offsets const size_t  xoff_ = 0,
const size_t  yoff_ = 0,
const size_t  zoff_ = 0
[inline]
 

Set the array offsets.

By default an EMArray ranges from 0..nx-1,0..ny-1,0..nz-1. Setting the offsets to (1,1,1) changes the ranges to 1..nx,1..ny,1..nz, for example.

Definition at line 68 of file emarray.h.

00069                                                          {
00070                 xoff = xoff_; yoff = yoff_; zoff = zoff_;
00071             }


Member Data Documentation

template<class T>
T* EMAN::EMArray< T >::array [private]
 

Definition at line 109 of file emarray.h.

template<class T>
const size_t EMAN::EMArray< T >::nx [private]
 

Definition at line 106 of file emarray.h.

template<class T>
const size_t EMAN::EMArray< T >::ny [private]
 

Definition at line 106 of file emarray.h.

template<class T>
const size_t EMAN::EMArray< T >::nz [private]
 

Definition at line 106 of file emarray.h.

template<class T>
size_t EMAN::EMArray< T >::size [private]
 

Definition at line 107 of file emarray.h.

template<class T>
size_t EMAN::EMArray< T >::xoff [private]
 

Definition at line 108 of file emarray.h.

template<class T>
size_t EMAN::EMArray< T >::yoff [private]
 

Definition at line 108 of file emarray.h.

template<class T>
size_t EMAN::EMArray< T >::zoff [private]
 

Definition at line 108 of file emarray.h.


The documentation for this class was generated from the following file:
Generated on Tue Jun 11 13:49:34 2013 for EMAN2 by  doxygen 1.3.9.1