eigenmath/arccosh.cpp

64 lines
738 B
C++
Raw Permalink Normal View History

2004-03-03 21:24:06 +01:00
#include "stdafx.h"
#include "defs.h"
void
eval_arccosh(void)
{
push(cadr(p1));
eval();
arccosh();
}
2006-01-04 02:21:32 +01:00
void
2004-03-03 21:24:06 +01:00
arccosh(void)
{
double d;
save();
p1 = pop();
2006-04-19 01:18:30 +02:00
if (car(p1) == symbol(COSH)) {
push(cadr(p1));
restore();
return;
}
2005-08-06 22:57:37 +02:00
if (isdouble(p1)) {
2004-03-03 21:24:06 +01:00
d = p1->u.d;
if (d < 1.0)
stop("arccosh function argument is less than 1.0");
d = log(d + sqrt(d * d - 1.0));
push_double(d);
restore();
return;
}
if (isplusone(p1)) {
2004-06-25 22:45:15 +02:00
push(zero);
2004-03-03 21:24:06 +01:00
restore();
return;
}
push_symbol(ARCCOSH);
push(p1);
list(2);
restore();
}
2007-05-08 16:57:30 +02:00
#if SELFTEST
2004-03-03 21:24:06 +01:00
static char *s[] = {
"arccosh(1.0)",
"0",
"arccosh(1)",
"0",
2006-04-19 01:18:30 +02:00
"arccosh(cosh(x))",
"x",
2004-03-03 21:24:06 +01:00
};
void
test_arccosh(void)
{
test(__FILE__, s, sizeof s / sizeof (char *));
}
2007-05-08 16:57:30 +02:00
#endif