error functions
[calc.git] / parser.c
index f88da5d28a7cde05bf79f1526d439e785ec3206a..c94a1e38841ce79e5056394646743ede94c4400a 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -130,7 +130,7 @@ keyword_t operators[NB_OPERATORS] = {
     { "|",   Or, 2, 1, -2}
 };
 
-#define NB_FUNCTIONS 32
+#define NB_FUNCTIONS 34
 keyword_t functions[NB_FUNCTIONS] = {
     { "sqrt", Sqr, 1, 4, 5},
     { "pow",  Pow, 2, 3, 5},
@@ -143,6 +143,8 @@ keyword_t functions[NB_FUNCTIONS] = {
     { "ln",   Ln, 1, 2, 5},
     { "log",  Log, 1, 3, 5},
     { "exp",  Exp, 1, 3, 5},
+    { "erfc", Erfc, 1, 4, 5},
+    { "erf",  Erf, 1, 3, 5},
     { "abs",  Abs, 1, 3, 5},
     { "floor", Floor, 1, 5, 5},
     { "ceil", Ceil, 1, 4, 5},
@@ -517,6 +519,8 @@ void print_element (element_t *root, int level)
     case Ln: func = "Logarithm (e base)"; break;
     case Log: func = "Logarithm (10 base)"; break;
     case Exp: func = "Exponantial"; break;
+    case Erfc: func = "Complementary Error Function"; break;
+    case Erf: func = "Error Function"; break;
     case Abs: func = "Absolute value"; break;
     case Ceil: func = "Ceil value"; break;
     case Floor: func = "Floor value"; break;
@@ -967,6 +971,8 @@ void help (void)
     fprintf (stdout, " exp ln log pow sqrt\n");
     fprintf (stdout, "trigonometric func.:");
     fprintf (stdout, " acos asin atan cos sin tan\n");
+    fprintf (stdout, "error functions:");
+    fprintf (stdout, " erf erfc\n");
     fprintf (stdout, "miscellaneous func.:");
     fprintf (stdout, " abs ceil floor\n");
     fprintf (stdout, "storage func.:");
@@ -1055,6 +1061,8 @@ double evaluate_element (element_t *root, char mask)
     case Ln:
     case Log:
     case Exp:
+    case Erfc:
+    case Erf:
     case Abs:
     case Ceil:
     case Floor:
@@ -1114,6 +1122,8 @@ double evaluate_element (element_t *root, char mask)
     case Ln: return log (op0);
     case Log: return log10 (op0);
     case Exp: return exp (op0);
+    case Erfc: return erfc (op0);
+    case Erf: return erf (op0);
     case Abs: return fabs (op0);
     case Ceil: return ceil (op0);
     case Floor: return floor (op0);