Open Fixer-itb opened 10 months ago
Matrix Matrix_asDiagonal(MATRIX_TYPE data,int dimension) { Matrix mat_ = (Matrix)malloc(sizeof(Matrix)); if (mat == NULL) { printf("malloc space failed\n"); return NULL; } int size = dimension * dimension; mat->row = dimension; mat_->column = dimension;
mat_->data = (MATRIX_TYPE*)malloc((size) * sizeof(MATRIX_TYPE)); memset(mat_->data, 0, sizeof(MATRIX_TYPE) * size); for(int i = 0;i<dimension;i++){ for(int j =0;j<dimension;j++){ if(i==j){ mat_->data[i*dimension+j] = data[i]; } } } return mat_;
}
Matrix Matrix_asDiagonal(MATRIX_TYPE data,int dimension) { Matrix mat_ = (Matrix)malloc(sizeof(Matrix)); if (mat == NULL) { printf("malloc space failed\n"); return NULL; } int size = dimension * dimension; mat->row = dimension; mat_->column = dimension;
}