Loading graph_framework/equilibrium.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -1779,7 +1779,7 @@ namespace equilibrium { auto one = graph::one<T, SAFE_MATH> (); auto phip = get_phi(s)->df(s); auto jbsupu = (get_chi(s_norm_f)->df(s) - phip*l->df(v)); auto jbsupu = get_chi(s_norm_f)->df(s) - phip*l->df(v); auto jbsupv = phip*(one + l->df(u)); bvec_cache = (jbsupu*esubu + jbsupv*esubv)/jacobian; } Loading graph_framework/math.hpp +2 −1 Original line number Diff line number Diff line Loading @@ -856,7 +856,8 @@ namespace graph { } auto lp = pow_cast(this->left); if (lp.get()) { // Only run this reduction if the right is an integer constant value. if (lp.get() && rc.get() && rc->is_integer()) { return pow(lp->get_left(), lp->get_right()*this->right); } Loading graph_tests/math_test.cpp +24 −2 Original line number Diff line number Diff line Loading @@ -234,6 +234,10 @@ void test_pow() { auto sqrd = graph::pow(graph::constant(non_int), two); assert(sqrd->evaluate().at(0) == static_cast<T> (non_int*non_int) && "Expected x*x"); const auto non_int_neg = static_cast<T> (-0.438763); auto sqrd_neg = graph::pow(graph::constant(non_int_neg), two); assert(sqrd_neg->evaluate().at(0) == static_cast<T> (non_int_neg*non_int_neg) && "Expected x*x"); auto three = graph::two<T> (); auto pow_pow1 = graph::pow(graph::pow(ten, three), two); Loading Loading @@ -281,6 +285,24 @@ void test_pow() { assert(!pow_var->is_constant_like() && "Did not expect a constant."); assert(pow_var->is_all_variables() && "Expected a variable."); assert(pow_var->is_power_like() && "Expected a power like."); // Test power of power // (a^b)^n -> a^n*b when n is an integer. auto powpow_int = graph::pow(graph::pow(var_a, var_b), graph::constant<T> (static_cast<T> (3.0))); auto powpow_int_cast = graph::pow_cast(powpow_int); assert(graph::multiply_cast(powpow_int_cast->get_right()) && "Expected multiply node."); auto powpow_float = graph::pow(graph::pow(var_a, var_b), graph::constant<T> (static_cast<T> (1.5))); auto powpow_float_cast = graph::pow_cast(powpow_float); assert(!graph::multiply_cast(powpow_float_cast->get_right()) && "Did not expect multiply node."); auto powpow_var = graph::pow(graph::pow(var_a, var_b), ten); auto powpow_var_cast = graph::pow_cast(powpow_var); assert(!graph::multiply_cast(powpow_var_cast->get_right()) && "Did not expect multiply node."); } //------------------------------------------------------------------------------ Loading Loading
graph_framework/equilibrium.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -1779,7 +1779,7 @@ namespace equilibrium { auto one = graph::one<T, SAFE_MATH> (); auto phip = get_phi(s)->df(s); auto jbsupu = (get_chi(s_norm_f)->df(s) - phip*l->df(v)); auto jbsupu = get_chi(s_norm_f)->df(s) - phip*l->df(v); auto jbsupv = phip*(one + l->df(u)); bvec_cache = (jbsupu*esubu + jbsupv*esubv)/jacobian; } Loading
graph_framework/math.hpp +2 −1 Original line number Diff line number Diff line Loading @@ -856,7 +856,8 @@ namespace graph { } auto lp = pow_cast(this->left); if (lp.get()) { // Only run this reduction if the right is an integer constant value. if (lp.get() && rc.get() && rc->is_integer()) { return pow(lp->get_left(), lp->get_right()*this->right); } Loading
graph_tests/math_test.cpp +24 −2 Original line number Diff line number Diff line Loading @@ -234,6 +234,10 @@ void test_pow() { auto sqrd = graph::pow(graph::constant(non_int), two); assert(sqrd->evaluate().at(0) == static_cast<T> (non_int*non_int) && "Expected x*x"); const auto non_int_neg = static_cast<T> (-0.438763); auto sqrd_neg = graph::pow(graph::constant(non_int_neg), two); assert(sqrd_neg->evaluate().at(0) == static_cast<T> (non_int_neg*non_int_neg) && "Expected x*x"); auto three = graph::two<T> (); auto pow_pow1 = graph::pow(graph::pow(ten, three), two); Loading Loading @@ -281,6 +285,24 @@ void test_pow() { assert(!pow_var->is_constant_like() && "Did not expect a constant."); assert(pow_var->is_all_variables() && "Expected a variable."); assert(pow_var->is_power_like() && "Expected a power like."); // Test power of power // (a^b)^n -> a^n*b when n is an integer. auto powpow_int = graph::pow(graph::pow(var_a, var_b), graph::constant<T> (static_cast<T> (3.0))); auto powpow_int_cast = graph::pow_cast(powpow_int); assert(graph::multiply_cast(powpow_int_cast->get_right()) && "Expected multiply node."); auto powpow_float = graph::pow(graph::pow(var_a, var_b), graph::constant<T> (static_cast<T> (1.5))); auto powpow_float_cast = graph::pow_cast(powpow_float); assert(!graph::multiply_cast(powpow_float_cast->get_right()) && "Did not expect multiply node."); auto powpow_var = graph::pow(graph::pow(var_a, var_b), ten); auto powpow_var_cast = graph::pow_cast(powpow_var); assert(!graph::multiply_cast(powpow_var_cast->get_right()) && "Did not expect multiply node."); } //------------------------------------------------------------------------------ Loading