在C语言编程中分配内存时,调用matlab的内存分配函数:
double *hist = (double *)mxCalloc(blocks[0]*blocks[1]*18, sizeof(double));
double *norm = (double *)mxCalloc(blocks[0]*blocks[1], sizeof(double));
最后能得出正确的结果,而是用C语言的标准内存分配函数:
double *hist = (double*)malloc(blocks[0]*blocks[1]*18*sizeof(double));
double *norm = (double*)malloc(blocks[0]*blocks[1]*sizeof(double));*
却无法得出正确的结果。真的好奇怪。最后没办法使用了C语言中的函数:
double *hist = (double*)calloc(blocks[0]*blocks[1]*18,sizeof(double));
double *norm = (double*)calloc(blocks[0]*blocks[1],sizeof(double));
最终得到正确的计算结果!