14 Real wsum, shift, cff;
22 Real Fgamma = 0.284_rt;
38 for(
int i=1;i<=2*ndtfast;i++) {
57 scale=(Falpha+1.0_rt)*(Falpha+Fbeta+1.0_rt) /
58 ((Falpha+2.0_rt)*(Falpha+Fbeta+2.0_rt)*Real(ndtfast));
64 gamma = Fgamma*max(0.0_rt, 1.0_rt-10.0_rt/Real(ndtfast));
66 for (
int iter=1;iter<=16;iter++) {
68 for(
int i=1;i<=2*ndtfast;i++) {
71 weight1[i-1]=Real(pow(cff,Falpha)-pow(cff,(Falpha+Fbeta)))-gamma*cff;
73 if (weight1[i-1] > 0.0_rt) {
77 if ( (
nfast>0) && (weight1[i-1] < 0.0_rt) ) {
78 weight1[i-1] = 0.0_rt;
83 for(
int i=1;i<=
nfast;i++) {
84 wsum=wsum+weight1[i-1];
85 shift=shift+weight1[i-1]*Real(i);
87 scale *= shift/(wsum*Real(ndtfast));
106 for (
int iter=1;iter<=ndtfast;iter++) {
109 for(
int i=1;i<=
nfast;i++) {
110 wsum=wsum+weight1[i-1];
111 shift=shift+Real(i)*weight1[i-1];
114 cff=Real(ndtfast)-shift;
121 for (
int i=
nfast;i>=2;i--) {
122 weight1[i-1]=weight1[i-1-1];
124 weight1[1-1] = 0.0_rt;
125 }
else if (cff> 0.0_rt) {
127 for (
int i=
nfast;i>=2;i--) {
128 weight1[i-1]=wsum*weight1[i-1]+cff*weight1[i-1-1];
130 weight1[1-1]=wsum*weight1[1-1];
131 }
else if (cff < -1.0_rt) {
133 for (
int i=1;i<=
nfast;i++) {
134 weight1[i-1]=weight1[i+1-1];
136 weight1[
nfast+1-1] = 0.0_rt;
137 }
else if (cff < 0.0_rt) {
139 for (
int i=1;i<=
nfast-1;i++) {
140 weight1[i-1]=wsum*weight1[i-1]-cff*weight1[i+1-1];
149 for(
int j=1;j<=
nfast;j++) {
151 for(
int i=1;i<=j;i++) {
152 weight2[i-1]=weight2[i-1]+cff;
161 for(
int i=1;i<=
nfast;i++) {
162 wsum=wsum+weight1[i-1];
163 cff=cff+weight2[i-1];
166 wsum = 1.0_rt / wsum;
169 for(
int i=1;i<=
nfast;i++) {
170 weight1[i-1]=wsum*weight1[i-1];
171 weight2[i-1]=cff*weight2[i-1];
178 if (ParallelDescriptor::IOProcessor()) {
179 Print().SetPrecision(18)<<ParallelDescriptor::NProcs()<<
" "<<ndtfast<<
" "<<
nfast<<
" "<<wsum<<std::endl;
185 for(
int i=1;i<=
nfast;i++) {
186 cff=cff+weight1[i-1];
187 cff1=cff1+weight1[i-1]*Real(i);
188 cff2=cff2+weight1[i-1]*Real(i*i);
189 wsum=wsum+weight2[i-1];
190 shift=shift+weight2[i-1]*(Real(i)-0.5_rt);
191 Print().SetPrecision(18)<<
"i="<<i<<
" "<<weight1[i-1]<<
" "<<weight2[i-1]<<
" "<<cff<<
" "<<wsum<<std::endl;
193 cff1=cff1/Real(ndtfast);
194 cff2=cff2/(Real(ndtfast)*Real(ndtfast));
195 shift=shift/Real(ndtfast);
196 Print().SetPrecision(18)<<ndtfast <<
" "<<
nfast<<
" "<<Real(
nfast)/Real(ndtfast)<<std::endl;
197 Print().SetPrecision(18)<<cff1<<
" "<<cff2<<
" "<<shift<<
" "<<cff<<
" "<<wsum<<
" "<<Fgamma<<
" "<<gamma<<std::endl;
198 if (cff2<1.0_rt001_rt) Print()<<
"\n\n\n"<<std::endl;