OS  2.9.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
OSnLNode.h
Go to the documentation of this file.
1 /* $Id: OSnLNode.h 4985 2015-03-12 14:14:49Z tkr $ */
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>
36 typedef CppAD::AD<double> ADdouble;
37 typedef CppAD::vector<ADdouble> ADvector;
38 #else
39 typedef double ADdouble;
40 typedef std::vector<ADdouble> ADvector;
41 #endif
42 
46 class OSnLNode;
47 class OSnLMNode;
48 class OSMatrix;
49 
56 class ExprNode
57 {
58 public:
59 
62  int inodeInt;
63 
69  int inodeType;
70 
74  unsigned int inumberOfChildren;
75 
80 
85 
90 
91 
95  ExprNode();
96 
100  virtual ~ExprNode();
101 
102 
106  virtual std::string getTokenNumber();
107 
111  virtual std::string getTokenName() = 0;
112 
122  virtual std::string getNonlinearExpressionInXML();
123 
132  virtual std::vector<ExprNode*> getPrefixFromExpressionTree();
133 
143  virtual std::vector<ExprNode*> preOrderOSnLNodeTraversal( std::vector<ExprNode*> *prefixVector);
144 
153  virtual std::vector<ExprNode*> getPostfixFromExpressionTree();
154 
164  virtual std::vector<ExprNode*> postOrderOSnLNodeTraversal( std::vector<ExprNode*> *postfixVector);
165 
176  virtual ExprNode *cloneExprNode() = 0;
177 
181  virtual bool IsEqual(ExprNode *that);
182 };//end ExprNode
183 
184 
192 class OSnLNode: public ExprNode
193 {
194 public:
199 
204 
205 
209  OSnLNode();
210 
214  virtual ~OSnLNode();
215 
216 
226  virtual void getVariableIndexMap(std::map<int, int> *varIdx);
227 
238  virtual double calculateFunction(double *x) = 0;
239 
249  virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD) = 0;
250 
261  OSnLNode* createExpressionTreeFromPrefix(std::vector<ExprNode*> nlNodeVec);
262 
271  virtual std::vector<ExprNode*> getPrefixFromExpressionTree();
272 
282  virtual std::vector<ExprNode*> preOrderOSnLNodeTraversal( std::vector<ExprNode*> *prefixVector);
283 
294  OSnLNode* createExpressionTreeFromPostfix(std::vector<ExprNode*> nlNodeVec);
295 
304  virtual std::vector<ExprNode*> getPostfixFromExpressionTree();
305 
315  virtual std::vector<ExprNode*> postOrderOSnLNodeTraversal( std::vector<ExprNode*> *postfixVector);
316 
322 
326  bool IsEqual(OSnLNode *that);
327 };//end OSnLNode
328 
329 
341 class OSnLNodePlus : public OSnLNode
342 {
343 public:
347  OSnLNodePlus();
348 
352  ~OSnLNodePlus();
353 
358  virtual std::string getTokenName();
359 
364  virtual double calculateFunction( double *x);
365 
370  virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
371 
376  virtual OSnLNode *cloneExprNode();
377 
378 };//end OSnLNodePlus
379 
391 class OSnLNodeSum : public OSnLNode
392 {
393 public:
397  OSnLNodeSum();
398 
402  ~OSnLNodeSum();
403 
408  virtual std::string getTokenName();
409 
414  virtual double calculateFunction( double *x);
415 
420  virtual OSnLNode *cloneExprNode();
421 
426  virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
427 };//end OSnLNodeSum
428 
440 class OSnLNodeMax : public OSnLNode
441 {
442 public:
446  OSnLNodeMax();
447 
451  ~OSnLNodeMax();
452 
457  virtual std::string getTokenName();
458 
463  virtual double calculateFunction( double *x);
464 
469  virtual OSnLNode *cloneExprNode();
470 
475  virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
476 };//end OSnLNodeMax
477 
489 class OSnLNodeMin : public OSnLNode
490 {
491 public:
495  OSnLNodeMin();
496 
500  ~OSnLNodeMin();
501 
506  virtual std::string getTokenName();
507 
512  virtual double calculateFunction( double *x);
513 
519  virtual OSnLNode *cloneExprNode();
520 
525  virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
526 
527 };//end OSnLNodeMin
528 
529 
541 class OSnLNodeMinus : public OSnLNode
542 {
543 public:
547  OSnLNodeMinus();
548 
552  ~OSnLNodeMinus();
553 
554 
559  virtual std::string getTokenName();
560 
565  virtual double calculateFunction( double *x);
566 
571  virtual OSnLNode *cloneExprNode();
572 
577  virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
578 };//end OSnLNodeMinus
579 
580 
592 class OSnLNodeNegate : public OSnLNode
593 {
594 public:
598  OSnLNodeNegate();
599 
603  ~OSnLNodeNegate();
604 
609  virtual std::string getTokenName();
610 
615  virtual double calculateFunction( double *x);
616 
621  virtual OSnLNode *cloneExprNode();
622 
623 
628  virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
629 };//end OSnLNodeNegate
630 
631 
643 class OSnLNodeTimes : public OSnLNode
644 {
645 public:
649  OSnLNodeTimes();
650 
654  ~OSnLNodeTimes();
655 
660  virtual std::string getTokenName();
661 
666  virtual double calculateFunction( double *x);
667 
672  virtual OSnLNode *cloneExprNode();
673 
678  virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
679 
680 };//end OSnLNodeTimes
681 
682 
694 class OSnLNodeDivide : public OSnLNode
695 {
696 public:
700  OSnLNodeDivide();
701 
705  ~OSnLNodeDivide();
706 
710  virtual std::string getTokenName();
711 
716  virtual double calculateFunction( double *x);
717 
722  virtual OSnLNode *cloneExprNode();
723 
728  virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
729 };//end OSnLNodeDivide
730 
731 
743 class OSnLNodePower : public OSnLNode
744 {
745 public:
749  OSnLNodePower();
750 
754  ~OSnLNodePower();
755 
759  virtual std::string getTokenName();
760 
765  virtual double calculateFunction( double *x);
766 
771  virtual OSnLNode *cloneExprNode();
772 
777  virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
778 };//end OSnLNodePower
779 
780 
792 class OSnLNodeProduct : public OSnLNode
793 {
794 public:
798  OSnLNodeProduct();
799 
804 
808  virtual std::string getTokenName();
809 
814  virtual double calculateFunction( double *x);
815 
820  virtual OSnLNode *cloneExprNode();
821 
826  virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
827 };//end OSnLNodeProduct
828 
829 
841 class OSnLNodeLn : public OSnLNode
842 {
843 public:
847  OSnLNodeLn();
848 
852  ~OSnLNodeLn();
853 
857  virtual std::string getTokenName();
858 
863  virtual double calculateFunction( double *x);
864 
869  virtual OSnLNode *cloneExprNode();
870 
875  virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
876 };//end OSnLNodeLn
877 
878 
890 class OSnLNodeSqrt : public OSnLNode
891 {
892 public:
896  OSnLNodeSqrt();
897 
901  ~OSnLNodeSqrt();
902 
906  virtual std::string getTokenName();
907 
912  virtual double calculateFunction( double *x);
913 
918  virtual OSnLNode *cloneExprNode();
923  virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
924 };//end OSnLNodeSqrt
925 
926 
938 class OSnLNodeSquare : public OSnLNode
939 {
940 public:
944  OSnLNodeSquare();
945 
949  ~OSnLNodeSquare();
950 
955  virtual std::string getTokenName();
956 
961  virtual double calculateFunction( double *x);
962 
967  virtual OSnLNode *cloneExprNode();
968 
973  virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
974 };//end OSnLNodeSquare
975 
976 
988 class OSnLNodeCos : public OSnLNode
989 {
990 public:
994  OSnLNodeCos();
995 
999  ~OSnLNodeCos();
1000 
1005  virtual std::string getTokenName();
1006 
1011  virtual double calculateFunction( double *x);
1012 
1017  virtual OSnLNode *cloneExprNode();
1018 
1023  virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
1024 };//end OSnLNodeCos
1025 
1026 
1038 class OSnLNodeSin : public OSnLNode
1039 {
1040 public:
1044  OSnLNodeSin();
1045 
1049  ~OSnLNodeSin();
1050 
1055  virtual std::string getTokenName();
1056 
1061  virtual double calculateFunction( double *x);
1062 
1067  virtual OSnLNode *cloneExprNode();
1068 
1073  virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
1074 };//end OSnLNodeSin
1075 
1076 
1088 class OSnLNodeExp : public OSnLNode
1089 {
1090 public:
1094  OSnLNodeExp();
1095 
1099  ~OSnLNodeExp();
1100 
1105  virtual std::string getTokenName();
1106 
1111  virtual double calculateFunction( double *x);
1112 
1117  virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
1118 
1123  virtual OSnLNode *cloneExprNode();
1124 };//end OSnLNodeExp
1125 
1126 
1138 class OSnLNodeAbs : public OSnLNode
1139 {
1140 public:
1144  OSnLNodeAbs();
1145 
1149  ~OSnLNodeAbs();
1150 
1155  virtual std::string getTokenName();
1156 
1161  virtual double calculateFunction( double *x);
1162 
1167  virtual OSnLNode *cloneExprNode();
1168 
1173  virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
1174 };//end OSnLNodeAbs
1175 
1176 
1188 class OSnLNodeErf : public OSnLNode
1189 {
1190 public:
1194  OSnLNodeErf();
1195 
1199  ~OSnLNodeErf();
1200 
1205  virtual std::string getTokenName();
1206 
1211  virtual double calculateFunction( double *x);
1212 
1217  virtual OSnLNode *cloneExprNode();
1218 
1223  virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
1224 };//end OSnLNodeErf
1225 
1226 
1238 class OSnLNodeIf : public OSnLNode
1239 {
1240 public:
1244  OSnLNodeIf();
1245 
1249  ~OSnLNodeIf();
1250 
1255  virtual std::string getTokenName();
1256 
1261  virtual double calculateFunction( double *x);
1262 
1267  virtual OSnLNode *cloneExprNode();
1268 
1273  virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
1274 };//end OSnLNodeIf
1275 
1276 
1288 class OSnLNodeNumber : public OSnLNode
1289 {
1290 public:
1291 
1292 
1294  double value;
1296  std::string type;
1300  std::string id;
1301 
1305  OSnLNodeNumber();
1306 
1310  ~OSnLNodeNumber();
1311 
1316  virtual std::string getTokenName();
1317 
1322  virtual std::string getTokenNumber();
1323 
1328  virtual std::string getNonlinearExpressionInXML();
1329 
1334  virtual double calculateFunction( double *x);
1335 
1340  virtual OSnLNode *cloneExprNode();
1341 
1342 
1347  virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
1348 };//end OSnLNodeNumber
1349 
1350 
1362 class OSnLNodeE : public OSnLNode
1363 {
1364 public:
1365 
1369  OSnLNodeE();
1370 
1374  ~OSnLNodeE();
1375 
1376 
1381  virtual std::string getTokenNumber();
1382 
1383 
1388  virtual std::string getTokenName();
1389 
1394  virtual std::string getNonlinearExpressionInXML();
1395 
1400  virtual double calculateFunction( double *x);
1401 
1406  virtual OSnLNode *cloneExprNode();
1407 
1408 
1413  virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
1414 };//end OSnLNodeE
1415 
1416 
1428 class OSnLNodePI : public OSnLNode
1429 {
1430 public:
1431 
1435  OSnLNodePI();
1436 
1440  ~OSnLNodePI();
1441 
1442 
1447  virtual std::string getTokenNumber();
1448 
1449 
1454  virtual std::string getTokenName();
1455 
1460  virtual std::string getNonlinearExpressionInXML();
1461 
1466  virtual double calculateFunction( double *x);
1467 
1472  virtual OSnLNode *cloneExprNode();
1473 
1474 
1479  virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
1480 };//end OSnLNodePI
1481 
1482 
1495 {
1496 public:
1497 
1501  double coef;
1502 
1504  int idx;
1505 
1509  OSnLNodeVariable();
1510 
1515 
1516  virtual void getVariableIndexMap(std::map<int, int> *varIdx);
1517 
1521  virtual std::string getTokenNumber();
1522 
1526  virtual std::string getTokenName();
1527 
1531  virtual std::string getNonlinearExpressionInXML();
1532 
1537  virtual double calculateFunction( double *x);
1538 
1543  virtual OSnLNode *cloneExprNode();
1544 
1549  virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
1550 };//end OSnLNodeVariable
1551 
1552 
1566 {
1567 public:
1571  OSnLNodeAllDiff();
1572 
1576  ~OSnLNodeAllDiff();
1577 
1582  virtual std::string getTokenName();
1583 
1588  virtual double calculateFunction( double *x);
1589 
1594  virtual OSnLNode *cloneExprNode();
1595 
1600  virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
1601 };//end OSnLNodeAllDiff
1602 
1603 
1618 {
1619 public:
1624 
1629 
1634  virtual std::string getTokenName();
1635 
1640  virtual double calculateFunction( double *x);
1641 
1646  virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
1647 
1652  virtual OSnLNode *cloneExprNode();
1653 
1654 };//end OSnLNodeMatrixDeterminant
1655 
1668 {
1669 public:
1674 
1680 
1685  virtual std::string getTokenName();
1686 
1691  virtual double calculateFunction( double *x);
1692 
1697  virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
1698 
1703  virtual OSnLNode *cloneExprNode();
1704 };//end OSnLNodeMatrixToScalar
1705 
1718 {
1719 public:
1724 
1730 
1735  virtual std::string getTokenName();
1736 
1741  virtual double calculateFunction( double *x);
1742 
1747  virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
1748 
1753  virtual OSnLNode *cloneExprNode();
1754 };//end OSnLNodeMatrixToScalar
1755 
1756 
1765 class OSnLMNode: public ExprNode
1766 {
1767 public:
1768 
1772  OSnLMNode();
1773 
1777  virtual ~OSnLMNode();
1778 
1779 
1790  OSnLMNode* createExpressionTreeFromPrefix(std::vector<ExprNode*> nlNodeVec);
1791 
1800  std::vector<ExprNode*> getPrefixFromExpressionTree();
1801 
1811  std::vector<ExprNode*> preOrderOSnLNodeTraversal( std::vector<ExprNode*> *prefixVector);
1812 
1823  OSnLMNode* createExpressionTreeFromPostfix(std::vector<ExprNode*> nlNodeVec);
1824 
1833  std::vector<ExprNode*> getPostfixFromExpressionTree();
1834 
1844  std::vector<ExprNode*> postOrderOSnLNodeTraversal( std::vector<ExprNode*> *postfixVector);
1845 
1846 
1852 
1856  bool IsEqual(OSnLMNode *that);
1857 };//end OSnLMNode
1858 
1860 {
1861 public:
1866 
1871 
1876  virtual std::string getTokenName();
1877 
1882 // virtual std::string getTokenNumber();
1883 
1888 // virtual std::string getNonlinearExpressionInXML();
1889 
1894  virtual OSnLMNode *cloneExprNode();
1895 };//end OSnLMNodeMatrixPlus
1896 
1898 {
1899 public:
1904 
1909 
1914  virtual std::string getTokenName();
1915 
1920 // virtual std::string getTokenNumber();
1921 
1926 // virtual std::string getNonlinearExpressionInXML();
1931  virtual OSnLMNode *cloneExprNode();
1932 
1933 #if 0
1934 
1938  virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
1939 #endif
1940 
1941 };//end OSnLMNodeMatrixPlus
1942 
1944 {
1945 public:
1950 
1955 
1960  virtual std::string getTokenName();
1961 
1966 // virtual std::string getTokenNumber();
1967 
1972 // virtual std::string getNonlinearExpressionInXML();
1973 
1978  virtual OSnLMNode *cloneExprNode();
1979 };//end OSnLMNodeMatrixMinus
1980 
1982 {
1983 public:
1988 
1993 
1998  virtual std::string getTokenName();
1999 
2004 // virtual std::string getTokenNumber();
2005 
2010 // virtual std::string getNonlinearExpressionInXML();
2011 
2012 
2017  virtual OSnLMNode *cloneExprNode();
2018 };//end OSnLMNodeMatrixNegate
2019 
2021 {
2022 public:
2027 
2032 
2037  virtual std::string getTokenName();
2038 
2043 // virtual std::string getTokenNumber();
2044 
2049 // virtual std::string getNonlinearExpressionInXML();
2050 
2055  virtual OSnLMNode *cloneExprNode();
2056 };//end OSnLMNodeMatrixTimes
2057 
2059 {
2060 public:
2065 
2070 
2075  virtual std::string getTokenName();
2076 
2081 // virtual std::string getTokenNumber();
2082 
2087 // virtual std::string getNonlinearExpressionInXML();
2088 
2093  virtual OSnLMNode *cloneExprNode();
2094 };//end OSnLMNodeMatrixInverse
2095 
2097 {
2098 public:
2103 
2108 
2113  virtual std::string getTokenName();
2114 
2119 // virtual std::string getTokenNumber();
2120 
2125 // virtual std::string getNonlinearExpressionInXML();
2126 
2131  virtual OSnLMNode *cloneExprNode();
2132 };//end OSnLMNodeMatrixTranspose
2133 
2135 {
2136 public:
2141 
2146 
2151  virtual std::string getTokenName();
2152 
2157 // virtual std::string getTokenNumber();
2158 
2163 // virtual std::string getNonlinearExpressionInXML();
2164 
2169  virtual OSnLMNode *cloneExprNode();
2170 };//end OSnLMNodeMatrixScalarTimes
2171 
2173 {
2174 public:
2179 
2184 
2189  virtual std::string getTokenName();
2190 
2195 // virtual std::string getTokenNumber();
2196 
2201 // virtual std::string getNonlinearExpressionInXML();
2202 
2207  virtual OSnLMNode *cloneExprNode();
2208 };//end OSnLMNodeMatrixDotTimes
2209 
2211 {
2212 public:
2217 
2222 
2227  virtual std::string getTokenName();
2228 
2233 // virtual std::string getTokenNumber();
2234 
2239 // virtual std::string getNonlinearExpressionInXML();
2240 
2245  virtual OSnLMNode *cloneExprNode();
2246 };//end OSnLMNodeIdentityMatrix
2247 
2249 {
2250 public:
2255 
2260 
2265 
2270  virtual std::string getTokenName();
2271 
2276 // virtual std::string getTokenNumber();
2277 
2282  virtual std::string getNonlinearExpressionInXML();
2283 
2288  virtual OSnLMNode *cloneExprNode();
2289 };//end OSnLMNodeMatrixLowerTriangle
2290 
2292 {
2293 public:
2298 
2303 
2308 
2313  virtual std::string getTokenName();
2314 
2319 // virtual std::string getTokenNumber();
2320 
2325  virtual std::string getNonlinearExpressionInXML();
2326 
2331  virtual OSnLMNode *cloneExprNode();
2332 };//end OSnLMNodeMatrixUpperTriangle
2333 
2334 
2336 {
2337 public:
2342 
2347 
2352  virtual std::string getTokenName();
2353 
2358 // virtual std::string getTokenNumber();
2359 
2364 // virtual std::string getNonlinearExpressionInXML();
2365 
2370  virtual OSnLMNode *cloneExprNode();
2371 };//end OSnLMNodeMatrixDiagonal
2372 
2374 {
2375 public:
2380 
2385 
2390  virtual std::string getTokenName();
2391 
2396 // virtual std::string getTokenNumber();
2397 
2402 // virtual std::string getNonlinearExpressionInXML();
2403 
2408  virtual OSnLMNode *cloneExprNode();
2409 };//end OSnLMNodeDiagonalMatrixFromVector
2410 
2411 
2413 {
2414 public:
2419 
2424 
2429  virtual std::string getTokenName();
2430 
2435 // virtual std::string getTokenNumber();
2436 
2441 // virtual std::string getNonlinearExpressionInXML();
2442 
2447  virtual OSnLMNode *cloneExprNode();
2448 };//end OSnLMNodeMatrixSubmatrixAt
2449 
2450 
2452 {
2453 public:
2457  int idx;
2458 
2463 
2468 
2473  virtual std::string getTokenName();
2474 
2479  virtual std::string getTokenNumber();
2480 
2485  virtual std::string getNonlinearExpressionInXML();
2486 
2487 #if 0
2488 
2492  virtual double calculateFunction( double *x);
2493 #endif
2494 
2499  virtual OSnLMNode *cloneExprNode();
2500 
2501 #if 0
2502 
2506  virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
2507 #endif
2508 
2509 };//end OSnLMNodeMatrixReference
2510 
2511 
2524 {
2525 public:
2530 
2535 
2539  virtual std::string getTokenName();
2540 
2545  //virtual double calculateFunction( double *x);
2546 
2551  virtual OSnLMNode *cloneExprNode();
2552 
2558  //virtual ADdouble constructADTape(std::map<int, int> *ADIdx, ADvector *XAD);
2559 };//end OSnLNodeProduct
2560 
2561 
2562 
2563 /*
2564 TO DO:
2565 
2566 1. Allow for a variable node with a child
2567 
2568 2. When we create the Expression Tree from postfix, do we check if the coefficient of a variable is 1?
2569 */
2570 #endif
2571 
2572 
virtual std::string getTokenName()=0
virtual std::string getTokenName()
virtual std::string getTokenName()
virtual double calculateFunction(double *x)
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
~OSnLMNodeMatrixTranspose()
default destructor.
The OSnLNodeSum Class.
Definition: OSnLNode.h:391
The OSnLNodeDivide Class.
Definition: OSnLNode.h:694
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
OSnLMNode * copyNodeAndDescendants()
make a copy of this node and all its descendants
virtual double calculateFunction(double *x)
The implementation of the virtual functions.
The OSnLNodeAllDiff Class.
Definition: OSnLNode.h:1565
OSnLNode()
default constructor.
virtual double calculateFunction(double *x)
virtual std::string getTokenName()
~OSnLNodeE()
default destructor.
The OSnLNodeMinus Class.
Definition: OSnLNode.h:541
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual OSnLMNode * cloneExprNode()
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.
bool includeDiagonal
A boolean to express whether the diagonal is to be part of the upper triangle or not.
Definition: OSnLNode.h:2254
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
The OSnLMNode Class for nonlinear expressions involving matrices.
Definition: OSnLNode.h:1765
virtual ~OSnLNode()
default destructor.
~OSnLNodePI()
default destructor.
virtual std::string getTokenName()
OSnLNodeDivide()
default constructor.
virtual std::string getTokenName()
virtual double calculateFunction(double *x)=0
OSnLNodeTimes()
default constructor.
OSnLMNodeDiagonalMatrixFromVector()
default constructor.
virtual OSnLMNode * cloneExprNode()
virtual double calculateFunction(double *x)
virtual std::vector< ExprNode * > postOrderOSnLNodeTraversal(std::vector< ExprNode * > *postfixVector)
virtual std::string getTokenName()
The OSnLNodePower Class.
Definition: OSnLNode.h:743
OSnLNodeAllDiff()
default constructor.
~OSnLNodeLn()
default destructor.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
OSnLMNodeMatrixTimes()
default constructor.
~OSnLNodeMatrixDeterminant()
default destructor.
virtual void getVariableIndexMap(std::map< int, int > *varIdx)
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)=0
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
OSnLMNodeMatrixScalarTimes()
default constructor.
unsigned int inumberOfChildren
inumberOfChildren is the number of OSnLNode child elements If this number is not fixed, e.g., for a sum node, it is temporarily set to 0
Definition: OSnLNode.h:74
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
OSnLNodeExp()
default constructor.
std::vector< ExprNode * > getPostfixFromExpressionTree()
virtual double calculateFunction(double *x)
OSnLNodePlus()
default constructor.
OSnLNodeNegate()
default constructor.
virtual double calculateFunction(double *x)
The OSnLNodeVariable Class.
Definition: OSnLNode.h:1494
OSnLMNodeMatrixUpperTriangle()
default constructor.
virtual std::string getTokenName()
virtual double calculateFunction(double *x)
OSnLMNodeMatrixReference()
default constructor.
~OSnLMNodeMatrixInverse()
default destructor.
The OSnLNodeLn Class.
Definition: OSnLNode.h:841
OSnLMNode * createExpressionTreeFromPostfix(std::vector< ExprNode * > nlNodeVec)
virtual std::string getTokenName()
virtual std::string getTokenName()
virtual double calculateFunction(double *x)
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual OSnLMNode * cloneExprNode()
virtual std::string getTokenName()
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
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()
virtual double calculateFunction(double *x)
OSnLNodeE()
default constructor.
virtual std::string getTokenName()
virtual double calculateFunction(double *x)
virtual std::string getTokenName()
virtual void getVariableIndexMap(std::map< int, int > *varIdx)
virtual std::string getNonlinearExpressionInXML()
virtual std::string getTokenName()
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
virtual std::string getNonlinearExpressionInXML()
OSnLNodeSin()
default constructor.
The OSnLNodeMax Class.
Definition: OSnLNode.h:440
bool includeDiagonal
A boolean to express whether the diagonal is to be part of the upper triangle or not.
Definition: OSnLNode.h:2297
~OSnLNodeIf()
default destructor.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual double calculateFunction(double *x)
~OSnLNodeNumber()
default destructor.
OSnLNode * createExpressionTreeFromPostfix(std::vector< ExprNode * > nlNodeVec)
OSnLNodeProduct()
default constructor.
virtual OSnLNode * cloneExprNode()
~OSnLNodeVariable()
default destructor.
OSnLMNode()
default constructor.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
~OSnLMNodeMatrixDotTimes()
default destructor.
virtual std::string getTokenName()
virtual std::string getTokenName()
virtual OSnLMNode * cloneExprNode()
OSnLNodeCos()
default constructor.
int idx
The index of the matrix.
Definition: OSnLNode.h:2457
OSnLNodeSqrt()
default constructor.
virtual std::string getTokenNumber()
~OSnLNodeErf()
default destructor.
~OSnLMNodeMatrixPlus()
default destructor.
OSnLNodeMatrixDeterminant()
default constructor.
The OSnLNodeE Class.
Definition: OSnLNode.h:1362
virtual std::string getTokenName()
OSnLMNodeMatrixProduct()
default constructor.
virtual std::string getTokenName()
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual std::vector< ExprNode * > getPrefixFromExpressionTree()
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
~OSnLNodeSin()
default destructor.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
The OSnLNodeMatrixTrace Class.
Definition: OSnLNode.h:1717
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual ExprNode * cloneExprNode()=0
The OSnLMNodeMatrixProduct Class.
Definition: OSnLNode.h:2523
virtual std::string getTokenName()
OSnLMNodeMatrixPlus()
default constructor.
OSnLNode * createExpressionTreeFromPrefix(std::vector< ExprNode * > nlNodeVec)
virtual std::string getTokenName()
~OSnLNodePlus()
default destructor.
virtual std::vector< ExprNode * > getPostfixFromExpressionTree()
double m_dFunctionValue
m_dFunctionValue holds the function value given the current variable values.
Definition: OSnLNode.h:198
virtual std::string getNonlinearExpressionInXML()
virtual std::vector< ExprNode * > postOrderOSnLNodeTraversal(std::vector< ExprNode * > *postfixVector)
virtual std::string getTokenName()
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
~OSnLMNodeMatrixTimes()
default destructor.
OSnLMNodeMatrixMinus()
default constructor.
OSnLMNodeMatrixNegate()
default constructor.
The OSnLNodeTimes Class.
Definition: OSnLNode.h:643
~OSnLNodeDivide()
default destructor.
unsigned int inumberOfMatrixChildren
inumberOfMatrixChildren is the number of OSnLMNode child elements If this number is not fixed...
Definition: OSnLNode.h:79
OSnLNodeMax()
default constructor.
virtual OSnLMNode * cloneExprNode()
The OSnLNodeExp Class.
Definition: OSnLNode.h:1088
std::vector< ADdouble > ADvector
Definition: OSnLNode.h:40
virtual OSnLMNode * cloneExprNode()
~OSnLNodeNegate()
default destructor.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
~OSnLNodeMatrixTrace()
default destructor.
double ADdouble
Definition: OSnLNode.h:39
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
bool IsEqual(OSnLMNode *that)
A function to check for the equality of two objects.
The OSnLNodeMin Class.
Definition: OSnLNode.h:489
The OSnLNodePI Class.
Definition: OSnLNode.h:1428
The OSnLNodeMatrixTrace Class.
Definition: OSnLNode.h:1667
virtual std::vector< ExprNode * > preOrderOSnLNodeTraversal(std::vector< ExprNode * > *prefixVector)
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
The OSnLNodeIf Class.
Definition: OSnLNode.h:1238
virtual std::string getTokenName()
~OSnLMNodeMatrixMinus()
default destructor.
The OSnLNodeSin Class.
Definition: OSnLNode.h:1038
std::string type
in the C++ type is real
Definition: OSnLNode.h:1296
virtual std::string getTokenName()
virtual std::string getTokenName()
OSnLNodeMin()
default constructor.
OSnLMNodeMatrixDiagonal()
default constructor.
~OSnLMNodeMatrixScalarTimes()
default destructor.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
double coef
coef is an option coefficient on the variable, the default value is 1.0
Definition: OSnLNode.h:1501
The next few nodes evaluate to a scalar even though one or more of its arguments are matrices...
Definition: OSnLNode.h:1617
OSnLMNodeMatrixSubmatrixAt()
default constructor.
virtual std::string getTokenName()
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
~OSnLNodeAbs()
default destructor.
virtual std::string getTokenName()
~OSnLNodeMatrixToScalar()
default destructor.
virtual bool IsEqual(ExprNode *that)
A function to check for the equality of two objects.
int idx
idx is the index of the variable
Definition: OSnLNode.h:1504
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual std::string getTokenNumber()
virtual std::string getTokenName()
virtual OSnLMNode * cloneExprNode()
~OSnLNodeSquare()
default destructor.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual OSnLMNode * cloneExprNode()
virtual std::string getNonlinearExpressionInXML()
virtual std::string getTokenNumber()
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
OSnLMNodeIdentityMatrix()
default constructor.
virtual OSnLMNode * cloneExprNode()
~OSnLMNodeMatrixProduct()
default destructor.
virtual std::vector< ExprNode * > getPrefixFromExpressionTree()
The OSnLNodeNegate Class.
Definition: OSnLNode.h:592
~OSnLNodeProduct()
default destructor.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
OSnLMNode ** m_mMatrixChildren
m_mMatrixChildren holds all the matrix-valued operands, if any.
Definition: OSnLNode.h:89
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
~OSnLMNodeIdentityMatrix()
default destructor.
~OSnLNodeSqrt()
default destructor.
~OSnLNodeTimes()
default destructor.
~OSnLMNodeMatrixReference()
default destructor.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
OSnLNodeLn()
default constructor.
virtual OSnLNode * cloneExprNode()
~OSnLNodeMin()
default destructor.
virtual std::string getTokenName()
OSnLMNodeMatrixTranspose()
default constructor.
virtual std::string getTokenName()
std::vector< ExprNode * > postOrderOSnLNodeTraversal(std::vector< ExprNode * > *postfixVector)
virtual double calculateFunction(double *x)
The implementation of the virtual functions.
OSnLNodeSquare()
default constructor.
virtual double calculateFunction(double *x)
The implementation of the virtual functions.
virtual std::string getNonlinearExpressionInXML()
virtual double calculateFunction(double *x)
OSnLNodeVariable()
default constructor.
virtual std::string getTokenName()
virtual OSnLMNode * cloneExprNode()
virtual std::string getTokenName()
virtual double calculateFunction(double *x)
virtual std::string getTokenName()
OSnLNodeMatrixTrace()
default constructor.
virtual double calculateFunction(double *x)
virtual OSnLMNode * cloneExprNode()
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
std::string id
later, e.g.
Definition: OSnLNode.h:1300
~OSnLNodeCos()
default destructor.
virtual OSnLMNode * cloneExprNode()
virtual std::string getTokenName()
OSnLMNode * createExpressionTreeFromPrefix(std::vector< ExprNode * > nlNodeVec)
OSnLNodeIf()
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.
The OSnLNodeNumber Class.
Definition: OSnLNode.h:1288
virtual double calculateFunction(double *x)
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual std::string getTokenNumber()
virtual std::string getNonlinearExpressionInXML()
virtual std::string getTokenNumber()
virtual OSnLMNode * cloneExprNode()
A generic class from which we derive both OSnLNode and OSnLMNode.
Definition: OSnLNode.h:56
virtual std::string getTokenName()
virtual double calculateFunction(double *x)
~OSnLMNodeMatrixUpperTriangle()
default destructor.
~OSnLMNodeDiagonalMatrixFromVector()
default destructor.
OSnLNodeErf()
default constructor.
virtual std::vector< ExprNode * > preOrderOSnLNodeTraversal(std::vector< ExprNode * > *prefixVector)
~OSnLNodeAllDiff()
default destructor.
The OSnLNodeSquare Class.
Definition: OSnLNode.h:938
OSnLMNodeMatrixSum()
default constructor.
OSnLNode * copyNodeAndDescendants()
make a copy of this node and all its descendants
ExprNode()
default constructor.
The OSnLNodeAbs Class.
Definition: OSnLNode.h:1138
virtual std::string getNonlinearExpressionInXML()
virtual double calculateFunction(double *x)
~OSnLNodeMax()
default destructor.
virtual std::string getTokenName()
virtual double calculateFunction(double *x)
virtual ~OSnLMNode()
default destructor.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
std::vector< ExprNode * > preOrderOSnLNodeTraversal(std::vector< ExprNode * > *prefixVector)
virtual double calculateFunction(double *x)
virtual double calculateFunction(double *x)
virtual double calculateFunction(double *x)
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual std::vector< ExprNode * > getPostfixFromExpressionTree()
OSnLMNodeMatrixInverse()
default constructor.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual std::string getTokenNumber()
virtual std::string getTokenName()
virtual ~ExprNode()
default destructor.
virtual double calculateFunction(double *x)
OSnLNodePI()
default constructor.
~OSnLMNodeMatrixLowerTriangle()
default destructor.
The OSnLNodeSqrt Class.
Definition: OSnLNode.h:890
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
int inodeInt
inodeInt is the unique integer assigned to the OSnLNode or OSnLMNode in OSParameters.h.
Definition: OSnLNode.h:62
OSnLNodeSum()
default constructor.
OSnLNode ** m_mChildren
m_mChildren holds all the operands, that is, nodes that the current node operates on...
Definition: OSnLNode.h:84
OSnLMNodeMatrixDotTimes()
default constructor.
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual double calculateFunction(double *x)
virtual std::string getTokenName()
OSnLNodeMatrixToScalar()
default constructor.
~OSnLMNodeMatrixSubmatrixAt()
default destructor.
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
virtual std::string getNonlinearExpressionInXML()
virtual OSnLMNode * cloneExprNode()
The implementation of the virtual functions.
~OSnLNodePower()
default destructor.
a data structure to represent a matrix object (derived from MatrixType)
Definition: OSMatrix.h:1137
~OSnLMNodeMatrixSum()
default destructor.
virtual std::string getTokenName()
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
ADdouble m_ADTape
m_ADTape stores the expression tree for the this OSnLNode as an ADdouble.
Definition: OSnLNode.h:203
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
std::vector< ExprNode * > getPrefixFromExpressionTree()
OSnLNodeAbs()
default constructor.
virtual std::string getTokenName()
virtual double calculateFunction(double *x)
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
~OSnLNodeMinus()
default destructor.
virtual std::string getTokenName()
~OSnLNodeExp()
default destructor.
OSnLNodePower()
default constructor.
OSnLNodeNumber()
default constructor.
virtual OSnLMNode * cloneExprNode()
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
virtual OSnLNode * cloneExprNode()
~OSnLNodeSum()
default destructor.
virtual OSnLMNode * cloneExprNode()
OSnLNodeMinus()
default constructor.
~OSnLMNodeMatrixDiagonal()
default destructor.
virtual double calculateFunction(double *x)
virtual std::string getTokenName()
virtual ADdouble constructADTape(std::map< int, int > *ADIdx, ADvector *XAD)
The implementation of the virtual functions.
OSnLMNodeMatrixLowerTriangle()
default constructor.
The OSnLNodeErf Class.
Definition: OSnLNode.h:1188
virtual OSnLMNode * cloneExprNode()
virtual std::string getTokenName()
The OSnLNodeProduct Class.
Definition: OSnLNode.h:792
virtual std::string getTokenName()
virtual OSnLNode * cloneExprNode()
The implementation of the virtual functions.
bool IsEqual(OSnLNode *that)
A function to check for the equality of two objects.
The OSnLNodeCos Class.
Definition: OSnLNode.h:988
virtual std::string getTokenName()
double value
value is the value of the number
Definition: OSnLNode.h:1294
The OSnLNode Class for nonlinear expressions.
Definition: OSnLNode.h:192
int inodeType
inodeType essentially tracks whether the number of children are known or not.
Definition: OSnLNode.h:69
The OSnLNodePlus Class.
Definition: OSnLNode.h:341
~OSnLMNodeMatrixNegate()
default destructor.