modarithmeticop: Basic Modular-Arithmetic Operators for vli Objects In VeryLargeIntegers: Store and Operate with Arbitrarily Large Integers

Description

Basic modular-arithmetic operators for vli (Very Large Integers) objects.

Usage

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65``` ```summod(x, y, mod) ## Default S3 method: summod(x, y, mod) ## S3 method for class 'numeric' summod(x, y, mod) ## S3 method for class 'vli' summod(x, y, mod) submod(x, y, mod) ## Default S3 method: submod(x, y, mod) ## S3 method for class 'numeric' submod(x, y, mod) ## S3 method for class 'vli' submod(x, y, mod) mulmod(x, y, mod) ## Default S3 method: mulmod(x, y, mod) ## S3 method for class 'numeric' mulmod(x, y, mod) ## S3 method for class 'vli' mulmod(x, y, mod) powmod(x, n, mod) ## Default S3 method: powmod(x, n, mod) ## S3 method for class 'numeric' powmod(x, n, mod) ## S3 method for class 'vli' powmod(x, n, mod) invmod(x, n) ## Default S3 method: invmod(x, n) ## S3 method for class 'numeric' invmod(x, n) ## S3 method for class 'vli' invmod(x, n) divmod(x, y, mod) ## Default S3 method: divmod(x, y, mod) ## S3 method for class 'numeric' divmod(x, y, mod) ## S3 method for class 'vli' divmod(x, y, mod) ```

Arguments

 `x` vli class object or 32 bits integer `y` vli class object or 32 bits integer `mod` vli class object or 32 bits integer `n` vli class object or 32 bits integer

Details

The functions `summod`, `submod` and `mulmod` compute respectively the sum, the substraction and the multiplication of `x` and `y` under modulo `mod`.

The function `powmod` computes the `n`-th power of `x` under modulo `mod`.

The function `invmod` returns the modular multiplicative inverse of `x` in Z`n`; that is, `y = x^(-1)` such that ` x * y = 1 (`mod` n)`.

The function `divmod` returns the modular division of `x` over `y`; that is, `z` such that `y * z (`mod `mod) = x (`mod `mod)`.

Value

object of class vli

Author(s)

 ``` 1 2 3 4 5 6 7 8 9 10``` ```x <- as.vli("8925378246957826904701") y <- as.vli("347892325634785693") mod <- as.vli(21341) summod(x, y, mod) mulmod(x, invmod(x, n = 123), mod = 123) == 1 z <- divmod(x, y, mod) mulmod(z, y, mod) == x %% mod ```