Questions tagged [pari]

a C library targeted at number theorists and mathematicians allowing fast number-theoretic computations (factorizations, algebraic number theory, elliptic curves...), also including routines for computing with matrices, polynomials, power series, algebraic numbers etc.

This tag is for the C-library PARI. See for the scripting language GP and associated computer algebra system PARI/GP. Questions with this tag should generally also have the tag.

118 questions
0
votes
1 answer

Fraction Value Problem in Ctypes to PARI/GP

I have written a code to compare the solution of sympy and PARI/GP, but when I give a fraction value D=13/12, I get error, TypeError: int expected instead of float. So I changed p1[i] = pari.stoi(c_long(numbers[i - 1])) to p1[i] =…
0
votes
1 answer

Getting an Array/Vector from PARI/GP in Python using Ctypes

I have written a code to compare the solution of sympy and PARI/GP, how ever I am facing a problem to get an array/vector from PARI/GP. When I try to return the vector res from PARI/GP function nfroots, I get a address like this (see the last line)…
0
votes
1 answer

How to use Cypari package in python?

I searched instruction documents or manuals on cypari but couldn't found, I found the below code only - import cypari print(cypari.pari('factor({})'.format(2**127-2))) So, I don't know how to use it.
0
votes
1 answer

Removing items from a vector in a loop - PARI/GP

I am looking at vectors [a,b,c], for a,b,c in [-1,0,1] along with a function, cycle, which shifts each entry of a vector one to the left: cycle( v ) = [v[3], v[1], v[2]]. I want to only consider vectors such that no two vectors are…
Mystery_Jay
  • 161
  • 5
0
votes
1 answer

Calling an external function from pari/gp

Is it possible to call the primesieve (Kim Walisch tool), from the pari/gp and pass the value in a variable in pari/gp? I would like to replace the primePi () function with this (as external function, maybe with system("f") command), because the…
0
votes
1 answer

bitcount in PARI/GP

Is there a method to get the position of the most significant bit, that is floor(log(x)/log(2)) + 1? Currently I'm running the following abomination: bitcount(a)={ my(l2, ap, l2ap); if(a == 0, return(0); ); \\ TODO: set upper…
deamentiaemundi
  • 5,502
  • 2
  • 12
  • 20
0
votes
0 answers

Matrix powering in PARI/GP

Which algorithm is used for matrix powering in PARI/GP and what is its computational complexity? Is it repeated squaring algorithm (binary powering) or something else? I cannot find these informations on the internet. SOLVED According to Bill…
Pedja
  • 373
  • 4
  • 14
0
votes
1 answer

In PARI/GP in function FACTOR the -1 is a bug or means somthing else?

First run the function b(n): ? b(n) = lcm(vector(n, i, i))/n After function c(n): ? c(n)=sum(j=1,n,sum(i=1,n,(-1)^(i+j)/(i+j-1))) Last run d(n): ? d(n)=factor(denominator(c(n))/b(n))~ and test with 202 ? d(202) The result is: %8 = [3 7 17 19 31…
0
votes
1 answer

Can you get a list of the powers in a polynomial? Pari GP

I'm working with single variable polynomials with coefficients +1/-1 (and zero). These can be very long and the range of powers can be quite big. It would be convenient for me to view the powers as a vector - is there any way of doing this quickly?…
Mystery_Jay
  • 161
  • 5
0
votes
2 answers

Returning the factors of a polynomial as a vector in Pari/GP

When using factor, Pari prints the factors of a polynomial and their multiplicities. When using, say, polcyclofactors, however, the cyclotomic factors of the polynomial are listed as a vector, without multiplicity. Is there are way to mimic…
Mystery_Jay
  • 161
  • 5
0
votes
1 answer

Writing a code for a path graph in Pari/GP

I am trying to write a matrix for the adjacency matrix of the path graph on n vertices in Pari. For sake of clarity, when I say the graph P_n, I mean the graph with n vertices and n-1 edges. So far, I have managed to do this for specific…
Mystery_Jay
  • 161
  • 5
0
votes
1 answer

Nested for loops in Pari/GP

Is there a way to nest for loops inside other for loops in Pari/GP (2.7.6) since the following error always appears: *** at top-level: read("prog.txt") *** ^---------------- *** read: sorry, embedded braces (in parser) is not…
J. Linne
  • 275
  • 4
  • 15
0
votes
1 answer

Linear sieving algorithm

Is there a simple pari/gp program which can sieve numbers of the form k*n+c (where n and c fixed) up to a certain prime p and k is restricted within a certain range (a.k.a. for(k=1,10000,)? Pseudocode: n = (some number); c = (some number); T=[all k…
T. Rex
  • 125
  • 5
0
votes
2 answers

How to get the power series G(z^2) from G(z)

I think it's an easy question, but I can't find how to do it correctly. substpol works almost as I need, but doubles the polynomial degree. For example, with : G(z)=1+2*z+3*z^2+O(z^5) I got: substpol(1+2*z^2+3*z^3 + O(z^5),z,z^2) %20 = 1 + 2*z^4…
Damien
  • 300
  • 1
  • 8
0
votes
1 answer

Removing Cyclotomic Factors from a Polynomial - Pari

I want to take some polynomial f and remove all of it's cyclotomic factors, and then look at the resulting polynomial (say g). I'm aware of polcyclofactors and the current code I have tried…
Mystery_Jay
  • 161
  • 5