Commit c9ae7048 authored by Cianciosa, Mark's avatar Cianciosa, Mark
Browse files

Merge branch 'powfix' into 'main'

Fix an error in power reductions of negative constant coefficents in the numberator of a divide.

See merge request !48
parents c29e0f38 616af37c
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -985,9 +985,9 @@ namespace graph {
                if (ldlm.get()) {
                    if (rc.get() &&
                        rc->evaluate().is_even()) {
                        if (ldlm->get_left()->is_constant() &&
                            ldlm->get_left()->evaluate().is_negative()) {
                            return pow(ldlm->get_right()/ld->get_right(),
                        if (ldlm->get_left()->is_constant()) {
                            return pow(ldlm->get_left(), this->right) *
                                   pow(ldlm->get_right()/ld->get_right(),
                                       this->right);
                        }
                    }
+6 −6
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ namespace timeing {
            } else if (total_time_ns.count() < 3600000000000) {
                std::cout << total_time_ns.count()/60000000000.0   << " min" << std::endl;
            } else {
                std::cout << total_time_ns.count()/3600000000000 << " h"   << std::endl;
                std::cout << total_time_ns.count()/3600000000000.0 << " h"   << std::endl;
            }
            std::cout << std::endl;
        }
+8 −0
Original line number Diff line number Diff line
@@ -409,6 +409,14 @@ void test_pow() {
                                   graph::pow(var_c, var_b) *
                                   graph::pow(var_d, var_b)) &&
           "Expected a^(d/2)*b^2*c^d.");

    auto factorconst = graph::pow(-0.5*var_a/var_b, 2.0);
    auto factorconst_cast = graph::multiply_cast(factorconst);
    assert(factorconst_cast.get() && "Expected a multiply node.");
    assert(factorconst_cast->get_left()->is_match(graph::constant<T> (static_cast<T> (0.25))) &&
           "Expected 0.25 on the left.");
    assert(factorconst_cast->get_right()->is_match(graph::pow(var_a/var_b, 2.0)) &&
           "Expected (a/b)^2 on the right.");
}

//------------------------------------------------------------------------------