From c43797aa19a8dbf84ce2c51d14715815b1abdfb1 Mon Sep 17 00:00:00 2001 From: Andreas Wurst <1720808@stud.hs-mannheim.de> Date: Tue, 20 May 2025 10:28:53 +0200 Subject: [PATCH] feat: Matrix Mult verbessert --- Vector.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Vector.java b/Vector.java index a8087a7..c63156c 100644 --- a/Vector.java +++ b/Vector.java @@ -47,19 +47,26 @@ public class Vector { } public static int[][] matrixMultiplication(int[][] matrix, int scalar) { - int[][] ausgabe = null; + int[][] ausgabe; // boolean matrixFlag = false; // if (matrix.length ==3 && matrix[0].length == 3 && matrix[1].length == 3 && // matrix[2].length == 3){ // 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]; for (int außenPos = 0; außenPos < matrix.length; außenPos++) { for (int innenPos = 0; innenPos < matrix[außenPos].length; innenPos++) { ausgabe[außenPos][innenPos] = matrix[außenPos][innenPos] * scalar; } } + + } + else { + ausgabe = null; } return ausgabe;