/*We use the Cauchy Gourat theorem to compute the derivatives of the double(Mellin+Laplace) transform */
static dcomplex dermellin(dcomplex l, double sg, double r, int nummom)
{
  dcomplex term, cv, mu;
  int i;
  double r0,sumr, sumi/*,x[NPOINTS_FUSAITAGL+1],w[NPOINTS_FUSAITAGL+1]*/;
  double v;
  double *x,*w;

  x=malloc((NPOINTS_FUSAITAGL+1)*sizeof(double));
  w=malloc((NPOINTS_FUSAITAGL+1)*sizeof(double));

  sumr=0.0;
  sumi=0.0;
  
  gauleg(0, 2*M_PI, x, w,NPOINTS_FUSAITAGL);
	
  v   = 2*r/(sg*sg)-1.0;
  cv = Complex(v,0.0);
  mu = Csqrt(Cadd(Complex(v*v,0), RCmul(2.0,l)));
  r0 = Creal(RCmul(0.5,Csub(mu,cv)));	
  if(r0>1.0) r0=0.25;


  for (i=1;i<=NPOINTS_FUSAITAGL;i++) 
    {
    term = 	RCmul(pow(r0,nummom), Cexp(Complex(0.0, nummom*x[i])));
    sumr += w[i]*Creal(Cdiv(mellintransform(l, RCmul(r0, Cexp(Complex(0.0, x[i]))),  sg, r), term));
    sumi += w[i]*Cimag(Cdiv(mellintransform(l, RCmul(r0, Cexp(Complex(0.0, x[i]))),  sg, r), term));
    }

  free(x);
  free(w);
  
  return Complex(exp(factln(nummom))*sumr/(2.0*M_PI),exp(factln(nummom))*sumi/(2.0*M_PI));
}
Example #2
0
float bico(int n, int k)
/*returns the binomial coefficient Cn(haut)k(bas) = n!/(k!(n-k)!) as a floating-
point number*/
{
	float factln(int n);
	return (float)floor(0.5+exp(factln(n)-factln(k)-factln(n-k))); 
}
Example #3
0
 arma::mat factln(const arma::imat& x) {
   arma::mat ans; ans.copy_size(x);
   for(size_t i = 0; i < x.n_elem; i++) {
     ans[i] = factln(x[i]);
   }
   return ans;
 }
Example #4
0
double bino_pdf(int k, int n, float p)
{   
    double ln_binco = factln(n)-factln(k)-factln(n-k);
    double ln_ret = ln_binco + k*log(p) + (n-k)*log(1-p);
    return exp(ln_ret);
}
Example #5
0
File: zsm.c Project: rforge/sads
//funcao log-choose
double Lchoose(int n, int k){
  return(factln(n) - factln(k) - factln((n) - (k)));
}
Example #6
0
 template<> template<typename eT> arma_hot arma_pure arma_inline eT
 eop_core<eop_factln>::process(const eT val, const eT  ) {
   return factln(val);
 }
Example #7
0
/**
 * Compute the binomial coefficient (n,k)
 * Taken from numerical recipes.
 **/
inline double bico(const int64 n, const int64 k)
{
    MTOOLS_ASSERT((n >= 0) || (k >= 0) || (k <= n));
    if (n < 171) return floor(0.5 + factrl(n) / (factrl(k)*factrl(n - k)));
    return floor(0.5 + exp(factln(n) - factln(k) - factln(n - k)));
}
Example #8
0
double bico(int n, int k)
{
    double factln(int n);
    return floor(0.5+exp(factln(n)-factln(k)-factln(n-k)));
}
Example #9
0
float bico(int n, int k)			// returns binomial coefficients (nCk)
{
	if (k == 1) return n;
	if (k == 0) return 1.0;
	else return floor(0.5+exp(factln(n)-factln(k)-factln(n-k)));
}
 /* function bico(int n, int k)
  * ----------------------------
  * Binomial coefficient
  */
 REAL_TYPE bico(int n, int k)
 {
     return std::floor(0.5+std::exp(factln(n)-factln(k)-factln(n-k)));
 }
Example #11
0
File: bico.c Project: berndf/avg_q
float bico(int n, int k) {
 return floor(0.5+exp(factln(n)-factln(k)-factln(n-k)));
}