GMP Library Issue



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[i]) for(int j=i*i;j<190;j+=i) p[j]=1;
int cnt=0;
for(int i=2;i<190;i++) if(!p[i])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[i]);
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[i],v_r[i]);
//sort(v_l,v_l+cnt);//creates error

}
.



Relevant Pages

  • A Fast sorting algorithm for almost sorted data
    ... which I am currently calling Run sort. ... entire selected run can be added to the sorted output array. ... public class RunSort implements Comparator ... public static void sort(Comparable a, int start,int end) ...
    (comp.compression)
  • Re: resize JTable
    ... >able to easily sort the data, from a user point of view. ... public static final int DESCENDING = -1; ... private Comparator comparator; ... * @param model OrderedTableModel to be kept deduped/sorted. ...
    (comp.lang.java.programmer)
  • Re: qsort returning index
    ... However if you have salaries in a parallel array, ... just to do the sort. ... int *qsortindex(void *buf, int N, int size, int (*compfunc)(const void ...
    (comp.lang.c)
  • Re: problem with array
    ... > different sort algorythms. ... > the sort the array elements are compared and swapped. ... void selectionsort(void *base, size_t n, size_t size, ... void PrintArrays(int *a, int **pa,size_t n); ...
    (comp.lang.c)
  • Re: max size of ptr array
    ... The problem is that I get a stack overflow error when I do a quick sort ... you'll get a compiler error. ... int main{ ... And since an int requires 4 "bytes" plus the fact that your array is ...
    (microsoft.public.vc.language)