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

Latest commit

 

History

History
History
84 lines (73 loc) · 1.75 KB

File metadata and controls

84 lines (73 loc) · 1.75 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package symjava.domains;
import symjava.math.Transformation;
import symjava.symbolic.Expr;
import symjava.symbolic.SymDouble;
import static symjava.symbolic.Symbol.x;
public class Interval extends Domain1D {
Expr start;
Expr end;
public Interval(Expr start, Expr end) {
super("["+start+","+end+"]", x);
this.start = start;
this.end = end;
}
public Interval(Expr start, Expr end, Expr coordVar) {
super("["+start+","+end+"]", coordVar);
this.start = start;
this.end = end;
}
public Expr getStart() {
return start;
}
public Expr getEnd() {
return end;
}
/**
* Define a interval by giving two number of the bounds
* @param start
* @param end
* @return
*/
public static <T1, T2> Interval apply(T1 start, T2 end) {
Expr s = null, e = null;
if(start instanceof Number) {
s = new SymDouble(((Number)start).doubleValue());
} else {
s = (Expr)start;
}
if(end instanceof Number) {
e = new SymDouble(((Number)end).doubleValue());
} else {
e = (Expr)end;
}
return new Interval(s, e);
}
public static <T1, T2> Interval apply(T1 start, T2 end, Expr coordVar) {
Expr s = null, e = null;
if(start instanceof Number) {
s = new SymDouble(((Number)start).doubleValue());
} else {
s = (Expr)start;
}
if(end instanceof Number) {
e = new SymDouble(((Number)end).doubleValue());
} else {
e = (Expr)end;
}
return new Interval(s, e, coordVar);
}
@Override
public String toString() {
return "["+start+","+end+"]";
}
@Override
public Domain transform(String label, Transformation trans) {
Expr from = trans.getFromVars()[0];
Expr to = trans.getToVars()[0];
Expr toSolve = trans.eqs[0].solve(to);
return new Interval(
toSolve.subs(from, start),
toSolve.subs(from, end),
to);
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.