Annotation of OpenXM_contrib/pari/doc/usersch5.tex, Revision 1.1
1.1 ! maekawa 1: \chapter{Technical Reference Guide for Low-Level Functions}
! 2: \def\B{\kbd{BIL}}
! 3: \def\op{{\it op\/}}
! 4: \def\fun#1#2#3{\noindent{\tt #1 \key{#2}(#3)}:}
! 5:
! 6: In this chapter, we give a description all public low-level functions of the
! 7: PARI system. These essentially include functions for handling all the PARI
! 8: types. Higher level functions, such as arithmetic or transcendental
! 9: functions, are described fully in Chapter~3 of this manual.
! 10:
! 11: Many other undocumented functions can be found throughout the source code.
! 12: These private functions are more efficient than the library functions that
! 13: call them, but much sloppier on argument checking and damage control. Use
! 14: them at your own risk!
! 15:
! 16: \section{Level 0 kernel (operations on unsigned longs)}
! 17:
! 18: \noindent
! 19: For the non-68k versions, we need level 0 operations simulating basic
! 20: operations of the 68020 processor (on which PARI was originally
! 21: implemented). The type \tet{ulong} is defined in the file \kbd{parigen.h} as
! 22: \kbd{unsigned long}. Note that in the prototypes below a \kbd{ulong} is
! 23: sometimes implicitly typecast to \kbd{int} or \kbd{long}.
! 24:
! 25: The global \kbd{ulong} variables \kbd{overflow} (which will contain
! 26: only 0 or 1) and \kbd{hiremainder} used to be declared in the file
! 27: \kbd{pariinl.h}. However, for certain architectures they are no longer
! 28: needed, and/or have been replaced with local variables for efficiency;
! 29: and the `functions' mentioned below are really chunks of assembler code which
! 30: will be inlined at each invocation by the compiler. If you really need to
! 31: use these lowest-level operations directly, make sure you know your way
! 32: through the PARI kernel sources, and understand the architecture dependencies.
! 33:
! 34: To make the following descriptions valid both for 32-bit and 64-bit
! 35: machines, we will set \B\ to be equal to 32 (resp.~64), an abbreviation of
! 36: \kbd{BITS\_IN\_LONG}, which is what is actually used in the source code.
! 37:
! 38: \fun{int}{addll}{int x, int y} adds the ulongs \kbd{x} and \kbd{y},
! 39: returns the lower \B\ bits and puts the carry bit into \kbd{overflow}.
! 40:
! 41: \fun{int}{addllx}{int x, int y} adds \kbd{overflow} to the sum of the
! 42: ulongs \kbd{x} and \kbd{y}, returns the lower \B\ bits and puts the
! 43: carry bit into \kbd{overflow}.
! 44:
! 45: \fun{int}{subll}{int x, int y} subtracts the ulongs \kbd{x} and \kbd{y},
! 46: returns the lower \B\ bits and put the carry (borrow) bit into \kbd{overflow}.
! 47:
! 48: \fun{int}{subllx}{int x, int y} subtracts \kbd{overflow} from the
! 49: difference of the ulongs \kbd{x} and \kbd{y}, returns the lower \B\ bits
! 50: and puts the carry (borrow) bit into \kbd{overflow}.
! 51:
! 52: \fun{int}{shiftl}{ulong x, ulong y} shifts the ulong \kbd{x} left by \kbd{y}
! 53: bits, returns the lower \B\ bits and stores the high-order \B\ bits into
! 54: \kbd{hiremainder}. We must have $1\le\kbd{y}\le\B$. In particular, \kbd{y}
! 55: must be non-zero; the caller is responsible for testing this.
! 56:
! 57: \fun{int}{shiftlr}{ulong x, ulong y} shifts the ulong \kbd{x << \B} right
! 58: by \kbd{y} bits, returns the higher \B\ bits and stores the low-order
! 59: \B\ bits into \kbd{hiremainder}. We must have $1\le\kbd{y}\le\B$. In
! 60: particular, \kbd{y} must be non-zero.
! 61:
! 62: % break ugly ff ligatures in bfffo
! 63: \fun{int}{b{}f{}f{}fo}{ulong x} returns the number of leading zero bits in the
! 64: ulong \kbd{x} (i.e. the number of bit positions by which it would have to be
! 65: shifted left until its leftmost bit first becomes equal to~1, which can be
! 66: between 0 and $\B-1$ for nonzero \kbd{x}). When \kbd{x} is~0, \B\ is returned.
! 67:
! 68: \fun{int}{mulll}{ulong x, ulong y} multiplies the ulong \kbd{x} by the ulong
! 69: \kbd{y}, returns the lower \B\ bits and stores the high-order \B\ bits into
! 70: \kbd{hiremainder}.
! 71:
! 72: \fun{int}{addmul}{ulong x, ulong y} adds \kbd{hiremainder} to the product
! 73: of the ulongs \kbd{x} and \kbd{y}, returns the lower \B\ bits and stores the
! 74: high-order \B\ bits into \kbd{hiremainder}.
! 75:
! 76: \fun{int}{divll}{ulong x, ulong y} returns the Euclidean quotient of
! 77: (\kbd{hiremainder << \B})${}+{}$\kbd{x} and the ulong divisor \kbd{y} and
! 78: stores the remainder into \kbd{hiremainder}. An error occurs if the quotient
! 79: cannot be represented by a ulong, i.e.~if $\kbd{hiremainder}\ge\kbd{y}$
! 80: initially.
! 81:
! 82: \section{Level 1 kernel (operations on longs, integers and reals)}
! 83:
! 84: \noindent
! 85: In this section as elsewhere, \kbd{long} denotes a \B-bit signed C-integer,
! 86: ``integer'' denotes a PARI multiprecise integer (type \typ{INT}), ``real''
! 87: denotes a PARI multiprecise real (type \typ{REAL}). Refer to Chapters
! 88: 1--2 and~4 for general background.
! 89:
! 90: \misctitle{Note:} Many functions consist of an elementary operation,
! 91: immediately followed by an assignment statement. All such functions are
! 92: obtained using macros (see the file \kbd{paricom.h}), hence you can easily
! 93: extend the list. Below, they will be introduced like in the following
! 94: example:
! 95:
! 96: \fun{GEN}{gadd[z]}{GEN x, GEN y[, GEN z]} followed by the explicit
! 97: description of the function
! 98:
! 99: \kbd{GEN \key{gadd}(GEN x, GEN y)}
! 100:
! 101: \noindent which creates its result on the stack, returning a \kbd{GEN} pointer
! 102: to it, and the parts in brackets indicate that there exists also a function
! 103:
! 104: \kbd{void \key{gaddz}(GEN x, GEN y, GEN z)}
! 105:
! 106: \noindent which assigns its result to the pre-existing object
! 107: \kbd{z}, leaving the stack unchanged.
! 108:
! 109: \subsec{Basic unit and subunit handling functions}
! 110:
! 111: \fun{long}{typ}{GEN x} returns the type number of~\kbd{x}. (The header files
! 112: included through \kbd{pari.h} will give you access to the symbolic constants
! 113: \typ{INT} etc., so you should never need to know the actual numerical values.)
! 114:
! 115: \fun{long}{lg}{GEN x} returns the length of~\kbd{x} in \B-bit words.
! 116:
! 117: \fun{long}{lgef}{GEN x} returns the effective length of the polynomial \kbd{x}
! 118: in \B-bit words.
! 119:
! 120: \fun{long}{lgefint}{GEN x} returns the effective length of the integer \kbd{x}
! 121: in \B-bit words.
! 122:
! 123: \fun{long}{signe}{GEN x} returns the sign ($-1$, 0 or 1) of~\kbd{x}. Can be
! 124: used for integers, reals, polynomials and power series (for the last two
! 125: types, only 0 or 1 are possible).
! 126:
! 127: \fun{long}{gsigne}{GEN x} same as \kbd{signe}, but also valid for rational
! 128: numbers (and marginally less efficient for the other types).
! 129:
! 130: \fun{long}{expo}{GEN x} returns the unbiased binary exponent of the real
! 131: number~\kbd{x}.
! 132:
! 133: \fun{long}{gexpo}{GEN x} same as \kbd{expo}, but also valid when \kbd{x}
! 134: is not a real number. When \kbd{x} is an exact~0, this returns
! 135: \hbox{\kbd{-HIGHEXPOBIT}}.
! 136:
! 137: \fun{long}{expi}{GEN x} returns the binary exponent of the real number equal
! 138: to the integer~\kbd{x}. This is a special case of \kbd{gexpo} above, covering
! 139: the case where \kbd{x} is of type~\typ{INT}.
! 140:
! 141: \fun{long}{valp}{GEN x} returns the unbiased 16-bit $p$-adic valuation (for
! 142: a $p$-adic) or $X$-adic valuation (for a power series, taken with respect
! 143: to the main variable) of~\kbd{x}.
! 144:
! 145: \fun{long}{precp}{GEN x} returns the precision of the $p$-adic~\kbd{x}.
! 146:
! 147: \fun{long}{varn}{GEN x} returns the variable number of \kbd{x} (between 0 and
! 148: \kbd{MAXVARN}). Should be used only for polynomials and power series.
! 149:
! 150: \fun{long}{gvar}{(GEN x)} returns the main variable number when any variable
! 151: at all occurs in the composite object~\kbd{x} (the smallest variable number
! 152: which occurs), and \kbd{BIGINT} otherwise.
! 153:
! 154: \fun{void}{settyp}{GEN x, long s} sets the type number of~\kbd{x} to~\kbd{s}.
! 155: This should be used with extreme care since usually the type is set
! 156: otherwise, and the components and further codeword fields (which are left
! 157: unchanged) may not match the PARI conventions for the new type.
! 158:
! 159: \fun{void}{setlg}{GEN x, long s} sets the length of~\kbd{x} to~\kbd{s}. Again
! 160: this should be used with extreme care since usually the length is set
! 161: otherwise, and increasing the length joins previously unrelated memory words
! 162: to the root node of~\kbd{x}. This is, however, an extremely efficient way of
! 163: truncating vectors or polynomials.
! 164:
! 165: \fun{void}{setlgef}{GEN x, long s} sets the effective length of \kbd{x}
! 166: to~\kbd{s}, where \kbd{x} is a polynomial. The number \kbd{s} must be less
! 167: than or equal to the length of~\kbd{x}.
! 168:
! 169: \fun{void}{setlgefint}{GEN x, long s} sets the effective length
! 170: of the integer \kbd{x} to~\kbd{s}. The number \kbd{s} must be less than or
! 171: equal to the length of~\kbd{x}.
! 172:
! 173: \fun{void}{setsigne}{GEN x, long s} sets the sign of~\kbd{x} to~\kbd{s}.
! 174: If \kbd{x} is an integer or real, \kbd{s} must be equal to $-1$, 0 or~1,
! 175: and if \kbd{x} is a polynomial or a power series, \kbd{s} must be equal to
! 176: 0 or~1.
! 177:
! 178: \fun{void}{setexpo}{GEN x, long s} sets the binary exponent of the real
! 179: number~\kbd{x} to \kbd{s}, after adding the appropriate bias. The unbiased
! 180: value \kbd{s} must be a 24-bit signed number.
! 181:
! 182: \fun{void}{setvalp}{GEN x, long s} sets the $p$-adic or $X$-adic valuation
! 183: of~\kbd{x} to~\kbd{s}, if \kbd{x} is a $p$-adic or a power series,
! 184: respectively.
! 185:
! 186: \fun{void}{setprecp}{GEN x, long s} sets the $p$-adic precision of the
! 187: $p$-adic number~\kbd{x} to~\kbd{s}.
! 188:
! 189: \fun{void}{setvarn}{GEN x, long s} sets the variable number of the polynomial
! 190: or power series~\kbd{x} to~\kbd{s} (where $0\le \kbd{s}\le\kbd{MAXVARN}$).
! 191:
! 192:
! 193: \subsec{Memory allocation on the PARI stack}
! 194:
! 195: \fun{GEN}{cgetg}{long n, long t} allocates memory on the PARI stack for
! 196: an object of length \kbd{n} and type~\kbd{t}, and initializes its first
! 197: codeword.
! 198:
! 199: \fun{GEN}{cgeti}{long n} allocates memory on the PARI stack for an
! 200: integer of length~\kbd{n}, and initializes its first codeword. Identical to
! 201: {\tt cgetg(n,\typ{INT})}.
! 202:
! 203: \fun{GEN}{cgetr}{long n} allocates memory on the PARI stack for a real
! 204: of length~\kbd{n}, and initializes its first codeword. Identical to
! 205: {\tt cgetg(n,\typ{REAL})}.
! 206:
! 207: \fun{void}{cgiv}{GEN x} frees object \kbd{x} if it is the last created on the
! 208: PARI stack (otherwise disaster occurs).
! 209:
! 210: \fun{GEN}{gerepile}{long p, long q, GEN x} general garbage collector
! 211: for the PARI stack. See \secref{se:garbage} for a detailed explanation and
! 212: many examples.
! 213:
! 214: \subsec{Assignments, conversions and integer parts}
! 215:
! 216: \fun{void}{mpaff}{GEN x, GEN z} assigns \kbd{x} into~\kbd{z} (where
! 217: \kbd{x} and \kbd{z} are integers or reals).
! 218:
! 219: \fun{void}{affsz}{long s, GEN z} assigns the long \kbd{s} into the integer or
! 220: real~\kbd{z}.
! 221:
! 222: \fun{void}{affsi}{long s, GEN z} assigns the long \kbd{s} into the
! 223: integer~\kbd{z}.
! 224:
! 225: \fun{void}{affsr}{long s, GEN z} assigns the long \kbd{s} into the
! 226: real~\kbd{z}.
! 227:
! 228: \fun{void}{affii}{GEN x, GEN z} assigns the integer \kbd{x} into the
! 229: integer~\kbd{z}.
! 230:
! 231: \fun{void}{affir}{GEN x, GEN z} assigns the integer \kbd{x} into the
! 232: real~\kbd{z}.
! 233:
! 234: \fun{void}{affrs}{GEN x, long s} assigns the real \kbd{x} into the
! 235: long~\kbd{s}\dots not. This is a forbidden assignment in PARI, so an error
! 236: message is issued.
! 237:
! 238: \fun{void}{affri}{GEN x, GEN z} assigns the real \kbd{x} into the
! 239: integer~\kbd{z}\dots no it doesn't. This is a forbidden assignment in PARI,
! 240: so an error message is issued.
! 241:
! 242: \fun{void}{affrr}{GEN x, GEN z} assigns the real \kbd{x} into the real~\kbd{z}.
! 243: \smallskip
! 244:
! 245: \fun{GEN}{stoi}{long s} creates the PARI integer corresponding to the
! 246: long~\kbd{s}.
! 247:
! 248: \fun{long}{itos}{GEN x} converts the PARI integer \kbd{x} to a C long (if
! 249: possible, otherwise an error message is issued).
! 250: \smallskip
! 251:
! 252: \fun{GEN}{mptrunc[z]}{GEN x[, GEN z]} truncates the integer or real~\kbd{x}
! 253: (not the same as the integer part if \kbd{x} is non-integer and negative).
! 254:
! 255: \fun{GEN}{mpent[z]}{GEN x[, GEN z]} true integer part of the integer or
! 256: real~\kbd{x} (i.e.~the \kbd{floor} function).
! 257:
! 258: \subsec{Valuation and shift}
! 259:
! 260: \fun{long}{vals}{long s} 2-adic valuation of the long~\kbd{s}. Returns $-1$
! 261: if \kbd{s} is equal to 0, with no error.
! 262:
! 263: \fun{long}{vali}{GEN x} 2-adic valuation of the integer~\kbd{x}. Returns $-1$
! 264: if \kbd{s} is equal to 0, with no error.
! 265:
! 266: \fun{GEN}{mpshift[z]}{GEN x, long n[, GEN z]} shifts the real or
! 267: integer \kbd{x} by~\kbd{n}. If \kbd{n} is positive, this is a left shift,
! 268: i.e.~multiplication by $2^{\kbd{n}}$. If \kbd{n} is negative, it is a right
! 269: shift by~$-\kbd{n}$, which amounts to the truncation of the quotient of \kbd{x}
! 270: by~$2^{-\kbd{n}}$.
! 271:
! 272: \fun{GEN}{shifts}{long s, long n} converts the long \kbd{s} into a PARI
! 273: integer and shifts the value by~\kbd{n}.
! 274:
! 275: \fun{GEN}{shifti}{GEN x, long n} shifts the integer~\kbd{x} by~\kbd{n}.
! 276:
! 277: \fun{GEN}{shiftr}{GEN x, long n} shifts the real~\kbd{x} by~\kbd{n}.
! 278:
! 279: \subsec{Unary operations}
! 280:
! 281: \noindent
! 282: Let ``\op'' be some unary operation of type \kbd{GEN (*)(GEN)}. The names and
! 283: prototypes of the low-level functions corresponding to \op\ will be as follows.
! 284:
! 285: \fun{GEN}{mp\op}{GEN x} creates the result of \op\ applied to the integer
! 286: or real~\kbd{x}.
! 287:
! 288: \fun{GEN}{\op s}{long s} creates the result of \op\ applied to the
! 289: long~\kbd{s}.
! 290:
! 291: \fun{GEN}{\op i}{GEN x} creates the result of \op\ applied to the
! 292: integer~\kbd{x}.
! 293:
! 294: \fun{GEN}{\op r}{GEN x} creates the result of \op\ applied to the real~\kbd{x}.
! 295:
! 296: \fun{GEN}{mp\op z}{GEN x, GEN z} assigns the result of applying \op\ to the
! 297: integer or real~\kbd{x} into the integer or real \kbd{z}.
! 298:
! 299: \misctitle{Remark:} it has not been considered useful to include the
! 300: functions {\tt void \op sz(long,GEN)}, {\tt void \op iz(GEN,GEN)} and
! 301: {\tt void \op rz(GEN, GEN)}.
! 302: \smallskip
! 303:
! 304: \noindent The above prototype schemes apply to the following operators:
! 305:
! 306: \op=\key{neg}: negation ($-$\kbd{x}). The result is of the same type
! 307: as~\kbd{x}.
! 308:
! 309: \op=\key{abs}: absolute value ($|\kbd{x}|$). The result is of the same type
! 310: as~\kbd{x}.
! 311:
! 312: \noindent In addition, there exist the following special unary functions with
! 313: assignment:
! 314:
! 315: \fun{void}{mpinvz}{GEN x, GEN z} assigns the inverse of the integer or
! 316: real \kbd{x} into the real~\kbd{z}. The inverse is computed as a quotient
! 317: of real numbers, not as a Euclidean division.
! 318:
! 319: \fun{void}{mpinvsr}{long s, GEN z} assigns the inverse of the long \kbd{s}
! 320: into the real~\kbd{z}.
! 321:
! 322: \fun{void}{mpinvir}{GEN x, GEN z} assigns the inverse of the integer \kbd{x}
! 323: into the real~\kbd{z}.
! 324:
! 325: \fun{void}{mpinvrr}{GEN x, GEN z} assigns the inverse of the real \kbd{x} into
! 326: the real~\kbd{z}.
! 327:
! 328: \subsec{Comparison operators}
! 329:
! 330: \fun{long}{mpcmp}{GEN x, GEN y} compares the integer or real \kbd{x} to the
! 331: integer or real~\kbd{y}. The result is the sign of $\kbd{x}-\kbd{y}$.
! 332:
! 333: \fun{long}{cmpss}{long s, long t} returns the sign of $\kbd{s}-\kbd{t}$.
! 334:
! 335: \fun{long}{cmpsi}{long s, GEN x} compares the long \kbd{s} to the
! 336: integer~\kbd{x}.
! 337:
! 338: \fun{long}{cmpsr}{long s, GEN x} compares the long \kbd{s} to the real~\kbd{x}.
! 339:
! 340: \fun{long}{cmpis}{GEN x, long s} compares the integer \kbd{x} to the
! 341: long~\kbd{s}.
! 342:
! 343: \fun{long}{cmpii}{GEN x, GEN y} compares the integer \kbd{x} to the
! 344: integer~\kbd{y}.
! 345:
! 346: \fun{long}{cmpir}{GEN x, GEN y} compares the integer \kbd{x} to the
! 347: real~\kbd{y}.
! 348:
! 349: \fun{long}{cmprs}{GEN x, long s} compares the real \kbd{x} to the
! 350: long~\kbd{s}.
! 351:
! 352: \fun{long}{cmpri}{GEN x, GEN y} compares the real \kbd{x} to the
! 353: integer~\kbd{y}.
! 354:
! 355: \fun{long}{cmprr}{GEN x, GEN y} compares the real \kbd{x} to the real~\kbd{y}.
! 356:
! 357: \subsec{Binary operations}
! 358:
! 359: \noindent
! 360: Let ``\op'' be some operation of type \kbd{GEN (*)(GEN,GEN)}. The names and
! 361: prototypes of the low-level functions corresponding to \op\ will be as follows.
! 362: In this section, the \kbd{z} argument in the \kbd{z}-functions must be of type
! 363: \typ{INT} or~\typ{REAL}.
! 364:
! 365: \fun{GEN}{mp\op[z]}{GEN x, GEN y[, GEN z]} applies \op\ to
! 366: the integer-or-reals \kbd{x} and~\kbd{y}.
! 367:
! 368: \fun{GEN}{\op ss[z]}{long s, long t[, GEN z]} applies \op\ to the longs
! 369: \kbd{s} and~\kbd{t}.
! 370:
! 371: \fun{GEN}{\op si[z]}{long s, GEN x[, GEN z]} applies \op\ to the long \kbd{s}
! 372: and the integer~\kbd{x}.
! 373:
! 374: \fun{GEN}{\op sr[z]}{long s, GEN x[, GEN z]} applies \op\ to the long \kbd{s}
! 375: and the real~\kbd{x}.
! 376:
! 377: \fun{GEN}{\op is[z]}{GEN x, long s[, GEN z]} applies \op\ to the
! 378: integer \kbd{x} and the long~\kbd{s}.
! 379:
! 380: \fun{GEN}{\op ii[z]}{GEN x, GEN y[, GEN z]} applies \op\ to the
! 381: integers \kbd{x} and~\kbd{y}.
! 382:
! 383: \fun{GEN}{\op ir[z]}{GEN x, GEN y[, GEN z]} applies \op\ to the
! 384: integer \kbd{x} and the real~\kbd{y}.
! 385:
! 386: \fun{GEN}{\op rs[z]}{GEN x, long s[, GEN z]} applies \op\ to the real \kbd{x}
! 387: and the long~\kbd{s}.
! 388:
! 389: \fun{GEN}{\op ri[z]}{GEN x, GEN y[, GEN z]} applies \op\ to the real \kbd{x}
! 390: and the integer~\kbd{y}.
! 391:
! 392: \fun{GEN}{\op rr[z]}{GEN x, GEN y[, GEN z]} applies \op\ to the reals \kbd{x}
! 393: and~\kbd{y}.
! 394: \smallskip
! 395: \noindent Each of the above can be used with the following operators.
! 396:
! 397: \op=\key{add}: addition (\kbd{x + y}). The result is real unless both \kbd{x}
! 398: and \kbd{y} are integers (or longs).
! 399:
! 400: \op=\key{sub}: subtraction (\kbd{x - y}). The result is real unless both
! 401: \kbd{x} and \kbd{y} are integers (or longs).
! 402:
! 403: \op=\key{mul}: multiplication (\kbd{x * y}). The result is real unless both
! 404: \kbd{x} and \kbd{y} are integers (or longs), OR if \kbd{x} or \kbd{y} is the
! 405: integer or long zero.
! 406:
! 407: \op=\key{div}: division (\kbd{x / y}). In the case where \kbd{x} and \kbd{y}
! 408: are both integers or longs, the result is the Euclidean quotient, where the
! 409: remainder has the same sign as the dividend~\kbd{x}. If one of \kbd{x} or
! 410: \kbd{y} is real, the result is real unless \kbd{x} is the integer or long
! 411: zero. A division-by-zero error occurs if \kbd{y} is equal to zero.
! 412:
! 413: \op=\key{res}: remainder (``\kbd{x \% y}''). This operation is defined only
! 414: when \kbd{x} and \kbd{y} are longs or integers. The result is the Euclidean
! 415: remainder corresponding to \kbd{div},~i.e. its sign is that of the
! 416: dividend~\kbd{x}. The result is always an integer.
! 417:
! 418: \op=\key{mod}: remainder (\kbd{x \% y}). This operation is defined only when
! 419: \kbd{x} and \kbd{y} are longs or integers. The result is the true Euclidean
! 420: remainder, i.e.~non-negative and less than the absolute value of~\kbd{y}.
! 421:
! 422: \subsec{Division with remainder}: the following functions return two objects,
! 423: unless specifically asked for only one of them~--- a quotient and a remainder.
! 424: The remainder will be created on the stack, and a \kbd{GEN} pointer to this
! 425: object will be returned through the variable whose address is passed as the
! 426: \kbd{r} argument.
! 427:
! 428: \fun{GEN}{dvmdss}{long s, long t, GEN *r} creates the Euclidean
! 429: quotient and remainder of the longs \kbd{s} and~\kbd{t}. If \kbd{r} is not
! 430: \kbd{NULL} or \kbd{ONLY\_REM}, this puts the remainder into \kbd{*r},
! 431: and returns the quotient. If \kbd{r} is equal to \kbd{NULL}, only the
! 432: quotient is returned. If \kbd{r} is equal to \kbd{ONLY\_REM}, the remainder
! 433: is returned instead of the quotient. In the generic case, the remainder is
! 434: created after the quotient and can be disposed of individually with a
! 435: \kbd{cgiv(r)}. The remainder is always of the sign of the dividend~\kbd{s}.
! 436:
! 437: \fun{GEN}{dvmdsi}{long s, GEN x, GEN *r} creates the Euclidean
! 438: quotient and remainder of the long \kbd{s} by the integer~\kbd{x}.
! 439: Obeys the same conventions with respect to~\kbd{r}.
! 440:
! 441: \fun{GEN}{dvmdis}{GEN x, long s, GEN *r} create the Euclidean
! 442: quotient and remainder of the integer x by the long~s.
! 443:
! 444: \fun{GEN}{dvmdii}{GEN x, GEN y, GEN *r} returns the Euclidean quotient
! 445: of the integer \kbd{x} by the integer \kbd{y} and puts the remainder
! 446: into~\kbd{*r}. If \kbd{r} is equal to \kbd{NULL}, the remainder is not
! 447: created, and if \kbd{r} is equal to \kbd{ONLY\_REM}, only the remainder
! 448: is created and returned. In the generic case, the remainder is created
! 449: after the quotient and can be disposed of individually with a \kbd{cgiv(r)}.
! 450: The remainder is always of the sign of the dividend~\kbd{x}.
! 451:
! 452: \fun{GEN}{truedvmdii}{GEN x, GEN y, GEN *r}, as \kbd{dvmdii} but with a
! 453: non-negative remainder.
! 454:
! 455: \fun{void}{mpdvmdz}{GEN x, GEN y, GEN z, GEN *r} assigns the Euclidean
! 456: quotient of the integers \kbd{x} and \kbd{y} into the integer or real~\kbd{z},
! 457: putting the remainder into~\kbd{*r} (unless \kbd{r} is equal to \kbd{NULL} or
! 458: \kbd{ONLY\_REM} as above).
! 459:
! 460: \fun{void}{dvmdssz}{long s, long t, GEN z, GEN *r} assigns the Euclidean
! 461: quotient of the longs \kbd{s} and \kbd{t} into the integer or real~\kbd{z},
! 462: putting the remainder into~\kbd{*r} (unless \kbd{r} is equal to \kbd{NULL} or
! 463: \kbd{ONLY\_REM} as above).
! 464:
! 465: \fun{void}{dvmdsiz}{long s, GEN x, GEN z, GEN *r} assigns the Euclidean
! 466: quotient of the long \kbd{s} and the integer \kbd{x} into the integer or
! 467: real~\kbd{z}, putting the remainder into \kbd{*r} (unless \kbd{r} is equal
! 468: to \kbd{NULL} or \kbd{ONLY\_REM} as above).
! 469:
! 470: \fun{void}{dvmdisz}{GEN x, long s, GEN z, GEN *r} assigns the Euclidean
! 471: quotient of the integer \kbd{x} and the long \kbd{s} into the integer or
! 472: real~\kbd{z}, putting the remainder into~\kbd{*r} (unless \kbd{r} is equal
! 473: to \kbd{NULL} or \kbd{ONLY\_REM} as above).
! 474:
! 475: \fun{void}{dvmdiiz}{GEN x, GEN y, GEN z, GEN *r} assigns the Euclidean
! 476: quotient of the integers \kbd{x} and \kbd{y} into the integer or real~\kbd{z},
! 477: putting the address of the remainder into~\kbd{*r} (unless \kbd{r} is equal
! 478: to \kbd{NULL} or \kbd{ONLY\_REM} as above).
! 479:
! 480: \subsec{Miscellaneous functions}
! 481:
! 482: \fun{void}{addsii}{long s, GEN x, GEN z} assigns the sum of the long \kbd{s}
! 483: and the integer \kbd{x} into the integer~\kbd{z} (essentially identical to
! 484: \kbd{addsiz} except that \kbd{z} is specifically an integer).
! 485:
! 486: \fun{long}{divise}{GEN x, GEN y} if the integer \kbd{y} divides the
! 487: integer~\kbd{x}, returns 1 (true), otherwise returns 0 (false).
! 488:
! 489: \fun{long}{divisii}{GEN x, long s, GEN z} assigns the Euclidean quotient of
! 490: the integer \kbd{x} and the long \kbd{s} into the integer \kbd{z}, and returns
! 491: the remainder as a long.
! 492:
! 493: \fun{long}{mpdivis}{GEN x, GEN y, GEN z} if the integer \kbd{y} divides the
! 494: integer~\kbd{x}, assigns the quotient to the integer~\kbd{z} and returns
! 495: 1 (true), otherwise returns 0 (false).
! 496:
! 497: \fun{void}{mulsii}{long s, GEN x, GEN z} assigns the product of the long
! 498: \kbd{s} and the integer \kbd{x} into the integer~\kbd{z} (essentially
! 499: dentical to \kbd{mulsiz} except that \kbd{z} is specifically an integer).
! 500:
! 501: \section{Level 2 kernel (operations on general PARI objects)}
! 502:
! 503: \noindent The functions available to handle subunits are the following.
! 504:
! 505: \fun{GEN}{compo}{GEN x, long n} creates a copy of the \kbd{n}-th true
! 506: component (i.e.\ not counting the codewords) of the object~\kbd{x}.
! 507:
! 508: \fun{GEN}{truecoeff}{GEN x, long n} creates a copy of the coefficient of
! 509: degree~\kbd{n} of~\kbd{x} if \kbd{x} is a scalar, polynomial or power series,
! 510: and otherwise of the \kbd{n}-th component of~\kbd{x}.
! 511:
! 512: \noindent % borderline case -- looks better like this [GN]
! 513: The remaining two are macros, NOT functions (see \secref{se:typecast} for a
! 514: detailed explanation):
! 515:
! 516: \fun{long}{coeff}{GEN x, long i, long j} applied to a matrix \kbd{x} (type
! 517: \typ{MAT}), this gives the address of the coefficient at row \kbd{i} and
! 518: column~\kbd{j} of~\kbd{x}.
! 519:
! 520: \fun{long}{mael$n$}{GEN x, long $a_1$, ..., long $a_n$} stands for
! 521: \kbd{x[$a_1$][$a_2$]...[$a_n$]}, where $2\le n \le 5$, with all the
! 522: necessary typecasts.
! 523:
! 524: \subsec{Copying and conversion}
! 525:
! 526: \fun{GEN}{cgetp}{GEN x} creates space sufficient to hold the $p$-adic~\kbd{x},
! 527: and sets the prime $p$ and the $p$-adic precision to those of~\kbd{x}, but
! 528: does not copy (the $p$-adic unit or zero representative and the modulus
! 529: of)~\kbd{x}.
! 530:
! 531: \fun{GEN}{gcopy}{GEN x} creates a new copy of the object~\kbd{x} on the PARI
! 532: stack. For permanent subobjects, only the pointer is copied.
! 533:
! 534: \fun{GEN}{forcecopy}{GEN x} same as \key{copy} except that even permanent
! 535: subobjects are copied onto the stack.
! 536:
! 537: \fun{long}{taille}{GEN x} returns the total number of \B-bit words occupied
! 538: by the tree representing~\kbd{x}.
! 539:
! 540: \fun{GEN}{gclone}{GEN x} creates a new permanent copy of the object \kbd{x}
! 541: on the heap.
! 542:
! 543: \fun{GEN}{greffe}{GEN x, long l, int use\_stack} applied to a
! 544: polynomial~\kbd{x} (type \typ{POL}), creates a power series (type \typ{SER})
! 545: of length~\kbd{l} starting with~\kbd{x}, but without actually copying the
! 546: coefficients, just the pointers. If \kbd{use\_stack} is zero, this is created
! 547: through malloc, and must be freed after use. Intended for internal use only.
! 548:
! 549: \fun{double}{rtodbl}{GEN x} applied to a real~\kbd{x} (type \typ{REAL}),
! 550: converts \kbd{x} into a C double if possible.
! 551:
! 552: \fun{GEN}{dbltor}{double x} converts the C double \kbd{x} into a PARI real.
! 553:
! 554: \fun{double}{gtodouble}{GEN x} if \kbd{x} is a real number (but not
! 555: necessarily of type \typ{REAL}), converts \kbd{x} into a C double if possible.
! 556:
! 557: \fun{long}{gtolong}{GEN x} if \kbd{x} is an integer (not a C long,
! 558: but not necessarily of type \typ{INT}), converts \kbd{x} into a C long
! 559: if possible.
! 560:
! 561: \fun{GEN}{gtopoly}{GEN x, long v} converts or truncates the object~\kbd{x}
! 562: into a polynomial with main variable number~\kbd{v}. A common application
! 563: would be the conversion of coefficient vectors.
! 564:
! 565: \fun{GEN}{gtopolyrev}{GEN x, long v} converts or truncates the object~\kbd{x}
! 566: into a polynomial with main variable number~\kbd{v}, but vectors are converted
! 567: in reverse order.
! 568:
! 569: \fun{GEN}{gtoser}{GEN x, long v} converts the object~\kbd{x} into a power
! 570: series with main variable number~\kbd{v}.
! 571:
! 572: \fun{GEN}{gtovec}{GEN x} converts the object~\kbd{x} into a (row) vector.
! 573:
! 574: \fun{GEN}{co8}{GEN x, long l} applied to a quadratic number~\kbd{x}
! 575: (type \typ{QUAD}), converts \kbd{x} into a real or complex number
! 576: depending on the sign of the discriminant of~\kbd{x}, to precision
! 577: \hbox{\kbd{l} \B-bit} words.% absolutely forbid line brk at hyphen here [GN]
! 578:
! 579: \fun{GEN}{gcvtop}{GEN x, GEN p, long l} converts \kbd{x} into a \kbd{p}-adic
! 580: number of precision~\kbd{l}.
! 581:
! 582: \fun{GEN}{gmodulcp}{GEN x, GEN y} creates the object \kbd{\key{Mod}(x,y)}
! 583: on the PARI stack, where \kbd{x} and \kbd{y} are either both integers, and
! 584: the result is an integermod (type \typ{INTMOD}), or \kbd{x} is a scalar or
! 585: a polynomial and \kbd{y} a polynomial, and the result is a polymod
! 586: (type \typ{POLMOD}).
! 587:
! 588: \fun{GEN}{gmodulgs}{GEN x, long y} same as \key{gmodulcp} except \kbd{y} is a
! 589: \kbd{long}.
! 590:
! 591: \fun{GEN}{gmodulss}{long x, long y} same as \key{gmodulcp} except both \kbd{x}
! 592: and \kbd{y} are \kbd{long}s.
! 593:
! 594: \fun{GEN}{gmodulo}{GEN x, GEN y} same as \key{gmodulcp} except that the
! 595: modulus \kbd{y} is copied onto the heap and not onto the PARI stack.
! 596:
! 597: \fun{long}{gexpo}{GEN x} returns the binary exponent of \kbd{x} or the maximal
! 598: binary exponent of the coefficients of~\kbd{x}. Returns
! 599: \hbox{\kbd{-HIGHEXPOBIT}} if \kbd{x} has no components or is an exact zero.
! 600:
! 601: \fun{long}{gsize}{GEN x} returns 0 if \kbd{x} is exactly~0. Otherwise,
! 602: returns \kbd{\key{gexpo}(x)} multiplied by $\log_{10}(2)$. This gives a
! 603: crude estimate for the maximal number of decimal digits of the components
! 604: of~\kbd{x}.
! 605:
! 606: \fun{long}{gsigne}{GEN x} returns the sign of~\kbd{x} ($-1$, 0 or 1) when
! 607: \kbd{x} is an integer, real or (irreducible or reducible) fraction. Raises
! 608: an error for all other types.
! 609:
! 610: \fun{long}{gvar}{GEN x} returns the main variable of~\kbd{x}. If no component
! 611: of~\kbd{x} is a polynomial or power series, this returns \kbd{BIGINT}.
! 612:
! 613: \fun{int}{precision}{GEN x} If \kbd{x} is of type \typ{REAL}, returns the
! 614: precision of~\kbd{x} (the length of \kbd{x} in \B-bit words if \kbd{x} is
! 615: not zero, and a reasonable quantity obtained from the exponent of \kbd{x}
! 616: if \kbd{x} is numerically equal to zero). If \kbd{x} is of type \typ{COMPLEX},
! 617: returns the minimum of the precisions of the real and imaginary part.
! 618: Otherwise, returns~0 (which stands in fact for infinite precision).
! 619:
! 620: \subsec{Comparison operators and valuations}
! 621:
! 622: \fun{int}{gcmp0}{GEN x} returns 1 (true) if \kbd{x} is equal to~0, 0~(false)
! 623: otherwise.
! 624:
! 625: \fun{int}{isexactzero}{GEN x} returns 1 (true) if \kbd{x} is exactly equal
! 626: to~0, 0~(false) otherwise. Note that many PARI functions will return a
! 627: pointer to \key{gzero} when they are aware that the result they return is
! 628: an exact zero, so it is almost always faster to test for pointer equality
! 629: first, and call \key{isexactzero} (or \key{gcmp0}) only when the first
! 630: test fails.
! 631:
! 632: \fun{int}{gcmp1}{GEN x} returns 1 (true) if \kbd{x} is equal to~1, 0~(false)
! 633: otherwise.
! 634:
! 635: \fun{int}{gcmp\_1}{GEN x} returns 1 (true) if \kbd{x} is equal to~$-1$,
! 636: 0~(false) otherwise.
! 637:
! 638: \fun{long}{gcmp}{GEN x, GEN y} comparison of \kbd{x} with \kbd{y} (returns
! 639: the sign of $\kbd{x}-\kbd{y}$).
! 640:
! 641: \fun{long}{gcmpsg}{long s, GEN x} comparison of the long \kbd{s} with~\kbd{x}.
! 642:
! 643: \fun{long}{gcmpgs}{GEN x, long s} comparison of \kbd{x} with the long~\kbd{s}.
! 644:
! 645: \fun{long}{lexcmp}{GEN x, GEN y} comparison of \kbd{x} with \kbd{y} for the
! 646: lexicographic ordering.
! 647:
! 648: \fun{long}{gegal}{GEN x, GEN y} returns 1 (true) if \kbd{x} is equal
! 649: to~\kbd{y}, 0~otherwise.
! 650:
! 651: \fun{long}{gegalsg}{long s, GEN x} returns 1 (true) if the long \kbd{s} is
! 652: equal to~\kbd{x}, 0~otherwise.
! 653:
! 654: \fun{long}{gegalgs}{GEN x, long s} returns 1 (true) if \kbd{x} is equal to
! 655: the long~\kbd{s}, 0~otherwise.
! 656:
! 657: \fun{long}{iscomplex}{GEN x} returns 1 (true) if \kbd{x} is a complex number
! 658: (of component types embeddable into the reals) but is not itself real, 0~if
! 659: \kbd{x} is a real (not necessarily of type \typ{REAL}), or raises an error
! 660: if \kbd{x} is not embeddable into the complex numbers.
! 661:
! 662: \fun{long}{ismonome}{GEN x} returns 1 (true) if \kbd{x} is a non-zero monomial
! 663: in its main variable, 0~otherwise.
! 664:
! 665: \fun{long}{ggval}{GEN x, GEN p} returns the greatest exponent~$e$ such that
! 666: $\kbd{p}^e$ divides~\kbd{x}, when this makes sense.
! 667:
! 668: \fun{long}{gval}{GEN x, long v} returns the highest power of the variable
! 669: number \kbd{v} dividing the polynomial~\kbd{x}.
! 670:
! 671: \fun{int}{pvaluation}{GEN x, GEN p, GEN *r} applied to non-zero integers
! 672: \kbd{x} and~\kbd{p}, returns the highest exponent $e$ such that
! 673: $\kbd{p}^{e}$ divides~\kbd{x}, creates the quotient $\kbd{x}/\kbd{p}^{e}$
! 674: and returns its address in~\kbd{*r}.
! 675: In particular, if \kbd{p} is a prime, this returns the valuation at \kbd{p}
! 676: of~\kbd{x}, and \kbd{*r} will obtain the prime-to-\kbd{p} part of~\kbd{x}.
! 677:
! 678: \subsec{Assignment statements}
! 679:
! 680: \fun{void}{gaffsg}{long s, GEN x} assigns the long \kbd{s} into the
! 681: object~\kbd{x}.
! 682:
! 683: \fun{void}{gaffect}{GEN x, GEN y} assigns the object \kbd{x} into the
! 684: object~\kbd{y}.
! 685:
! 686: \subsec{Unary operators}
! 687:
! 688: \fun{GEN}{gneg[\key{z}]}{GEN x[, GEN z]} yields $-\kbd{x}$.
! 689:
! 690: \fun{GEN}{gabs[\key{z}]}{GEN x[, GEN z]} yields $|\kbd{x}|$.
! 691:
! 692: \fun{GEN}{gsqr}{GEN x} creates the square of~\kbd{x}.
! 693:
! 694: \fun{GEN}{ginv}{GEN x} creates the inverse of~\kbd{x}.
! 695:
! 696: \fun{GEN}{gfloor}{GEN x} creates the floor of~\kbd{x}, i.e.\ the (true)
! 697: integral part.
! 698:
! 699: \fun{GEN}{gfrac}{GEN x} creates the fractional part of~\kbd{x}, i.e.\ \kbd{x}
! 700: minus the floor of~\kbd{x}.
! 701:
! 702: \fun{GEN}{gceil}{GEN x} creates the ceiling of~\kbd{x}.
! 703:
! 704: \fun{GEN}{ground}{GEN x} rounds the components of \kbd{x} to the nearest
! 705: integers. Exact half-integers are rounded towards~$+\infty$.
! 706:
! 707: \fun{GEN}{grndtoi}{GEN x, long *e} same as \key{round}, but in addition puts
! 708: minus the number of significant binary bits left after rounding into~\kbd{*e}.
! 709: If \kbd{*e} is positive, all significant bits have been lost. This kind of
! 710: situation raises an error message in \key{ground} but not in \key{grndtoi}.
! 711:
! 712: \fun{GEN}{gtrunc}{GEN x} truncates~\kbd{x}. This is the (false) integer part
! 713: if \kbd{x} is an integer (i.e.~the unique integer closest to \kbd{x} among
! 714: those between 0 and~\kbd{x}). If \kbd{x} is a series, it will be truncated
! 715: to a polynomial; if \kbd{x} is a rational function, this takes the
! 716: polynomial part.
! 717:
! 718: \fun{GEN}{gcvtoi}{GEN x, long *e} same as \key{grndtoi} except that
! 719: rounding is replaced by truncation.
! 720:
! 721: \fun{GEN}{gred[z]}{GEN x[, GEN z]} reduces \kbd{x} to lowest terms if \kbd{x}
! 722: is a fraction or rational function (types \typ{FRAC}, \typ{FRACN},
! 723: \typ{RFRAC} and \typ{RFRACN}), otherwise creates a copy of~\kbd{x}.
! 724:
! 725: \fun{GEN}{content}{GEN x} creates the GCD of all the components of~\kbd{x}.
! 726:
! 727: \fun{GEN}{normalize}{GEN x} applied to an unnormalized power series~\kbd{x}
! 728: (i.e.~type \typ{SER} with all coefficients correctly set except that \kbd{x[2]}
! 729: might be zero), normalizes \kbd{x} correctly in place. Returns~\kbd{x}.
! 730: For internal use.
! 731:
! 732: \fun{GEN}{normalizepol}{GEN x} applied to an unnormalized polynomial~\kbd{x}
! 733: (i.e.~type \typ{POL} with all coefficients correctly set except that \kbd{x[2]}
! 734: might be zero), normalizes \kbd{x} correctly in place and returns~\kbd{x}.
! 735: For internal use.
! 736:
! 737: \subsec{Binary operators}
! 738:
! 739: \fun{GEN}{gmax[z]}{GEN x, GEN y[, GEN z]} yields the maximum of the objects
! 740: \kbd{x} and~\kbd{y} if they can be compared.
! 741:
! 742: \fun{GEN}{gmaxsg[z]}{long s, GEN x[, GEN z]} yields the maximum of the long
! 743: \kbd{s} and the object~\kbd{x}.
! 744:
! 745: \fun{GEN}{gmaxgs[z]}{GEN x, long s[, GEN z]} yields the maximum of the object
! 746: \kbd{x} and the long~\kbd{s}.
! 747:
! 748: \fun{GEN}{gmin[z]}{GEN x, GEN y[, GEN z]} yields the minimum of the objects
! 749: \kbd{x} and~\kbd{y} if they can be compared.
! 750:
! 751: \fun{GEN}{gminsg[z]}{long s, GEN x[, GEN z]} yields the minimum of the long
! 752: \kbd{s} and the object~\kbd{x}.
! 753:
! 754: \fun{GEN}{gmings[z]}{GEN x, long s[, GEN z]} yields the minimum of the object
! 755: \kbd{x} and the long~\kbd{s}.
! 756:
! 757: \fun{GEN}{gadd[z]}{GEN x, GEN y[, GEN z]} yields the sum of the objects \kbd{x}
! 758: and~\kbd{y}.
! 759:
! 760: \fun{GEN}{gaddsg[z]}{long s, GEN x[, GEN z]} yields the sum of the long \kbd{s}
! 761: and the object~\kbd{x}.
! 762:
! 763: \fun{GEN}{gaddgs[z]}{GEN x, long s[, GEN z]} yields the sum of the object
! 764: \kbd{x} and the long~\kbd{s}.
! 765:
! 766: \fun{GEN}{gsub[z]}{GEN x, GEN y[, GEN z]} yields the difference of the objects
! 767: \kbd{x} and~\kbd{y}.
! 768:
! 769: \fun{GEN}{gsubgs[z]}{GEN x, long s[, GEN z]} yields the difference of the
! 770: object \kbd{x} and the long~\kbd{s}.
! 771:
! 772: \fun{GEN}{gsubsg[z]}{long s, GEN x[, GEN z]} yields the difference of the
! 773: long \kbd{s} and the object~\kbd{x}.
! 774:
! 775: \fun{GEN}{gmul[z]}{GEN x, GEN y[, GEN z]} yields the product of the objects
! 776: \kbd{x} and~\kbd{y}.
! 777:
! 778: \fun{GEN}{gmulsg[z]}{long s, GEN x[, GEN z]} yields the product of the long
! 779: \kbd{s} with the object~\kbd{x}.
! 780:
! 781: \fun{GEN}{gmulgs[z]}{GEN x, long s[, GEN z]} yields the product of the object
! 782: \kbd{x} with the long~\kbd{s}.
! 783:
! 784: \fun{GEN}{gshift[z]}{GEN x, long n[, GEN z]} yields the result of shifting
! 785: (the components of) \kbd{x} left by \kbd{n} (if \kbd{n} is non-negative)
! 786: or right by $-\kbd{n}$ (if \kbd{n} is negative).
! 787: Applies only to integers, reals and vectors/matrices of such. For other
! 788: types, it is simply multiplication by~$2^{\kbd{n}}$.
! 789:
! 790: \fun{GEN}{gmul2n[z]}{GEN x, long n[, GEN z]} yields the product of \kbd{x}
! 791: and~$2^{\kbd{n}}$. This is different from \kbd{gshift} when \kbd{n} is negative
! 792: and \kbd{x} is of type \typ{INT}: \key{gshift} truncates, while \key{gmul2n}
! 793: creates a fraction if necessary.
! 794:
! 795: \fun{GEN}{gdiv[z]}{GEN x, GEN y[, GEN z]} yields the quotient of the objects
! 796: \kbd{x} and~\kbd{y}.
! 797:
! 798: \fun{GEN}{gdivgs[z]}{GEN x, long s[, GEN z]} yields the quotient of the object
! 799: \kbd{x} and the long~\kbd{s}.
! 800:
! 801: \fun{GEN}{gdivsg[z]}{long s, GEN x[, GEN z]} yields the quotient of the long
! 802: \kbd{s} and the object~\kbd{x}.
! 803:
! 804: \fun{GEN}{gdivent[z]}{GEN x, GEN y[, GEN z]} yields the true Euclidean
! 805: quotient of \kbd{x} and the integer or polynomial~\kbd{y}.
! 806:
! 807: \fun{GEN}{gdiventsg[z]}{long s, GEN x[, GEN z]} yields the true Euclidean
! 808: quotient of the long \kbd{s} by the integer~\kbd{x}.
! 809:
! 810: \fun{GEN}{gdiventgs[z]}{GEN x, long s[, GEN z]} yields the true Euclidean
! 811: quotient of the integer \kbd{x} by the long~\kbd{s}.
! 812:
! 813: \fun{GEN}{gdiventres}{GEN x, GEN y} creates a 2-component vertical
! 814: vector whose components are the true Euclidean quotient and remainder
! 815: of \kbd{x} and~\kbd{y}.
! 816:
! 817: \fun{GEN}{gdivmod}{GEN x, GEN y, GEN *r} If \kbd{r} is not equal to
! 818: \kbd{NULL} or \kbd{ONLY\_REM}, creates the (false) Euclidean quotient of
! 819: \kbd{x} and~\kbd{y}, and puts (the address of) the remainder into~\kbd{*r}.
! 820: If \kbd{r} is equal to \kbd{NULL}, do not create the remainder, and if
! 821: \kbd{r} is equal to \kbd{ONLY\_REM}, create and output only the remainder.
! 822: The remainder is created after the quotient and can be disposed of
! 823: individually with a \kbd{cgiv(r)}.
! 824:
! 825: \fun{GEN}{poldivres}{GEN x, GEN y, GEN *r} same as \key{gdivmod} but
! 826: specifically for polynomials \kbd{x} and~\kbd{y}.
! 827:
! 828: \fun{GEN}{gdeuc}{GEN x, GEN y} creates the Euclidean quotient of the
! 829: polynomials \kbd{x} and~\kbd{y}.
! 830:
! 831: \fun{GEN}{gdivround}{GEN x, GEN y} if \kbd{x} and \kbd{y} are integers,
! 832: returns the quotient $\kbd{x}/\kbd{y}$ of \kbd{x} and~\kbd{y}, rounded to
! 833: the nearest integer. If $\kbd{x}/\kbd{y}$ falls exactly halfway between
! 834: two consecutive integers, then it is rounded towards~$+\infty$ (as for
! 835: \key{round}). If \kbd{x} and \kbd{y} are not both integers, the result
! 836: is the same as that of \key{gdivent}.
! 837:
! 838: \fun{GEN}{gmod[z]}{GEN x, GEN y[, GEN z]} yields the true remainder of \kbd{x}
! 839: modulo the integer or polynomial~\kbd{y}.
! 840:
! 841: \fun{GEN}{gmodsg[z]}{long s, GEN x[, GEN z]} yields the true remainder of the
! 842: long \kbd{s} modulo the integer~\kbd{x}.
! 843:
! 844: \fun{GEN}{gmodgs[z]}{GEN x, long s[, GEN z]} yields the true remainder of the
! 845: integer \kbd{x} modulo the long~\kbd{s}.
! 846:
! 847: \fun{GEN}{gres}{GEN x, GEN y} creates the Euclidean remainder of the
! 848: polynomial \kbd{x} divided by the polynomial~\kbd{y}.
! 849:
! 850: \fun{GEN}{ginvmod}{GEN x, GEN y} creates the inverse of \kbd{x} modulo \kbd{y}
! 851: when it exists.
! 852:
! 853: \fun{GEN}{gpow}{GEN x, GEN y, long l} creates $\kbd{x}^{\kbd{y}}$. The
! 854: precision \kbd{l} is taken into account only if \kbd{y} is not an integer
! 855: and \kbd{x} is an exact object. If \kbd{y} is an integer, binary powering
! 856: is done. Otherwise, the result is $\exp(\kbd{y}*\log(\kbd{x}))$ computed
! 857: to precision~\kbd{l}.
! 858:
! 859: \fun{GEN}{ggcd}{GEN x, GEN y} creates the GCD of \kbd{x} and~\kbd{y}.
! 860:
! 861: \fun{GEN}{glcm}{GEN x, GEN y} creates the LCM of \kbd{x} and~\kbd{y}.
! 862:
! 863: \fun{GEN}{subres}{GEN x, GEN y} creates the resultant of the polynomials
! 864: \kbd{x} and~\kbd{y} computed using the subresultant algorithm.
! 865:
! 866: \fun{GEN}{gpowgs}{GEN x, long n} creates $\kbd{x}^{\kbd{n}}$ using
! 867: binary powering.
! 868:
! 869: \fun{GEN}{gsubst}{GEN x, long v, GEN y} substitutes the object \kbd{y}
! 870: into~\kbd{x} for the variable number~\kbd{v}.
! 871:
! 872: \fun{int}{gdivise}{GEN x, GEN y} returns 1 (true) if \kbd{y} divides~\kbd{x},
! 873: 0~otherwise.
! 874:
! 875: \fun{GEN}{gbezout}{GEN x, GEN y, GEN *u, GEN *v} creates the GCD of \kbd{x}
! 876: and~\kbd{y}, and puts (the adresses of) objects $u$ and~$v$ such that
! 877: $u\kbd{x}+v\kbd{y}=\gcd(\kbd{x},\kbd{y})$ into \kbd{*u} and~\kbd{*v}.
! 878: \vfill\eject
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>