Skip to content

Commit

Permalink
Tweaks for Rubi.
Browse files Browse the repository at this point in the history
  • Loading branch information
corywalker committed Sep 7, 2017
1 parent 9c1aab9 commit 8a4c575
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions 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;

Expand Down
8 changes: 6 additions & 2 deletions expreduce/evalstate.go
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 8a4c575

Please sign in to comment.