n1,n2,n3갯수로 이루어진 배열을 리턴하는 코드입니다.
/* ========= Make a n1,n2 and n3 cubic matrix =====================*/
double ***cube_mat(n1,n2,n3) int n1,n2,n3; {
int i,j;
double ***m;
m = (double***) calloc(n1, sizeof(double**));
if( m == (double ***) NULL) {
printf("Out of Memory\007 at make_mat \n" );
exit(0);
}
for(i=0; i<n1; i++){
m[i] = (double**) calloc(n2, sizeof(double*));
if( m[i] == (double **) NULL) {
printf("Out of Memory\007 at make_mat \n" );
exit(0);
}
}
for(i=0; i<n1; i++)
for(j=0; j<n2; j++){
m[i][j] = (double*) calloc(n3, sizeof(double));
if( m[i][j] == (double *) NULL) {
printf("Out of Memory\007 at make_mat \n" );
exit(0);
}
}
return (double***)m;
}