add numerical recipes library
This commit is contained in:
34
lib/nr/k_and_r/recipes/hypser.c
Normal file
34
lib/nr/k_and_r/recipes/hypser.c
Normal file
@@ -0,0 +1,34 @@
|
||||
|
||||
#include "complex.h"
|
||||
#define ONE Complex(1.0,0.0)
|
||||
|
||||
void hypser(a,b,c,z,series,deriv)
|
||||
fcomplex *deriv,*series,a,b,c,z;
|
||||
{
|
||||
void nrerror();
|
||||
int n;
|
||||
fcomplex aa,bb,cc,fac,temp;
|
||||
|
||||
deriv->r=0.0;
|
||||
deriv->i=0.0;
|
||||
fac=Complex(1.0,0.0);
|
||||
temp=fac;
|
||||
aa=a;
|
||||
bb=b;
|
||||
cc=c;
|
||||
for (n=1;n<=1000;n++) {
|
||||
fac=Cmul(fac,Cdiv(Cmul(aa,bb),cc));
|
||||
deriv->r+=fac.r;
|
||||
deriv->i+=fac.i;
|
||||
fac=Cmul(fac,RCmul(1.0/n,z));
|
||||
*series=Cadd(temp,fac);
|
||||
if (series->r == temp.r && series->i == temp.i) return;
|
||||
temp= *series;
|
||||
aa=Cadd(aa,ONE);
|
||||
bb=Cadd(bb,ONE);
|
||||
cc=Cadd(cc,ONE);
|
||||
|
||||
}
|
||||
nrerror("convergence failure in hypser");
|
||||
}
|
||||
#undef ONE
|
||||
Reference in New Issue
Block a user