There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies. C.A.R. Hoare

Verify matrix multiplication

Language Java | Level Intermediate | Category Algorithms | August 5, 2015 9:06 am


Algorithm Problem Description

Freivalds algorithm is used to verify the correctness of the matrix multiplication. We can also use the native way to verify the matrix multiplication. But the current method is slow. It is a probabilistic randomized algorithm used to verify matrix multiplication.

A native algorithm would compute the product A x B explicitly and compare term by term whether this product equals C. Write a program to verify the matrix multiplication using Freivalds algorithm.

Output

          	        
          	        

Dimesion of the matrices: 2
Matrix One values: [[2.0, 3.0], [3.0, 4.0]]
Matrix two values: [[1.0, 1.0], [0.0, 2.0]]
Result Matrix values: [[6.0, 5.0], [8.0, 7.0]]
Failed to verify matrix multiplication using Freivalds algorithm

          	        
          	        				    


Comments



Please login to add comments.