Created
April 2, 2020 06:11
-
-
Save duken-blog/1249119b1bebc4633b9aabfdb77d38e7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| template<class ValT> | |
| void mmult(const ValT* A, int ADim1, int ADim2, const ValT* B, int BDim1, int BDim2, ValT* C) | |
| { | |
| if ( ADim2!=BDim1 ) | |
| throw std::runtime_error("Error sizes off"); | |
| memset((void*)C,0,sizeof(ValT)*ADim1*BDim2); | |
| int cc2,cc1,cr1; | |
| for ( cc2=0 ; cc2<BDim2 ; ++cc2 ) | |
| for ( cc1=0 ; cc1<ADim2 ; ++cc1 ) | |
| for ( cr1=0 ; cr1<ADim1 ; ++cr1 ) | |
| C[cc2*ADim2+cr1] += A[cc1*ADim1+cr1]*B[cc2*BDim1+cc1]; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment