谁能帮我这个?
void _vect_mat(float *vect,float **mat){
float temp[4];
temp[0] = vect[0];
temp[1] = vect[1];
temp[2] = vect[2];
temp[3] = vect[3];
vect[0] = (temp[0] * mat[0][0]) + (temp[1] * mat[1][0]) + (temp[2] * mat[2][0]) + (temp[3] * mat[3][0]);
vect[1] = (temp[0] * mat[0][1]) + (temp[1] * mat[1][1]) + (temp[2] * mat[2][1]) + (temp[3] * mat[3][1]);
vect[2] = (temp[0] * mat[0][2]) + (temp[1] * mat[1][2]) + (temp[2] * mat[2][2]) + (temp[3] * mat[3][2]);
vect[3] = (temp[0] * mat[0][3]) + (temp[1] * mat[1][3]) + (temp[2] * mat[2][3]) + (temp[3] * mat[3][3]);
}
int main(){
int i,j,k;
float *vect,**mat;
vect = (float *)malloc(4 * sizeof(float));
mat = (float **)malloc(4 * sizeof(float *);
for(i=0;i<4;i++)mat[i] = (float *)malloc(4 * sizeof(float));
vect[0] = 1.0;
vect[n] = ......etc.
mat[0][0] = 1.0;
mat[n][m] ......etc.
while (1){
for(i = 0;i < 5;i++){
for(j = 0;j< 6;j++){
for(k = 0;k < 3600;k++)_vect_mat(vect,mat);
}
}
}
}
_vect_mat
当我在循环内调用函数时,所有性能都会下降。这是正常的?我究竟做错了什么?