package ‘gmp’package ‘gmp’ february 15, 2013 version 0.5-4 date 2013-02-04 title multiple...

39
Package ‘gmp’ February 15, 2013 Version 0.5-4 Date 2013-02-04 Title Multiple Precision Arithmetic Author Antoine Lucas, Immanuel Scholz, Rainer Boehme <[email protected]>, Sylvain Jasson <[email protected]>, Martin Maechler <[email protected]> Maintainer Antoine Lucas <[email protected]> Description Multiple Precision Arithmetic (big integers and rationals,prime number tests, matrix com- putation), ‘‘arithmetic without limitations’’ using the C library GMP (GNU Multiple Precision Arithmetic). Depends methods Suggests Rmpfr SystemRequirements gmp (>= 4.2.3) License GPL BuildResaveData no LazyDataNote not available, as we use data/*.R *and* our classes URL http://mulcyber.toulouse.inra.fr/projects/gmp Repository CRAN Date/Publication 2013-02-05 18:42:33 NeedsCompilation yes 1

Upload: others

Post on 28-Jan-2021

1 views

Category:

Documents


0 download

TRANSCRIPT

  • Package ‘gmp’February 15, 2013

    Version 0.5-4

    Date 2013-02-04

    Title Multiple Precision Arithmetic

    Author Antoine Lucas, Immanuel Scholz, Rainer Boehme, Sylvain Jasson, Martin Maechler

    Maintainer Antoine Lucas

    Description Multiple Precision Arithmetic (big integers and rationals,prime number tests, matrix com-putation), ‘‘arithmetic without limitations’’ using the C library GMP (GNU Multiple PrecisionArithmetic).

    Depends methods

    Suggests Rmpfr

    SystemRequirements gmp (>= 4.2.3)

    License GPL

    BuildResaveData no

    LazyDataNote not available, as we use data/*.R *and* our classes

    URL http://mulcyber.toulouse.inra.fr/projects/gmp

    Repository CRAN

    Date/Publication 2013-02-05 18:42:33

    NeedsCompilation yes

    1

    http://mulcyber.toulouse.inra.fr/projects/gmp

  • 2 apply

    R topics documented:apply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2asNumeric . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3Bigq . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4bigq . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5Bigq operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7bigz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8bigz operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11cumsum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12Extract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14Extremes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15factorialZ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16factorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17formatN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18frexpZ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19gcd.bigz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20gcdex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21gmp.utils . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22is.whole . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22isprime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23lucnum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25modulus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27nextprime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28Oakley . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29powm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30Random . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31Relational Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32sizeinbase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32solve.bigz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33Stirling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

    Index 37

    apply Apply Functions Over Matrix Margins (Rows or Columns)

    Description

    These are S3 methods for apply() which we re-export as S3 generic function. They “overload”the apply() function for big rationals ("bigq") and big integers ("bigz").

    Usage

    ## S3 method for class ’bigz’apply(X, MARGIN, FUN, ...)## S3 method for class ’bigq’apply(X, MARGIN, FUN, ...)

  • asNumeric 3

    Arguments

    X a matrix of class bigz or bigq, see e.g., matrix.bigz.

    MARGIN 1: apply function to rows; 2: apply function to columns

    FUN function to be applied

    ... (optional) extra arguments for FUN(), as e.g., in lapply.

    Value

    The bigz and bigq methods return a vector of class "bigz" or "bigq", respectively.

    Author(s)

    Antoine Lucas

    See Also

    apply; lapply is used by our apply() method.

    Examples

    x

  • 4 Bigq

    Value

    an R object of type (typeof) "numeric", a matrix or array if x had non-NULL dimension dim().

    Methods

    signature(x = "ANY") the default method, which is the identity for numeric array.

    signature(x = "bigq") the method for big rationals.

    signature(x = "bigq") the method for big integers.

    Note that package Rmpfr provides methods for its number-like objects.

    Author(s)

    Martin Maechler

    See Also

    as.numeric coerces to both "numeric" and to a vector, whereas asNumeric() should keep dim(and other) attributes.

    Examples

    m

  • bigq 5

    e1 >= e2## S3 method for class ’bigq’e1 > e2## S3 method for class ’bigq’e1 != e2

    Arguments

    x, e1, e2 Object or vector of class bigq

    Examples

    x

  • 6 bigq

    ... additional arguments passed to methods

    quote (for printing:) logical indicating if the numbers should be quoted (as charactersare); the default used to be TRUE (implicitly) till 2011.

    initLine (for printing:) logical indicating if an initial line (with the class and length ordimension) should be printed.

    Details

    as.bigz.bigq() returns the smallest integers not less than the corresponding rationals bigq.

    Value

    An R object of (S3) class "bigq" representing the parameter value.

    Author(s)

    Antoine Lucas

    References

    http://mulcyber.toulouse.inra.fr/projects/gmp/

    Examples

    x

  • Bigq operators 7

    Bigq operators Basic arithmetic operators for large rationals

    Description

    Addition, subtraction, multiplication, division, and absolute value for large rationals, i.e. "bigq"class R objects.

    Usage

    add.bigq(e1, e2)## S3 method for class ’bigq’e1 + e2

    sub.bigq(e1, e2=NULL)## S3 method for class ’bigq’e1 - e2

    mul.bigq(e1, e2)## S3 method for class ’bigq’e1 * e2

    div.bigq(e1, e2)## S3 method for class ’bigq’e1 / e2

    ## S3 method for class ’bigq’e1 ^ e2

    ## S3 method for class ’bigq’abs(x)

    Arguments

    e1,e2, x of class "bigq", or (e1 and e2) integer or string from an integer

    Details

    Operators can be use directly when the objects are of class "bigq": a + b, a * b, etc, and a ^ n,where n must be coercable to a biginteger ("bigz").

    Value

    A bigq class representing the result of the arithmetic operation.

    Author(s)

    Immanuel Scholz and Antoine Lucas

  • 8 bigz

    References

    http://mulcyber.toulouse.inra.fr/projects/gmp/

    Examples

    ## 1/3 + 1 = 4/3 :as.bigq(1,3) + 1

    r

  • bigz 9

    Details

    Bigz’s are integers of arbitrary, but given length (means: only restricted by the host memory).Basic arithmetic operations can be performed on bigzs as addition, subtraction, multiplication, divi-sion, modulation (remainder of division), power, multiplicative inverse, calculating of the greatestcommon divisor, test whether the integer is prime and other operations needed when performingstandard cryptographic operations.

    For a review of basic arithmetics, see add.bigz.

    Comparison are supported, i.e., "==", "!=", "=".

    Objects of class "bigz" may have an attribute mod which specifies a modulus that is applied aftereach arithmetic operation. When the object has such a modulus m, all arithmetic is performed“modulo m”, i.e.,

    result

  • 10 bigz

    References

    The GNU MP Library, see http://gmplib.org

    Examples

    ## 1+1=2a

  • bigz operators 11

    bigz operators Basic Arithmetic Operators for Large Integers ("bigz")

    Description

    Addition, substraction, multiplication, (integer) division, remainder of division, multiplicative in-verse, power and logarithm functions.

    Usage

    add.bigz(e1, e2)sub.bigz(e1, e2 = NULL)mul.bigz(e1, e2)div.bigz(e1, e2)divq.bigz(e1,e2) ## == e1 %/% e2mod.bigz(e1, e2) ## == e1 %% e2## S3 method for class ’bigz’abs(x)

    inv.bigz(a, b,...)## == (1 / a) (modulo b)

    pow.bigz(e1, e2,...)## == e1 ^ e2

    ## S3 method for class ’bigz’log(x, base=exp(1))## S3 method for class ’bigz’log2(x)## S3 method for class ’bigz’log10(x)

    Arguments

    x bigz, integer or string from an integer

    e1, e2, a,b bigz, integer or string from an integer

    base base of the logarithm; base e as default

    ... Additional parameters

    Details

    For details about the internal modulus state, see the manpage of bigz.

    div or "/" return a rational number; divq or "%/%" return the quotient of integer division.

    Operators can be used directly when objects are of class bigz: a + b, log(a), etc.

    Value

    A bigz class representing the result of the arithmetic operation.

  • 12 cumsum

    Author(s)

    Immanuel Scholz and Antoine Lucas

    References

    The GNU MP Library, see http://gmplib.org

    Examples

    # 1+1=2as.bigz(1) + 1as.bigz(2)^10as.bigz(2)^200

    # if my.large.num.string is set to a number, this returns the least byte(my.large.num.string 1 (mod 11)inv.bigz(7, 11)## hence, 8a

  • cumsum 13

    Usage

    ## S3 method for class ’bigz’cumsum(x)## S3 method for class ’bigq’cumsum(x)## S3 method for class ’bigz’sum(..., na.rm = FALSE)## S3 method for class ’bigq’sum(..., na.rm = FALSE)## S3 method for class ’bigz’prod(..., na.rm = FALSE)## S3 method for class ’bigq’prod(..., na.rm = FALSE)

    Arguments

    x, ... R objects of class bigz or bigq or ‘simple’ numbers.

    na.rm logical indicating if missing values (NA) should be removed before the compu-tation.

    Value

    return an element of class bigz or bigq.

    Author(s)

    Antoine Lucas

    See Also

    apply

    Examples

    x

  • 14 Extract

    Extract Extract or Replace Parts of an Object

    Description

    Operators acting on vectors, arrays and lists to extract or replace subsets.

    Usage

    ## S3 method for class ’bigz’c(..., recursive = FALSE)## S3 method for class ’bigq’c(..., recursive = FALSE)## S3 method for class ’bigz’rep(x,times, ...)## S3 method for class ’bigq’rep(x,times, ...)

    Arguments

    x R object of class "bigz" or "bigq", respectively.

    ... further arguments, notably for c().

    times integer

    recursive unused here

    Note

    Unlike standard matrices, x[i] and x[i,] do the same.

    Examples

    a extends the vectors (filling with NA)a[2]

  • Extremes 15

    m[-c(2,3),]m[-c(2,3)]m[c(TRUE,FALSE,FALSE)]

    ##_modification on matrixm[2,-1]

  • 16 factorialZ

    Examples

    x

  • factorization 17

    system.time(replicate(8, f1e4

  • 18 formatN

    formatN Format Numbers Keeping Classes Distinguishable

    Description

    Format (generalized) numbers in a way that their classes are distinguishable. Contrary to format()which uses a common format for all elements of x, here, each entry is formatted individually.

    Usage

    formatN(x, ...)## Default S3 method:formatN(x, ...)## S3 method for class ’integer’formatN(x, ...)## S3 method for class ’double’formatN(x, ...)## S3 method for class ’bigz’formatN(x, ...)## S3 method for class ’bigq’formatN(x, ...)

    Arguments

    x any R object, typically “number-like”.

    ... potentially further arguments passed to methods.

    Value

    a character vector of the same length as x, each entry a representation of the corresponding entryin x.

    Author(s)

    Martin Maechler

    See Also

    format, including its (sophisticated) default method; as.character.

    Examples

    ## Note that each class is uniquely recognizable from its output:formatN( -2:5)# integerformatN(0 + -2:5)# double precisionformatN(as.bigz(-2:5))formatN(as.bigq(-2:5, 4))

  • frexpZ 19

    frexpZ Split Number into Fractional and Exponent of 2 Parts

    Description

    Breaks the number x into its binary significand (“fraction”) d ∈ [0.5, 1) and ex, the integral expo-nent for 2, such that x = d · 2ex.If x is zero, both parts (significand and exponent) are zero.

    Usage

    frexpZ(x)

    Arguments

    x integer or big integer (bigz).

    Value

    a list with the two components

    d a numeric vector whose absolute values are either zero, or in [ 12 , 1).

    exp an integer vector of the same length; note that exp == 1 + floor(log2(x)),and hence always exp > log2(x).

    Author(s)

    Martin Maechler

    See Also

    log2, etc; for bigz objects built on (the C++ equivalent of) frexp(), actually GMP’s ‘mpz_get_d_2exp()’.

    Examples

    frexpZ(1:10)## and confirm :with(frexpZ(1:10), d * 2^exp)x

  • 20 gcd.bigz

    gcd.bigz Greatest Common Divisor, Least Common Multiple

    Description

    Compute the greatest common divisor (GCD) and least common multiple (LCD) of two (big) inte-gers.

    Usage

    ## S3 method for class ’bigz’gcd(a, b)lcm.bigz(a, b)

    Arguments

    a,b Either integer, numeric, bigz or a string value; if a string, either starting with 0xfor hexadecimal, 0b for binary or without prefix for decimal values.

    Value

    An element of class bigz

    Author(s)

    Antoine Lucas

    References

    The GNU MP Library, see http://gmplib.org

    See Also

    gcdex

    Examples

    gcd.bigz(210,342) # or alsolcm.bigz(210,342)a

  • gcdex 21

    gcdex Compute Bezoult coefficient

    Description

    Compute g,s,t as as+ bt = g = gcd(a, b). s and t are also known as Bezoult coefficients.

    Usage

    gcdex(a, b)

    Arguments

    a,b Either integer, numeric or string value (String value: ither starting with 0x forhexadecimal, 0b for binary or without prefix for decimal values.) Or an elementof class bigz.

    Value

    3 values:

    g,s,t Elements of class bigz

    Author(s)

    Antoine Lucas

    References

    The GNU MP Library, see http://gmplib.org

    See Also

    gcd.bigz

    Examples

    gcdex(342,654)

    http://gmplib.org

  • 22 is.whole

    gmp.utils GMP Number Utilities

    Description

    gmpVersion() returns the version of the GMP library which gmp is currently linked to.

    Usage

    gmpVersion()

    References

    The GNU MP Library, see http://gmplib.org

    Examples

    gmpVersion()

    is.whole Whole ("Integer") Numbers

    Description

    Check which elements of x[] are integer valued aka “whole” numbers.

    Usage

    is.whole(x)## Default S3 method:is.whole(x)## S3 method for class ’bigz’is.whole(x)## S3 method for class ’bigq’is.whole(x)

    Arguments

    x any R vector

    Value

    logical vector of the same length as x, indicating where x[.] is integer valued.

    Author(s)

    Martin Maechler

    http://gmplib.org

  • isprime 23

    See Also

    is.integer(x) (base package) checks for the internal mode or class; not if x[i] are integer valued.

    The is.whole() method for "mpfr" numbers.

    Examples

    is.integer(3) # FALSE, it’s internally a doubleis.whole(3) # TRUE## integer valued complex numbers (two FALSE) :is.whole(c(7, 1 + 1i, 1.2, 3.4i, 7i))is.whole(factorialZ(20)^(10:12)) ## "bigz" are *always* whole numbersq

  • 24 lucnum

    Author(s)

    Antoine Lucas

    References

    The GNU MP Library, see http://gmplib.org

    See Also

    nextprime, factorize.

    Note that for “small” n, which means something like n < 10′000′000, non-probabilistic methods(such as factorize()) are fast enough. For example, primes in package sfsmisc.

    Examples

    isprime(210)isprime(71)

    # All primes numbers from 1 to 100t 0]

    table(isprime(1:10000))# 0 and 2 : surely prime or not prime

    primes

  • matrix 25

    Description

    fibnum compute n-th Fibonacci number. fibnum2 compute (n-1)-th and n-th Fibonacci number.lucnum compute n-th lucas number. lucnum2 compute (n-1)-th and n-th lucas number.

    Fibonacci numbers are define by: Fn = Fn−1 + Fn−2 Lucas numbers are define by: Ln = Fn +2Fn−1

    Usage

    fibnum(n)fibnum2(n)lucnum(n)lucnum2(n)

    Arguments

    n Integer

    Value

    Fibonacci numbers and Lucas number.

    Author(s)

    Antoine Lucas

    References

    The GNU MP Library, see http://gmplib.org

    Examples

    fibnum(10)fibnum2(10)lucnum(10)lucnum2(10)

    matrix Matrix manipulation with gmp

    Description

    Overload of “all” standard tools useful for matrix manipulation adapted to large numbers.

    http://gmplib.org

  • 26 matrix

    Usage

    ## S3 method for class ’bigz’matrix(data = NA, nrow = 1, ncol = 1, byrow = FALSE, dimnames = NULL, mod = NA,...)

    ## S3 method for class ’bigz’x %*% y## S3 method for class ’bigq’x %*% y## S3 method for class ’bigq’crossprod(x, y=NULL)## S3 method for class ’bigz’tcrossprod(x, y=NULL)## ..... etc

    Arguments

    data an optional data vectornrow the desired number of rowsncol the desired number of columnsbyrow logical. If FALSE (the default), the matrix is filled by columns, otherwise the

    matrix is filled by rows.dimnames not implemented for "bigz" or "bigq" matrices.mod optional modulus (when data is "bigz").... Not usedx,y numeric, bigz, or bigq matrices or vectors.

    Details

    Extract function is the same use for vector or matrix. Then, x[i] return same value as x[i,].

    Special features concerning the "bigz" class: the modulus can be

    Unset: Just play with large numbersSet with a vector of size 1: Example: matrix.bigz(1:6,nrow=2,ncol=3,mod=7) This means you

    work in Z/nZ, for the whole matrix. It is the only case where the %*% and solve functionswill work in Z/nZ.

    Set with a vector smaller than data: Example: matrix.bigz(1:6,nrow=2,ncol=3,mod=1:5). Then,the modulus is repeated to the end of data. This can be used to define a matrix with a differentmodulus at each row.

    Set with same size as data: Modulus is defined for each cell

    Value

    A matrix of class bigz or bigq

    Author(s)

    Antoine Lucas

  • modulus 27

    See Also

    Solving linear algebra system solve.bigz; matrix

    Examples

    V

  • 28 nextprime

    Description

    The modulus of a bigz number a is “unset” when a is a regular integer, a ∈ Z). Or the moduluscan be set to m which means a ∈ Z/m · Z), i.e., all arithmetic with a is performed ‘modulo m’.

    Usage

    modulus(a)modulus(a)

  • Oakley 29

    Details

    This function uses probabilistic algorithm to identify primes. For practical purposes, it is adequate,the chance of a composite passing will be extremely small.

    Value

    A (probably) prime number

    Author(s)

    Antoine Lucas

    References

    The GNU MP Library, see http://gmplib.org

    See Also

    isprime and its references and examples.

    Examples

    nextprime(14)## still very fast:(p

  • 30 powm

    References

    The Internet Key Exchange (RFC 2409), Nov. 1998

    Examples

    packageDescription("gmp") # {possibly useful for debugging}

    data(Oakley1)(M1

  • Random 31

    Examples

    powm(4,7,9)

    x = as.bigz(4,9)x ^ 7

    Random Generate a random number

    Description

    Generate a uniformly distributed random number in the range 0 to 2size − 1, inclusive.

    Usage

    urand.bigz(nb=1,size=200, seed = 0)

    Arguments

    nb Integer: number of random numbers to be generated (size of vector returned)size Integer: number will be generated in the range 0 to 2size − 1seed Bigz: random seed initialisation

    Value

    A biginteger of class bigz.

    Author(s)

    Antoine Lucas

    References

    ‘mpz_urandomb’ from the GMP Library, see http://gmplib.org

    Examples

    # Integers are differentsurand.bigz()urand.bigz()urand.bigz()

    # Integers are the sameurand.bigz(seed="234234234324323")urand.bigz(seed="234234234324323")

    # Vectorurand.bigz(nb=50,size=30)

    http://gmplib.org

  • 32 sizeinbase

    Relational Operator Relational Operators

    Description

    Binary operators which allow the comparison of values in atomic vectors.

    Usage

    ## S3 method for class ’bigz’sign(x)## S3 method for class ’bigz’e1 == e2## S3 method for class ’bigz’e1 < e2

    ## S3 method for class ’bigz’e1 >= e2

    Arguments

    x, e1, e2 R object (vector or matrix-like) of class "bigz".

    See Also

    mod.bigz for arithmetic operators.

    Examples

    x

  • solve.bigz 33

    Arguments

    a big integer, i.e. "bigz"

    b base

    Value

    integer of the same length as a: the size, i.e. number of digits, of each a[i].

    Author(s)

    Antoine Lucas

    References

    The GNU MP Library, see http://gmplib.org

    Examples

    sizeinbase(342434, 10)# 6 obviously

    Iv

  • 34 Stirling

    Details

    It uses the Gauss and trucmuch algo . . . (to be detailled).

    Value

    If a and b are rational, return is a rational matrix.

    If a and b are big integers (of class bigz) solution is in Z/nZ if there is a common modulus, of arational matrix if not.

    Author(s)

    Antoine Lucas

    See Also

    solve

    Examples

    x

  • Stirling 35

    Usage

    Stirling1(n, k)Stirling2(n, k, method = c("lookup.or.store", "direct"))Eulerian (n, k, method = c("lookup.or.store", "direct"))

    Stirling1.all(n)Stirling2.all(n)Eulerian.all (n)

    Arguments

    n positive integer (0 is allowed for Eulerian()).

    k integer in 0:n.

    method for Eulerian() and Stirling2(), string specifying the method to be used."direct" uses the explicit formula (which may suffer from some cancelationfor “large” n).

    Details

    Eulerian numbers:A(n, k) = the number of permutations of 1,2,. . . ,n with exactly k ascents (or exactly k descents).

    Stirling numbers of the first kind:s(n,k) = (-1)^n-k times the number of permutations of 1,2,. . . ,n with exactly k cycles.

    Stirling numbers of the second kind:S(k)n is the number of ways of partitioning a set of n elements into k non-empty subsets.

    Value

    A(n, k), s(n, k) or S(n, k) = S(k)n , respectively.

    Eulerian.all(n) is the same as sapply(0:(n-1), Eulerian, n=n) (for n > 0),Stirling1.all(n) is the same as sapply(1:n, Stirling1, n=n), andStirling2.all(n) is the same as sapply(1:n, Stirling2, n=n), but more efficient.

    Note

    For typical double precision arithmetic,Eulerian*(n, *) overflow (to Inf) for n ≥ 172,Stirling1*(n, *) overflow (to ±Inf) for n ≥ 171, andStirling2*(n, *) overflow (to Inf) for n ≥ 220.

    Author(s)

    Martin Maechler ("direct": May 1992)

  • 36 Stirling

    References

    Eulerians:NIST Digital Library of Mathematical Functions, 26.14: http://dlmf.nist.gov/26.14

    Stirling numbers:Abramowitz and Stegun 24,1,4 (p. 824-5 ; Table 24.4, p.835); Closed Form : p.824 "C."

    NIST Digital Library of Mathematical Functions, 26.8: http://dlmf.nist.gov/26.8

    See Also

    chooseZ for the binomial coefficients.

    Examples

    Stirling1(7,2)Stirling2(7,3)

    stopifnot(Stirling1.all(9) == c(40320, -109584, 118124, -67284, 22449, -4536, 546, -36, 1),Stirling2.all(9) == c(1, 255, 3025, 7770, 6951, 2646, 462, 36, 1),Eulerian.all(7) == c(1, 120, 1191, 2416, 1191, 120, 1)

    )

    http://dlmf.nist.gov/26.14http://dlmf.nist.gov/26.8

  • Index

    !=.bigq (Bigq), 4!=.bigz (Relational Operator), 32∗Topic arithmetic

    Stirling, 34∗Topic arith

    apply, 2asNumeric, 3Bigq, 4bigq, 5Bigq operators, 7bigz, 8bigz operators, 11cumsum, 12Extract, 14Extremes, 15factorialZ, 16factorization, 17frexpZ, 19gcd.bigz, 20gcdex, 21gmp.utils, 22isprime, 23lucnum, 24matrix, 25modulus, 27nextprime, 28powm, 30Random, 31Relational Operator, 32sizeinbase, 32solve.bigz, 33

    ∗Topic characterformatN, 18

    ∗Topic dataOakley, 29

    ∗Topic mathis.whole, 22

    ∗Topic methodsasNumeric, 3

    ∗Topic printformatN, 18

    *.bigq (Bigq operators), 7*.bigz (bigz operators), 11+.bigq (Bigq operators), 7+.bigz (bigz operators), 11-.bigq (Bigq operators), 7-.bigz (bigz operators), 11/.bigq (Bigq operators), 7/.bigz (bigz operators), 11=.bigz (Relational Operator), 32[.bigq (Extract), 14[.bigz (Extract), 14[

  • 38 INDEX

    array, 4as.bigq (bigq), 5as.bigz (bigz), 8as.bigz.bigq (bigq), 5as.character, 18as.character.bigq (bigq), 5as.character.bigz (bigz), 8as.double.bigq (bigq), 5as.double.bigz (bigz), 8as.matrix.bigq (matrix), 25as.matrix.bigz (matrix), 25as.numeric, 4as.vector.bigq (matrix), 25as.vector.bigz (matrix), 25asNumeric, 3asNumeric,ANY-method (asNumeric), 3asNumeric,bigq-method (asNumeric), 3asNumeric,bigz-method (asNumeric), 3asNumeric-methods (asNumeric), 3

    biginteger_as (bigz), 8biginteger_as_character (bigz), 8Bigq, 4bigq, 5, 5, 7Bigq operators, 7bigz, 3, 7, 8, 11, 16, 19, 20, 26, 28, 29, 32, 33bigz operators, 11

    c.bigq (Extract), 14c.bigz (Extract), 14cbind.bigq (matrix), 25cbind.bigz (matrix), 25character, 8chooseZ, 36chooseZ (factorialZ), 16class, 18crossprod (matrix), 25cumsum, 12, 12

    denominator (bigq), 5denominator

  • INDEX 39

    matrix, 4, 25, 27matrix.bigz, 3max, 15max.bigq (Extremes), 15max.bigz (Extremes), 15methods, 2, 15min, 15min.bigq (Extremes), 15min.bigz (Extremes), 15mod.bigz, 9, 32mod.bigz (bigz operators), 11modulus, 27modulus