dox/Common/vtkExponentialFunctions.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   vtkCNMRRLibrary
00004   Module:    $RCSfile: vtkExponentialFunctions.h,v $
00005 
00006   Copyright  2006  The Pennsylvania State University
00007   
00008           Notice
00009  
00010   The contents of this file are subject to The Pennsylvania State University 
00011   Open Source License (the "License"); you may not use this file except in 
00012   compliance with the License. You may obtain a copy of the License at H066 
00013   Radiology, NMR Building, 500 University Drive, Hershey, PA, 
00014   tel. (717) 531-6069 or via email at dcb210@psu.edu.
00015  
00016   Software distributed under the License is distributed on an "AS IS" basis, 
00017   WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
00018   for the specific language governing rights and limitations under the 
00019   License.
00020  
00021   The Original Code is listed under Exhibit A of the license.
00022  
00023   The Initial Developer of the Original Code is Don Bigler.
00024  
00025   Contributor(s):
00026 
00027 =========================================================================*/
00036 #ifndef __vtkExponentialFunctions_h
00037 #define __vtkExponentialFunctions_h
00038 
00039 #include "vtkObject.h"
00040 #include "vtkCNMRRCommonWin32Header.h"
00041 #if defined(AMD64_TRUE) && defined(USE_AMD_ACML)
00042 #include "acml_mv.h"
00043 #define SIN    fastsin
00044 #define COS    fastcos
00045 #define EXP    fastexp
00046 #else
00047 #define SIN    sin
00048 #define COS    cos
00049 #define EXP    exp
00050 #endif
00051 #include <math.h>
00052 
00053 #define SIGN(x) ((x>=0)?1:-1)
00054 
00055 class VTK_CNMRR_COMMON_EXPORT vtkExponentialFunctions : public vtkObject
00056 {
00057    public:
00058       static vtkExponentialFunctions *New();
00059       vtkTypeRevisionMacro(vtkExponentialFunctions,vtkObject);
00060       
00062 
00066       static void exponential(double *p, double *x, int m, int n, void *data)
00067       {
00068          register int i;
00070          
00071          for(i=0; i<n; ++i)
00072          {
00073             x[i]=p[0]*EXP(-(*((double *)data+i)*p[1]));
00074          }
00075       }
00076       
00078 
00082       static void exponentialWithConstant(double *p, double *x, int m, int n, void *data)
00083       {
00084          register int i;
00086          
00087          for(i=0; i<n; ++i)
00088          {
00089             x[i]=p[0]*EXP(-(*((double *)data+i)*p[1])) + p[2];
00090          }
00091       }
00092       
00094 
00097       static void jacexponential(double *p, double *jac, int m, int n, void *data)
00098       {
00099          register int i;
00101          
00102          for(i=0; i<n; ++i)
00103          {
00104             jac[i]=-p[1]*p[0]*EXP(-(*((double *)data+i)*p[1]));
00105          }
00106       }
00107       
00109 
00113       static void oneminusexponential(double *p, double *x, int m, int n, void *data)
00114       {
00115          register int i;
00117          
00118          for(i=0; i<n; ++i)
00119          {
00120             x[i]=p[0]*(1-EXP(-(*((double *)data+i)*p[1])));
00121          }
00122       }
00123       
00125 
00128       static void jaconeminusexponential(double *p, double *jac, int m, int n, void *data)
00129       {
00130          register int i;
00132          
00133          for(i=0; i<n; ++i)
00134          {
00135             jac[i]=p[1]*p[0]*EXP(-(*((double *)data+i)*p[1]));
00136          }
00137       }
00138       
00140 
00141       static double sinc(double x)
00142       {
00143          return static_cast<double>((x==0)?1:(SIN(x)/x));
00144       }
00146       
00148 
00153       static void exponentialSincMod(double *p, double *x, int m, int n, void *data)
00154       {
00155          register int i;
00157          
00158          for(i=0; i<n; ++i)
00159          {
00160             x[i]=p[0]*EXP(-((*((double *)data+1+i))*p[1]))
00161                *fabs(vtkExponentialFunctions::sinc((*((double *)data))*(*((double *)data+1+i))));
00162          }
00163       }
00164       
00166 
00171       static void exponentialSincModWithConstant(double *p, double *x, int m, int n, void *data)
00172       {
00173          register int i;
00175          
00176          for(i=0; i<n; ++i)
00177          {
00178             x[i]=p[0]*EXP(-((*((double *)data+1+i))*p[1]))
00179                *fabs(vtkExponentialFunctions::sinc((*((double *)data))*(*((double *)data+1+i))))
00180                + p[2];
00181          }
00182       }
00183       
00185 
00187       static void jacexponentialSincMod(double *p, double *jac, int m, int n, void *data)
00188       {
00189          register int i;
00191          
00192          for(i=0; i<n; ++i)
00193          {
00194             jac[i]=SIGN(vtkExponentialFunctions::sinc((*((double *)data))*(*((double *)data+1+i))))
00195                *p[0]*EXP(-((*((double *)data+1+i))*p[1]))
00196                *((COS((*((double *)data))*(*((double *)data+1+i)))/(*((double *)data+1+i)))
00197                -(vtkExponentialFunctions::sinc((*((double *)data))*(*((double *)data+1+i)))*p[1])
00198                -(vtkExponentialFunctions::sinc((*((double *)data))*(*((double *)data+1+i)))/
00199                                                          (*((double *)data+1+i))));
00200          }
00201       }
00202       
00204 
00209       static void exponentialSincModThreeParam(double *p, double *x, int m, int n, void *data)
00210       {
00211          register int i;
00213          
00214          for(i=0; i<n; ++i)
00215          {
00216             x[i]=p[0]*EXP(-((*((double *)data+1+i))*p[1]))
00217                *fabs(vtkExponentialFunctions::sinc((*((double *)data))*p[2]*(*((double *)data+1+i))));
00218          }
00219       }
00220       
00222 
00227       static void exponentialSincModThreeParamWithConstant(double *p, double *x, int m, int n, void *data)
00228       {
00229          register int i;
00231          
00232          for(i=0; i<n; ++i)
00233          {
00234             x[i]=p[0]*EXP(-((*((double *)data+1+i))*p[1]))
00235                *fabs(vtkExponentialFunctions::sinc((*((double *)data))*p[2]*(*((double *)data+1+i))))
00236                + p[3];
00237          }
00238       }
00239       
00241 
00243       static void jacexponentialSincModThreeParam(double *p, double *jac, int m, int n, void *data)
00244       {
00245          register int i;
00247          
00248          for(i=0; i<n; ++i)
00249          {
00250             jac[i]=SIGN(vtkExponentialFunctions::sinc((*((double *)data))*p[2]*(*((double *)data+1+i))))
00251                *p[0]*EXP(-((*((double *)data+1+i))*p[1]))
00252                *((COS((*((double *)data))*p[2]*(*((double *)data+1+i)))/(*((double *)data+1+i)))
00253                -(vtkExponentialFunctions::sinc((*((double *)data))*p[2]*(*((double *)data+1+i)))*p[1])
00254                -(vtkExponentialFunctions::sinc((*((double *)data))*p[2]*(*((double *)data+1+i)))/
00255                                                          (*((double *)data+1+i))));
00256          }
00257       }
00258 
00260 
00262       static void CalculateParameterApproximates(double *x, double *y, unsigned int num, 
00263                                  double &A, double &B);
00265 
00267 
00269       static void CalculateParameterApproximatesWithConstant(double *x, double *y, unsigned int num, 
00270                                  double &A, double &B, double &C);
00272    
00273    protected:
00274       vtkExponentialFunctions() {};
00275       ~vtkExponentialFunctions() {};
00276    
00277    private:
00278       vtkExponentialFunctions(const vtkExponentialFunctions&);  // Not implemented.
00279       void operator=(const vtkExponentialFunctions&);  // Not implemented.
00280 };
00281 
00282 #endif

Generated on Tue May 12 14:53:03 2009 for vtkCNMRRLibrary by  doxygen 1.4.7