forked from JavaTX/JavaCompilerCore
Merge branch 'bigRefactoring' into addPackages
This commit is contained in:
commit
802d7726d4
22
PlugInBau.txt
Normal file
22
PlugInBau.txt
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
Repositories: Branches: JavaCompilerCore: simplyRes
|
||||||
|
JavaCompilerPlugin: copy_libs
|
||||||
|
JavaCompilerCore > mvn install -Dskip.test=true
|
||||||
|
|
||||||
|
[INFO] Installing /Users/pl/workspace_oxygen/JavaCompilerCore/target/JavaTXcompiler-0.2.jar to /Users/pl/.m2/repository/de/dhbwstuttgart/JavaTXcompiler/0.2/JavaTXcompiler-0.2.jar
|
||||||
|
[INFO] Installing /Users/pl/workspace_oxygen/JavaCompilerCore/pom.xml to /Users/pl/.m2/repository/de/dhbwstuttgart/JavaTXcompiler/0.2/JavaTXcompiler-0.2.pom
|
||||||
|
[INFO] Installing /Users/pl/workspace_oxygen/JavaCompilerCore/target/JavaTXcompiler-0.2-jar-with-dependencies.jar to /Users/pl/.m2/repository/de/dhbwstuttgart/JavaTXcompiler/0.2/JavaTXcompiler-0.2-jar-with-dependencies.jar
|
||||||
|
[INFO] ------------------------------------------------------------------------
|
||||||
|
[INFO] BUILD SUCCESS
|
||||||
|
[INFO] ------------------------------------------------------------------------
|
||||||
|
[INFO] Total time: 23.279 s
|
||||||
|
[INFO] Finished at: 2019-09-17T09:31:30+02:00
|
||||||
|
[INFO] -------------------------------------
|
||||||
|
|
||||||
|
JavaCompilerCore > cd target
|
||||||
|
|
||||||
|
JavaCompilerCore/target > cp JavaTXcompiler-0.2.jar ../../Plugin_JCC/JavaCompilerPlugin/bundles/JavaCompilerPlugin.Plugin/lib/JavaTXcompiler.jar
|
||||||
|
|
||||||
|
Im Eclipse: Plugin_JCC/JavaCompilerPlugin> mvn install
|
||||||
|
|
||||||
|
Plugin_JCC/JavaCompilerPlugin/releng/JavaCompilerPlugin.Update/target > cp JavaCompilerPlugin.Update-0.1.0-SNAPSHOT.zip ~/webdav/public_html/javatx/javatx_XXXXXX.zip
|
||||||
|
|
@ -192,7 +192,10 @@ public class TPHExtractor extends AbstractASTWalker {
|
|||||||
@Override
|
@Override
|
||||||
public void visit(Constructor cons) {
|
public void visit(Constructor cons) {
|
||||||
inMethod = false;
|
inMethod = false;
|
||||||
super.visit(cons);
|
//super.visit(cons);
|
||||||
|
cons.getParameterList().accept(this);
|
||||||
|
if(cons.block != null)
|
||||||
|
cons.block.accept(this);
|
||||||
inMethod = true;
|
inMethod = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,4 +370,10 @@ public class Signature {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
if(sw == null)
|
||||||
|
return super.toString();
|
||||||
|
return sw.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -474,9 +474,9 @@ public class JavaTXCompiler {
|
|||||||
return x;
|
return x;
|
||||||
|
|
||||||
};
|
};
|
||||||
logFile.write(unifyCons.toString());
|
logFile.write("Unify:" + unifyCons.toString());
|
||||||
unifyCons = unifyCons.map(distributeInnerVars);
|
unifyCons = unifyCons.map(distributeInnerVars);
|
||||||
logFile.write(unifyCons.toString());
|
logFile.write("\nUnify_distributeInnerVars: " + unifyCons.toString());
|
||||||
TypeUnify unify = new TypeUnify();
|
TypeUnify unify = new TypeUnify();
|
||||||
// Set<Set<UnifyPair>> results = new HashSet<>(); Nach vorne gezogen
|
// Set<Set<UnifyPair>> results = new HashSet<>(); Nach vorne gezogen
|
||||||
logFile.write("FC:\\" + finiteClosure.toString() + "\n");
|
logFile.write("FC:\\" + finiteClosure.toString() + "\n");
|
||||||
|
@ -35,7 +35,7 @@ public class SyntaxTreeGenerator{
|
|||||||
Set<JavaClassName> imports = new HashSet();
|
Set<JavaClassName> imports = new HashSet();
|
||||||
private Map<String, RefTypeOrTPHOrWildcardOrGeneric> fields = new HashMap<>(); //PL 2018-11-01 fields eingefuegt, damit die fields immer die gleiche TPH bekommen
|
private Map<String, RefTypeOrTPHOrWildcardOrGeneric> fields = new HashMap<>(); //PL 2018-11-01 fields eingefuegt, damit die fields immer die gleiche TPH bekommen
|
||||||
|
|
||||||
List<Statement> fieldInitializations = new ArrayList<>();
|
List<Statement> fieldInitializations = new ArrayList<>(); //PL 2019-10-23: Muss für jede Klasse neu initilisiert werden
|
||||||
|
|
||||||
public SyntaxTreeGenerator(JavaClassRegistry reg, GenericsRegistry globalGenerics){
|
public SyntaxTreeGenerator(JavaClassRegistry reg, GenericsRegistry globalGenerics){
|
||||||
//Die Generics müssen während des Bauens des AST erstellt werden,
|
//Die Generics müssen während des Bauens des AST erstellt werden,
|
||||||
@ -159,6 +159,7 @@ public class SyntaxTreeGenerator{
|
|||||||
|
|
||||||
private ClassOrInterface convertClass(Java8Parser.ClassDeclarationContext ctx) {
|
private ClassOrInterface convertClass(Java8Parser.ClassDeclarationContext ctx) {
|
||||||
ClassOrInterface newClass;
|
ClassOrInterface newClass;
|
||||||
|
fieldInitializations = new ArrayList<>(); //PL 2019-10-22: muss für jede Klasse neu initilisiert werden
|
||||||
if(ctx.normalClassDeclaration() != null){
|
if(ctx.normalClassDeclaration() != null){
|
||||||
newClass = convertNormal(ctx.normalClassDeclaration());
|
newClass = convertNormal(ctx.normalClassDeclaration());
|
||||||
}
|
}
|
||||||
|
@ -19,4 +19,8 @@ public class This extends Expression
|
|||||||
public void accept(StatementVisitor visitor) {
|
public void accept(StatementVisitor visitor) {
|
||||||
visitor.visit(this);
|
visitor.visit(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "this: "+ this.getType();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,8 +39,8 @@ public class TypeUnify2Task extends TypeUnifyTask {
|
|||||||
return new HashSet<>(); }
|
return new HashSet<>(); }
|
||||||
else
|
else
|
||||||
*/
|
*/
|
||||||
|
//writeLog("xxx");
|
||||||
noOfThread--;
|
//noOfThread--;
|
||||||
synchronized (usedTasks) {
|
synchronized (usedTasks) {
|
||||||
if (this.myIsCancelled()) {
|
if (this.myIsCancelled()) {
|
||||||
return new HashSet<>();
|
return new HashSet<>();
|
||||||
|
@ -904,9 +904,10 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
|
|
||||||
/* FORK ANFANG */
|
/* FORK ANFANG */
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
noOfThread--;
|
|
||||||
writeLog("wait "+ forkOrig.thNo);
|
writeLog("wait "+ forkOrig.thNo);
|
||||||
|
noOfThread--;
|
||||||
res = forkOrig.join();
|
res = forkOrig.join();
|
||||||
|
//noOfThread++;
|
||||||
forkOrig.writeLog("final Orig 1");
|
forkOrig.writeLog("final Orig 1");
|
||||||
forkOrig.closeLogFile();
|
forkOrig.closeLogFile();
|
||||||
//Set<Set<UnifyPair>> fork_res = forkOrig.join();
|
//Set<Set<UnifyPair>> fork_res = forkOrig.join();
|
||||||
@ -919,7 +920,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
forks.forEach(x -> writeLog("wait: " + x.thNo));
|
forks.forEach(x -> writeLog("wait: " + x.thNo));
|
||||||
for(TypeUnify2Task fork : forks) {
|
for(TypeUnify2Task fork : forks) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
|
noOfThread--;
|
||||||
Set<Set<UnifyPair>> fork_res = fork.join();
|
Set<Set<UnifyPair>> fork_res = fork.join();
|
||||||
|
//noOfThread++;
|
||||||
writeLog("Join " + new Integer(fork.thNo).toString());
|
writeLog("Join " + new Integer(fork.thNo).toString());
|
||||||
//noOfThread--; an das Ende von compute verschoben
|
//noOfThread--; an das Ende von compute verschoben
|
||||||
writeLog("fork_res: " + fork_res.toString());
|
writeLog("fork_res: " + fork_res.toString());
|
||||||
@ -932,7 +935,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
fork.closeLogFile();
|
fork.closeLogFile();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
noOfThread++;
|
//noOfThread++;
|
||||||
} else {
|
} else {
|
||||||
if(parallel && (variance == -1) && noOfThread <= MaxNoOfThreads) {
|
if(parallel && (variance == -1) && noOfThread <= MaxNoOfThreads) {
|
||||||
Set<TypeUnify2Task> forks = new HashSet<>();
|
Set<TypeUnify2Task> forks = new HashSet<>();
|
||||||
@ -1007,9 +1010,10 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
|
|
||||||
/* FORK ANFANG */
|
/* FORK ANFANG */
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
noOfThread--;
|
|
||||||
writeLog("wait "+ forkOrig.thNo);
|
writeLog("wait "+ forkOrig.thNo);
|
||||||
|
noOfThread--;
|
||||||
res = forkOrig.join();
|
res = forkOrig.join();
|
||||||
|
//noOfThread++;
|
||||||
forkOrig.writeLog("final Orig -1");
|
forkOrig.writeLog("final Orig -1");
|
||||||
forkOrig.closeLogFile();
|
forkOrig.closeLogFile();
|
||||||
//Set<Set<UnifyPair>> fork_res = forkOrig.join();
|
//Set<Set<UnifyPair>> fork_res = forkOrig.join();
|
||||||
@ -1022,7 +1026,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
forks.forEach(x -> writeLog("wait: " + x.thNo));
|
forks.forEach(x -> writeLog("wait: " + x.thNo));
|
||||||
for(TypeUnify2Task fork : forks) {
|
for(TypeUnify2Task fork : forks) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
|
noOfThread--;
|
||||||
Set<Set<UnifyPair>> fork_res = fork.join();
|
Set<Set<UnifyPair>> fork_res = fork.join();
|
||||||
|
//noOfThread++;
|
||||||
writeLog("Join " + new Integer(fork.thNo).toString());
|
writeLog("Join " + new Integer(fork.thNo).toString());
|
||||||
//noOfThread--; an das Ende von compute verschoben
|
//noOfThread--; an das Ende von compute verschoben
|
||||||
writeLog("fork_res: " + fork_res.toString());
|
writeLog("fork_res: " + fork_res.toString());
|
||||||
@ -1035,7 +1041,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
fork.closeLogFile();
|
fork.closeLogFile();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
noOfThread++;
|
//noOfThread++;
|
||||||
} else {
|
} else {
|
||||||
if(parallel && (variance == 2) && noOfThread <= MaxNoOfThreads) {
|
if(parallel && (variance == 2) && noOfThread <= MaxNoOfThreads) {
|
||||||
writeLog("var2einstieg");
|
writeLog("var2einstieg");
|
||||||
@ -1080,9 +1086,10 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
|
|
||||||
/* FORK ANFANG */
|
/* FORK ANFANG */
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
noOfThread--;
|
|
||||||
writeLog("wait "+ forkOrig.thNo);
|
writeLog("wait "+ forkOrig.thNo);
|
||||||
|
noOfThread--;
|
||||||
res = forkOrig.join();
|
res = forkOrig.join();
|
||||||
|
//noOfThread++;
|
||||||
forkOrig.writeLog("final Orig 2");
|
forkOrig.writeLog("final Orig 2");
|
||||||
forkOrig.closeLogFile();
|
forkOrig.closeLogFile();
|
||||||
//Set<Set<UnifyPair>> fork_res = forkOrig.join();
|
//Set<Set<UnifyPair>> fork_res = forkOrig.join();
|
||||||
@ -1094,7 +1101,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
forks.forEach(x -> writeLog("wait: " + x.thNo));
|
forks.forEach(x -> writeLog("wait: " + x.thNo));
|
||||||
for(TypeUnify2Task fork : forks) {
|
for(TypeUnify2Task fork : forks) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
|
noOfThread--;
|
||||||
Set<Set<UnifyPair>> fork_res = fork.join();
|
Set<Set<UnifyPair>> fork_res = fork.join();
|
||||||
|
//noOfThread++;
|
||||||
writeLog("Join " + new Integer(fork.thNo).toString());
|
writeLog("Join " + new Integer(fork.thNo).toString());
|
||||||
//noOfThread--; an das Ende von compute verschoben
|
//noOfThread--; an das Ende von compute verschoben
|
||||||
add_res.add(fork_res);
|
add_res.add(fork_res);
|
||||||
@ -1102,7 +1111,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
fork.closeLogFile();
|
fork.closeLogFile();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
noOfThread++;
|
//noOfThread++;
|
||||||
} else {
|
} else {
|
||||||
//parallel = false; //Wenn MaxNoOfThreads erreicht ist, sequentiell weiterarbeiten
|
//parallel = false; //Wenn MaxNoOfThreads erreicht ist, sequentiell weiterarbeiten
|
||||||
elems.add(a); //PL 2019-01-16 muss das wirklich hin steht schon in Zeile 859 ja braucht man siehe Zeile 859
|
elems.add(a); //PL 2019-01-16 muss das wirklich hin steht schon in Zeile 859 ja braucht man siehe Zeile 859
|
||||||
|
38
src/test/java/bytecode/mathStrucIntegerTest.java
Normal file
38
src/test/java/bytecode/mathStrucIntegerTest.java
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
package bytecode;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLClassLoader;
|
||||||
|
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
|
public class mathStrucIntegerTest {
|
||||||
|
|
||||||
|
private static String path;
|
||||||
|
private static File fileToTest;
|
||||||
|
private static JavaTXCompiler compiler;
|
||||||
|
private static ClassLoader loader;
|
||||||
|
private static Class<?> classToTest;
|
||||||
|
private static String pathToClassFile;
|
||||||
|
private static Object instanceOfClass;
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test() throws Exception {
|
||||||
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecode/javFiles/mathStrucInteger.jav";
|
||||||
|
fileToTest = new File(path);
|
||||||
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
|
compiler.generateBytecode(System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/");
|
||||||
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
|
classToTest = loader.loadClass("mathStrucInteger");
|
||||||
|
//instanceOfClass = classToTest.getDeclaredConstructor(Integer.class).newInstance("A");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -3,9 +3,9 @@ import java.lang.Integer;
|
|||||||
//import java.lang.Short;
|
//import java.lang.Short;
|
||||||
|
|
||||||
public class Faculty {
|
public class Faculty {
|
||||||
//public fact;
|
public fact;
|
||||||
//Faculty() {
|
Faculty() {
|
||||||
public fact = (x) -> {
|
fact = (x) -> {
|
||||||
if (x == 1) {
|
if (x == 1) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -13,6 +13,7 @@ public class Faculty {
|
|||||||
return x * (fact.apply(x-1));
|
return x * (fact.apply(x-1));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ import java.lang.String;
|
|||||||
import java.lang.Integer;
|
import java.lang.Integer;
|
||||||
import java.lang.Double;
|
import java.lang.Double;
|
||||||
import java.lang.Boolean;
|
import java.lang.Boolean;
|
||||||
import java.util.Vector;
|
//import java.util.Vector;
|
||||||
|
|
||||||
|
|
||||||
public class OL {
|
public class OL {
|
||||||
@ -13,11 +13,11 @@ public class OL {
|
|||||||
|
|
||||||
// if the class contains just this method, then correct BC will be generated.
|
// if the class contains just this method, then correct BC will be generated.
|
||||||
// But if another methods are contained then the generated BC is not correct
|
// But if another methods are contained then the generated BC is not correct
|
||||||
m(x) {
|
// m(x) {
|
||||||
//x.add(1);
|
// //x.add(1);
|
||||||
x.addAll(x);
|
// x.addAll(x);
|
||||||
return x;
|
// return x;
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,9 +8,23 @@ class Y {
|
|||||||
y = f -> t -> f.apply(y.apply(f)).apply(t);
|
y = f -> t -> f.apply(y.apply(f)).apply(t);
|
||||||
//factorial = y.apply(f -> n -> { if (n == 0) return 1; else return n * f.apply(n - 1); });
|
//factorial = y.apply(f -> n -> { if (n == 0) return 1; else return n * f.apply(n - 1); });
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
getY() {
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
class fac1 {
|
||||||
|
factorial;
|
||||||
|
|
||||||
|
fac1() {
|
||||||
|
var y;
|
||||||
|
y = new Y<Integer,Integer,Integer,Integer,Integer>().getY();
|
||||||
|
factorial = y.apply(f -> n -> { if (n == 0) return 1; else return n * f.apply(n - 1); });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
ergibt Parse-Error
|
ergibt Parse-Error
|
||||||
class fac1 {
|
class fac1 {
|
||||||
factorial;
|
factorial;
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
import java.util.Vector;
|
||||||
|
import java.lang.Integer;
|
||||||
|
|
||||||
public class mathStruc {
|
public class mathStruc {
|
||||||
model;
|
model;
|
||||||
|
|
||||||
@ -8,4 +11,5 @@ public class mathStruc {
|
|||||||
model =m;
|
model =m;
|
||||||
//innerOp = (o) -> (ms) -> new mathStruc<>(o.apply(this.model,ms.model));
|
//innerOp = (o) -> (ms) -> new mathStruc<>(o.apply(this.model,ms.model));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
23
src/test/resources/bytecode/javFiles/mathStrucInteger.jav
Normal file
23
src/test/resources/bytecode/javFiles/mathStrucInteger.jav
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import java.util.Vector;
|
||||||
|
import java.lang.Integer;
|
||||||
|
|
||||||
|
public class mathStrucInteger {
|
||||||
|
model;
|
||||||
|
|
||||||
|
innerOp = (o) -> (ms) -> new mathStrucInteger<>(o.apply(model,ms.model));
|
||||||
|
|
||||||
|
public mathStrucInteger(m) {
|
||||||
|
model =m;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class mathStrucIntegerUse {
|
||||||
|
|
||||||
|
main() {
|
||||||
|
var ms;
|
||||||
|
ms = new mathStrucInteger<>(2);
|
||||||
|
var ms2;
|
||||||
|
ms2 = ms.innerOp.apply((x,y) -> x+y).apply(ms);
|
||||||
|
return ms2;
|
||||||
|
}
|
||||||
|
}
|
91
src/test/resources/bytecode/javFiles/mathStrucMatrixOP.jav
Normal file
91
src/test/resources/bytecode/javFiles/mathStrucMatrixOP.jav
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
//PL 2019-10-24: laeuft nicht durch, zu gross
|
||||||
|
import java.util.Vector;
|
||||||
|
import java.lang.Integer;
|
||||||
|
import java.lang.Boolean;
|
||||||
|
|
||||||
|
public class mathStrucMatrixOP {
|
||||||
|
model;
|
||||||
|
|
||||||
|
innerOp = (o) -> (ms) -> new mathStrucMatrixOP<>(o.apply(model,ms.model));
|
||||||
|
|
||||||
|
public mathStrucMatrixOP(m) {
|
||||||
|
model =m;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MatrixOP extends Vector<Vector<Integer>> {
|
||||||
|
|
||||||
|
MatrixOP () {
|
||||||
|
}
|
||||||
|
|
||||||
|
MatrixOP(vv) {
|
||||||
|
Integer i;
|
||||||
|
i = 0;
|
||||||
|
while(i < vv.size()) {
|
||||||
|
// Boolean a = this.add(vv.elementAt(i));
|
||||||
|
this.add(vv.elementAt(i));
|
||||||
|
i=i+1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public mul = (m1, m2) -> {
|
||||||
|
var ret = new MatrixOP();
|
||||||
|
var i = 0;
|
||||||
|
while(i < m1.size()) {
|
||||||
|
var v1 = m1.elementAt(i);
|
||||||
|
var v2 = new Vector<Integer>();
|
||||||
|
var j = 0;
|
||||||
|
while(j < v1.size()) {
|
||||||
|
var erg = 0;
|
||||||
|
var k = 0;
|
||||||
|
while(k < v1.size()) {
|
||||||
|
erg = erg + v1.elementAt(k)
|
||||||
|
* m2.elementAt(k).elementAt(j);
|
||||||
|
k++; }
|
||||||
|
// v2.addElement(new Integer(erg));
|
||||||
|
v2.addElement(erg);
|
||||||
|
j++; }
|
||||||
|
ret.addElement(v2);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class mathStrucUseMatrixOP {
|
||||||
|
|
||||||
|
main() {
|
||||||
|
Vector<Vector<Integer>> vv = new Vector<Vector<Integer>>();
|
||||||
|
Vector<Integer> v1 = new Vector<Integer>();
|
||||||
|
v1.addElement(2);
|
||||||
|
v1.addElement(2);
|
||||||
|
Vector<Integer> v2 = new Vector<Integer>();
|
||||||
|
v2.addElement(3);
|
||||||
|
v2.addElement(3);
|
||||||
|
vv.addElement(v1);
|
||||||
|
vv.addElement(v2);
|
||||||
|
|
||||||
|
MatrixOP m1 = new MatrixOP(vv);
|
||||||
|
|
||||||
|
Vector<Vector<Integer>> vv1 = new Vector<Vector<Integer>>();
|
||||||
|
Vector<Integer> v3 = new Vector<Integer>();
|
||||||
|
v3.addElement(2);
|
||||||
|
v3.addElement(2);
|
||||||
|
Vector<Integer> v4 = new Vector<Integer>();
|
||||||
|
v4.addElement(3);
|
||||||
|
v4.addElement(3);
|
||||||
|
vv1.addElement(v3);
|
||||||
|
vv1.addElement(v4);
|
||||||
|
|
||||||
|
MatrixOP m2 = new MatrixOP(vv1);
|
||||||
|
|
||||||
|
var mms;
|
||||||
|
mms = new mathStrucMatrixOP<>(m1);
|
||||||
|
var mms2;
|
||||||
|
mms2 = new mathStrucMatrixOP<>(m2);
|
||||||
|
var mms3;
|
||||||
|
mms3 = mms.innerOp.apply(m1.mul).apply(mms2);
|
||||||
|
return mms3;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user