//头文件中的定义/
//纯C里面定义的布尔类型
typedef enum { False = 0, True = 1 }Bool;
//定义矩阵元素的类型为matrixType
typedef double matrixType;
//此结构体用来表示矩阵,其中row为行,column为列,height为高,array用来存放矩阵元素(用一维来模拟二维/三维)
typedef struct
{
unsigned int row, column, height;
matrixType *array; //使用时,必须对*array进行初始化
}Matrix;
///函数/
/*
matrix为要设置大小并分配内存的矩阵,row、column、height分别为行,列,高。
函数调用成功则则返回true,否则返回false
*/
Bool SetMatrixSize(Matrix *matrix, const unsigned int row, const unsigned int column, const unsigned int height)
{
unsigned int size = row * column * height * sizeof(matrixType);
if (size <= 0)
{
return False;
}
matrix->array = (matrixType*)malloc(size);
//如果分配内存成功