#include <emarray.h>
Collaboration diagram for EMAN::EMArray< T >:
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 &) | |
EMArray & | operator= (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 |
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.
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 EMAN::EMArray< T >::array, EMAN::EMArray< T >::nx, EMAN::EMArray< T >::ny, EMAN::EMArray< T >::nz, and EMAN::EMArray< T >::size.
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 }
EMAN::EMArray< T >::~EMArray | ( | ) | [inline] |
Destructor.
Definition at line 63 of file emarray.h.
References EMAN::EMArray< T >::array.
00063 { delete [] array; }
EMAN::EMArray< T >::EMArray | ( | const EMArray< T > & | ) | [private] |
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.
References EMAN::EMArray< T >::xoff, EMAN::EMArray< T >::yoff, and EMAN::EMArray< T >::zoff.
00079 { 00080 vector<int> offsets; 00081 offsets.push_back(xoff); 00082 offsets.push_back(yoff); 00083 offsets.push_back(zoff); 00084 return offsets; 00085 }
int EMAN::EMArray< T >::get_xsize | ( | ) | const [inline] |
int EMAN::EMArray< T >::get_ysize | ( | ) | const [inline] |
int EMAN::EMArray< T >::get_zsize | ( | ) | const [inline] |
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 EMAN::EMArray< T >::array, EMAN::EMArray< T >::nx, EMAN::EMArray< T >::ny, OutofRangeException, EMAN::EMArray< T >::size, EMAN::EMArray< T >::xoff, EMAN::EMArray< T >::yoff, and EMAN::EMArray< T >::zoff.
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 }
EMArray& EMAN::EMArray< T >::operator= | ( | const EMArray< T > & | ) | [private] |
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 EMAN::EMArray< T >::set_array_offsets().
00075 { 00076 set_array_offsets(offsets[0],offsets[1],offsets[2]); 00077 }
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.
References EMAN::EMArray< T >::xoff, EMAN::EMArray< T >::yoff, and EMAN::EMArray< T >::zoff.
Referenced by EMAN::EMArray< T >::set_array_offsets().
T* EMAN::EMArray< T >::array [private] |
Definition at line 109 of file emarray.h.
Referenced by EMAN::EMArray< T >::EMArray(), EMAN::EMArray< T >::operator()(), and EMAN::EMArray< T >::~EMArray().
const size_t EMAN::EMArray< T >::nx [private] |
Definition at line 106 of file emarray.h.
Referenced by EMAN::EMArray< T >::EMArray(), EMAN::EMArray< T >::get_xsize(), and EMAN::EMArray< T >::operator()().
const size_t EMAN::EMArray< T >::ny [private] |
Definition at line 106 of file emarray.h.
Referenced by EMAN::EMArray< T >::EMArray(), EMAN::EMArray< T >::get_ysize(), and EMAN::EMArray< T >::operator()().
const size_t EMAN::EMArray< T >::nz [private] |
Definition at line 106 of file emarray.h.
Referenced by EMAN::EMArray< T >::EMArray(), and EMAN::EMArray< T >::get_zsize().
size_t EMAN::EMArray< T >::size [private] |
Definition at line 107 of file emarray.h.
Referenced by EMAN::EMArray< T >::EMArray(), and EMAN::EMArray< T >::operator()().
size_t EMAN::EMArray< T >::xoff [private] |
Definition at line 108 of file emarray.h.
Referenced by EMAN::EMArray< T >::get_array_offsets(), EMAN::EMArray< T >::operator()(), and EMAN::EMArray< T >::set_array_offsets().
size_t EMAN::EMArray< T >::yoff [private] |
Definition at line 108 of file emarray.h.
Referenced by EMAN::EMArray< T >::get_array_offsets(), EMAN::EMArray< T >::operator()(), and EMAN::EMArray< T >::set_array_offsets().
size_t EMAN::EMArray< T >::zoff [private] |
Definition at line 108 of file emarray.h.
Referenced by EMAN::EMArray< T >::get_array_offsets(), EMAN::EMArray< T >::operator()(), and EMAN::EMArray< T >::set_array_offsets().