00001 // QMcBeaver 00002 // 00003 // Constructed by 00004 // 00005 // Michael Todd Feldmann 00006 // and 00007 // David Randall "Chip" Kent IV 00008 // 00009 // Copyright 2000. All rights reserved. 00010 // 00011 // drkent@users.sourceforge.net mtfeldmann@users.sourceforge.net 00012 00013 #include "PadeCorrelationFunction.h" 00014 00015 void PadeCorrelationFunction::initializeParameters( 00016 Array1D<int> & BeginningIndexOfParameterType, 00017 Array1D<double> &Parameters, 00018 Array1D<int> & BeginningIndexOfConstantType, 00019 Array1D<double> & Constants) 00020 { 00021 if( BeginningIndexOfParameterType.dim1() != 2 ) 00022 { 00023 cerr << "ERROR: Pade correlation function entered with an incorrect " 00024 << "number of parameter types!" << endl; 00025 exit(0); 00026 } 00027 00028 00029 Array1D<double> numeratorParameters(BeginningIndexOfParameterType(1)+1); 00030 00031 numeratorParameters(0) = 0.0; 00032 00033 for(int i=0; i<numeratorParameters.dim1()-1; i++) 00034 { 00035 numeratorParameters(i+1) = Parameters(i); 00036 } 00037 00038 Numerator.initialize(numeratorParameters); 00039 00040 Array1D<double> denominatorParameters(Parameters.dim1()- 00041 numeratorParameters.dim1()+2); 00042 00043 denominatorParameters(0) = 1.0; 00044 00045 for(int i=0; i<denominatorParameters.dim1()-1; i++) 00046 { 00047 denominatorParameters(i+1) = 00048 Parameters(i+BeginningIndexOfParameterType(1)); 00049 } 00050 00051 Denominator.initialize(denominatorParameters); 00052 } 00053 00054 bool PadeCorrelationFunction::isSingular() 00055 { 00056 return Denominator.hasNonNegativeZeroes(); 00057 } 00058 00059 Array1D<Complex> PadeCorrelationFunction::getPoles() 00060 { 00061 return Denominator.getRoots(); 00062 } 00063 00064 void PadeCorrelationFunction::evaluate( double r ) 00065 { 00066 // p = a/b 00067 // p' = a'/b - a b'/b^2 00068 // p'' = a"/b - 2 a' b'/b^2 + 2a (b')^2 /b^3 -a b"/b^2 00069 00070 Numerator.evaluate(r); 00071 double a = Numerator.getFunctionValue(); 00072 double ap = Numerator.getFirstDerivativeValue(); 00073 double app = Numerator.getSecondDerivativeValue(); 00074 00075 Denominator.evaluate(r); 00076 double b = Denominator.getFunctionValue(); 00077 double bp = Denominator.getFirstDerivativeValue(); 00078 double bpp = Denominator.getSecondDerivativeValue(); 00079 00080 FunctionValue = a/b; 00081 dFunctionValue = ap/b - a*bp/b/b; 00082 d2FunctionValue = app/b - 2*ap*bp/b/b + 2*a*bp*bp/b/b/b - a*bpp/b/b; 00083 } 00084 00085 double PadeCorrelationFunction::getFunctionValue() 00086 { 00087 return FunctionValue; 00088 } 00089 00090 double PadeCorrelationFunction::getFunctionValue(double r) 00091 { 00092 return Numerator.getFunctionValue(r) / Denominator.getFunctionValue(r); 00093 } 00094 00095 double PadeCorrelationFunction::get_p_a(int ai) 00096 { 00097 cout << "Parameter derivatives not implemented yet!!\n"; 00098 return 0.0; 00099 } 00100 00101 double PadeCorrelationFunction::getFirstDerivativeValue() 00102 { 00103 return dFunctionValue; 00104 } 00105 00106 double PadeCorrelationFunction::get_p2_xa(int ai) 00107 { 00108 cout << "Parameter derivatives not implemented yet!!\n"; 00109 return 0.0; 00110 } 00111 00112 double PadeCorrelationFunction::getSecondDerivativeValue() 00113 { 00114 return d2FunctionValue; 00115 } 00116 00117 double PadeCorrelationFunction::get_p3_xxa(int ai) 00118 { 00119 cout << "Parameter derivatives not implemented yet!!\n"; 00120 return 0.0; 00121 } 00122 00123 Array1D<double> PadeCorrelationFunction::getNumeratorCoeffs() 00124 { 00125 return Numerator.getCoefficients(); 00126 } 00127 00128 Array1D<double> PadeCorrelationFunction::getDenominatorCoeffs() 00129 { 00130 return Denominator.getCoefficients(); 00131 } 00132 00133 00134 00135 00136 00137