| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

LutForBdlFunction Class Reference

#include <LutForBdlFunction.h>

List of all members.


Public Member Functions

 LutForBdlFunction (int nVar, int *nBinVar, double *minVar, double *maxVar)
 ~LutForBdlFunction ()
void resetIndexVector ()
int incrementIndexVector ()
void fillTable (double lutValue)
double getVariable (int ivar)
void getVariableVector (double *var)
double getValueFromTable (double *var)
double getInterpolatedValueFromTable (double *var)

Private Member Functions

void createVectors ()
void deleteVectors ()
void createTable ()
void deleteTable ()
void resetVariableVector ()
int tableLocation ()
void calculateVariableVector ()
void calculateIndexVector (double *var)
void calculateClosestIndexVector (double *var)

Private Attributes

int m_nVar
int * m_nPointVar
double * m_minVar
double * m_maxVar
double * m_deltaVar
float * m_table
int * m_indexVector
double * m_variableVector

Detailed Description

Definition at line 60 of file LutForBdlFunction.h.


Constructor & Destructor Documentation

LutForBdlFunction::LutForBdlFunction ( int  nVar,
int *  nBinVar,
double *  minVar,
double *  maxVar 
)

Definition at line 5 of file LutForBdlFunction.cpp.

00005                                                                                            {
00006 
00007     m_nVar = 0;
00008     m_nPointVar = NULL;
00009     m_minVar    = NULL;
00010     m_maxVar    = NULL;
00011     m_deltaVar  = NULL;
00012     m_table     = NULL;
00013 
00014     m_indexVector    = NULL;
00015     m_variableVector = NULL;
00016 
00017   int i;
00018   int good_input = 1;
00019 
00020   // check arguments 
00021   if(nVar<1 || nVar>100) {
00022     good_input=0;
00023   }
00024   else {
00025     for (i=0; i<nVar; i++) {
00026       if( nBinVar[i] < 1 || (maxVar[i] - minVar[i]) < 1.e-10 ) {
00027         good_input=0;
00028       }
00029     }
00030   }
00031 
00032   if(good_input) {
00033     m_nVar = nVar;
00034     createVectors();
00035     for (i=0; i< m_nVar; i++) {
00036       m_nPointVar[i]  = nBinVar[i]+1;
00037       m_minVar[i]     = minVar[i];
00038       m_maxVar[i]     = maxVar[i];
00039       m_deltaVar[i]   = ( maxVar[i] - minVar[i] ) /  (m_nPointVar[i]-1);  
00040     }
00041     createTable();
00042     // reset internal vectors
00043     for (i=0; i<m_nVar; i++) {
00044       m_indexVector[i] = 0;
00045       m_variableVector[i]   = 0.0;
00046     }
00047   }
00048   else {
00049     std::cout << " PatVTTLutForFunction: incorrect input for lookup table \n";
00050   }
00051 }

LutForBdlFunction::~LutForBdlFunction (  ) 

Definition at line 53 of file LutForBdlFunction.cpp.

00053                                       {
00054   deleteVectors();
00055   deleteTable();
00056 }


Member Function Documentation

void LutForBdlFunction::resetIndexVector (  ) 

Definition at line 92 of file LutForBdlFunction.cpp.

00092                                          {
00093   int i;
00094   for (i=0; i<m_nVar; i++) {
00095     m_indexVector[i] = 0;
00096   }  
00097 }

int LutForBdlFunction::incrementIndexVector (  ) 

Definition at line 106 of file LutForBdlFunction.cpp.

00106                                             {
00107   int i;
00108   m_indexVector[0]++;
00109   for (i=0; i<m_nVar-1; i++) {
00110     if(m_indexVector[i] > m_nPointVar[i]-1) {
00111       m_indexVector[i]=0;
00112       m_indexVector[i+1]++;
00113     }
00114     else {
00115         break;
00116     }
00117   }  
00118   if(m_indexVector[m_nVar-1] > m_nPointVar[m_nVar-1]-1) { 
00119     resetIndexVector();
00120     return 1;
00121   }
00122 
00123   return 0;
00124 }

void LutForBdlFunction::fillTable ( double  lutValue  ) 

Definition at line 127 of file LutForBdlFunction.cpp.

00127                                                  {
00128   m_table[tableLocation()] = (float) lutValue;
00129 }

double LutForBdlFunction::getVariable ( int  ivar  ) 

Definition at line 131 of file LutForBdlFunction.cpp.

00131                                             {
00132   calculateVariableVector();
00133   if(iv<0 || iv> m_nVar-1) return 0.0;
00134   return m_variableVector[iv];
00135 }

void LutForBdlFunction::getVariableVector ( double *  var  ) 

Definition at line 137 of file LutForBdlFunction.cpp.

00137                                                      {
00138   int i;
00139   calculateVariableVector();
00140   for (i=0; i<m_nVar; i++) {
00141     var[i] = m_variableVector[i];
00142   }
00143 }

double LutForBdlFunction::getValueFromTable ( double *  var  ) 

Definition at line 145 of file LutForBdlFunction.cpp.

00145                                                        {
00146   calculateClosestIndexVector(var);
00147   return (double) m_table[tableLocation()];
00148 }

double LutForBdlFunction::getInterpolatedValueFromTable ( double *  var  ) 

Definition at line 150 of file LutForBdlFunction.cpp.

00150                                                                    {
00151   int i;
00152   calculateIndexVector(var);
00153   calculateVariableVector();
00154   double tabVal = m_table[tableLocation()];
00155   double addTabVal = 0.0;
00156   for(i=0; i<m_nVar; i++) {
00157     if(var[i]<m_variableVector[i]) continue;
00158     if(m_indexVector[i] > m_nPointVar[i]-2) continue;
00159     if(var[i]<m_minVar[i] || var[i]>m_maxVar[i]) continue;
00160     m_indexVector[i]++;
00161     double dTab_dVar =  (m_table[tableLocation()] - tabVal) / m_deltaVar[i];  
00162     m_indexVector[i]--;
00163     double dVar = (var[i]-m_variableVector[i]);
00164     addTabVal += dTab_dVar*dVar;
00165   }  
00166   tabVal+=addTabVal;
00167   return tabVal;
00168 }

void LutForBdlFunction::createVectors (  )  [private]

Definition at line 58 of file LutForBdlFunction.cpp.

00058                                       {
00059   m_nPointVar    = new    int[m_nVar];
00060   m_minVar       = new double[m_nVar];
00061   m_maxVar       = new double[m_nVar];
00062   m_deltaVar     = new double[m_nVar];
00063 
00064   m_indexVector       = new    int[m_nVar];
00065   m_variableVector    = new double[m_nVar];
00066 }

void LutForBdlFunction::deleteVectors (  )  [private]

Definition at line 68 of file LutForBdlFunction.cpp.

00068                                       {
00069   if(m_nPointVar   != NULL) delete[] m_nPointVar;
00070   if(m_minVar      != NULL) delete[] m_minVar;
00071   if(m_maxVar      != NULL) delete[] m_maxVar;
00072   if(m_deltaVar    != NULL) delete[] m_deltaVar;
00073 
00074   if(m_indexVector      != NULL) delete[] m_indexVector;
00075   if(m_variableVector   != NULL) delete[] m_variableVector;
00076 }

void LutForBdlFunction::createTable (  )  [private]

Definition at line 78 of file LutForBdlFunction.cpp.

00078                                     {
00079   int i;
00080   int iSize = 1; 
00081   for (i=0; i<m_nVar; i++) {
00082     iSize *= (m_nPointVar[i]);
00083   }
00084 
00085   m_table = new float[iSize];
00086 }

void LutForBdlFunction::deleteTable (  )  [private]

Definition at line 88 of file LutForBdlFunction.cpp.

00088                                     {
00089   if(m_table != NULL) delete[] m_table;
00090 }

void LutForBdlFunction::resetVariableVector (  )  [private]

Definition at line 99 of file LutForBdlFunction.cpp.

00099                                             {
00100   int i;
00101   for (i=0; i<m_nVar; i++) {
00102     m_variableVector[i] = 0;
00103   }  
00104 }

int LutForBdlFunction::tableLocation (  )  [private]

Definition at line 170 of file LutForBdlFunction.cpp.

00170                                      {
00171   int i;
00172   if(1==m_nVar) return m_indexVector[0];
00173   int location;
00174   location = m_indexVector[m_nVar-1];
00175   for (i=m_nVar-2; i>=0; i--) {
00176     location = location*m_nPointVar[i] + m_indexVector[i];
00177   }
00178   return location;
00179 }

void LutForBdlFunction::calculateVariableVector (  )  [private]

Definition at line 181 of file LutForBdlFunction.cpp.

00181                                                 {
00182   int i;
00183   for (i=0; i<m_nVar; i++) {
00184     m_variableVector[i]=m_minVar[i]+m_indexVector[i]*m_deltaVar[i];
00185   }
00186 }

void LutForBdlFunction::calculateIndexVector ( double *  var  )  [private]

Definition at line 188 of file LutForBdlFunction.cpp.

00188                                                         {
00189   int i;
00190   for (i=0; i<m_nVar; i++) {
00191     int idx = (int) ((var[i]-m_minVar[i])/m_deltaVar[i] + 0.000000001);
00192     if(idx<0) idx=0;
00193     if(idx>(m_nPointVar[i]-1)) idx=m_nPointVar[i]-1;
00194     m_indexVector[i]=idx;
00195   }  
00196 }

void LutForBdlFunction::calculateClosestIndexVector ( double *  var  )  [private]

Definition at line 198 of file LutForBdlFunction.cpp.

00198                                                                {
00199   int i;
00200   for (i=0; i<m_nVar; i++) {
00201     int idx = (int) ((var[i]-m_minVar[i])/m_deltaVar[i] + 0.5);
00202     if(idx<0) idx=0;
00203     if(idx>(m_nPointVar[i]-1)) idx=m_nPointVar[i]-1;
00204     m_indexVector[i]=idx;
00205   }  
00206 }


Member Data Documentation

int LutForBdlFunction::m_nVar [private]

Definition at line 91 of file LutForBdlFunction.h.

int* LutForBdlFunction::m_nPointVar [private]

Definition at line 92 of file LutForBdlFunction.h.

double* LutForBdlFunction::m_minVar [private]

Definition at line 93 of file LutForBdlFunction.h.

double* LutForBdlFunction::m_maxVar [private]

Definition at line 94 of file LutForBdlFunction.h.

double* LutForBdlFunction::m_deltaVar [private]

Definition at line 95 of file LutForBdlFunction.h.

float* LutForBdlFunction::m_table [private]

Definition at line 96 of file LutForBdlFunction.h.

int* LutForBdlFunction::m_indexVector [private]

Definition at line 98 of file LutForBdlFunction.h.

double* LutForBdlFunction::m_variableVector [private]

Definition at line 99 of file LutForBdlFunction.h.


The documentation for this class was generated from the following files:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:04:55 2011 for Magnet by doxygen 1.4.7