eigenmath/bessely.cpp

86 lines
1.0 KiB
C++
Raw Permalink Normal View History

2005-07-30 21:37:29 +02:00
//-----------------------------------------------------------------------------
//
// Bessel Y function
//
// Input: tos-2 x (can be a symbol or expr)
//
// tos-1 n
//
// Output: Result on stack
//
//-----------------------------------------------------------------------------
#include "stdafx.h"
#include "defs.h"
void
eval_bessely(void)
{
push(cadr(p1));
eval();
push(caddr(p1));
eval();
bessely();
}
void
bessely(void)
{
save();
2005-10-04 02:02:16 +02:00
yybessely();
2005-07-30 21:37:29 +02:00
restore();
}
#define X p1
#define N p2
2006-01-04 02:47:50 +01:00
void
2005-10-04 02:02:16 +02:00
yybessely(void)
2005-07-30 21:37:29 +02:00
{
double d;
int n;
N = pop();
X = pop();
push(N);
n = pop_integer();
2005-10-04 02:02:16 +02:00
if (isdouble(X) && n != (int) 0x80000000) {
d = yn(n, X->u.d);
2005-07-30 21:37:29 +02:00
push_double(d);
return;
}
if (isnegativeterm(N)) {
push_integer(-1);
push(N);
power();
push_symbol(BESSELY);
push(X);
push(N);
negate();
list(3);
multiply();
return;
}
push_symbol(BESSELY);
push(X);
push(N);
list(3);
return;
}
static char *s[] = {
"bessely(x,n)",
"bessely(x,n)",
};
void
test_bessely(void)
{
test(__FILE__, s, sizeof s / sizeof (char *));
}