我正在尝试在 gmp 中定义矩阵,但收到错误报告。 这是我的程序的稍微简化的版本:
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include <gmp.h>
mpz_t matrix[2][2];
mpz_init(matrix[0][0]), mpz_init(matrix[0][1]);
mpz_init(matrix[1][0]), mpz_init(matrix[1][1]);
mpz_set(matrix[0][0],1), mpz_set(matrix[0][1],2);
mpz_set(matrix[1][0],3), mpz_set(matrix[1][1],5);
然后是我的其他程序等,但它们的错误函数是这样的:
matdet.c:8:16: error: expected ‘)’ before ‘[’ token
所以我的问题是,如何在 gmp 中定义矩阵, 任何帮助都会很棒!
最佳答案
您应该将这些函数调用放入您的 main 方法中。在 C 中,不可能在方法之外进行方法调用。
关于c - GMP 库中的矩阵(C 语言),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15717881/