#include <pari/pari.h>
#include <pthread.h>
void *
mydet(void *arg)
{
GEN F, M;
M = pari_thread_start((struct pari_thread*) arg);
F = det(M);
pari_thread_close();
return (void*)F;
}
void *
myfactor(void *arg)
{
GEN F, N;
N = pari_thread_start((struct pari_thread*) arg);
F = factor(N);
pari_thread_close();
return (void*)F;
}
int
main(void)
{
GEN M,N1,N2, F1,F2,D;
pthread_t th1, th2, th3;
struct pari_thread pth1, pth2, pth3;
pari_init(4000000,500000);
N1 = addis(int2n(256), 1);
N2 = subis(int2n(193), 1);
M = mathilbert(80);
pari_thread_sync();
pari_thread_alloc(&pth1,4000000,N1);
pari_thread_alloc(&pth2,4000000,N2);
pari_thread_alloc(&pth3,4000000,M);
pthread_create(&th1,NULL, &myfactor, (void*)&pth1);
pthread_create(&th2,NULL, &myfactor, (void*)&pth2);
pthread_create(&th3,NULL, &mydet, (void*)&pth3);
pthread_join(th1,(void*)&F1);
pthread_join(th2,(void*)&F2);
pthread_join(th3,(void*)&D);
pari_printf("F1=%Ps\nF2=%Ps\nlog(D)=%Ps\n", F1, F2, glog(D,3));
pari_thread_free(&pth1);
pari_thread_free(&pth2);
pari_thread_free(&pth3);
return 0;
}