Pari/GP Reference Documentation |
Contents - Index - Meta commands |

Col List Mat Mod Pol Polrev Qfb Ser Set Str Strchr Strexpand Strtex Vec Vecsmall binary bitand bitneg bitnegimply bitor bittest bitxor ceil centerlift changevar component conj conjvec denominator floor frac imag length lift norm norml2 numerator numtoperm padicprec permtonum precision random real round simplify sizebyte sizedigit truncate valuation variable | |

Col({x = []}) | |

transforms the object x into a column vector. The vector will be with one component only, except when x is a vector or a quadratic form (in which case the resulting vector is simply the initial object considered as a column vector), a matrix (the column of row vectors comprising the matrix is returned), a character string (a column of individual characters is returned), but more importantly when x is a polynomial or a power series. In the case of a polynomial, the coefficients of the vector start with the leading coefficient of the polynomial, while for power series only the significant coefficients are taken into account, but this time by increasing order of degree. The library syntax is | |

List({x = []}) | |

transforms a (row or column) vector x
into a list. The only other way to create a This is useless in library mode. | |

Mat({x = []}) | |

transforms the object x into a matrix.
If x is already a matrix, a copy of x is created.
If x is not a vector or a matrix, this creates a 1 x 1 matrix.
If x is a row (resp. column) vector, this creates a 1-row (resp.
1-column) matrix,
The library syntax is | |

Mod(x,y,{flag = 0}) | |

creates the PARI object (x mod y), i.e.an intmod or a polmod. y must be an integer or a polynomial. If y is an integer, x must be an integer, a rational number, or a p-adic number compatible with the modulus y. If y is a polynomial, x must be a scalar (which is not a polmod), a polynomial, a rational function, or a power series. This function is not the same as x
The library syntax is | |

Pol(x,{v = x}) | |

transforms the object x into a polynomial with
main variable v. If x is a scalar, this gives a constant polynomial. If
x is a power series, the effect is identical to
The library syntax is | |

Polrev(x,{v = x}) | |

transform the object x into a polynomial
with main variable v. If x is a scalar, this gives a constant polynomial.
If x is a power series, the effect is identical to The library syntax is | |

Qfb(a,b,c,{D = 0.}) | |

creates the binary quadratic form ax^2+bxy+cy^2. If b^2-4ac > 0, initialize Shanks' distance function to D. Negative definite forms are not implemented, use their positive definite counterpart instead. The library syntax is
(when b^2-4ac > 0).qfr(a,b,c,d) | |

Ser(x,{v = x}) | |

transforms the object x into a power series
with main variable v (x by default). If x is a scalar, this gives a
constant power series with precision given by the default The warning given for The library syntax is | |

Set({x = []}) | |

converts x into a set, i.e.into a row
vector of character strings, with strictly increasing entries with respect to
lexicographic ordering. The components of x are put in canonical form (type
The library syntax is | |

Str({x}*) | |

converts its argument list into a
single character string (type
This function is mostly useless in library mode. Use the pair
| |

Strchr(x) | |

converts x to a string, translating each integer into a character.
| |

Strexpand({x}*) | |

converts its argument list into a
single character string (type
The individual arguments are read in string context, see Section [ | |

Strtex({x}*) | |

translates its arguments to TeX
format, and concatenates the results into a single character string (type
The individual arguments are read in string context, see Section [ | |

Vec({x = []}) | |

transforms the object x into a row vector. The vector will be with one component only, except when x is a vector or a quadratic form (in which case the resulting vector is simply the initial object considered as a row vector), a matrix (the vector of columns comprising the matrix is return), a character string (a vector of individual characters is returned), but more importantly when x is a polynomial or a power series. In the case of a polynomial, the coefficients of the vector start with the leading coefficient of the polynomial, while for power series only the significant coefficients are taken into account, but this time by increasing order of degree. The library syntax is | |

Vecsmall({x = []}) | |

transforms the object x into a row
vector of type The library syntax is | |

binary(x) | |

outputs the vector of the binary digits of |x|. Here x can be an integer, a real number (in which case the result has two components, one for the integer part, one for the fractional part) or a vector/matrix. The library syntax is | |

bitand(x,y) | |

bitwise Negative numbers behave 2-adically, i.e.the result is the 2-adic limit
of
The library syntax is | |

bitneg(x,{n = -1}) | |

bitwise negation of an integer x,
truncated to n bits, that is the integer sum_{i = 0}^{n-1} See Section [ The library syntax is | |

bitnegimply(x,y) | |

bitwise negated imply of two integers x and
y (or See Section [ The library syntax is | |

bitor(x,y) | |

bitwise (inclusive)
See Section [ The library syntax is | |

bittest(x,n) | |

outputs the n^{{th}} bit of x starting from the right (i.e.the coefficient of 2^n in the binary expansion of x). The result is 0 or 1. To extract several bits at once as a vector, pass a vector for n. See Section [ The library syntax is | |

bitxor(x,y) | |

bitwise (exclusive) See Section [ The library syntax is | |

ceil(x) | |

ceiling of x. When x is in The library syntax is | |

centerlift(x,{v}) | |

lifts an element x = a mod n of The library syntax is
centerlift0(x,-1). | |

changevar(x,y) | |

creates a copy of the object x where its
variables are modified according to the permutation specified by the vector
y. For example, assume that the variables have been introduced in the
order The library syntax is | |

components of a PARI object | |

There are essentially three ways to extract the components from a PARI object. The first and most general, is the function
component implies the knowledge of the structure of the different PARI
types, which can be recalled by typing
\t under
gp.The library syntax is The two other methods are more natural but more restricted. The function
reorder, see
Section [Label: se:reorder]). In particular if n is less than the valuation of
x or in the case of a polynomial, greater than the degree, the result is
zero (contrary to
compo which would send an error message). If x is
a power series and n is greater than the largest significant degree, then
an error message is issued.For greater flexibility, vector or matrix types are also accepted for x,
and the meaning is then identical with that of Finally note that a scalar type is considered by The library syntax is The third method is specific to vectors or matrices in GP. If x is a
(row or column) vector, then Finally note that in library mode, the macros | |

conj(x) | |

conjugate of x. The meaning of this
is clear, except that for real quadratic numbers, it means conjugation in the
real quadratic field. This function has no effect on integers, reals,
intmods, fractions or p-adics. The only forbidden type is polmod
(see The library syntax is | |

conjvec(x) | |

conjugate vector representation of x. If x is a
polmod, equal to The library syntax is | |

denominator(x) | |

denominator of x. The meaning of this is clear when x is a rational number or function. If x is an integer or a polynomial, it is treated as a rational number of function, respectively, and the result is equal to 1. For polynomials, you probably want to use
instead. As for modular objects, If x is a recursive structure, for instance a vector or matrix, the lcm
of the denominators of its components (a common denominator) is computed.
This also applies for
The library syntax is | |

floor(x) | |

floor of x. When x is in The library syntax is | |

frac(x) | |

fractional part of x. Identical to x-{floor}(x). If x is real, the result is in [0,1[. The library syntax is | |

imag(x) | |

imaginary part of x. When x is a quadratic number, this is the coefficient of omega in the "canonical" integral basis (1,omega). The library syntax is | |

length(x) | |

number of non-code words in x really used
(i.e.the effective length minus 2 for integers and polynomials). In
particular, the degree of a polynomial is equal to its length minus 1. If x
has type The library syntax is | |

lift(x,{v}) | |

lifts an element x = a mod n of
The library syntax is
lift0(x,-1). | |

norm(x) | |

algebraic norm of x, i.e.the product of x with
its conjugate (no square roots are taken), or conjugates for polmods. For
vectors and matrices, the norm is taken componentwise and hence is not the
L^2-norm (see The library syntax is | |

norml2(x) | |

square of the L^2-norm of x. More precisely,
if x is a scalar,
The library syntax is | |

numerator(x) | |

numerator of x. The meaning of this is clear when x is a rational number or function. If x is an integer or a polynomial, it is treated as a rational number of function, respectively, and the result is x itself. For polynomials, you probably want to use
instead. In other cases,
The library syntax is | |

numtoperm(n,k) | |

generates the k-th permutation (as a
row vector of length n) of the numbers 1 to n. The number k is taken
modulo n!, i.e.inverse function of The library syntax is | |

padicprec(x,p) | |

absolute p-adic precision of the object x.
This is the minimum precision of the components of x. The result is
The library syntax is | |

permtonum(x) | |

given a permutation x on n elements,
gives the number k such that x = The library syntax is | |

precision(x,{n}) | |

gives the precision in decimal digits of the PARI object x. If x is an exact object, the largest single precision integer is returned. If n is not omitted, creates a new object equal to x with a new precision n. This is to be understood as follows: For exact types, no change. For x a vector or a matrix, the operation is done componentwise. For real x, n is the number of desired significant For x a p-adic or a power series, n is the desired number of significant p-adic or X-adic digits, where X is the main variable of x. Note that the function The library syntax is
GEN) and
, where
n is a gprec(x,n)
long. | |

random({N = 2^{31}}) | |

returns a random integer between 0 and N-1. N is an integer, which can be arbitrary large. This is an internal PARI function and does not depend on the system's random number generator. The resulting integer is obtained by means of linear congruences and will not
be well distributed in arithmetic progressions. The random seed may be
obtained via Note that The library syntax is | |

real(x) | |

real part of x. In the case where x is a quadratic number, this is the coefficient of 1 in the "canonical" integral basis (1,omega). The library syntax is | |

round(x,{&e}) | |

If x is in
The library syntax is | |

simplify(x) | |

this function simplifies x as much as it can.
Specifically, a complex or quadratic number whose imaginary part is an exact
0 (i.e.not an approximate one as a This function is especially useful before using arithmetic functions, which expect integer arguments:
Note that GP results are simplified as above before they are stored in the
history. (Unless you disable automatic simplification with
The library syntax is | |

sizebyte(x) | |

outputs the total number of bytes occupied by the tree representing the PARI object x. The library syntax is words instead. | |

sizedigit(x) | |

outputs a quick bound for the number of decimal
digits of (the components of) x, off by at most 1. If you want the
exact value, you can use The library syntax is | |

truncate(x,{&e}) | |

truncates x and sets e to the number of
error bits. When x is in Note a very special use of The library syntax is | |

valuation(x,p) | |

computes the highest exponent of p dividing x. If p is of type integer, x must be an integer, an intmod whose modulus is divisible by p, a fraction, a q-adic number with q = p, or a polynomial or power series in which case the valuation is the minimum of the valuation of the coefficients. If p is of type polynomial, x must be of type polynomial or rational function, and also a power series if x is a monomial. Finally, the valuation of a vector, complex or quadratic number is the minimum of the component valuations. If x = 0, the result is The library syntax is | |

variable(x) | |

gives the main variable of the object x, and
p if x is a p-adic number. Gives an error if x has no variable
associated to it. Note that this function is useful only in GP, since in
library mode the function The library syntax is number of x if it exists,
BIGINT otherwise. | |