[英]How to initialize multidimensional array using GMP lib
This is java code which is using BigInterger lib. 这是使用BigInterger库的Java代码。 I want to rewrite in C, I referred GMP Documentation but not able to find and logic can anyone help me?
我想用C重写,我参考了GMP文档,但找不到并且逻辑上有人可以帮助我吗?
BigInteger X[][] = new BigInteger[4][4];
Here is the basic approach to multi-dim arrays in gmp: 这是gmp中多维度数组的基本方法:
mpz_t **A;
size_t n;
A=malloc(n*sizeof(mpz_t*));
a[0]=malloc(n*n*sizeof(mpz_t));
for(int i=1;i<n;i++)
A[i]=A[i-1]+(n*sizeof(mpz_t));
Even better, embed it in a struct to carry round size info 更好的是,将其嵌入结构中以携带整数信息
struct GMPMatrix
{
unsigned int m_size;
mpz_t **m_data;
};
and write an initialization routine for the matrix. 并为矩阵编写初始化例程。
If you are simply looking for a robust matrix library have a look at: 如果您只是在寻找可靠的矩阵库,请查看:
https://cs.uwaterloo.ca/~astorjoh/iml.html https://cs.uwaterloo.ca/~astorjoh/iml.html
Uses gmp and atlas 使用gmp和地图集
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.