GMP Library Issue

M

mukesh tiwari

I don't where to post this so kindly forgive me for posting on this
forum. I have create a mpz_t array and i want to sort this. Using c++
sort function generates lot of errors and i searched on net but did
not get anything useful. Kindly tell me how to sort the array.
#include<cstdio>
#include<iostream>
#include<gmp.h>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
mpz_t ret_1;
int v[42];
mpz_t v_l[2097160],v_r[2097160];
void _prime()
{
bool p[190];
memset(p,0,sizeof p);
for(int i=2;i*i<190;i++)
if(!p) for(int j=i*i;j<190;j+=i) p[j]=1;
int cnt=0;
for(int i=2;i<190;i++) if(!p)cout<<i<<" ",v[cnt++]=i;
cout<<endl<<cnt<<endl;
mpz_add_ui(ret_1,ret_1,1);//ret_1=1;
for(int i=0;i<cnt;i++) mpz_mul_ui(ret_1,ret_1,v);
gmp_printf("%Zd\n",ret_1);
}
int main()
{
_prime();
//i have generated prime
mpz_t t_1,t_2;
int cnt=0;
for(int i=0;i<(1<<21);i++)
{
mpz_init(t_1),mpz_init(t_2);
mpz_add_ui(t_1,t_1,1),mpz_add_ui(t_2,t_2,1);
for(int j=0;j<21;j++)
if(i&(1<<j))mpz_mul_ui(t_1,t_1,v[j]),mpz_mul_ui(t_2,t_2,v[j+21]);
mpz_set(v_l[cnt],t_1);
mpz_set(v_r[cnt],t_2);
cnt++;
}
printf("%d\n",cnt);
for(int i=100000;i<100010;i++) gmp_printf("%Zd %Zd
\n",v_l,v_r);
//sort(v_l,v_l+cnt);//creates error

}
 
B

Ben Bacarisse

Rui Maciel said:
mukesh said:
I don't where to post this so kindly forgive me for posting on this
forum.

Have you tried GMP's mailing list[1]?

That might work but the problem is a C++ one.

To the OP: why did you pick comp.lang.c? Post in comp.lang.c++ and
they'll explain what sort needs as a third argument.

There is a related GMP issue in that mpz_t is an array type, but the
solution is again a C++ one: use GMP's C++ interface!

<snip>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top