Standard monadic or dyadic operators.

± + x and - x refer to monadic operators (+ x does nothing and - x negates x).

The library syntax is $\teb$gneg(x) for - x.

+, - x + y and x - y are the [*] and [*] of x and y. Among the prominent impossibilities are addition/subtraction between a scalar type and a vector or a matrix, between vector/matrices of incompatible sizes and between an integermod and a real number.

The library syntax is $\teb$gadd(x, y) for x + y, $\teb$gsub(x, y) for x - y.

* x*y is the [*] of x and y. Among the prominent impossibilities are multiplication between vector/matrices of incompatible sizes, between an integermod and a real number. Note that because of vector and matrix operations, * is not necessarily commutative. Note also that since multiplication between two column or two row vectors is not allowed, to obtain the [*] of two vectors of the same length, you must multiply a line vector by a column vector, if necessary by transposing one of the vectors (using ˜ or trans( ), see 3.7.30).

The library syntax is $\teb$gmul(x, y) for x*y.

/ x/y is the [*] of x and y. In addition to the impossibilities for multiplication, note that if the divisor is a matrix, it must be an invertible square matrix, and in that case the result is x*y-1. Furthermore note that the result is as exact as possible: in particular, division of two integers always gives a rational number (which may be an integer if the quotient is exact) and not the euclidean quotient (see x\y for that), and similarly the quotient of two polynomials is a rational function in general. To obtain the approximate real value of the quotient of two integers, add 0. to the result; to obtain the approximate p-adic value of the quotient of two integers, add O(pk) to the result; finally, to obtain the [*] expansion of the quotient of two polynomials, add O(X$\hat{{\ }}$k) to the result or use the taylor function (3.6.33).

The library syntax is $\teb$gdiv(x, y) for x/y.

\ x\y is the [*] of x and y. The types must be either both integer or both polynomials. The result is the euclidean quotient. In the case of integer division, the quotient is such that the corresponding remainder is nonnegative.

The library syntax is $\teb$gdivent(x, y) for x\y.

% x%y is the [*] of x and y. The modulus y must be of type integer or polynomial. The result is the remainder, always nonnegative in the case of integers. Allowed dividend types are scalar exact types when the modulus is an integer, and polynomials, polymods and rational functions when the modulus is a polynomial.

The library syntax is $\teb$gmod(x, y) for x%y.

[*](x, y) creates a vector with two components, the first being the euclidean quotient, the second the euclidean remainder, of the division of x by y. This avoids the need to do two divisions if one needs both the quotient and the remainder. The arguments must be both integers or both polynomials, and in the case of integers the remainder is always nonnegative.

The library syntax is $\teb$gdiventres(x, y).

$\hat{{\ }}$ x$\hat{{\ }}$y is [*]. If the exponent is an integer, then exact operations are performed using binary powering techniques. In particular, in this case the first argument cannot be a vector or matrix unless it is a square matrix (and moreover invertible if the exponent is negative). If the exponent is not of type integer, this is treated as a transcendental function (see 3.3.1.), and in particular has the effect of componentwise powering on vector or matrices.

The library syntax is $\teb$gpui(x, y) for x$\hat{{\ }}$y.

comparison and [*]. The six standard [*] < =, <, > =, >, = =, ! = are available in GP, and in library mode under the names [*], [*], [*], [*], [*], [*] respectively. The library syntax is $\bf co$(x, y), where co is the comparison operator. The result is 1 if the comparison is true, 0 if it is false.

The standard boolean functions | | ([*]) and && ([*]) orare also available, and the library syntax is $\teb$gor(x, y) and $\teb$gand(x, y) respectively. Note that to avoid confusion with the factorial function, there is no ! ([*]) operator, but this can easily be circumvented.

In library mode, it is in fact usually preferable to use the two basic functions which are $\teb$gcmp(x, y) which gives the sign (1, 0, or -1) of x - y, where x and y must be in $\Bbb$R, and $\teb$gegal(x, y) which can be applied to any two PARI objects x and y and gives 1 (i.e. true) if they are equal (but not necessarily identical), 0 (i.e. false) otherwise. Particular cases of gegal which should be used are $\teb$gcmp0(x) (x = 0 ?), $\teb$gcmp1(x) (x = 1 ?), and gcmp\_1 gcmp_1 (x) (x = - 1 ?).

Note that $\teb$gcmp0(x) tests whether x is equal to zero, even if x is not an exact object. To test whether x is an exact object which is equal to zero, one must use $\teb$isexactzero.

GP accepts the following synonyms for some of the above functions: since there is no bitwise and or bitwise or, | and & are accepted asbitwise and bitwise or synonyms of | | and && respectively. Also, < > is accepted as a synonym for ! =. On the other hand, = is definitely not a synomym for = = since it is the assignment statement.

sign(x): [*] of x, which must be of type integer, real or fraction. The result (0, 1 or -1) is a C-integer.

The library syntax is $\teb$gsigne(x).

[*](x, y) and [*](x, y) create the maximum and minimum of x and y when they can be compared.

The library syntax is $\teb$gmax(x, y) and $\teb$gmin(x, y).

Important remark. In all the above library syntaxes, we have given only the basic names of the functions. For example $\tt gadd$(x, y) assumes that x and y are PARI objects (the GEN type) and creates the result x + y on the PARI stack. From most of these basic names, the names and effects of other functions can be obtained in the following way. We give the example for gadd, but the same is true for all the other functions above, and a few more that we have not given:

$\teb$gaddgs(x, y): here x is a GEN, y is an ordinary 32-bit integer.

$\teb$gaddsg(x, y): here x is an ordinary 32-bit integer, y is a GEN.

$\teb$gaddz(x, y, z), $\teb$gaddgsz(x, y, z), $\teb$gaddsgz(x, y, z): here z is a preexisting GEN and the result of the corresponding operation is put in z. The size of the PARI stack does not change.

As simplification to programming, for many functions beginning with a g, such as gadd, one can replace the g by an l to obtain a long result instead of a GEN (i.e. pointer to long) result. For instance $\teb$ladd(x, y) is identical with ($\tt (long)gadd$(x, y)). These macros are written in the files listed in [*].