Skip to content

Add matrix multiplication with double[][] and unit tests #6417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 28 commits into
base: master
Choose a base branch
from

Conversation

Nishitha0730
Copy link

Summary

This PR adds an implementation of standard matrix multiplication using double[][] arrays in the com.thealgorithms.matrix package.

  • The MatrixMultiplication class multiplies two 2D matrices with floating-point support.
  • Includes input validation for null, empty, and incompatible dimensions.

Tests

Added a comprehensive JUnit 5 test class MatrixMultiplicationTest with:

  • Valid multiplication tests
  • Edge cases: null input, empty matrix, incompatible dimensions
  • Floating-point accuracy check using EPSILON

Please let me know if any changes are needed!

@codecov-commenter
Copy link

codecov-commenter commented Jul 19, 2025

Codecov Report

Attention: Patch coverage is 93.33333% with 1 line in your changes missing coverage. Please review.

Project coverage is 74.88%. Comparing base (31bf130) to head (5328d9a).

Files with missing lines Patch % Lines
...com/thealgorithms/matrix/MatrixMultiplication.java 93.33% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #6417      +/-   ##
============================================
+ Coverage     74.86%   74.88%   +0.02%     
- Complexity     5482     5490       +8     
============================================
  Files           682      683       +1     
  Lines         19012    19027      +15     
  Branches       3670     3675       +5     
============================================
+ Hits          14233    14249      +16     
+ Misses         4224     4223       -1     
  Partials        555      555              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@@ -0,0 +1,48 @@
package com.thealgorithms.matrix;

public final class MatrixMultiplication {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add here another detailed explanation above the class. For example by providing a link and most importantly adding the time- and space complexity :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay:)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please add testcases for 1x1 matrices and not-rectangular matrices?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants