OS 2.10.2
Loading...
Searching...
No Matches
OSnLNode.h
Go to the documentation of this file.
1/* $Id: OSnLNode.h 5284 2017-12-08 13:52:50Z stefan $ */
24#ifndef OSNLNODE_H
25#define OSNLNODE_H
26
27#include "OSConfig.h"
28#include "OSGeneral.h"
29#include "OSErrorClass.h"
30#include <iostream>
31#include <vector>
32#include <map>
33
34#ifdef OS_HAS_CPPAD
35# include <cppad/cppad.hpp>
36typedef CppAD::AD<double> ADdouble;
37typedef CppAD::vector<ADdouble> ADvector;
38#else
39typedef double ADdouble;
40typedef std::vector<ADdouble> ADvector;
41#endif
42
46class OSnLNode;
47class OSnLMNode;
48class OSMatrix;
49
57{
58public:
59
63
70
74 unsigned int inumberOfChildren;
75
80
85
90
91
96
100 virtual ~ExprNode();
101
102
106 virtual std::string getTokenNumber();
107
111 virtual std::string getTokenName() = 0;
112
120 virtual std::string getNonlinearExpressionInXML();
121
128 virtual std::vector<ExprNode*> getPrefixFromExpressionTree();
129
138 virtual std::vector<ExprNode*> preOrderOSnLNodeTraversal( std::vector<ExprNode*> *prefixVector);
139
146 virtual std::vector<ExprNode*> getPostfixFromExpressionTree();
147
156 virtual std::vector<ExprNode*> postOrderOSnLNodeTraversal( std::vector<ExprNode*> *postfixVector);
157
163 virtual ExprNode *cloneExprNode() = 0;
164
168 virtual bool IsEqual(ExprNode *that);
169};//end ExprNode
170
171
179class OSnLNode: public ExprNode
180{
181public:
186
191
192
197
201 virtual ~OSnLNode();
202
203
212 virtual void getVariableIndexMap(std::map<int, int> *varIdx);
213
222 virtual double calculateFunction(double *x) = 0;
223
231 virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD) = 0;
232
242 OSnLNode* createExpressionTreeFromPrefix(std::vector<ExprNode*> nlNodeVec);
243
250 virtual std::vector<ExprNode*> getPrefixFromExpressionTree();
251
260 virtual std::vector<ExprNode*> preOrderOSnLNodeTraversal( std::vector<ExprNode*> *prefixVector);
261
271 OSnLNode* createExpressionTreeFromPostfix(std::vector<ExprNode*> nlNodeVec);
272
279 virtual std::vector<ExprNode*> getPostfixFromExpressionTree();
280
289 virtual std::vector<ExprNode*> postOrderOSnLNodeTraversal( std::vector<ExprNode*> *postfixVector);
290
296
300 bool IsEqual(OSnLNode *that);
301};//end OSnLNode
302
303
315class OSnLNodePlus : public OSnLNode
316{
317public:
322
327
332 virtual std::string getTokenName();
333
338 virtual double calculateFunction( double *x);
339
344 virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
345
351
352};//end OSnLNodePlus
353
365class OSnLNodeSum : public OSnLNode
366{
367public:
372
377
382 virtual std::string getTokenName();
383
388 virtual double calculateFunction( double *x);
389
395
400 virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
401};//end OSnLNodeSum
402
414class OSnLNodeMax : public OSnLNode
415{
416public:
421
426
431 virtual std::string getTokenName();
432
437 virtual double calculateFunction( double *x);
438
444
449 virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
450};//end OSnLNodeMax
451
463class OSnLNodeMin : public OSnLNode
464{
465public:
470
475
480 virtual std::string getTokenName();
481
486 virtual double calculateFunction( double *x);
487
494
499 virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
500
501};//end OSnLNodeMin
502
503
516{
517public:
522
527
528
533 virtual std::string getTokenName();
534
539 virtual double calculateFunction( double *x);
540
546
551 virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
552};//end OSnLNodeMinus
553
554
567{
568public:
573
578
583 virtual std::string getTokenName();
584
589 virtual double calculateFunction( double *x);
590
596
597
602 virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
603};//end OSnLNodeNegate
604
605
618{
619public:
624
629
634 virtual std::string getTokenName();
635
640 virtual double calculateFunction( double *x);
641
647
652 virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
653
654};//end OSnLNodeTimes
655
656
669{
670public:
675
680
684 virtual std::string getTokenName();
685
690 virtual double calculateFunction( double *x);
691
697
702 virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
703};//end OSnLNodeDivide
704
705
718{
719public:
724
729
733 virtual std::string getTokenName();
734
739 virtual double calculateFunction( double *x);
740
746
751 virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
752};//end OSnLNodePower
753
754
767{
768public:
773
778
782 virtual std::string getTokenName();
783
788 virtual double calculateFunction( double *x);
789
795
800 virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
801};//end OSnLNodeProduct
802
803
815class OSnLNodeLn : public OSnLNode
816{
817public:
822
827
831 virtual std::string getTokenName();
832
837 virtual double calculateFunction( double *x);
838
844
849 virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
850};//end OSnLNodeLn
851
852
864class OSnLNodeSqrt : public OSnLNode
865{
866public:
871
876
880 virtual std::string getTokenName();
881
886 virtual double calculateFunction( double *x);
887
897 virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
898};//end OSnLNodeSqrt
899
900
913{
914public:
919
924
929 virtual std::string getTokenName();
930
935 virtual double calculateFunction( double *x);
936
942
947 virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
948};//end OSnLNodeSquare
949
950
962class OSnLNodeCos : public OSnLNode
963{
964public:
969
974
979 virtual std::string getTokenName();
980
985 virtual double calculateFunction( double *x);
986
992
997 virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
998};//end OSnLNodeCos
999
1000
1012class OSnLNodeSin : public OSnLNode
1013{
1014public:
1019
1024
1029 virtual std::string getTokenName();
1030
1035 virtual double calculateFunction( double *x);
1036
1042
1047 virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
1048};//end OSnLNodeSin
1049
1050
1062class OSnLNodeExp : public OSnLNode
1063{
1064public:
1069
1074
1079 virtual std::string getTokenName();
1080
1085 virtual double calculateFunction( double *x);
1086
1091 virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
1092
1098};//end OSnLNodeExp
1099
1100
1112class OSnLNodeAbs : public OSnLNode
1113{
1114public:
1119
1124
1129 virtual std::string getTokenName();
1130
1135 virtual double calculateFunction( double *x);
1136
1142
1147 virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
1148};//end OSnLNodeAbs
1149
1150
1162class OSnLNodeErf : public OSnLNode
1163{
1164public:
1169
1174
1179 virtual std::string getTokenName();
1180
1185 virtual double calculateFunction( double *x);
1186
1192
1197 virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
1198};//end OSnLNodeErf
1199
1200
1212class OSnLNodeIf : public OSnLNode
1213{
1214public:
1219
1224
1229 virtual std::string getTokenName();
1230
1235 virtual double calculateFunction( double *x);
1236
1242
1247 virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
1248};//end OSnLNodeIf
1249
1250
1263{
1264public:
1266 double value;
1267
1269 std::string type;
1270
1274 std::string id;
1275
1280
1285
1290 virtual std::string getTokenName();
1291
1296 virtual std::string getTokenNumber();
1297
1302 virtual std::string getNonlinearExpressionInXML();
1303
1308 virtual double calculateFunction( double *x);
1309
1315
1321
1326 virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
1327
1331 virtual bool IsEqual(OSnLNodeNumber *that);
1332};//end OSnLNodeNumber
1333
1334
1346class OSnLNodeE : public OSnLNode
1347{
1348public:
1349
1354
1359
1360
1365 virtual std::string getTokenNumber();
1366
1367
1372 virtual std::string getTokenName();
1373
1378 virtual std::string getNonlinearExpressionInXML();
1379
1384 virtual double calculateFunction( double *x);
1385
1391
1392
1397 virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
1398};//end OSnLNodeE
1399
1400
1412class OSnLNodePI : public OSnLNode
1413{
1414public:
1415
1420
1425
1426
1431 virtual std::string getTokenNumber();
1432
1433
1438 virtual std::string getTokenName();
1439
1444 virtual std::string getNonlinearExpressionInXML();
1445
1450 virtual double calculateFunction( double *x);
1451
1457
1458
1463 virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
1464};//end OSnLNodePI
1465
1466
1479{
1480public:
1481
1485 double coef;
1486
1488 int idx;
1489
1494
1499
1500 virtual void getVariableIndexMap(std::map<int, int> *varIdx);
1501
1505 virtual std::string getTokenNumber();
1506
1510 virtual std::string getTokenName();
1511
1515 virtual std::string getNonlinearExpressionInXML();
1516
1521 virtual double calculateFunction( double *x);
1522
1528
1534
1539 virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
1540
1544 virtual bool IsEqual(OSnLNodeVariable *that);
1545};//end OSnLNodeVariable
1546
1547
1561{
1562public:
1567
1572
1577 virtual std::string getTokenName();
1578
1583 virtual double calculateFunction( double *x);
1584
1590
1595 virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
1596};//end OSnLNodeAllDiff
1597
1598
1613{
1614public:
1619
1624
1629 virtual std::string getTokenName();
1630
1635 virtual double calculateFunction( double *x);
1636
1641 virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
1642
1648
1649};//end OSnLNodeMatrixDeterminant
1650
1663{
1664public:
1669
1675
1680 virtual std::string getTokenName();
1681
1686 virtual double calculateFunction( double *x);
1687
1692 virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
1693
1699};//end OSnLNodeMatrixToScalar
1700
1713{
1714public:
1719
1725
1730 virtual std::string getTokenName();
1731
1736 virtual double calculateFunction( double *x);
1737
1742 virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
1743
1749};//end OSnLNodeMatrixToScalar
1750
1751
1760class OSnLMNode: public ExprNode
1761{
1762public:
1763
1768
1772 virtual ~OSnLMNode();
1773
1774
1784 OSnLMNode* createExpressionTreeFromPrefix(std::vector<ExprNode*> nlNodeVec);
1785
1792 std::vector<ExprNode*> getPrefixFromExpressionTree();
1793
1802 std::vector<ExprNode*> preOrderOSnLNodeTraversal( std::vector<ExprNode*> *prefixVector);
1803
1813 OSnLMNode* createExpressionTreeFromPostfix(std::vector<ExprNode*> nlNodeVec);
1814
1821 std::vector<ExprNode*> getPostfixFromExpressionTree();
1822
1831 std::vector<ExprNode*> postOrderOSnLNodeTraversal( std::vector<ExprNode*> *postfixVector);
1832
1833
1839
1843 bool IsEqual(OSnLMNode *that);
1844};//end OSnLMNode
1845
1847{
1848public:
1853
1858
1863 virtual std::string getTokenName();
1864
1869// virtual std::string getTokenNumber();
1870
1875// virtual std::string getNonlinearExpressionInXML();
1876
1882};//end OSnLMNodeMatrixPlus
1883
1885{
1886public:
1891
1896
1901 virtual std::string getTokenName();
1902
1907// virtual std::string getTokenNumber();
1908
1913// virtual std::string getNonlinearExpressionInXML();
1919
1920#if 0
1925 virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
1926#endif
1927
1928};//end OSnLMNodeMatrixPlus
1929
1931{
1932public:
1937
1942
1947 virtual std::string getTokenName();
1948
1953// virtual std::string getTokenNumber();
1954
1959// virtual std::string getNonlinearExpressionInXML();
1960
1966};//end OSnLMNodeMatrixMinus
1967
1969{
1970public:
1975
1980
1985 virtual std::string getTokenName();
1986
1991// virtual std::string getTokenNumber();
1992
1997// virtual std::string getNonlinearExpressionInXML();
1998
1999
2005};//end OSnLMNodeMatrixNegate
2006
2008{
2009public:
2014
2019
2024 virtual std::string getTokenName();
2025
2030// virtual std::string getTokenNumber();
2031
2036// virtual std::string getNonlinearExpressionInXML();
2037
2043};//end OSnLMNodeMatrixTimes
2044
2046{
2047public:
2052
2057
2062 virtual std::string getTokenName();
2063
2068// virtual std::string getTokenNumber();
2069
2074// virtual std::string getNonlinearExpressionInXML();
2075
2081};//end OSnLMNodeMatrixInverse
2082
2084{
2085public:
2090
2095
2100 virtual std::string getTokenName();
2101
2106// virtual std::string getTokenNumber();
2107
2112// virtual std::string getNonlinearExpressionInXML();
2113
2119};//end OSnLMNodeMatrixTranspose
2120
2122{
2123public:
2128
2133
2138 virtual std::string getTokenName();
2139
2144// virtual std::string getTokenNumber();
2145
2150// virtual std::string getNonlinearExpressionInXML();
2151
2157};//end OSnLMNodeMatrixScalarTimes
2158
2160{
2161public:
2166
2171
2176 virtual std::string getTokenName();
2177
2182// virtual std::string getTokenNumber();
2183
2188// virtual std::string getNonlinearExpressionInXML();
2189
2195};//end OSnLMNodeMatrixDotTimes
2196
2198{
2199public:
2204
2209
2214 virtual std::string getTokenName();
2215
2220// virtual std::string getTokenNumber();
2221
2226// virtual std::string getNonlinearExpressionInXML();
2227
2233};//end OSnLMNodeIdentityMatrix
2234
2236{
2237public:
2242
2247
2252
2257 virtual std::string getTokenName();
2258
2263// virtual std::string getTokenNumber();
2264
2269 virtual std::string getNonlinearExpressionInXML();
2270
2276
2282
2287};//end OSnLMNodeMatrixLowerTriangle
2288
2290{
2291public:
2296
2301
2306
2311 virtual std::string getTokenName();
2312
2317// virtual std::string getTokenNumber();
2318
2323 virtual std::string getNonlinearExpressionInXML();
2324
2330
2336
2341};//end OSnLMNodeMatrixUpperTriangle
2342
2343
2345{
2346public:
2351
2356
2361 virtual std::string getTokenName();
2362
2367// virtual std::string getTokenNumber();
2368
2373// virtual std::string getNonlinearExpressionInXML();
2374
2380};//end OSnLMNodeMatrixDiagonal
2381
2383{
2384public:
2389
2394
2399 virtual std::string getTokenName();
2400
2405// virtual std::string getTokenNumber();
2406
2411// virtual std::string getNonlinearExpressionInXML();
2412
2418};//end OSnLMNodeDiagonalMatrixFromVector
2419
2420
2422{
2423public:
2428
2433
2438 virtual std::string getTokenName();
2439
2444// virtual std::string getTokenNumber();
2445
2450// virtual std::string getNonlinearExpressionInXML();
2451
2457};//end OSnLMNodeMatrixSubmatrixAt
2458
2459
2461{
2462public:
2466 int idx;
2467
2472
2477
2482 virtual std::string getTokenName();
2483
2488 virtual std::string getTokenNumber();
2489
2494 virtual std::string getNonlinearExpressionInXML();
2495
2496#if 0
2501 virtual double calculateFunction( double *x);
2502#endif
2503
2509
2515
2516#if 0
2521 virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
2522#endif
2523
2528};//end OSnLMNodeMatrixReference
2529
2530
2532{
2533public:
2537 int idx;
2538
2543
2548
2553 virtual std::string getTokenName();
2554
2559 virtual std::string getTokenNumber();
2560
2565 virtual std::string getNonlinearExpressionInXML();
2566
2567#if 0
2572 virtual double calculateFunction( double *x);
2573#endif
2574
2580
2586
2587#if 0
2592 virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
2593#endif
2594
2598 virtual bool IsEqual(OSnLMNodeMatrixVar *that);
2599};//end OSnLMNodeMatrixVar
2600
2601
2603{
2604public:
2608 int idx;
2609
2614
2619
2624 virtual std::string getTokenName();
2625
2630 virtual std::string getTokenNumber();
2631
2636 virtual std::string getNonlinearExpressionInXML();
2637
2638#if 0
2643 virtual double calculateFunction( double *x);
2644#endif
2645
2651
2657
2658#if 0
2663 virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
2664#endif
2665
2669 virtual bool IsEqual(OSnLMNodeMatrixObj *that);
2670};//end OSnLMNodeMatrixObj
2671
2672
2674{
2675public:
2679 int idx;
2680
2685
2690
2695 virtual std::string getTokenName();
2696
2701 virtual std::string getTokenNumber();
2702
2707 virtual std::string getNonlinearExpressionInXML();
2708
2709#if 0
2714 virtual double calculateFunction( double *x);
2715#endif
2716
2722
2728
2729#if 0
2734 virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
2735#endif
2736
2740 virtual bool IsEqual(OSnLMNodeMatrixCon *that);
2741};//end OSnLMNodeMatrixCon
2742
2743
2756{
2757public:
2762
2767
2771 virtual std::string getTokenName();
2772
2777 //virtual double calculateFunction( double *x);
2778
2784
2790 //virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
2791};//end OSnLNodeProduct
2792
2793
2794
2795/*
2796TO DO:
2797
27981. Allow for a variable node with a child
2799
28002. When we create the Expression Tree from postfix, do we check if the coefficient of a variable is 1?
2801*/
2802#endif
2803
2804
std::vector< ADdouble > ADvector
Definition: OSnLNode.h:40
double ADdouble
Definition: OSnLNode.h:39
A generic class from which we derive both OSnLNode and OSnLMNode.
Definition: OSnLNode.h:57
OSnLNode ** m_mChildren
m_mChildren holds all the operands, that is, nodes that the current node operates on.
Definition: OSnLNode.h:84
int inodeType
inodeType essentially tracks whether the number of children are known or not.
Definition: OSnLNode.h:69
int inodeInt
inodeInt is the unique integer assigned to the OSnLNode or OSnLMNode in OSParameters....
Definition: OSnLNode.h:62
virtual std::vector< ExprNode * > getPostfixFromExpressionTree()
Get a vector of pointers to ExprNodes that correspond to the expression tree in postfix format.
virtual std::vector< ExprNode * > getPrefixFromExpressionTree()
Get a vector of pointers to OSnLNodes and OSnLMNodes that correspond to the (scalar-valued or matrix-...
virtual std::string getNonlinearExpressionInXML()
The following method writes an OSnLNode or OSnLMNode in OSiL format.
ExprNode()
default constructor.
unsigned int inumberOfMatrixChildren
inumberOfMatrixChildren is the number of OSnLMNode child elements If this number is not fixed,...
Definition: OSnLNode.h:79
unsigned int inumberOfChildren
inumberOfChildren is the number of OSnLNode child elements If this number is not fixed,...
Definition: OSnLNode.h:74
virtual std::vector< ExprNode * > preOrderOSnLNodeTraversal(std::vector< ExprNode * > *prefixVector)
Called by getPrefixFromExpressionTree().
OSnLMNode ** m_mMatrixChildren
m_mMatrixChildren holds all the matrix-valued operands, if any.
Definition: OSnLNode.h:89
virtual bool IsEqual(ExprNode *that)
A function to check for the equality of two objects.
virtual ~ExprNode()
default destructor.
virtual ExprNode * cloneExprNode()=0
Create or clone a node of this type.
virtual std::vector< ExprNode * > postOrderOSnLNodeTraversal(std::vector< ExprNode * > *postfixVector)
Called by getPostfixFromExpressionTree().
virtual std::string getTokenName()=0
virtual std::string getTokenNumber()
a data structure to represent a matrix object (derived from MatrixType)
Definition: OSMatrix.h:2186
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
~OSnLMNodeDiagonalMatrixFromVector()
default destructor.
OSnLMNodeDiagonalMatrixFromVector()
default constructor.
virtual std::string getTokenName()
OSnLMNodeIdentityMatrix()
default constructor.
~OSnLMNodeIdentityMatrix()
default destructor.
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
virtual std::string getTokenName()
int idx
The index of the matrixCon.
Definition: OSnLNode.h:2679
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
virtual bool IsEqual(OSnLMNodeMatrixCon *that)
A function to check for the equality of two objects.
~OSnLMNodeMatrixCon()
default destructor.
virtual std::string getTokenName()
virtual OSnLMNode * copyNodeAndDescendants()
make a copy of this node and all its descendants
OSnLMNodeMatrixCon()
default constructor.
virtual std::string getTokenNumber()
virtual std::string getNonlinearExpressionInXML()
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
OSnLMNodeMatrixDiagonal()
default constructor.
~OSnLMNodeMatrixDiagonal()
default destructor.
virtual std::string getTokenName()
~OSnLMNodeMatrixDotTimes()
default destructor.
virtual std::string getTokenName()
OSnLMNodeMatrixDotTimes()
default constructor.
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
~OSnLMNodeMatrixInverse()
default destructor.
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
virtual std::string getTokenName()
OSnLMNodeMatrixInverse()
default constructor.
bool includeDiagonal
A boolean to express whether the diagonal is to be part of the upper triangle or not.
Definition: OSnLNode.h:2241
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
virtual std::string getNonlinearExpressionInXML()
virtual bool IsEqual(OSnLMNodeMatrixLowerTriangle *that)
A function to check for the equality of two objects.
virtual std::string getTokenName()
OSnLMNodeMatrixLowerTriangle()
default constructor.
~OSnLMNodeMatrixLowerTriangle()
default destructor.
virtual OSnLMNode * copyNodeAndDescendants()
make a copy of this node and all its descendants
~OSnLMNodeMatrixMinus()
default destructor.
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
virtual std::string getTokenName()
OSnLMNodeMatrixMinus()
default constructor.
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
OSnLMNodeMatrixNegate()
default constructor.
~OSnLMNodeMatrixNegate()
default destructor.
virtual std::string getTokenName()
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
OSnLMNodeMatrixObj()
default constructor.
virtual bool IsEqual(OSnLMNodeMatrixObj *that)
A function to check for the equality of two objects.
~OSnLMNodeMatrixObj()
default destructor.
virtual std::string getTokenName()
int idx
The index of the matrixObj.
Definition: OSnLNode.h:2608
virtual std::string getNonlinearExpressionInXML()
virtual std::string getTokenNumber()
virtual OSnLMNode * copyNodeAndDescendants()
make a copy of this node and all its descendants
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
virtual std::string getTokenName()
OSnLMNodeMatrixPlus()
default constructor.
~OSnLMNodeMatrixPlus()
default destructor.
The OSnLMNodeMatrixProduct Class.
Definition: OSnLNode.h:2756
~OSnLMNodeMatrixProduct()
default destructor.
virtual std::string getTokenName()
OSnLMNodeMatrixProduct()
default constructor.
virtual OSnLMNode * cloneExprNode()
The implementation of the virtual functions.
int idx
The index of the matrix.
Definition: OSnLNode.h:2466
virtual OSnLMNode * copyNodeAndDescendants()
make a copy of this node and all its descendants
virtual std::string getTokenNumber()
virtual bool IsEqual(OSnLMNodeMatrixReference *that)
A function to check for the equality of two objects.
OSnLMNodeMatrixReference()
default constructor.
virtual std::string getTokenName()
virtual std::string getNonlinearExpressionInXML()
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
~OSnLMNodeMatrixReference()
default destructor.
~OSnLMNodeMatrixScalarTimes()
default destructor.
OSnLMNodeMatrixScalarTimes()
default constructor.
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
virtual std::string getTokenName()
~OSnLMNodeMatrixSubmatrixAt()
default destructor.
OSnLMNodeMatrixSubmatrixAt()
default constructor.
virtual std::string getTokenName()
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
virtual std::string getTokenName()
~OSnLMNodeMatrixSum()
default destructor.
OSnLMNodeMatrixSum()
default constructor.
~OSnLMNodeMatrixTimes()
default destructor.
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
virtual std::string getTokenName()
OSnLMNodeMatrixTimes()
default constructor.
virtual std::string getTokenName()
OSnLMNodeMatrixTranspose()
default constructor.
~OSnLMNodeMatrixTranspose()
default destructor.
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
virtual OSnLMNode * copyNodeAndDescendants()
make a copy of this node and all its descendants
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
virtual std::string getNonlinearExpressionInXML()
bool includeDiagonal
A boolean to express whether the diagonal is to be part of the upper triangle or not.
Definition: OSnLNode.h:2295
virtual std::string getTokenName()
OSnLMNodeMatrixUpperTriangle()
default constructor.
virtual bool IsEqual(OSnLMNodeMatrixUpperTriangle *that)
A function to check for the equality of two objects.
~OSnLMNodeMatrixUpperTriangle()
default destructor.
virtual std::string getTokenName()
virtual std::string getNonlinearExpressionInXML()
~OSnLMNodeMatrixVar()
default destructor.
virtual OSnLMNode * cloneExprNode()
Create or clone a node of this type.
int idx
The index of the matrixVar.
Definition: OSnLNode.h:2537
virtual OSnLMNode * copyNodeAndDescendants()
make a copy of this node and all its descendants
virtual bool IsEqual(OSnLMNodeMatrixVar *that)
A function to check for the equality of two objects.
virtual std::string getTokenNumber()
OSnLMNodeMatrixVar()
default constructor.
The OSnLMNode Class for nonlinear expressions involving matrices.
Definition: OSnLNode.h:1761
std::vector< ExprNode * > postOrderOSnLNodeTraversal(std::vector< ExprNode * > *postfixVector)
Called by getPostfixFromExpressionTree().
std::vector< ExprNode * > getPrefixFromExpressionTree()
Get a vector of pointers to OSnLNodes and OSnLMNodes that correspond to the (matrix-valued) expressio...
OSnLMNode * createExpressionTreeFromPrefix(std::vector< ExprNode * > nlNodeVec)
Take a vector of ExprNodes (OSnLNodes and OSnLMNodes) in prefix format and create a matrix-valued OSE...
OSnLMNode * createExpressionTreeFromPostfix(std::vector< ExprNode * > nlNodeVec)
Take a vector of ExprNodes (OSnLNodes and OSnLMNodes) in postfix format and create a matrix-valued OS...
std::vector< ExprNode * > preOrderOSnLNodeTraversal(std::vector< ExprNode * > *prefixVector)
Called by getPrefixFromExpressionTree().
std::vector< ExprNode * > getPostfixFromExpressionTree()
Get a vector of pointers to ExprNodes that correspond to the expression tree in postfix format.
bool IsEqual(OSnLMNode *that)
A function to check for the equality of two objects.
virtual ~OSnLMNode()
default destructor.
virtual OSnLMNode * copyNodeAndDescendants()
make a copy of this node and all its descendants
OSnLMNode()
default constructor.
The OSnLNodeAbs Class.
Definition: OSnLNode.h:1113
~OSnLNodeAbs()
default destructor.
OSnLNodeAbs()
default constructor.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
virtual std::string getTokenName()
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
The OSnLNodeAllDiff Class.
Definition: OSnLNode.h:1561
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
~OSnLNodeAllDiff()
default destructor.
OSnLNodeAllDiff()
default constructor.
virtual std::string getTokenName()
The OSnLNodeCos Class.
Definition: OSnLNode.h:963
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual std::string getTokenName()
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
~OSnLNodeCos()
default destructor.
OSnLNodeCos()
default constructor.
The OSnLNodeDivide Class.
Definition: OSnLNode.h:669
~OSnLNodeDivide()
default destructor.
virtual std::string getTokenName()
OSnLNodeDivide()
default constructor.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
The OSnLNodeE Class.
Definition: OSnLNode.h:1347
virtual std::string getTokenName()
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
~OSnLNodeE()
default destructor.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual std::string getTokenNumber()
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
OSnLNodeE()
default constructor.
virtual std::string getNonlinearExpressionInXML()
The OSnLNodeErf Class.
Definition: OSnLNode.h:1163
OSnLNodeErf()
default constructor.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
Create the AD tape to be evaluated by AD.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual std::string getTokenName()
~OSnLNodeErf()
default destructor.
The OSnLNodeExp Class.
Definition: OSnLNode.h:1063
OSnLNodeExp()
default constructor.
~OSnLNodeExp()
default destructor.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual std::string getTokenName()
The OSnLNodeIf Class.
Definition: OSnLNode.h:1213
~OSnLNodeIf()
default destructor.
OSnLNodeIf()
default constructor.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
virtual std::string getTokenName()
The OSnLNodeLn Class.
Definition: OSnLNode.h:816
~OSnLNodeLn()
default destructor.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
OSnLNodeLn()
default constructor.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual std::string getTokenName()
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
The next few nodes evaluate to a scalar even though one or more of its arguments are matrices.
Definition: OSnLNode.h:1613
virtual OSnLNode * cloneExprNode()
Create or clone a node of this type.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual std::string getTokenName()
~OSnLNodeMatrixDeterminant()
default destructor.
virtual double calculateFunction(double *x)
The implementation of the virtual functions.
OSnLNodeMatrixDeterminant()
default constructor.
The OSnLNodeMatrixTrace Class.
Definition: OSnLNode.h:1713
~OSnLNodeMatrixToScalar()
default destructor.
OSnLNodeMatrixToScalar()
default constructor.
virtual std::string getTokenName()
virtual OSnLNode * cloneExprNode()
Create or clone a node of this type.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
Create the AD tape to be evaluated by AD.
The OSnLNodeMatrixTrace Class.
Definition: OSnLNode.h:1663
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual double calculateFunction(double *x)
The implementation of the virtual functions.
~OSnLNodeMatrixTrace()
default destructor.
OSnLNodeMatrixTrace()
default constructor.
virtual OSnLNode * cloneExprNode()
Create or clone a node of this type.
virtual std::string getTokenName()
The OSnLNodeMax Class.
Definition: OSnLNode.h:415
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual std::string getTokenName()
~OSnLNodeMax()
default destructor.
OSnLNodeMax()
default constructor.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
The OSnLNodeMin Class.
Definition: OSnLNode.h:464
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
~OSnLNodeMin()
default destructor.
OSnLNodeMin()
default constructor.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual std::string getTokenName()
The OSnLNodeMinus Class.
Definition: OSnLNode.h:516
virtual std::string getTokenName()
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
~OSnLNodeMinus()
default destructor.
OSnLNodeMinus()
default constructor.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
The OSnLNodeNegate Class.
Definition: OSnLNode.h:567
virtual std::string getTokenName()
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
OSnLNodeNegate()
default constructor.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
~OSnLNodeNegate()
default destructor.
The OSnLNodeNumber Class.
Definition: OSnLNode.h:1263
double value
value is the value of the number
Definition: OSnLNode.h:1266
virtual OSnLNode * copyNodeAndDescendants()
make a copy of this node and all its descendants
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
~OSnLNodeNumber()
default destructor.
virtual std::string getNonlinearExpressionInXML()
virtual bool IsEqual(OSnLNodeNumber *that)
A function to check for the equality of two objects.
OSnLNodeNumber()
default constructor.
std::string id
later, e.g.
Definition: OSnLNode.h:1274
virtual std::string getTokenName()
std::string type
in the C++ type is real
Definition: OSnLNode.h:1269
virtual std::string getTokenNumber()
The OSnLNodePI Class.
Definition: OSnLNode.h:1413
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
virtual std::string getTokenName()
virtual std::string getNonlinearExpressionInXML()
~OSnLNodePI()
default destructor.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual std::string getTokenNumber()
OSnLNodePI()
default constructor.
The OSnLNodePlus Class.
Definition: OSnLNode.h:316
virtual double calculateFunction(double *x)
The implementation of the virtual functions.
OSnLNodePlus()
default constructor.
virtual std::string getTokenName()
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
~OSnLNodePlus()
default destructor.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
The OSnLNodePower Class.
Definition: OSnLNode.h:718
~OSnLNodePower()
default destructor.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
OSnLNodePower()
default constructor.
virtual std::string getTokenName()
The OSnLNodeProduct Class.
Definition: OSnLNode.h:767
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual std::string getTokenName()
OSnLNodeProduct()
default constructor.
~OSnLNodeProduct()
default destructor.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
The OSnLNodeSin Class.
Definition: OSnLNode.h:1013
virtual std::string getTokenName()
OSnLNodeSin()
default constructor.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
~OSnLNodeSin()
default destructor.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
The OSnLNodeSqrt Class.
Definition: OSnLNode.h:865
OSnLNodeSqrt()
default constructor.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
~OSnLNodeSqrt()
default destructor.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual std::string getTokenName()
The OSnLNodeSquare Class.
Definition: OSnLNode.h:913
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
OSnLNodeSquare()
default constructor.
virtual std::string getTokenName()
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
~OSnLNodeSquare()
default destructor.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
The OSnLNodeSum Class.
Definition: OSnLNode.h:366
OSnLNodeSum()
default constructor.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
~OSnLNodeSum()
default destructor.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual std::string getTokenName()
The OSnLNodeTimes Class.
Definition: OSnLNode.h:618
OSnLNodeTimes()
default constructor.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
Create the AD tape to be evaluated by AD.
~OSnLNodeTimes()
default destructor.
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual std::string getTokenName()
The OSnLNodeVariable Class.
Definition: OSnLNode.h:1479
~OSnLNodeVariable()
default destructor.
virtual void getVariableIndexMap(std::map< int, int > *varIdx)
varIdx is a map where the key is the index of an OSnLNodeVariable and (*varIdx)[ idx] is the kth vari...
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual std::string getTokenName()
virtual std::string getNonlinearExpressionInXML()
virtual OSnLNode * copyNodeAndDescendants()
make a copy of this node and all its descendants
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
OSnLNodeVariable()
default constructor.
int idx
idx is the index of the variable
Definition: OSnLNode.h:1488
virtual double calculateFunction(double *x)
Calculate the function value given the current variable values.
double coef
coef is an option coefficient on the variable, the default value is 1.0
Definition: OSnLNode.h:1485
virtual std::string getTokenNumber()
virtual bool IsEqual(OSnLNodeVariable *that)
A function to check for the equality of two objects.
The OSnLNode Class for nonlinear expressions.
Definition: OSnLNode.h:180
virtual std::vector< ExprNode * > preOrderOSnLNodeTraversal(std::vector< ExprNode * > *prefixVector)
Called by getPrefixFromExpressionTree().
OSnLNode * createExpressionTreeFromPostfix(std::vector< ExprNode * > nlNodeVec)
Take a vector of ExprNodes (OSnLNodes and OSnLMNodes) in postfix format and create a scalar-valued OS...
OSnLNode()
default constructor.
virtual std::vector< ExprNode * > getPostfixFromExpressionTree()
Get a vector of pointers to ExprNodes that correspond to the expression tree in postfix format.
bool IsEqual(OSnLNode *that)
A function to check for the equality of two objects.
virtual ~OSnLNode()
default destructor.
virtual OSnLNode * copyNodeAndDescendants()
make a copy of this node and all its descendants
virtual std::vector< ExprNode * > postOrderOSnLNodeTraversal(std::vector< ExprNode * > *postfixVector)
Called by getPostfixFromExpressionTree().
ADdouble m_ADTape
m_ADTape stores the expression tree for the this OSnLNode as an ADdouble.
Definition: OSnLNode.h:190
virtual std::vector< ExprNode * > getPrefixFromExpressionTree()
Get a vector of pointers to OSnLNodes and OSnLMNodes that correspond to the (scalar-valued or matrix-...
OSnLNode * createExpressionTreeFromPrefix(std::vector< ExprNode * > nlNodeVec)
Take a vector of ExprNodes (OSnLNodes and OSnLMNodes) in prefix format and create a scalar-valued OSE...
virtual double calculateFunction(double *x)=0
Calculate the function value given the current variable values.
virtual void getVariableIndexMap(std::map< int, int > *varIdx)
varIdx is a map where the key is the index of an OSnLNodeVariable and (*varIdx)[ idx] is the kth vari...
double m_dFunctionValue
m_dFunctionValue holds the function value given the current variable values.
Definition: OSnLNode.h:185
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)=0
Create the AD tape to be evaluated by AD.