Added Freivalds' Algorithm for randomized matrix multiplication verification by aditya-7562 · Pull Request #6340 · TheAlgorithms/Java · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

Added Freivalds' Algorithm for randomized matrix multiplication verification #6340

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

Merged
merged 2 commits into from
Jul 4, 2025

Conversation

aditya-7562
Copy link
Contributor

Summary

Added Freivalds' Algorithm under the randomized category as part of issue [#6219]

This algorithm offers a fast, probabilistic method to verify whether matrix multiplication A × B = C holds true, avoiding full recomputation of the product.


🧠 Randomized Algorithm Approach

  • Generate a random binary vector r
  • Perform matrix-vector multiplications and check if:
    A × (B × r) ≟ C × r
  • Repeat this process k times to reduce the probability of error
  • Probability of false positives becomes ≤ 1/2^k

⏱ Time Complexity

  • Per iteration: O(n²)
  • Total expected time: O(k × n²)
    (significantly faster than recomputing A × B, which is O(n³))

✅ Use Cases

  • Verifying matrix multiplication in:
    • Scientific computing workflows
    • Distributed computing systems
    • Cloud infrastructure and audit pipelines
  • Faster correctness checks in:
    • Numerical linear algebra
    • Cryptographic or zero-knowledge systems

📋 Checklist

  • I have read CONTRIBUTING.md
  • This pull request is entirely my work (no plagiarism)
  • All filenames follow PascalCase convention
  • All function and variable names follow Java naming conventions
  • Code has been formatted using:
    clang-format -i --style=file path/to/your/file.java

@codecov-commenter
Copy link

codecov-commenter commented Jul 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.37%. Comparing base (712ada5) to head (e1af216).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #6340      +/-   ##
============================================
+ Coverage     74.33%   74.37%   +0.04%     
- Complexity     5392     5403      +11     
============================================
  Files           679      680       +1     
  Lines         18820    18842      +22     
  Branches       3646     3656      +10     
============================================
+ Hits          13990    14014      +24     
+ Misses         4274     4273       -1     
+ Partials        556      555       -1     

☔ 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.

Copy link
Member

@siriak siriak left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@siriak siriak merged commit 58ac54c into TheAlgorithms:master Jul 4, 2025
6 of 7 checks passed
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

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.