00001 #include "orthogfunc_expansion1d.h"
00002 #include <cmath>
00003
00008 bool COrthogonalFuncExpansion1d::setDim(int __ndata){
00009 ndata = __ndata;
00010 Array1D<double> __data(__ndata,0.0);
00011 Array1D<double> __uncert(__ndata,0.0);
00012 Array2D<double> __covmtx(__ndata,__ndata,0.0);
00013 double min_ndata = std::min(__ndata,data.dim());
00014 for (int i=0; i<min_ndata; ++i){
00015 for (int j=0; j<min_ndata; ++j) __covmtx[i][j] = covmtx[i][j];
00016 __data[i] = data[i];
00017 __uncert[i] = uncert[i];
00018 }
00019 data = __data;
00020 uncert = __uncert;
00021 covmtx = __covmtx;
00022 return true;
00023 };
00024
00025 double COrthogonalFuncExpansion1d::basisFunction(double x, int i, int jderiv) const{
00026 if ( ( x < getLeftSupport(i) ) || (x > getRightSupport(i) ) ) return 0.0;
00027 double xx = rangeRemap(x);
00028 if (jderiv==0) return sqrt( weightFunction( xx )/normalization( i )/xScale() )*orthogFunctionValue( xx, i, 0 );
00029 else if (jderiv==1) {
00030 double w = sqrt( weightFunction( xx ) );
00031 return sqrt( 1.0/normalization( i )/xScale() )/xScale() *
00032 ( weightFunction( xx, 1 )*orthogFunctionValue( xx, i, 0 )/2.0/w + w*orthogFunctionValue( xx, i, 1 ) );
00033 }
00034 else MESSAGE << "Did not implement basisFunction for jderiv != 0 or 1"<<ENDM_WARN;
00035 return 0.0;
00036
00037 }