Skip to content

Instantly share code, notes, and snippets.

@zainabnazari
Last active June 28, 2023 05:02
Show Gist options
  • Save zainabnazari/d98770fc3e1565b6150a20edbac11a3f to your computer and use it in GitHub Desktop.
Save zainabnazari/d98770fc3e1565b6150a20edbac11a3f to your computer and use it in GitHub Desktop.
hash value function for a matrix multiplication
// C[] is the elements of matrix multiplication
// we consider the hash value as zero and add the sum of the elemnt of the matrix as its value
// if the two matrices that we have computed have diffrent hash value then there would be an error in the computation of the matrics.
int hash_value = 0;
int i_m;
for( i_m = 0; i_m < N*N; i_m++) {
hash_value += C[i_m];
}
// taking a modulo to shorten the final result.
hash_value %= 100000007;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment