1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
template <typename T_out,typename T_contour ,typename T_in> class C_Integrator_Cauchy: public C_Integrator{
protected:
T_out (C_Integrator_Cauchy::*Integrator_ref)(T_contour * Contour,T_in * Point);
C_Integrator_Cauchy(int _NumPoints, double _LimDown, double _LimUp, int _NumAps, Integrator_ID id):C_Integrator(_NumPoints, _LimDown, _LimUp, _NumAps, id){}
public:
static C_Integrator_Cauchy * createIntegrator(int _NumPoints, double _LimDown, double _LimUp, int _NumAps, Integrator_ID id ){
C_Integrator_Cauchy * p = 0;
switch (id)
{
case qcauchyleg_lin_ID:
p = new C_Integrator_Cauchy(_NumPoints, _LimDown, _LimUp, _NumAps, id);
p->Integrator_ref=&C_Integrator_Cauchy::qcauchyleg_lin;
p->setNodes(id);
break;
default:
cout << "Integrator_ID Error" << endl;
assert( false);
}
return p;
}
T_out getResult(T_contour * Contour,T_in * Point){
return (this->*Integrator_ref)(Contour,Point);
}
T_out qcauchyleg_lin(T_contour * Contour,T_in * Point)
{
T_out result(NumAps);
T_out F(NumAps),resF(NumAps),sumF(NumAps);
T_in N,temp,sumN,resN;
T_in z_i,dz_i,coordin;
for (int i = 0; i < NumAps ; i++){sumF[i] = T_in(0.0,0.0);}
sumN = T_in(0.0,0.0);
for (int j=1;j<=NumPoints;j++)
{
temp = w[j];
z_i=(*Contour)[0][j-1];
dz_i=(*Contour)[1][j-1];
coordin=(*Point);
for (int i = 0; i < NumAps ; i++){F[i]=conj(z_i-coordin)/norm(z_i-coordin)*dz_i*(*Contour)[i+2][j-1];}
N=conj(z_i-coordin)/norm(z_i-coordin)*dz_i;
for (int i = 0; i < NumAps ; i++){sumF[i] += temp*F[i];}
sumN += temp*N;
}
for (int i = 0; i < NumAps ; i++){ result[i]=(sumF[i]/sumN); }
return result;
}
};
|