38 template<
int Degree,
class Real>
46 template<
int Degree,
class Real>
62 template<
int Degree,
class Real>
63#if BOUNDARY_CONDITIONS
69 this->normalize = normalize;
70 this->useDotRatios = useDotRatios;
71#if BOUNDARY_CONDITIONS
72 this->reflectBoundary = reflectBoundary;
86 baseFunction=F/sqrt((F*F).integral(F.polys[0].start,F.polys[F.polyCount-1].start));
89 baseFunction=F/F.integral(F.polys[0].start,F.polys[F.polyCount-1].start);
95#if BOUNDARY_CONDITIONS
98 dLeftBaseFunction = leftBaseFunction.derivative();
99 dRightBaseFunction = rightBaseFunction.derivative();
102 for(
int i=0 ; i<
res ; i++ )
105#if BOUNDARY_CONDITIONS
106 if( reflectBoundary )
110 if ( off==0 )
baseFunctions[i] = leftBaseFunction.scale( w1 ).shift( c1 );
111 else if( off==((1<<d)-1) )
baseFunctions[i] = rightBaseFunction.scale( w1 ).shift( c1 );
130 template<
int Degree,
class Real>
154 for(
int i=0 ; i<
res ; i++ )
156 double c1 , c2 , w1 , w2;
158#if BOUNDARY_CONDITIONS
159 int d1 , d2 , off1 , off2;
162 if ( reflectBoundary && off1==0 ) boundary1 = -1;
163 else if( reflectBoundary && off1==( (1<<d1)-1 ) ) boundary1 = 1;
165 double start1 = t1 * w1 + c1;
166 double end1 = t2 * w1 + c1;
167 for(
int j=0 ; j<=i ; j++ )
170#if BOUNDARY_CONDITIONS
173 if ( reflectBoundary && off2==0 ) boundary2 = -1;
174 else if( reflectBoundary && off2==( (1<<d2)-1 ) ) boundary2 = 1;
178 double start = t1 * w2 + c2;
179 double end = t2 * w2 + c2;
180#if BOUNDARY_CONDITIONS
181 if( reflectBoundary )
183 if( start<0 ) start = 0;
184 if( start>1 ) start = 1;
185 if( end <0 ) end = 0;
186 if( end >1 ) end = 1;
190 if( start< start1 ) start = start1;
191 if( end > end1 ) end = end1;
192 if( start>= end )
continue;
194#if BOUNDARY_CONDITIONS
195 Real dot =
dotProduct( c1 , w1 , c2 , w2 , boundary1 , boundary2 );
199 if( fabs(dot)<1e-15 )
continue;
203#if BOUNDARY_CONDITIONS
213#if BOUNDARY_CONDITIONS
224 template<
int Degree,
class Real>
237 template<
int Degree,
class Real>
245 for(
int i=0 ; i<
res ; i++ )
250 dFunction=
baseFunctions[i].derivative().MovingAverage(smooth);
257 for(
int j=0 ; j<
res2 ; j++ )
259 double x=double(j)/(
res2-1);
265 template<
int Degree,
class Real>
272 for(
int i=0;i<
res;i++){
273 if(valueSmooth>0) { function=
baseFunctions[i].MovingAverage(valueSmooth);}
275 if(normalSmooth>0) {dFunction=
baseFunctions[i].derivative().MovingAverage(normalSmooth);}
278 for(
int j=0;j<
res2;j++){
279 double x=double(j)/(
res2-1);
287 template<
int Degree,
class Real>
294#if BOUNDARY_CONDITIONS
295 template<
int Degree,
class Real>
299 if ( boundary1==-1 ) b1 = & leftBaseFunction;
300 else if( boundary1== 0 ) b1 = & baseFunction;
301 else if( boundary1== 1 ) b1 = &rightBaseFunction;
302 if ( boundary2==-1 ) b2 = & leftBaseFunction;
303 else if( boundary2== 0 ) b2 = & baseFunction;
304 else if( boundary2== 1 ) b2 = &rightBaseFunction;
305 double r=fabs( baseFunction.polys[0].start );
309 return Real(((*b1)*b2->
scale(width2/width1).
shift((center2-center1)/width1)).integral(-2*r,2*r)*width1/sqrt(width1*width2));
311 return Real(((*b1)*b2->
scale(width2/width1).
shift((center2-center1)/width1)).integral(-2*r,2*r)*width1/(width1*width2));
313 return Real(((*b1)*b2->
scale(width2/width1).
shift((center2-center1)/width1)).integral(-2*r,2*r)*width1);
316 template<
int Degree,
class Real>
319 const PPolynomial< Degree-1 > *b1;
320 const PPolynomial< Degree > *b2;
321 if ( boundary1==-1 ) b1 = & dLeftBaseFunction;
322 else if( boundary1== 0 ) b1 = & dBaseFunction;
323 else if( boundary1== 1 ) b1 = &dRightBaseFunction;
324 if ( boundary2==-1 ) b2 = & leftBaseFunction;
325 else if( boundary2== 0 ) b2 = & baseFunction;
326 else if( boundary2== 1 ) b2 = & rightBaseFunction;
327 double r=fabs(baseFunction.polys[0].start);
330 return Real(((*b1)*b2->scale(width2/width1).shift((center2-center1)/width1)).integral(-2*r,2*r)/sqrt(width1*width2));
332 return Real(((*b1)*b2->scale(width2/width1).shift((center2-center1)/width1)).integral(-2*r,2*r)/(width1*width2));
334 return Real(((*b1)*b2->scale(width2/width1).shift((center2-center1)/width1)).integral(-2*r,2*r));
337 template<
int Degree,
class Real>
341 if ( boundary1==-1 ) b1 = & dLeftBaseFunction;
342 else if( boundary1== 0 ) b1 = & dBaseFunction;
343 else if( boundary1== 1 ) b1 = &dRightBaseFunction;
344 if ( boundary2==-1 ) b2 = & dLeftBaseFunction;
345 else if( boundary2== 0 ) b2 = & dBaseFunction;
346 else if( boundary2== 1 ) b2 = &dRightBaseFunction;
347 double r=fabs(baseFunction.polys[0].start);
351 return Real(((*b1)*b2->scale(width2/width1).shift((center2-center1)/width1)).integral(-2*r,2*r)/width2/sqrt(width1*width2));
353 return Real(((*b1)*b2->scale(width2/width1).shift((center2-center1)/width1)).integral(-2*r,2*r)/width2/(width1*width2));
355 return Real(((*b1)*b2->scale(width2/width1).shift((center2-center1)/width1)).integral(-2*r,2*r)/width2);
359 template<
int Degree,
class Real>
365 return Real((
baseFunction*
baseFunction.scale(width2/width1).shift((center2-center1)/width1)).integral(-2*r,2*r)*width1/sqrt(width1*width2));
367 return Real((
baseFunction*
baseFunction.scale(width2/width1).shift((center2-center1)/width1)).integral(-2*r,2*r)*width1/(width1*width2));
372 template<
int Degree,
class Real>
384 template<
int Degree,
class Real>
397 template<
int Degree,
class Real>
400 if( i1>i2 )
return ((i1*i1+i1)>>1)+i2;
401 else return ((i2*i2+i2)>>1)+i1;
403 template<
int Degree,
class Real>
408 index = ((i2*i2+i2)>>1)+i1;
412 index = ((i1*i1+i1)>>1)+i2;
static void CenterAndWidth(int depth, int offset, Real ¢er, Real &width)
static int CumulativeCenterCount(int maxDepth)
static void DepthAndOffset(int idx, int &depth, int &offset)
virtual void setDotTables(const int &flags)
static const int D_VALUE_FLAG
Real dotProduct(const double ¢er1, const double &width1, const double ¢er2, const double &width2) const
PPolynomial< Degree > baseFunction
Real d2DotProduct(const double ¢er1, const double &width1, const double ¢er2, const double &width2) const
static const int DOT_FLAG
static const int D_DOT_FLAG
PPolynomial< Degree-1 > dBaseFunction
virtual void clearValueTables(void)
PPolynomial< Degree+1 > * baseFunctions
static const int VALUE_FLAG
static const int D2_DOT_FLAG
static int SymmetricIndex(const int &i1, const int &i2)
virtual void setValueTables(const int &flags, const double &smooth=0)
void set(const int &maxDepth, const PPolynomial< Degree > &F, const int &normalize, bool useDotRatios=true)
virtual void clearDotTables(const int &flags)
Real dDotProduct(const double ¢er1, const double &width1, const double ¢er2, const double &width2) const
PPolynomial shift(double t) const
PPolynomial scale(double s) const