- UID
- 12305
注册时间2006-5-6
阅读权限20
最后登录1970-1-1
以武会友
 
该用户从未签到
|
发表于 2006-6-6 09:16:39
|
显示全部楼层
建议:用一维数组来代替二维数组,这样可以把这个程序写一个小的函数,以后想什么时候用,贴过去就可以了。
//the matrix mul
//m is the row_num of a,n is the col_num of the a,k is the col_num of the b
//c is the reslut
void matrix_mul(double a[],double b[],int m,int n,int k,double c[])
{
int i,j,l,u;
//calculate the ans
for (i=0;i<m;i++)
for (j=0;j<k;j++)
{
u=i*k+j;
c=0.0;
for (l=0;l<n;l++)
c=c+a[i*n+l]*b[l*k+j];
}
return;
} |
|