Little fix after the last commit (mostly a git fail)
[eigenmath-fx.git] / erf.cpp
blobdfe990569e909a623afe17d1893163b412e013a0
1 //-----------------------------------------------------------------------------
2 //
3 // Author : philippe.billet@noos.fr
4 //
5 // Error function erf(x)
6 // erf(-x)=erf(x)
7 //
8 //-----------------------------------------------------------------------------
10 #include "stdafx.h"
11 #include "defs.h"
12 static void yyerf(void);
14 void
15 eval_erf(void)
17 push(cadr(p1));
18 eval();
19 yerf();
22 void
23 yerf(void)
25 save();
26 yyerf();
27 restore();
30 static void
31 yyerf(void)
33 double d;
35 p1 = pop();
37 if (isdouble(p1)) {
38 d = 1.0 - erfc(p1->u.d);
39 push_double(d);
40 return;
43 if (isnegativeterm(p1)) {
44 push_symbol(ERF);
45 push(p1);
46 negate();
47 list(2);
48 negate();
49 return;
52 push_symbol(ERF);
53 push(p1);
54 list(2);
55 return;
58 #if SELFTEST
60 static char *s[] = {
62 "erf(a)",
63 "erf(a)",
65 "erf(0.0) + 1", // add 1 to round off
66 "1",
68 "float(erf(0)) + 1", // add 1 to round off
69 "1",
70 #if 0
71 "float(erf(1))",
72 "0.842701",
73 #endif
76 void
77 test_erf(void)
79 test(__FILE__, s, sizeof s / sizeof (char *));
82 #endif