48 case Teuchos::MathExpr::PROD_PROGRAM: {
52 case Teuchos::MathExpr::PROD_NO_STATEMENTS:
53 case Teuchos::MathExpr::PROD_NO_EXPR:
54 case Teuchos::MathExpr::PROD_NEXT_STATEMENT: {
57 case Teuchos::MathExpr::PROD_ASSIGN: {
58 std::string
const& name = Teuchos::any_ref_cast<std::string>(rhs.at(0));
62 case Teuchos::MathExpr::PROD_YES_EXPR:
63 case Teuchos::MathExpr::PROD_EXPR:
64 case Teuchos::MathExpr::PROD_TERNARY_DECAY:
65 case Teuchos::MathExpr::PROD_OR_DECAY:
66 case Teuchos::MathExpr::PROD_AND_DECAY:
67 case Teuchos::MathExpr::PROD_ADD_SUB_DECAY:
68 case Teuchos::MathExpr::PROD_MUL_DIV_DECAY:
69 case Teuchos::MathExpr::PROD_POW_DECAY:
70 case Teuchos::MathExpr::PROD_NEG_DECAY:
71 case Teuchos::MathExpr::PROD_SOME_ARGS:
74 case Teuchos::MathExpr::PROD_TERNARY:
75 this->
ternary_op(result, rhs.at(0), rhs.at(3), rhs.at(6));
77 case Teuchos::MathExpr::PROD_OR:
80 case Teuchos::MathExpr::PROD_AND:
83 case Teuchos::MathExpr::PROD_GT:
86 case Teuchos::MathExpr::PROD_LT:
89 case Teuchos::MathExpr::PROD_GEQ:
92 case Teuchos::MathExpr::PROD_LEQ:
95 case Teuchos::MathExpr::PROD_EQ:
98 case Teuchos::MathExpr::PROD_BOOL_PARENS:
101 case Teuchos::MathExpr::PROD_ADD:
104 case Teuchos::MathExpr::PROD_SUB:
107 case Teuchos::MathExpr::PROD_MUL:
110 case Teuchos::MathExpr::PROD_DIV:
113 case Teuchos::MathExpr::PROD_POW:
116 case Teuchos::MathExpr::PROD_CALL: {
117 std::string
const& name = Teuchos::any_ref_cast<std::string>(rhs.at(0));
119 TEUCHOS_TEST_FOR_EXCEPTION(it ==
symbol_map.end(), Teuchos::ParserFail,
120 "symbol \"" << name <<
"\" being called doesn't exist!");
121 Function& func = Teuchos::any_ref_cast<Function>(it->second);
122 std::vector<Teuchos::any>& args = Teuchos::any_ref_cast<std::vector<Teuchos::any>>(rhs.at(4));
126 case Teuchos::MathExpr::PROD_NO_ARGS: {
127 result = std::vector<Teuchos::any>{};
130 case Teuchos::MathExpr::PROD_FIRST_ARG: {
131 std::vector<Teuchos::any>& args = Teuchos::make_any_ref<std::vector<Teuchos::any>>(
result);
132 args.push_back(Teuchos::any{});
133 swap(args.back(), rhs.at(0));
136 case Teuchos::MathExpr::PROD_NEXT_ARG: {
138 std::vector<Teuchos::any>& args = Teuchos::any_ref_cast<std::vector<Teuchos::any>>(
result);
139 args.push_back(Teuchos::any{});
140 swap(args.back(), rhs.at(3));
143 case Teuchos::MathExpr::PROD_NEG:
144 this->
neg_op(result, rhs.at(2));
146 case Teuchos::MathExpr::PROD_VAL_PARENS:
149 case Teuchos::MathExpr::PROD_CONST:
152 case Teuchos::MathExpr::PROD_VAR:
153 std::string
const& name = Teuchos::any_ref_cast<std::string>(rhs.at(0));
155 TEUCHOS_TEST_FOR_EXCEPTION(it ==
symbol_map.end(), Teuchos::ParserFail,
156 "symbol " << name <<
" being referenced doesn't exist!");
165 this->
inspect_arg(cond, cond_is_many, cond_is_bool);
166 TEUCHOS_TEST_FOR_EXCEPTION(!cond_is_bool, Teuchos::ParserFail,
167 "Ternary condition is not of boolean type!");
172 TEUCHOS_TEST_FOR_EXCEPTION(is_bool[0], Teuchos::ParserFail,
173 "Boolean values in ternary operator not yet supported");
175 auto cond_value = Teuchos::any_cast<Kokkos::View<bool const>>(cond);
176 auto host_cond_value = Kokkos::create_mirror_view(cond_value);
177 Kokkos::deep_copy(host_cond_value, cond_value);
178 if (host_cond_value()) {
184 if (!is_many[0] && !is_many[1]) {
186 }
else if (!is_many[0] && is_many[1]) {
188 }
else if (is_many[0] && !is_many[1]) {
190 }
else if (is_many[0] && is_many[1]) {