feat: Matrix Mult verbessert
parent
b151cbe35c
commit
c43797aa19
11
Vector.java
11
Vector.java
|
|
@ -47,19 +47,26 @@ public class Vector {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int[][] matrixMultiplication(int[][] matrix, int scalar) {
|
public static int[][] matrixMultiplication(int[][] matrix, int scalar) {
|
||||||
int[][] ausgabe = null;
|
int[][] ausgabe;
|
||||||
// boolean matrixFlag = false;
|
// boolean matrixFlag = false;
|
||||||
// if (matrix.length ==3 && matrix[0].length == 3 && matrix[1].length == 3 &&
|
// if (matrix.length ==3 && matrix[0].length == 3 && matrix[1].length == 3 &&
|
||||||
// matrix[2].length == 3){
|
// matrix[2].length == 3){
|
||||||
// matrixFlag =true;
|
// matrixFlag =true;
|
||||||
// }
|
// }
|
||||||
if (matrix.length == 3 && matrix[0].length == 3 && matrix[1].length == 3 && matrix[2].length == 3) {
|
if (matrix == null){
|
||||||
|
ausgabe = null;
|
||||||
|
}
|
||||||
|
else if (matrix.length == 3 && matrix[0].length == 3 && matrix[1].length == 3 && matrix[2].length == 3) {
|
||||||
ausgabe = new int[3][3];
|
ausgabe = new int[3][3];
|
||||||
for (int außenPos = 0; außenPos < matrix.length; außenPos++) {
|
for (int außenPos = 0; außenPos < matrix.length; außenPos++) {
|
||||||
for (int innenPos = 0; innenPos < matrix[außenPos].length; innenPos++) {
|
for (int innenPos = 0; innenPos < matrix[außenPos].length; innenPos++) {
|
||||||
ausgabe[außenPos][innenPos] = matrix[außenPos][innenPos] * scalar;
|
ausgabe[außenPos][innenPos] = matrix[außenPos][innenPos] * scalar;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ausgabe = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ausgabe;
|
return ausgabe;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue