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 "PlayaTabs.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(0);
00087   int verb = context.setupVerbosity();
00088   SUNDANCE_MSG2(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   Tabs tab1;
00100   SUNDANCE_MSG3(verb, tab1 << "calling findW(0) for left");
00101   const Set<MultipleDeriv>& wLeft 
00102     = leftEvaluatable()->findW(0, context);
00103   SUNDANCE_MSG3(verb, tab1 << "found wLeft(0)=" << wLeft);
00104 
00105   SUNDANCE_MSG3(verb, tab1 << "calling findW(0) for right");
00106   const Set<MultipleDeriv>& wRight
00107     = rightEvaluatable()->findW(0, context);
00108   SUNDANCE_MSG3(verb, tab1 << "found wRight(0)=" << wRight);
00109   
00110   if (order==0)
00111   {
00112     if (wLeft.size() > 0)
00113     {
00114       rtn.put(makeMultiSet<int>(0));
00115     }
00116     if (wRight.size() > 0)
00117     {
00118       rtn.put(makeMultiSet<int>(1));
00119     }
00120   }
00121   
00122   if (order==1)
00123   {
00124     if (wLeft.size() > 0) rtn.put(makeMultiSet<int>(1));
00125     if (wRight.size() > 0) rtn.put(makeMultiSet<int>(0));
00126   }
00127   
00128   SUNDANCE_MSG2(verb, tab0 << "Q_W[" << order << "]=" << rtn);
00129   return rtn;
00130 }
00131 
00132 
00133 Set<MultiSet<int> > ProductExpr::internalFindQ_V(int order, const EvalContext& context) const
00134 {
00135   Tabs tab0(0);
00136   int verb = context.setupVerbosity();
00137   SUNDANCE_MSG2(verb, tab0 << "ProdExpr::internalFindQ_V(" << order << ")");
00138 
00139   Set<MultiSet<int> > rtn;
00140   if (order > 1) return rtn;
00141 
00142   const Set<MultipleDeriv>& vLeft 
00143     = leftEvaluatable()->findV(0, context);
00144   const Set<MultipleDeriv>& vRight
00145     = rightEvaluatable()->findV(0, context);
00146 
00147   if (order==0)
00148   {
00149     if (vLeft.size() > 0)
00150     {
00151       rtn.put(makeMultiSet<int>(0));
00152     }
00153     if (vRight.size() > 0)
00154     {
00155       rtn.put(makeMultiSet<int>(1));
00156     }
00157   }
00158 
00159   if (order==1)
00160   {
00161     if (vLeft.size() > 0) rtn.put(makeMultiSet<int>(1));
00162     if (vRight.size() > 0) rtn.put(makeMultiSet<int>(0));
00163   }
00164 
00165   SUNDANCE_MSG2(verb, tab0 << "Q_V[" << order << "]=" << rtn);  
00166   return rtn;
00167 }
00168