modarithmeticop: Basic Modular-Arithmetic Operators for vli Objects

08. Modular-arithmeticR Documentation

Basic Modular-Arithmetic Operators for vli Objects

Description

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

Usage

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 Zn; 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)

Javier Leiva Cuadrado

Examples

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

VeryLargeIntegers documentation built on May 31, 2023, 7:06 p.m.