Minsky
operationType.cc
Go to the documentation of this file.
1 /*
2  @copyright Steve Keen 2013
3  @author Russell Standish
4  This file is part of Minsky.
5 
6  Minsky is free software: you can redistribute it and/or modify it
7  under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Minsky is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with Minsky. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #include <vector>
21 #include "operationType.h"
22 #include "minsky_epilogue.h"
23 
24 
25 using namespace classdesc;
26 
27 namespace minsky
28 {
29  string OperationType::typeName(int type)
30  {return enumKey<Type>(type);}
31 
32  OperationType::Group OperationType::classify(Type t)
33  {
34  if (t<euler) return general;
35  if (t<add) return constop;
36  if (t<copy) return binop;
37  if (t<sum) return function;
38  if (t<runningSum) return reduction;
39  if (t<innerProduct) return scan;
40  if (t<mean) return tensor;
41  return statistics;
42  }
43 
44 
45  namespace OperationTypeInfo
46  {
47  template <> int numArguments<OperationType::constant>() {return 0;}
48  template <> int numArguments<OperationType::euler>() {return 0;}
49  template <> int numArguments<OperationType::pi>() {return 0;}
50  template <> int numArguments<OperationType::zero>() {return 0;}
51  template <> int numArguments<OperationType::one>() {return 0;}
52  template <> int numArguments<OperationType::inf>() {return 0;}
53  template <> int numArguments<OperationType::percent>() {return 1;}
54  template <> int numArguments<OperationType::add>() {return 2;}
55  template <> int numArguments<OperationType::subtract>() {return 2;}
56  template <> int numArguments<OperationType::multiply>() {return 2;}
57  template <> int numArguments<OperationType::divide>() {return 2;}
58  template <> int numArguments<OperationType::log>() {return 2;}
59  template <> int numArguments<OperationType::pow>() {return 2;}
60  template <> int numArguments<OperationType::polygamma>() {return 2;}
61  template <> int numArguments<OperationType::lt>() {return 2;}
62  template <> int numArguments<OperationType::le>() {return 2;}
63  template <> int numArguments<OperationType::eq>() {return 2;}
64  template <> int numArguments<OperationType::min>() {return 2;}
65  template <> int numArguments<OperationType::max>() {return 2;}
66  template <> int numArguments<OperationType::and_>() {return 2;}
67  template <> int numArguments<OperationType::or_>() {return 2;}
68  template <> int numArguments<OperationType::covariance>() {return 2;}
69  template <> int numArguments<OperationType::correlation>() {return 2;}
70  template <> int numArguments<OperationType::linearRegression>() {return 2;}
71  template <> int numArguments<OperationType::userFunction>() {return 2;}
72  template <> int numArguments<OperationType::not_>() {return 1;}
73  template <> int numArguments<OperationType::time>() {return 0;}
74  template <> int numArguments<OperationType::copy>() {return 1;}
75  template <> int numArguments<OperationType::integrate>() {return 2;}
76  template <> int numArguments<OperationType::differentiate>() {return 1;}
77  template <> int numArguments<OperationType::data>() {return 1;}
78  template <> int numArguments<OperationType::sqrt>() {return 1;}
79  template <> int numArguments<OperationType::exp>() {return 1;}
80  template <> int numArguments<OperationType::ln>() {return 1;}
81  template <> int numArguments<OperationType::sin>() {return 1;}
82  template <> int numArguments<OperationType::cos>() {return 1;}
83  template <> int numArguments<OperationType::tan>() {return 1;}
84  template <> int numArguments<OperationType::asin>() {return 1;}
85  template <> int numArguments<OperationType::acos>() {return 1;}
86  template <> int numArguments<OperationType::atan>() {return 1;}
87  template <> int numArguments<OperationType::sinh>() {return 1;}
88  template <> int numArguments<OperationType::cosh>() {return 1;}
89  template <> int numArguments<OperationType::tanh>() {return 1;}
90  template <> int numArguments<OperationType::abs>() {return 1;}
91  template <> int numArguments<OperationType::floor>() {return 1;}
92  template <> int numArguments<OperationType::frac>() {return 1;}
93  template <> int numArguments<OperationType::Gamma>() {return 1;}
94  template <> int numArguments<OperationType::fact>() {return 1;}
95  template <> int numArguments<OperationType::sum>() {return 1;}
96  template <> int numArguments<OperationType::product>() {return 1;}
97  template <> int numArguments<OperationType::infimum>() {return 1;}
98  template <> int numArguments<OperationType::supremum>() {return 1;}
99  template <> int numArguments<OperationType::infIndex>() {return 1;}
100  template <> int numArguments<OperationType::supIndex>() {return 1;}
101  template <> int numArguments<OperationType::size>() {return 1;}
102  template <> int numArguments<OperationType::shape>() {return 1;}
103  template <> int numArguments<OperationType::mean>() {return 1;}
104  template <> int numArguments<OperationType::median>() {return 1;}
105  template <> int numArguments<OperationType::stdDev>() {return 1;}
106  template <> int numArguments<OperationType::moment>() {return 1;}
107  template <> int numArguments<OperationType::histogram>() {return 1;}
108 
109  template <> int numArguments<OperationType::any>() {return 1;}
110  template <> int numArguments<OperationType::all>() {return 1;}
111  template <> int numArguments<OperationType::runningSum>() {return 1;}
112  template <> int numArguments<OperationType::runningProduct>() {return 1;}
113  template <> int numArguments<OperationType::difference>() {return 1;}
114  template <> int numArguments<OperationType::differencePlus>() {return 1;}
115  template <> int numArguments<OperationType::innerProduct>() {return 2;}
116  template <> int numArguments<OperationType::outerProduct>() {return 2;}
117  template <> int numArguments<OperationType::index>() {return 1;}
118  template <> int numArguments<OperationType::gather>() {return 2;}
119  template <> int numArguments<OperationType::meld>() {return 2;}
120  template <> int numArguments<OperationType::merge>() {return 2;}
121  template <> int numArguments<OperationType::slice>() {return 1;}
122  template <> int numArguments<OperationType::ravel>() {return 1;}
123  template <> int numArguments<OperationType::numOps>() {return -1;} //no output port as well
124  }
125 }
Creation and access to the minskyTCL_obj object, which has code to record whenever Minsky&#39;s state cha...
Definition: constMap.h:22