From 60327d54a57efd07d39ff8cd6446416da1208dd5 Mon Sep 17 00:00:00 2001 From: Cyrus Zahiri Date: Thu, 11 Sep 2025 08:57:46 -0700 Subject: [PATCH] Adds main2 method for matrix operations. Adds a new main2 method to demonstrate matrix multiplication. This allows testing and experimentation with matrix operations. --- MatrixExample.java | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/MatrixExample.java b/MatrixExample.java index 051e5bc..b84f147 100644 --- a/MatrixExample.java +++ b/MatrixExample.java @@ -66,5 +66,30 @@ public static int[][] generateRandomMatrix(int numRows, int numCols) { return matrix; } + public static void main2(String[] args) { + int[][] matrix = { + { 1, 2, 3, 4, 5, 6 }, + { 4, 5, 6, 3, 7, 2 }, + { 27, 8, 9, 5, 3, 21 }, + { 73, 2, 19, 5, 1, 8 }, + { 47, 9, 9, 5, 0, 22 }, + { 78, 86, 1, 4, 1, 21 }, + { 73, 18, 2, 2, 5, 11 } + }; + + int numRows = 6; + int numCols = 7; + int[][] matrix2 = generateRandomMatrix(numRows, numCols); + int[][] result = multiplyMatrices(matrix, matrix2); + + System.out.println("result length: " + result.length + " x " + result[0].length); + for (int i = 0; i < result.length; i++) { + for (int j = 0; j < result[i].length; j++) { + System.out.print(result[i][j] + " "); + } + System.out.println(); + } + } } +