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

EMAN::UnevenMatrix Class Reference

a general data structure for a matrix with variable x dim size for different y More...

#include <polardata.h>

Inheritance diagram for EMAN::UnevenMatrix:

Inheritance graph
[legend]
List of all members.

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, Xdimdesc_data
 describe for each y, the x dimension's size and range
int tot_size
 the total size of the data

Detailed Description

a general data structure for a matrix with variable x dim size for different y

Definition at line 53 of file polardata.h.


Constructor & Destructor Documentation

EMAN::UnevenMatrix::UnevenMatrix  )  [inline]
 

Definition at line 56 of file polardata.h.

References data.

00056                                : data(0) {
00057                         printf("Welcome to UnevenMatrix\n");
00058                 }

virtual EMAN::UnevenMatrix::~UnevenMatrix  )  [inline, virtual]
 

Definition at line 59 of file polardata.h.

References data.

00059                                         {
00060                         if(data) {
00061                                 delete data;
00062                                 data = 0;
00063                         }
00064                         printf("Destructor of UnevenMatrix...\n");
00065                 }


Member Function Documentation

void UnevenMatrix::alloc_data  )  [protected]
 

allocation memory for data array

Returns:
int
Exceptions:
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

Returns:
int the number of float stored in data

Definition at line 96 of file polardata.h.

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

Parameters:
y int the y value for which we need the corresponding maximal x dim value
Returns:
int the maximal x dim value for a given y

Definition at line 90 of file polardata.h.

00090                                            {
00091                         return desc_data[y].x1 - 1;
00092                 }

int EMAN::UnevenMatrix::get_xmin int  y  )  [inline]
 

get the minimal x dim value for a given y

Parameters:
y int the y value for which we need the corresponding minimal x dim value
Returns:
int the minimal x dim value for a given y

Definition at line 83 of file polardata.h.

00083                                            {
00084                         return desc_data[y].x0;
00085                 }

int EMAN::UnevenMatrix::get_xsize int  y  )  [inline]
 

get the x dim size for a given y

Parameters:
y int the y value for which we need the x dim size
Returns:
in tthe x dim size

Definition at line 70 of file polardata.h.

References 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                 }


Member Data Documentation

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().

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().

int EMAN::UnevenMatrix::tot_size [protected]
 

the total size of the data

Definition at line 133 of file polardata.h.

Referenced by alloc_data().


The documentation for this class was generated from the following files:
Generated on Tue Jun 11 13:48:14 2013 for EMAN2 by  doxygen 1.3.9.1