Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bfb1963

Browse filesBrowse files
committed
try local stack trick to overcome relation operator overload
1 parent e67c580 commit bfb1963
Copy full SHA for bfb1963

File tree

Expand file treeCollapse file tree

4 files changed

+32
-11
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+32
-11
lines changed
Open diff view settings
Collapse file

‎src/symjava/domains/Domain.java‎

Copy file name to clipboardExpand all lines: src/symjava/domains/Domain.java
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import symjava.math.Transformation;
99
import symjava.numeric.NumFunc;
10+
import symjava.relational.Ge;
1011
import symjava.symbolic.Expr;
1112

1213
/**
@@ -180,6 +181,14 @@ public Domain setConstraint(Expr logicalExpr) {
180181
return this;
181182
}
182183

184+
public Domain setConstraint(boolean dummy) {
185+
if(Ge.stackTop != null) {
186+
this.constraint = Ge.stackTop;
187+
Ge.stackTop = null;
188+
}
189+
return this;
190+
}
191+
183192
public Expr getConstraint() {
184193
return this.constraint;
185194
}
Collapse file

‎src/symjava/examples/NumericalIntegration.java‎

Copy file name to clipboardExpand all lines: src/symjava/examples/NumericalIntegration.java
+9-3Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,15 @@ public static void main(String[] args) {
2121
//test_2D();
2222
//test_ND();
2323

24-
Expr i = Integrate.apply(exp(pow(x,2)), Interval.apply(a, b).setStepSize(0.001));
25-
BytecodeFunc fi = JIT.compile(new Expr[]{a,b}, i);
26-
System.out.println(fi.apply(1,2));
24+
//Expr i = Integrate.apply(exp(pow(x,2)), Interval.apply(a, b).setStepSize(0.001));
25+
//BytecodeFunc fi = JIT.compile(new Expr[]{a,b}, i);
26+
//System.out.println(fi.apply(1,2));
27+
28+
Domain2D d = new Domain2D("D");
29+
d.setConstraint(
30+
x <=y & x <=z
31+
);
32+
System.out.println(d.getConstraint());
2733

2834
}
2935

Collapse file

‎src/symjava/relational/Ge.java‎

Copy file name to clipboardExpand all lines: src/symjava/relational/Ge.java
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import symjava.symbolic.arity.BinaryOp;
55

66
public class Ge extends BinaryOp implements Relation {
7+
public static Expr stackTop = null;
78

89
public Ge(Expr arg1, Expr arg2) {
910
super(arg1, arg2);
Collapse file

‎src/symjava/symbolic/Expr.java‎

Copy file name to clipboardExpand all lines: src/symjava/symbolic/Expr.java
+13-8Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import symjava.logic.Or;
99
import symjava.logic.Xor;
1010
import symjava.relational.Ge;
11+
import symjava.relational.Relation;
1112
import symjava.symbolic.utils.Utils;
1213

1314
abstract public class Expr implements Cloneable {
@@ -372,14 +373,18 @@ public Expr xor(Expr other) {
372373
return Xor.simplifiedIns(this, other);
373374
}
374375

375-
// /**
376-
// * TODO We cannot use the comparison operator overload in java-oo for our use case
377-
// * @param other
378-
// * @return
379-
// */
380-
// public int compareTo(Expr other) {
381-
// return 1;
382-
// }
376+
/**
377+
* TODO We cannot use the comparison operator overload in java-oo for our use case
378+
* @param other
379+
* @return
380+
*/
381+
public int compareTo(Expr other) {
382+
if(Ge.stackTop == null)
383+
Ge.stackTop = Ge.apply(this, other);
384+
else
385+
Ge.stackTop = Ge.apply(Ge.stackTop, other);
386+
return -1;
387+
}
383388

384389

385390
/**

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.