#include <polardata.h>
Inheritance diagram for EMAN::UnevenMatrix:
Public Member Functions | |
UnevenMatrix () | |
virtual | ~UnevenMatrix () |
int | get_xsize (int y) |
get the x dim size for a given y | |
int | get_xmin (int y) |
get the minimal x dim value for a given y | |
int | get_xmax (int y) |
get the maximal x dim value for a given y, note: x1 is one out of the max | |
int | get_size () |
get the total size of the data block | |
Protected Member Functions | |
void | alloc_data () |
allocation memory for data array | |
Protected Attributes | |
float * | data |
store all data in one dimension float array for cache efficiency, we calculate the offset for x, y dimension | |
map< int, Xdim > | desc_data |
describe for each y, the x dimension's size and range | |
int | tot_size |
the total size of the data | |
Classes | |
struct | Xdim |
struct to define x dimension size for each y, x0 is inclusive, x1 is one after the maximum, [x0, x1), so the corresponding x dim size is (x1-x0) More... |
Definition at line 53 of file polardata.h.
EMAN::UnevenMatrix::UnevenMatrix | ( | ) | [inline] |
Definition at line 56 of file polardata.h.
00056 : data(0) { 00057 printf("Welcome to UnevenMatrix\n"); 00058 }
virtual EMAN::UnevenMatrix::~UnevenMatrix | ( | ) | [inline, virtual] |
void UnevenMatrix::alloc_data | ( | ) | [protected] |
allocation memory for data array
InvalidValueException | if the desc_data map size is zero |
Definition at line 59 of file polardata.cpp.
References data, desc_data, get_xsize(), InvalidValueException, LOGERR, tot_size, and y.
00060 { 00061 if( desc_data.size() == 0 ) { 00062 LOGERR("No data space need to be allocated for UnevenMatrix, check you desc_data..."); 00063 throw InvalidValueException((float)desc_data.size(), "desc_data size == 0"); 00064 } 00065 00066 int size = 0; //total number of float need to be stored in data block 00067 map< int, Xdim >::const_iterator iter; 00068 int y = 0; 00069 for( iter = desc_data.begin(); iter != desc_data.end(); ++iter ) { 00070 y = (*iter).first; 00071 size += get_xsize(y); 00072 } 00073 00074 this->tot_size = size; 00075 try { 00076 this->data = new float[size]; 00077 } 00078 catch( bad_alloc exception ) { 00079 LOGERR("memory allocation for UnevenMatrix failed"); 00080 } 00081 catch(...) { 00082 LOGERR("Unknown error in memory allocation for UnevenMatrix"); 00083 } 00084 }
int EMAN::UnevenMatrix::get_size | ( | ) | [inline] |
get the total size of the data block
Definition at line 96 of file polardata.h.
References tot_size.
00096 { 00097 return tot_size; 00098 }
int EMAN::UnevenMatrix::get_xmax | ( | int | y | ) | [inline] |
get the maximal x dim value for a given y, note: x1 is one out of the max
y | int the y value for which we need the corresponding maximal x dim value |
Definition at line 90 of file polardata.h.
References desc_data.
int EMAN::UnevenMatrix::get_xmin | ( | int | y | ) | [inline] |
get the minimal x dim value for a given y
y | int the y value for which we need the corresponding minimal x dim value |
Definition at line 83 of file polardata.h.
References desc_data.
int EMAN::UnevenMatrix::get_xsize | ( | int | y | ) | [inline] |
get the x dim size for a given y
y | int the y value for which we need the x dim size |
Definition at line 70 of file polardata.h.
References desc_data, and InvalidValueException.
Referenced by alloc_data().
00070 { 00071 int xsize = desc_data[y].x1 - desc_data[y].x0; 00072 if( xsize <= 0 ) { 00073 throw InvalidValueException(xsize, "xsize <= 0"); 00074 } 00075 else { 00076 return xsize; 00077 } 00078 }
float* EMAN::UnevenMatrix::data [protected] |
store all data in one dimension float array for cache efficiency, we calculate the offset for x, y dimension
Definition at line 127 of file polardata.h.
Referenced by alloc_data(), and ~UnevenMatrix().
map< int, Xdim > EMAN::UnevenMatrix::desc_data [protected] |
describe for each y, the x dimension's size and range
Definition at line 130 of file polardata.h.
Referenced by alloc_data(), get_xmax(), get_xmin(), and get_xsize().
int EMAN::UnevenMatrix::tot_size [protected] |
the total size of the data
Definition at line 133 of file polardata.h.
Referenced by alloc_data(), and get_size().