diff --git a/examples/test_rubi.m b/examples/test_rubi.m index 4a03486..adc84d7 100644 --- a/examples/test_rubi.m +++ b/examples/test_rubi.m @@ -1,5 +1,7 @@ -testproblems = ReadList["/Users/cwalker32/Code/gocode/src/github.com/corywalker/expreduce/test_rubi/test_rubi.m"]; -testproblems = DeleteCases[testproblems, Null]; +(*testproblems = ReadList["/Users/cwalker32/Code/gocode/src/github.com/corywalker/expreduce/test_rubi/test_rubi.m"];*) +(*testproblems = DeleteCases[testproblems, Null];*) +testproblems = ReadList["/Users/cwalker32/Downloads/test.m"][[1]]; +Print[Length[testproblems]]; testi = 1; diff --git a/expreduce/evalstate.go b/expreduce/evalstate.go index a1f8751..e85b5d5 100644 --- a/expreduce/evalstate.go +++ b/expreduce/evalstate.go @@ -287,7 +287,10 @@ func (this *EvalState) MarkSeen(name string) { // Attempts to compute a specificity metric for a rule. Higher specificity rules // should be tried first. -func ruleSpecificity(lhs Ex, rhs Ex) int { +func ruleSpecificity(lhs Ex, rhs Ex, name string) int { + if name == "Rubi`Int" { + return 100 + } // I define complexity as the length of the Lhs.String() // because it is simple, and it works for most of the common cases. We wish // to attempt f[x_Integer] before we attempt f[x_]. If LHSs map to the same @@ -376,12 +379,13 @@ func (this *EvalState) Define(lhs Ex, rhs Ex) { // Insert into definitions for name. Maintain order of decreasing // complexity. var tmp = this.defined[name] - newSpecificity := ruleSpecificity(lhs, rhs) + newSpecificity := ruleSpecificity(lhs, rhs, name) for i, dv := range this.defined[name].downvalues { if dv.specificity == 0 { dv.specificity = ruleSpecificity( dv.rule.Parts[1], dv.rule.Parts[2], + name, ) } if dv.specificity < newSpecificity {