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

* +/- + / <,<,>=,>,==,!=,||,&&,!,|,&,<> \/ \ ^ bittest divrem lex max shift shiftmul sign vecmax vecmin | |

+/- | |

The expressions The library syntax is | |

+ | |

, The library syntax is
- y. | |

* | |

The expression x If x and y are binary quadratic forms, compose them. See also
The library syntax is
* x (faster of course!). | |

/ | |

The expression x The library syntax is | |

\ | |

The expression Note that when y is an integer and x a polynomial, y is first promoted to a polynomial of degree 0. When x is a vector or matrix, the operator is applied componentwise. The library syntax is | |

\/ | |

The expression x When x is a vector or matrix, the operator is applied componentwise. The library syntax is | |

divrem(x,y,{v}) | |

creates a column vector with two components,
the first being the Euclidean quotient ( Beware that
The library syntax is | |

^ | |

The expression x{ PARI is able to rewrite the multiplication x * x of two If the exponent is not of type integer, this is treated as a transcendental
function (see Section [ As an exception, if the exponent is a rational number p/q and x an integer modulo a prime or a p-adic number, return a solution y of y^q = x^p if it exists. Currently, q must not have large prime factors. Beware that
If the exponent is a negative integer, an inverse must be computed.
For non-invertible
(Here, a factor 2 is obtained directly. In general, take the gcd of the representative and the modulus.) This is most useful when performing complicated operations modulo an integer N whose factorization is unknown. Either the computation succeeds and all is well, or a factor d is discovered and the computation may be restarted modulo d or N/d. For non-invertible
In fact the latter polynomial is invertible, but the algorithm used
(subresultant) assumes the base ring is a domain. If it is not the case,
as here for
This is not guaranteed to work either since it must invert pivots. 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 | |

shift(x,n) | |

or x The library syntax is | |

shiftmul(x,n) | |

multiplies x by 2^n. The difference with
The library syntax is | |

Comparison and boolean operators | |

. The six
standard comparison operators The standard boolean functions
and gand(x,y)
respectively.gnot(x)In library mode, it is in fact usually preferable to use the two basic
functions which are R, and
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. Comparisons
to special constants are implemented and should be used instead of
gequal(x,y)
gequal:
(x == 0 ?), gcmp0(x)
(x == 1 ?), and
gcmp1(x)
(x == -1 ?).gcmp_1(x)Note that Also note that the
GP accepts the following synonyms for some of the above functions: since we
thought it might easily lead to confusion, we don't use the customary C
operators for bitwise | |

lex(x,y) | |

gives the result of a lexicographic comparison between x and y (as -1, 0 or 1). This is to be interpreted in quite a wide sense: It is admissible to compare objects of different types (scalars, vectors, matrices), provided the scalars can be compared, as well as vectors/matrices of different lengths. The comparison is recursive. In case all components are equal up to the smallest length of the operands, the more complex is considered to be larger. More precisely, the longest is the largest; when lengths are equal, we have matrix > vector > scalar. For example:
The library syntax is | |

sign(x) | |

sign (0, 1 or -1) of x, which must be of type integer, real or fraction. The library syntax is | |

max(x,y) | |

and The library syntax is | |

vecmax(x) | |

if x is a vector or a matrix, returns the maximum of the elements of x, otherwise returns a copy of x. Error if x is empty. The library syntax is | |

vecmin(x) | |

if x is a vector or a matrix, returns the minimum of the elements of x, otherwise returns a copy of x. Error if x is empty. The library syntax is | |