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
89 lines (74 loc) · 1.75 KB

File metadata and controls

89 lines (74 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
85
86
87
88
89
package symjava.math;
import java.util.ArrayList;
import java.util.List;
import symjava.matrix.SymVector;
import symjava.symbolic.Expr;
import symjava.symbolic.arity.NaryOp;
import symjava.symbolic.utils.Utils;
/**
* Divergence Operator
*
*/
public class Div extends NaryOp {
protected Expr expr;
public Div(SymVector vec) {
super(null);
if(vec instanceof Grad) {
Grad g = (Grad)vec;
if(g.isAbstract()) {
this.args = g.getData();
this.label = "div(" +g+ ")";
this.sortKey = this.label;
return;
}
}
List<Expr> freeVars = Utils.extractSymbols(vec.getData());
create(vec, freeVars.toArray(new Expr[0]));
}
public Div(SymVector vec, Expr... freeVars) {
super(null);
create(vec, freeVars);
}
private Div create(SymVector vec, Expr... freeVars) {
if(vec.dim() != freeVars.length) {
throw new RuntimeException("vec.dim() != freeVars.length");
}
this.args = vec.getData();
List<Expr> list = new ArrayList<Expr>();
for(int i=0; i<this.args.length; i++) {
list.add(vec.get(i).diff(freeVars[i]));
}
this.expr = Utils.addListToExpr(list).simplify();
this.label = expr.getLabel();
this.sortKey = expr.getSortKey();
return this;
}
public static Div apply(SymVector vec) {
return new Div(vec);
}
public static Div apply(SymVector vec, Expr ...expr) {
return new Div(vec, expr);
}
@Override
public boolean isAbstract() {
return expr == null;
}
public Expr getExpr() {
return this.expr;
}
@Override
public Expr simplify() {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean symEquals(Expr other) {
// TODO Auto-generated method stub
return false;
}
@Override
public Expr diff(Expr expr) {
// TODO Auto-generated method stub
return null;
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.