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

algdep charpoly concat lindep listcreate listinsert listkill listput listsort matadjoint matcompanion matdet matdetint matdiagonal mateigen matfrobenius mathess mathilbert mathnf mathnfmod mathnfmodid matid matimage matimagecompl matindexrank matintersect matinverseimage matisdiagonal matker matkerint matmuldiagonal matmultodiagonal matpascal matrank matrix matrixqz matsize matsnf matsolve matsolvemod matsupplement mattranspose minpoly qfgaussred qfjacobi qflll qflllgram qfminim qfperfection qfrep qfsign setintersect setisset setminus setsearch setunion trace vecextract vecsort vector vectorsmall vectorv | |

algdep(x,k,{flag = 0}) | |

x being real/complex, or p-adic, finds a polynomial of
degree at most k with integer coefficients having x as approximate root.
Note that the polynomial which is obtained is not necessarily the "correct"
one. In fact it is not even guaranteed to be irreducible. One can check the
closeness either by a polynomial evaluation (use Internally,
Proceeding by increments of 5 digits of accuracy, The above example is the testcase studied in a 2000 paper by Borwein and
Lisonek, Applications of integer relation algorithms, The library syntax is flag = 0). | |

charpoly(A,{v = x},{flag = 0}) | |

characteristic polynomial
of A with respect to the variable v, i.e.determinant of v*I-A if A
is a square matrix. If A is not a square matrix, it returns the characteristic polynomial of the map "multiplication by A" if A
is a scalar, in particular a polmod. E.g. The value of If If If The library syntax is flag = 1),
(carhess(A,v)flag = 2), and
where, in this last case,
caradj(A,v,pt)pt is a
GEN* which, if not equal to
NULL, will receive
the address of the adjoint matrix of A (see
matadjoint), so both
can be obtained at once. | |

concat(x,{y}) | |

concatenation of x and y. If x or y is not a vector or matrix, it is considered as a one-dimensional vector. All types are allowed for x and y, but the sizes must be compatible. Note that matrices are concatenated horizontally, i.e.the number of rows stays the same. Using transpositions, it is easy to concatenate them vertically. To concatenate vectors sideways (i.e.to obtain a two-row or two-column
matrix), use The empty matrix If y is omitted, x has to be a row vector or a list, in which case its elements are concatenated, from left to right, using the above rules.
The library syntax is | |

lindep(x,{flag = 0}) | |

x being a vector with p-adic or real/complex coefficients, finds a small integral linear combination among these coefficients. If x is p-adic, Otherwise, the value of If If If If If The library syntax is flag = 0). | |

listcreate(n) | |

creates an empty list of maximal length n. This function is useless in library mode. | |

listinsert(list,x,n) | |

inserts the object x at
position n in This function is useless in library mode. | |

listkill(list) | |

kill This function is useless in library mode. | |

listput(list,x,{n}) | |

sets the n-th element of the list
If you want to put an element into an occupied cell, i.e.if you don't want to
change the effective length, you can consider the list as a vector and use
the usual This function is useless in library mode. | |

listsort(list,{flag = 0}) | |

sorts This function is useless in library mode. | |

matadjoint(x) | |

adjoint matrix of x, i.e.the matrix y of cofactors of x, satisfying x*y = det(x)*\Id. x must be a (non-necessarily invertible) square matrix. The library syntax is | |

matcompanion(x) | |

the left companion matrix to the polynomial x. The library syntax is | |

matdet(x,{flag = 0}) | |

determinant of x. x must be a square matrix. If If The library syntax is flag = 1). | |

matdetint(x) | |

x being an m x n matrix with integer
coefficients, this function computes a Note that as soon as one of the dimensions gets large (m or n is larger
than 20, say), it will often be much faster to use The library syntax is | |

matdiagonal(x) | |

x being a vector, creates the diagonal matrix whose diagonal entries are those of x. The library syntax is | |

mateigen(x) | |

gives the eigenvectors of x as columns of a matrix. The library syntax is | |

matfrobenius(M,{flag = 0},{v = x}) | |

returns the Frobenius form of
the square matrix The library syntax is | |

mathess(x) | |

Hessenberg form of the square matrix x. The library syntax is | |

mathilbert(x) | |

x being a The library syntax is | |

mathnf(x,{flag = 0}) | |

if x is a (not necessarily square)
matrix with integer entries, finds the If If If If The library syntax is flag = 0) and
(hnfall(x)flag = 1). To reduce huge (say 400 x 400 and
more) relation matrices (sparse with small entries), you can use the pair
hnfspec /
hnfadd. Since this is rather technical and the
calling interface may change, they are not documented yet. Look at the code
in
basemath/alglin1.c. | |

mathnfmod(x,d) | |

if x is a (not necessarily square) matrix of
maximal rank with integer entries, and d is a multiple of the (non-zero)
determinant of the lattice spanned by the columns of x, finds the
If the rank of x is equal to its number of rows, the result is a square
matrix. In general, the columns of the result form a basis of the lattice
spanned by the columns of x. This is much faster than The library syntax is | |

mathnfmodid(x,d) | |

outputs the (upper triangular) Hermite normal form of x concatenated with d times the identity matrix. Assumes that x has integer entries. The library syntax is | |

matid(n) | |

creates the n x n identity matrix. The library syntax is Related functions are
GEN and n a
long), and
which is the same when x is a gscalsmat(x,n)
long. | |

matimage(x,{flag = 0}) | |

gives a basis for the image of the
matrix x as columns of a matrix. A priori the matrix can have entries of
any type. If The library syntax is flag = 0). | |

matimagecompl(x) | |

gives the vector of the column indices which
are not extracted by the function The library syntax is | |

matindexrank(x) | |

x being a matrix of rank r, gives two
vectors y and z of length r giving a list of rows and columns
respectively (starting from 1) such that the extracted matrix obtained from
these two vectors using The library syntax is | |

matintersect(x,y) | |

x and y being two matrices with the same
number of rows each of whose columns are independent, finds a basis of the
The library syntax is | |

matinverseimage(M,y) | |

gives a column vector belonging to the
inverse image z of the column vector or matrix y by the matrix M if one
exists (i.e such that Mz = y), the empty vector otherwise. To get the
complete inverse image, it suffices to add to the result any element of the
kernel of x obtained for example by The library syntax is | |

matisdiagonal(x) | |

returns true (1) if x is a diagonal matrix, false (0) if not. The library syntax is | |

matker(x,{flag = 0}) | |

gives a basis for the kernel of the matrix x as columns of a matrix. A priori the matrix can have entries of any type. If x is known to have integral entries, set
The library syntax is flag = 0),
(keri(x)flag = 1). | |

matkerint(x,{flag = 0}) | |

gives an LLL-reduced If If The library syntax is flag = 0). | |

matmuldiagonal(x,d) | |

product of the matrix x by the diagonal
matrix whose diagonal entries are those of the vector d. Equivalent to,
but much faster than x* The library syntax is | |

matmultodiagonal(x,y) | |

product of the matrices x and y assuming that the result is a diagonal matrix. Much faster than x*y in that case. The result is undefined if x*y is not diagonal. The library syntax is | |

matpascal(x,{q}) | |

creates as a matrix the lower triangular Pascal triangle of order x+1 (i.e.with binomial coefficients up to x). If q is given, compute the q-Pascal triangle (i.e.using q-binomial coefficients). The library syntax is | |

matrank(x) | |

rank of the matrix x. The library syntax is | |

matrix(m,n,{X},{Y},{expr = 0}) | |

creation of the
m x n matrix whose coefficients are given by the expression
The library syntax is | |

matrixqz(x,p) | |

x being an m x n matrix with m If p If p = -1, this function returns a matrix whose columns form a basis of the
lattice equal to If p = -2, returns a matrix whose columns form a basis of the lattice equal
to The library syntax is | |

matsize(x) | |

x being a vector or matrix, returns a row vector with two components, the first being the number of rows (1 for a row vector), the second the number of columns (1 for a column vector). The library syntax is | |

matsnf(X,{flag = 0}) | |

if X is a (singular or non-singular) matrix outputs the vector of elementary divisors of X (i.e.the diagonal of the Smith normal form of X). The binary digits of 1 (complete output): if set, outputs [U,V,D], where U and V are two unimodular matrices such that UXV is the diagonal matrix D. Otherwise output only the diagonal of D. 2 (generic input): if set, allows polynomial entries, in which case the input matrix must be square. Otherwise, assume that X has integer coefficients with arbitrary shape. 4 (cleanup): if set, cleans up the output. This means that elementary divisors equal to 1 will be deleted, i.e.outputs a shortened vector D' instead of D. If complete output was required, returns [U',V',D'] so that U'XV' = D' holds. If this flag is set, X is allowed to be of the form D or [U,V,D] as would normally be output with the cleanup flag unset. The library syntax is flag = 0). | |

matsolve(x,y) | |

x being an invertible matrix and y a column vector, finds the solution u of x*u = y, using Gaussian elimination. This has the same effect as, but is a bit faster, than x^{-1}*y. The library syntax is | |

matsolvemod(m,d,y,{flag = 0}) | |

m being any integral matrix, d a vector of positive integer moduli, and y an integral column vector, gives a small integer solution to the system of congruences sum_i m_{i,j}x_j = y_i (mod d_i) if one exists, otherwise returns zero. Shorthand notation: y (resp.d) can be given as a single integer, in which case all the y_i (resp.d_i) above are taken to be equal to y (resp.d).
If The library syntax is flag = 0)
and
(gaussmodulo2(m,d,y)flag = 1). | |

matsupplement(x) | |

assuming that the columns of the matrix x are linearly independent (if they are not, an error message is issued), finds a square invertible matrix whose first columns are the columns of x, i.e.supplement the columns of x to a basis of the whole space. The library syntax is | |

mattranspose(x) | |

or x~: transpose of x. This has an effect only on vectors and matrices. The library syntax is | |

minpoly(A,{v = x},{flag = 0}) | |

minimal polynomial of A with respect to the variable v., i.e. the monic polynomial P of minimal degree (in the variable v) such that P(A) = 0. The library syntax is | |

qfgaussred(q) | |

decomposition into squares of the quadratic form represented by the symmetric matrix q. The result is a matrix whose diagonal entries are the coefficients of the squares, and the non-diagonal entries represent the bilinear forms. More precisely, if (a_{ij}) denotes the output, one has q(x) = sum_i a_{ii} (x_i + sum_{j > i} a_{ij} x_j)^2 The library syntax is | |

qfjacobi(x) | |

x being a real symmetric matrix, this gives a vector having two components: the first one is the vector of eigenvalues of x, the second is the corresponding orthogonal matrix of eigenvectors of x. The method used is Jacobi's method for symmetric matrices. The library syntax is | |

qflll(x,{flag = 0}) | |

LLL algorithm applied to the
If If If This is significantly faster than If If If The library syntax is flag = 0),
(lllint(x)flag = 1), and
(lllkerim(x)flag = 4). | |

qflllgram(G,{flag = 0}) | |

same as If If
The library syntax is flag = 0),
(lllgramint(G)flag = 1), and
(lllgramkerim(G)flag = 4). | |

qfminim(x,{b},{m},{flag = 0}) | |

x being a square and symmetric
matrix representing a positive definite quadratic form, this function
deals with the vectors of x whose norm is less than or equal to b,
enumerated using the Fincke-Pohst algorithm. The function searches for
the minimal non-zero vectors if b is omitted. The precise behaviour
depends on If If In both these cases, x is assumed to have integral entries. The implementation uses low precision floating point computations for maximal speed, which gives incorrect result when x has large entries. (The condition is checked in the code and the routine will raise an error if large rounding errors occur.) A more robust, but much slower, implementation is chosen if the following flag is used: If The library syntax is flag = 0),
(minim2(x,b,m)flag = 1). In all cases, an omitted b
or m is coded as
NULL. | |

qfperfection(x) | |

x being a square and symmetric matrix with
integer entries representing a positive definite quadratic form, outputs the
perfection rank of the form. That is, gives the rank of the family of the s
symmetric matrices v_iv_i^t, where s is half the number of minimal
vectors and the v_i (1 As a side note to old-timers, this used to fail bluntly when x had more than 5000 minimal vectors. Beware that the computations can now be very lengthy when x has many minimal vectors. The library syntax is | |

qfrep(q, B, {flag = 0}) | |

q being a square and symmetric
matrix with integer entries representing a positive definite quadratic form,
outputs the vector whose i-th entry, 1 The binary digits of
The library syntax is | |

qfsign(x) | |

signature of the quadratic form represented by the symmetric matrix x. The result is a two-component vector. The library syntax is | |

setintersect(x,y) | |

intersection of the two sets x and y. The library syntax is | |

setisset(x) | |

returns true (1) if x is a set, false (0) if
not. In PARI, a set is simply a row vector whose entries are strictly
increasing. To convert any vector (and other objects) into a set, use the
function The library syntax is | |

setminus(x,y) | |

difference of the two sets x and y, i.e.set of elements of x which do not belong to y. The library syntax is | |

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

searches if y belongs to the set
x. If it does and This function works also if x is a The library syntax is | |

setunion(x,y) | |

union of the two sets x and y. The library syntax is | |

trace(x) | |

this applies to quite general x. If x is not a matrix, it is equal to the sum of x and its conjugate, except for polmods where it is the trace as an algebraic number. For x a square matrix, it is the ordinary trace. If x is a non-square matrix (but not a vector), an error occurs. The library syntax is | |

vecextract(x,y,{z}) | |

extraction of components of the
vector or matrix x according to y. In case x is a matrix, its
components are as usual the If y is an integer, it is considered as a mask: the binary bits of y are read from right to left, but correspond to taking the components from left to right. For example, if y = 13 = (1101)_2 then the components 1,3 and 4 are extracted. If y is a vector, which must have integer entries, these entries correspond to the component numbers to be extracted, in the order specified. If y is a string, it can be
In addition, if the first character in the string is If z is not omitted, x must be a matrix. y is then the
The library syntax is | |

vecsort(x,{k},{flag = 0}) | |

sorts the vector x in ascending order, using a mergesort method. x must be a vector, and its components integers, reals, or fractions. If k is present and is an integer, sorts according to the value of the k-th subcomponents of the components ofx. Note that mergesort is stable, hence is the initial ordering of "equal" entries (with respect to the sorting criterion) is not changed. k can also be a vector, in which case the sorting is done lexicographically according to the components listed in the vector k. For example, if k = [2,1,3], sorting will be done with respect to the second component, and when these are equal, with respect to the first, and when these are equal, with respect to the third. The binary digits of
The library syntax is
).vecsort0(x,
NULL,0)
).vecsort0(x,
NULL,1)
).vecsort0(x,
NULL,2)Also available are
which
return a sindexlexsort(x)
t_VECSMALL v, where v[1]...v[n] contain the indices. | |

vector(n,{X},{expr = 0}) | |

creates a row vector (type
Avoid modifying X within
as the following example shows:
The library syntax is | |

vectorsmall(n,{X},{expr = 0}) | |

creates a row vector of small integers (type
The library syntax is | |

vectorv(n,X,expr) | |

as The library syntax is | |