amath  1.8.5
Simple command line calculator
defs.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  */
26 
27 #ifndef AMATH_FUNCTION_DEFS_H
28 #define AMATH_FUNCTION_DEFS_H
29 
30 /**
31  * @file defs.h
32  * @brief Function definitions for math logic.
33  *
34  */
35 
36 #include "absolute.h"
37 #include "aexcosecant.h"
38 #include "aexsecant.h"
39 #include "arccos.h"
40 #include "arcchord.h"
41 #include "arcsin.h"
42 #include "arctan.h"
43 #include "arccosecant.h"
44 #include "arccotangent.h"
45 #include "arcsecant.h"
46 #include "arccovercosine.h"
47 #include "arccoversine.h"
48 #include "archacovercosine.h"
49 #include "archacoversine.h"
50 #include "archavercosine.h"
51 #include "archaversine.h"
52 #include "arcvercosine.h"
53 #include "arcversine.h"
54 #include "ceil.h"
55 #include "chord.h"
56 #include "cosecant.h"
57 #include "cosine.h"
58 #include "cotangent.h"
59 #include "covercos.h"
60 #include "coversin.h"
61 #include "cube.h"
62 #include "excosecant.h"
63 #include "exsecant.h"
64 #include "floor.h"
65 #include "hacovercos.h"
66 #include "hacoversin.h"
67 #include "havercos.h"
68 #include "haversin.h"
69 #include "hyparccosecant.h"
70 #include "hyparccosine.h"
71 #include "hyparccotangent.h"
72 #include "hyparcsecant.h"
73 #include "hyparcsine.h"
74 #include "hyparctangent.h"
75 #include "hypcosecant.h"
76 #include "hypcosine.h"
77 #include "hypcotangent.h"
78 #include "hypsecant.h"
79 #include "hypsine.h"
80 #include "hyptangent.h"
81 #include "ln.h"
82 #include "log2.h"
83 #include "log10.h"
84 #include "round.h"
85 #include "secant.h"
86 #include "signum.h"
87 #include "sine.h"
88 #include "trunc.h"
89 #include "square.h"
90 #include "tangent.h"
91 #include "vercos.h"
92 #include "versin.h"
93 
94 #include "main/nodes.h"
95 
96 class FunctionNode;
97 typedef FunctionNode* (*CreateFunctionNode)(ExpressionNode*, char*, char*);
98 
99 /**
100  * @brief Function definitions of known mathematical functions.
101  *
102  */
104 {
105  const char* name;
106  CreateFunctionNode create;
107 };
108 
109 static const functiondef functiondefs[] = {
111  {"sgn", SignumNode::Create},
112  {"round", RoundNode::Create},
113  {"trunc", TruncNode::Create},
114  {"floor", FloorNode::Create},
115  {"ceil", CeilingNode::Create},
116  {"sqrt", SquareRootNode::Create},
117  {"cbrt", CubeRootNode::Create},
118  {"lb", BinaryLogNode::Create},
119  {"ln", LnRootNode::Create},
120  {"lg", LogNode::Create},
121  {"sin", SineNode::Create},
122  {"cos", CosineNode::Create},
123  {"tan", TangentNode::Create},
124  {"tg", TangentNode::Create},
125  {"cot", CotangentNode::Create},
126  {"cotan", CotangentNode::Create},
127  {"cotg", CotangentNode::Create},
128  {"ctg", CotangentNode::Create},
129  {"ctn", CotangentNode::Create},
130  {"sec", SecantNode::Create},
131  {"csc", CosecantNode::Create},
132  {"cosec", CosecantNode::Create},
133  {"crd", ChordNode::Create},
134  {"exsec", ExsecantNode::Create},
135  {"excsc", ExcosecantNode::Create},
136  {"asin", ArcSineNode::Create},
137  {"acos", ArcCosineNode::Create},
138  {"atan", ArcTangentNode::Create},
139  {"acot", ArcCotangentNode::Create},
140  {"asec", ArcSecantNode::Create},
141  {"acsc", ArcCosecantNode::Create},
142  {"acrd", ArcChordNode::Create},
143  {"aexsec", ArcExsecantNode::Create},
144  {"aexcsc", ArcExcosecantNode::Create},
145  {"sinh", HyperbolicSineNode::Create},
157  {"ver", VersedSineNode::Create},
158  {"vcs", VersedCosineNode::Create},
159  {"cvs", CoversedSineNode::Create},
161  {"hv", HaVersedSineNode::Create},
165  {"aver", ArcVersedSineNode::Create},
166  {"avcs", ArcVersedCosineNode::Create},
167  {"acvs", ArcCoversedSineNode::Create},
173 };
174 
175 #endif
A versed sine function in a syntax tree.
Definition: versin.h:42
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: arcversine.cpp:37
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
An inverse coversed cosine function in a syntax tree.
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: cotangent.cpp:37
A chord function in a syntax tree.
Definition: chord.h:42
A cotangent function in a syntax tree.
Definition: cotangent.h:42
A coversed sine function in a syntax tree.
Definition: coversin.h:42
An inverse hyperbolic cosine function in a syntax tree.
Definition: hyparccosine.h:42
An inverse exsecant function in a syntax tree.
Definition: aexsecant.h:42
A sine function in a syntax tree.
Definition: sine.h:42
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: excosecant.cpp:37
A arccosine function in a syntax tree.
Definition: arccos.h:42
Represents a mathematical function in a syntax tree.
Definition: node.h:50
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: log10.cpp:37
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: chord.cpp:37
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: hypcosecant.cpp:37
A exsecant function in a syntax tree.
Definition: exsecant.h:42
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
A rounding function in a syntax tree.
Definition: round.h:44
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
An inverse chord function in a syntax tree.
Definition: arcchord.h:42
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: arccosecant.cpp:37
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: hacovercos.cpp:37
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: arcsin.cpp:37
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
A cube root function in a syntax tree.
Definition: cube.h:42
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: signum.cpp:37
An inverse haversed cosine function in a syntax tree.
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
A floor function in a syntax tree.
Definition: floor.h:42
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: tangent.cpp:37
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: secant.cpp:37
A cosecant function in a syntax tree.
Definition: cosecant.h:42
An inverse hyperbolic cotangent function in a syntax tree.
An inverse hyperbolic secant function in a syntax tree.
Definition: hyparcsecant.h:42
A truncation function in a syntax tree.
Definition: trunc.h:45
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: arccos.cpp:37
A arccotangent function in a syntax tree.
Definition: arccotangent.h:42
A secant function in a syntax tree.
Definition: secant.h:42
A arcsecant function in a syntax tree.
Definition: arcsecant.h:42
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: exsecant.cpp:37
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: round.cpp:37
An inverse hacoversed cosine function in a syntax tree.
A hyperbolic cotangent function in a syntax tree.
Definition: hypcotangent.h:42
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: versin.cpp:37
A natural logarithm function in a syntax tree.
Definition: ln.h:42
A logarithm function in a syntax tree.
Definition: log10.h:42
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: cube.cpp:37
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: cosine.cpp:37
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: absolute.cpp:37
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: hyparcsine.cpp:37
An inverse excosecant function in a syntax tree.
Definition: aexcosecant.h:42
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: log2.cpp:37
A versed cosine function in a syntax tree.
Definition: vercos.h:42
A hacoversed sine function in a syntax tree.
Definition: hacoversin.h:42
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: vercos.cpp:37
A hyperbolic sine function in a syntax tree.
Definition: hypsine.h:42
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: ceil.cpp:37
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: coversin.cpp:37
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: hypsine.cpp:37
An inverse hacoversed sine function in a syntax tree.
An inverse haversed sine function in a syntax tree.
Definition: archaversine.h:42
Function definitions of known mathematical functions.
Definition: defs.h:103
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: arcsecant.cpp:37
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: cosecant.cpp:37
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: havercos.cpp:37
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
An inverse hyperbolic tangent function in a syntax tree.
Definition: hyparctangent.h:42
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: arcchord.cpp:37
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: aexcosecant.cpp:37
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: hypsecant.cpp:37
A hacoversed cosine function in a syntax tree.
Definition: hacovercos.h:42
An inverse coversed sine function in a syntax tree.
Definition: arccoversine.h:42
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: hypcosine.cpp:37
CreateFunctionNode create
Definition: defs.h:106
A arccosecant function in a syntax tree.
Definition: arccosecant.h:42
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: aexsecant.cpp:37
A excosecant function in a syntax tree.
Definition: excosecant.h:42
A haversed sine function in a syntax tree.
Definition: haversin.h:42
A cosine function in a syntax tree.
Definition: cosine.h:42
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: arctan.cpp:37
A hyperbolic cosecant function in a syntax tree.
Definition: hypcosecant.h:42
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: hacoversin.cpp:37
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
An inverse hyperbolic sine function in a syntax tree.
Definition: hyparcsine.h:42
A arcsine function in a syntax tree.
Definition: arcsin.h:42
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: ln.cpp:37
A haversed cosine function in a syntax tree.
Definition: havercos.h:42
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: hyptangent.cpp:37
static const functiondef functiondefs[]
Definition: defs.h:109
A tangent function in a syntax tree.
Definition: tangent.h:42
A coversed cosine function in a syntax tree.
Definition: covercos.h:42
A signum function in a syntax tree.
Definition: signum.h:44
An inverse hyperbolic cosecant function in a syntax tree.
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: sine.cpp:37
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Base class for all nodes related to mathematical expressions.
Definition: nodes.h:99
A cube root function in a syntax tree.
Definition: square.h:42
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: trunc.cpp:37
A arctangent function in a syntax tree.
Definition: arctan.h:42
A hyperbolic tangent function in a syntax tree.
Definition: hyptangent.h:42
A ceiling function in a syntax tree.
Definition: ceil.h:42
const char * name
Definition: defs.h:105
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: floor.cpp:37
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
A hyperbolic secant function in a syntax tree.
Definition: hypsecant.h:42
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: haversin.cpp:37
An inverse versed cosine function in a syntax tree.
Definition: arcvercosine.h:42
A binary logarithm function in a syntax tree.
Definition: log2.h:42
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: square.cpp:37
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)
Definition: covercos.cpp:37
An inverse versed sine function in a syntax tree.
Definition: arcversine.h:42
A hyperbolic cosine function in a syntax tree.
Definition: hypcosine.h:42
static FunctionNode * Create(ExpressionNode *expression, char *text, char *sys)