-
Notifications
You must be signed in to change notification settings - Fork 0
/
erf.c
56 lines (48 loc) · 719 Bytes
/
erf.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//-----------------------------------------------------------------------------
//
// Author : philippe.billet@noos.fr
//
// Error function erf(x)
// erf(-x)=erf(x)
//
//-----------------------------------------------------------------------------
#include "stdafx.h"
#include "defs.h"
static void yyerf(void);
void
eval_erf(void)
{
push(cadr(p1));
eval();
yerf();
}
void
yerf(void)
{
save();
yyerf();
restore();
}
static void
yyerf(void)
{
double d;
p1 = pop();
if (isdouble(p1)) {
d = 1.0 - erfc(p1->u.d);
push_double(d);
return;
}
if (isnegativeterm(p1)) {
push_symbol(ERF);
push(p1);
negate();
list(2);
negate();
return;
}
push_symbol(ERF);
push(p1);
list(2);
return;
}