summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/gsl.cc
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2012-05-31 00:02:26 +0000
committerKarl Berry <karl@freefriends.org>2012-05-31 00:02:26 +0000
commit19fc9fd9a26973d87fad437ce549ffaba479df54 (patch)
treef40a9d2592b3cf827970c8bf54a1eebf9cc8f9c0 /Build/source/utils/asymptote/gsl.cc
parent24b3bac312553b2cc61e94fda581aba311967f5c (diff)
asy 2.16 sources
git-svn-id: svn://tug.org/texlive/trunk@26734 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/asymptote/gsl.cc')
-rw-r--r--Build/source/utils/asymptote/gsl.cc49
1 files changed, 32 insertions, 17 deletions
diff --git a/Build/source/utils/asymptote/gsl.cc b/Build/source/utils/asymptote/gsl.cc
index 0eb8c2590ba..cfb6a5a3785 100644
--- a/Build/source/utils/asymptote/gsl.cc
+++ b/Build/source/utils/asymptote/gsl.cc
@@ -48,6 +48,7 @@ using types::realArray;
using types::stringArray;
using vm::stack;
+using vm::array;
using vm::pop;
using vm::error;
using run::copyArrayC;
@@ -558,21 +559,21 @@ void GSLrngInit(stack *s)
void GSLrngList(stack *s)
{
- vm::array* a = new vm::array(0);
+ array* a = new array(0);
const gsl_rng_type **t;
for(t=GSLrngFirstType; *t!=0; ++t) {
a->push(string((*t)->name));
}
- s->push<vm::array*>(a);
+ s->push<array*>(a);
checkGSLerror();
}
void GSLrngSet(stack *s)
{
- unsigned long int i = unsignedcast(pop<Int>(s,-1));
+ Int i=pop<Int>(s,-1);
checkGSLrng();
- if(i<0) gsl_rng_set(GSLrng,gsl_rng_default_seed);
- else gsl_rng_set(GSLrng,i);
+ if(i < 0) gsl_rng_set(GSLrng,gsl_rng_default_seed);
+ else gsl_rng_set(GSLrng,unsignedcast(i));
checkGSLerror();
}
@@ -873,21 +874,21 @@ void GSLrng_dir(stack *s)
checkGSLrng();
double* p = new double[n];
gsl_ran_dir_nd(GSLrng,n,p);
- s->push<vm::array*>(copyCArray(n,p));
+ s->push<array*>(copyCArray(n,p));
delete[] p;
checkGSLerror();
}
void GSLrng_dirichlet(stack *s)
{
- vm::array* alpha = pop<vm::array*>(s);
+ array* alpha = pop<array*>(s);
size_t K = checkArray(alpha);
checkGSLrng();
double* calpha;
copyArrayC(calpha,alpha);
double* ctheta = new double[K];
gsl_ran_dirichlet(GSLrng,K,calpha,ctheta);
- s->push<vm::array*>(copyCArray(K,ctheta));
+ s->push<array*>(copyCArray(K,ctheta));
delete[] ctheta;
delete[] calpha;
checkGSLerror();
@@ -895,8 +896,8 @@ void GSLrng_dirichlet(stack *s)
void GSLpdf_dirichlet(stack *s)
{
- vm::array* theta = pop<vm::array*>(s);
- vm::array* alpha = pop<vm::array*>(s);
+ array* theta = pop<array*>(s);
+ array* alpha = pop<array*>(s);
size_t K = checkArray(alpha);
if(checkArray(theta) != K)
error(GSLinvalid);
@@ -912,7 +913,7 @@ void GSLpdf_dirichlet(stack *s)
void GSLrng_multinomial(stack *s)
{
- vm::array* p = pop<vm::array*>(s);
+ array* p = pop<array*>(s);
unsigned int N = unsignedcast(pop<Int>(s));
size_t K = checkArray(p);
checkGSLrng();
@@ -920,7 +921,7 @@ void GSLrng_multinomial(stack *s)
copyArrayC(cp,p);
unsigned int* cn = new unsigned int[K];
gsl_ran_multinomial(GSLrng,K,N,cp,cn);
- s->push<vm::array*>(copyCArray(K,cn));
+ s->push<array*>(copyCArray(K,cn));
delete[] cn;
delete[] cp;
checkGSLerror();
@@ -928,8 +929,8 @@ void GSLrng_multinomial(stack *s)
void GSLpdf_multinomial(stack *s)
{
- vm::array* n = pop<vm::array*>(s);
- vm::array* p = pop<vm::array*>(s);
+ array* n = pop<array*>(s);
+ array* p = pop<array*>(s);
size_t K = checkArray(p);
if(K != checkArray(n)) error(GSLinvalid);
double* cp;
@@ -942,6 +943,19 @@ void GSLpdf_multinomial(stack *s)
checkGSLerror();
}
+void GSLsf_elljac_e(stack *s)
+{
+ double m = pop<double>(s);
+ double u = pop<double>(s);
+ double sn,cn,dn;
+ gsl_sf_elljac_e(u,m,&sn,&cn,&dn);
+ array *result=new array(3);
+ (*result)[0]=sn;
+ (*result)[1]=cn;
+ (*result)[2]=dn;
+ s->push(result);
+}
+
// Handle GSL errors gracefully.
void GSLerrorhandler(const char *reason, const char *, int, int)
{
@@ -1080,9 +1094,6 @@ void gen_rungsl_venv(venv &ve)
addGSLDOUBLE3Func<gsl_sf_ellint_RF>(SYM(RF),SYM(x),SYM(y),SYM(z));
addGSLDOUBLE4Func<gsl_sf_ellint_RJ>(SYM(RJ),SYM(x),SYM(y),SYM(z),SYM(p));
- // Elliptic functions (Jacobi)
- // to be implemented
-
// Error functions
addGSLRealFunc<gsl_sf_erf>(SYM(erf));
addGSLRealFunc<gsl_sf_erfc>(SYM(erfc));
@@ -1395,6 +1406,10 @@ void gen_rungsl_venv(venv &ve)
addFunc(GSLModule->e.ve,GSLrng_dir3d,primTriple(),SYM(rng_dir3d));
addFunc(GSLModule->e.ve,GSLrng_dir,realArray(),SYM(rng_dir),
formal(primInt(),SYM(n)));
+
+ // Elliptic functions (Jacobi)
+ addFunc(GSLModule->e.ve,GSLsf_elljac_e,realArray(),SYM(sncndn),
+ formal(primReal(),SYM(u)),formal(primReal(),SYM(m)));
// Dirirchlet distribution
addFunc(GSLModule->e.ve,GSLrng_dirichlet,realArray(),SYM(rng_dirichlet),