Gamma function: Difference between revisions

Content added Content deleted
Line 3,812: Line 3,812:


function gamma_(x_) {
function gamma_(x_) {
external _gamma_coef
external _gamma_coef
x = x_
x = x_
y = 1
y = 1
while (x<0.5) y = y/x++
while (x<0.5) y = y/x++
while (x>1.5) y = --x*y
while (x>1.5) y = --x*y
z = _gamma_coef[30]
z = _gamma_coef[30]
x--
x--
for (i=29; i>=1; i--) z = z*x+_gamma_coef[i]
for (i=29; i>=1; i--) z = z*x+_gamma_coef[i]
return(y/z)
return(y/z)
}
}
function map(f,a) {
function map(f,a) {
n = rows(a)
n = rows(a)
p = cols(a)
p = cols(a)
b = J(n,p,.)
b = J(n,p,.)
for (i=1; i<=n; i++) {
for (i=1; i<=n; i++) {
for (j=1; j<=p; j++) {
for (j=1; j<=p; j++) {
b[i,j] = (*f)(a[i,j])
b[i,j] = (*f)(a[i,j])
}
}
}
}
return(b)
return(b)
}
}