Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include "SundanceProductExpr.hpp"
00033 #include "SundanceProductEvaluator.hpp"
00034 #include "SundanceDeriv.hpp"
00035
00036 #include "SundanceOut.hpp"
00037 #include "SundanceTabs.hpp"
00038
00039 using namespace Sundance;
00040 using namespace Sundance;
00041
00042 using namespace Sundance;
00043 using namespace Teuchos;
00044
00045
00046
00047 ProductExpr::ProductExpr(const RCP<ScalarExpr>& left,
00048 const RCP<ScalarExpr>& right)
00049 : BinaryExpr(left, right, 1)
00050 {}
00051
00052
00053 Evaluator* ProductExpr::createEvaluator(const EvaluatableExpr* expr,
00054 const EvalContext& context) const
00055 {
00056 return new ProductEvaluator(dynamic_cast<const ProductExpr*>(expr), context);
00057 }
00058
00059 bool ProductExpr::isHungryDiffOp() const
00060 {
00061 return rightScalar()->isHungryDiffOp();
00062 }
00063
00064
00065
00066 const std::string& ProductExpr::xmlTag() const
00067 {
00068 static std::string timesStr = "Times";
00069 static std::string divideStr = "Divide";
00070 if (sign() < 0) return divideStr;
00071 return timesStr;
00072 }
00073
00074 const std::string& ProductExpr::opChar() const
00075 {
00076 static std::string timesStr = "*";
00077 static std::string divideStr = "/";
00078 if (sign() < 0) return divideStr;
00079 return timesStr;
00080 }
00081
00082
00083
00084 Set<MultiSet<int> > ProductExpr::internalFindQ_W(int order, const EvalContext& context) const
00085 {
00086 Tabs tab0;
00087 int verb = context.setupVerbosity();
00088 SUNDANCE_MSG3(verb, tab0 << "ProdExpr::internalFindQ_W(" << order << ")");
00089
00090 Set<MultiSet<int> > rtn;
00091 if (order > 2) return rtn;
00092
00093 if (order==2)
00094 {
00095 rtn.put(makeMultiSet<int>(0,1));
00096 return rtn;
00097 }
00098
00099
00100 const Set<MultipleDeriv>& wLeft
00101 = leftEvaluatable()->findW(0, context);
00102 SUNDANCE_MSG3(verb, tab0 << "wLeft=" << wLeft);
00103
00104 const Set<MultipleDeriv>& wRight
00105 = rightEvaluatable()->findW(0, context);
00106 SUNDANCE_MSG3(verb, tab0 << "wRight=" << wRight);
00107
00108 if (order==0)
00109 {
00110 if (wLeft.size() > 0)
00111 {
00112 rtn.put(makeMultiSet<int>(0));
00113 }
00114 if (wRight.size() > 0)
00115 {
00116 rtn.put(makeMultiSet<int>(1));
00117 }
00118 }
00119
00120 if (order==1)
00121 {
00122 if (wLeft.size() > 0) rtn.put(makeMultiSet<int>(1));
00123 if (wRight.size() > 0) rtn.put(makeMultiSet<int>(0));
00124 }
00125
00126 return rtn;
00127 }
00128
00129
00130 Set<MultiSet<int> > ProductExpr::internalFindQ_V(int order, const EvalContext& context) const
00131 {
00132 Tabs tab0;
00133 int verb = context.setupVerbosity();
00134 SUNDANCE_MSG3(verb, tab0 << "ProdExpr::internalFindQ_V(" << order << ")");
00135
00136 Set<MultiSet<int> > rtn;
00137 if (order > 1) return rtn;
00138
00139 const Set<MultipleDeriv>& vLeft
00140 = leftEvaluatable()->findV(0, context);
00141 const Set<MultipleDeriv>& vRight
00142 = rightEvaluatable()->findV(0, context);
00143
00144 if (order==0)
00145 {
00146 if (vLeft.size() > 0)
00147 {
00148 rtn.put(makeMultiSet<int>(0));
00149 }
00150 if (vRight.size() > 0)
00151 {
00152 rtn.put(makeMultiSet<int>(1));
00153 }
00154 }
00155
00156 if (order==1)
00157 {
00158 if (vLeft.size() > 0) rtn.put(makeMultiSet<int>(1));
00159 if (vRight.size() > 0) rtn.put(makeMultiSet<int>(0));
00160 }
00161
00162
00163 return rtn;
00164 }
00165