forked from yuemingl/SymJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBytecodeBatchVecFunc.java
More file actions
30 lines (27 loc) · 842 Bytes
/
Copy pathBytecodeBatchVecFunc.java
File metadata and controls
30 lines (27 loc) · 842 Bytes
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
package symjava.bytecode;
public class BytecodeBatchVecFunc implements BytecodeVecFunc {
BytecodeVecFunc func;
int vecLen; //Input vector length
int retLen; //Return vector length
public BytecodeBatchVecFunc(BytecodeVecFunc func, int vecLen, int retLen) {
this.func = func;
this.vecLen = vecLen;
this.retLen = retLen;
}
@Override
public void apply(double[] outAry, int outPos, double[]... args) {
double[] tmpBuf = new double[retLen];
double[][] tmpArgs = new double[args.length][vecLen];
int destPos = 0;
int argPos = 0;
for(int i=0; i<args[0].length/vecLen; i++) {
for(int j=0; j<args.length; j++) {
System.arraycopy(args[j], argPos, tmpArgs[j], 0, vecLen);
}
func.apply(tmpBuf, 0, tmpArgs);
System.arraycopy(tmpBuf, 0, outAry, destPos, retLen);
destPos += retLen;
argPos += vecLen;
}
}
}