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
83 lines (71 loc) · 1.75 KB

File metadata and controls

83 lines (71 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
package symjava.numeric;
import java.util.Vector;
import symjava.bytecode.BytecodeFunc;
import symjava.matrix.SymMatrix;
import symjava.symbolic.Expr;
import symjava.symbolic.Func;
import symjava.symbolic.Expr;
public class NumMatrix {
Vector<Vector<BytecodeFunc>> data = new Vector<Vector<BytecodeFunc>>();
public NumMatrix() {
}
public NumMatrix(int m, int n) {
data.setSize(m);
for(int i=0; i<m; i++) {
data.set(i, new Vector<BytecodeFunc>(n));
}
}
public NumMatrix(SymMatrix sm, Expr[] args) {
int m = sm.rowDim();
int n = sm.colDim();
data.setSize(m);
for(int i=0; i<m; i++) {
Vector<BytecodeFunc> row = new Vector<BytecodeFunc>();
row.setSize(n);
data.set(i, row);
for(int j=0; j<n; j++) {
Expr e = sm.get(i, j);
if(e == null)
continue;
Func func = null;
if(sm.get(i, j) instanceof Func) {
func = (Func)e;
} else {
func = new Func(this.getClass().getSimpleName()+java.util.UUID.randomUUID().toString().replaceAll("-", "")+"_"+i+"_"+j,e);
func.args = args;
//System.out.println(func.getLabel());
}
row.set(j, func.toBytecodeFunc());
}
}
}
public BytecodeFunc get(int i, int j) {
return data.get(i).get(j);
}
public void set(int i, int j, BytecodeFunc func) {
Vector<BytecodeFunc> row = data.get(i);
row.set(j, func);
}
public void add(NumVector v) {
data.add(v.data);
}
public int rowDim() {
return data.size();
}
public int colDim() {
if(data.size() > 0)
return data.get(0).size();
return 0;
}
public double[][] eval(double ...args) {
int m = rowDim();
int n = colDim();
double[][] rlt = new double[m][n];
for(int i=0; i<m; i++) {
for(int j=0; j<n; j++) {
rlt[i][j] = this.get(i, j).apply(args);
}
}
return rlt;
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.