Skip to content

Commit 4e4625c

Browse files
committed
method created for 3by2 matrix multiply with 2by1 matrix
1 parent 05064a5 commit 4e4625c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/test/java/com/thealgorithms/matrix/MatrixMultiplicationTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ void testMultiply2by2(){
2020
assertMatrixEquals(expected, result); // Because assertEquals can fails due to floating point precision issues, Therfore use assertMatrixEquals
2121
}
2222

23+
@Test
24+
void testMultiply3by2and1(){
25+
double[][] matrixA = {{1.0,2.0},{3.0,4.0},{5.0,6.0}};
26+
double[][] matrixB = {{7.0},{8.0}};
27+
double[][] expected = {{23.0}, {53.0}, {83.0}};
28+
29+
double[][] result = MatrixMultiplication.multiply(matrixA, matrixB);
30+
assertMatrixEquals(expected, result); // Because assertEquals can fails due to floating point precision issues, Therfore use assertMatrixEquals
31+
}
32+
33+
2334
private void assertMatrixEquals(double[][] expected, double[][] actual) {
2435
assertEquals(expected.length, actual.length, "Row count mismatch");
2536
for (int i = 0; i < expected.length; i++) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy