Created
December 6, 2009 13:00
-
-
Save embed/250210 to your computer and use it in GitHub Desktop.
This file contains 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
float* matrixmul(float* fst, int frows, int fcols, float* sec, int srows, int scols) | |
{ | |
if(fcols != srows) | |
{ | |
printf("dimensions %d x %d to %d x %d\n",frows, fcols, srows, scols); | |
throw "Matrix dimension mismatch error"; | |
} | |
float *result=new float[frows*scols]; | |
for(int i=0 ; i<frows*scols ; i++) | |
result[i]=0.0; | |
int times=fcols; | |
for(int i=0; i<frows ; i++) | |
{ | |
for(int j=0; j<scols ; j++) | |
{ | |
for(int k=0; k<times; k++) | |
{ | |
float temp=fst[i*fcols+k]*sec[j+scols*k]; | |
result[j+i*times]+=temp; | |
} | |
} | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment