Multi-modular Arithmetic
   HOME

TheInfoList



OR:

A residue number system or residue numeral system (RNS) is a
numeral system A numeral system is a writing system for expressing numbers; that is, a mathematical notation for representing numbers of a given set, using digits or other symbols in a consistent manner. The same sequence of symbols may represent differe ...
representing
integer An integer is the number zero (0), a positive natural number (1, 2, 3, ...), or the negation of a positive natural number (−1, −2, −3, ...). The negations or additive inverses of the positive natural numbers are referred to as negative in ...
s by their values
modulo In computing and mathematics, the modulo operation returns the remainder or signed remainder of a division, after one number is divided by another, the latter being called the '' modulus'' of the operation. Given two positive numbers and , mo ...
several
pairwise coprime In number theory, two integers and are coprime, relatively prime or mutually prime if the only positive integer that is a divisor of both of them is 1. Consequently, any prime number that divides does not divide , and vice versa. This is equiva ...
integers called the moduli. This representation is allowed by the
Chinese remainder theorem In mathematics, the Chinese remainder theorem states that if one knows the remainders of the Euclidean division of an integer ''n'' by several integers, then one can determine uniquely the remainder of the division of ''n'' by the product of thes ...
, which asserts that, if is the product of the moduli, there is, in an interval of length , exactly one integer having any given set of modular values. Using a residue numeral system for
arithmetic operations Arithmetic is an elementary branch of mathematics that deals with numerical operations like addition, subtraction, multiplication, and Division (mathematics), division. In a wider sense, it also includes exponentiation, extraction of nth root, ...
is also called multi-modular arithmetic. Multi-modular arithmetic is widely used for computation with large integers, typically in
linear algebra Linear algebra is the branch of mathematics concerning linear equations such as :a_1x_1+\cdots +a_nx_n=b, linear maps such as :(x_1, \ldots, x_n) \mapsto a_1x_1+\cdots +a_nx_n, and their representations in vector spaces and through matrix (mathemat ...
, because it provides faster computation than with the usual numeral systems, even when the time for converting between numeral systems is taken into account. Other applications of multi-modular arithmetic include
polynomial greatest common divisor In algebra, the greatest common divisor (frequently abbreviated as GCD) of two polynomials is a polynomial, of the highest possible degree, that is a factor of both the two original polynomials. This concept is analogous to the greatest common d ...
,
Gröbner basis In mathematics, and more specifically in computer algebra, computational algebraic geometry, and computational commutative algebra, a Gröbner basis is a particular kind of generating set of an ideal in a polynomial ring K _1,\ldots,x_n/math> ove ...
computation and
cryptography Cryptography, or cryptology (from "hidden, secret"; and ''graphein'', "to write", or ''-logy, -logia'', "study", respectively), is the practice and study of techniques for secure communication in the presence of Adversary (cryptography), ...
.


Definition

A residue numeral system is defined by a set of integers :\, called the ''moduli'', which are generally supposed to be
pairwise coprime In number theory, two integers and are coprime, relatively prime or mutually prime if the only positive integer that is a divisor of both of them is 1. Consequently, any prime number that divides does not divide , and vice versa. This is equiva ...
(that is, any two of them have a
greatest common divisor In mathematics, the greatest common divisor (GCD), also known as greatest common factor (GCF), of two or more integers, which are not all zero, is the largest positive integer that divides each of the integers. For two integers , , the greatest co ...
equal to one). Residue number systems have been defined for non-coprime moduli, but are not commonly used because of worse properties. An integer is represented in the residue numeral system by the
family Family (from ) is a Social group, group of people related either by consanguinity (by recognized birth) or Affinity (law), affinity (by marriage or other relationship). It forms the basis for social order. Ideally, families offer predictabili ...
of its remainders (indexed by the moduli of the indexes of the moduli) :\ under
Euclidean division In arithmetic, Euclidean division – or division with remainder – is the process of dividing one integer (the dividend) by another (the divisor), in a way that produces an integer quotient and a natural number remainder strictly smaller than ...
by the moduli. That is : x_i = x \operatornamem_i, and :0\le x_i for every Let be the product of all the m_i. Two integers whose difference is a multiple of have the same representation in the residue numeral system defined by the s. More precisely, the
Chinese remainder theorem In mathematics, the Chinese remainder theorem states that if one knows the remainders of the Euclidean division of an integer ''n'' by several integers, then one can determine uniquely the remainder of the division of ''n'' by the product of thes ...
asserts that each of the different sets of possible residues represents exactly one
residue class In mathematics, modular arithmetic is a system of arithmetic operations for integers, other than the usual ones from elementary arithmetic, where numbers "wrap around" when reaching a certain value, called the modulus. The modern approach to mod ...
modulo . That is, each set of residues represents exactly one integer X in the interval 0,\dots,M-1. For signed numbers, the dynamic range is \le X \le \lfloor (M-1)/2 \rfloor (when M is even, generally an extra negative value is represented).


Arithmetic operations

For adding, subtracting and multiplying numbers represented in a residue number system, it suffices to perform the same modular operation on each pair of residues. More precisely, if : _1, \ldots, m_k/math> is the list of moduli, the sum of the integers and , respectively represented by the residues _1,\ldots, x_k/math> and _1,\ldots, y_k is the integer represented by _1,\ldots, z_k such that :z_i= (x_i+y_i)\operatorname m_i, for (as usual, mod denotes the
modulo operation In computing and mathematics, the modulo operation returns the remainder or signed remainder of a Division (mathematics), division, after one number is divided by another, the latter being called the ''modular arithmetic, modulus'' of the operatio ...
consisting of taking the remainder of the
Euclidean division In arithmetic, Euclidean division – or division with remainder – is the process of dividing one integer (the dividend) by another (the divisor), in a way that produces an integer quotient and a natural number remainder strictly smaller than ...
by the right operand). Subtraction and multiplication are defined similarly. For a succession of operations, it is not necessary to apply the modulo operation at each step. It may be applied at the end of the computation, or, during the computation, for avoiding overflow of hardware operations. However, operations such as magnitude comparison, sign computation, overflow detection, scaling, and division are difficult to perform in a residue number system.


Comparison

If two integers are equal, then all their residues are equal. Conversely, if all residues are equal, then the two integers are equal or differ by a multiple of . It follows that testing equality is easy. At the opposite, testing inequalities () is difficult and, usually, requires to convert integers to the standard representation. As a consequence, this representation of numbers is not suitable for algorithms using inequality tests, such as
Euclidean division In arithmetic, Euclidean division – or division with remainder – is the process of dividing one integer (the dividend) by another (the divisor), in a way that produces an integer quotient and a natural number remainder strictly smaller than ...
and
Euclidean algorithm In mathematics, the Euclidean algorithm,Some widely used textbooks, such as I. N. Herstein's ''Topics in Algebra'' and Serge Lang's ''Algebra'', use the term "Euclidean algorithm" to refer to Euclidean division or Euclid's algorithm, is a ...
.


Division

Division in residue numeral systems is problematic. On the other hand, if B is coprime with M (that is b_i\not =0) then :C=A\cdot B^ \mod M can be easily calculated by :c_i=a_i \cdot b_i^ \mod m_i, where B^ is
multiplicative inverse In mathematics, a multiplicative inverse or reciprocal for a number ''x'', denoted by 1/''x'' or ''x''−1, is a number which when Multiplication, multiplied by ''x'' yields the multiplicative identity, 1. The multiplicative inverse of a ra ...
of B modulo M, and b_i^ is multiplicative inverse of b_i modulo m_i.


Applications

RNS have applications in the field of
digital Digital usually refers to something using discrete digits, often binary digits. Businesses *Digital bank, a form of financial institution *Digital Equipment Corporation (DEC) or Digital, a computer company *Digital Research (DR or DRI), a software ...
computer arithmetic Computer arithmetic is the scientific field that deals with representation of numbers on computers and corresponding implementations of the arithmetic operations. It includes: *Fixed-point arithmetic *Floating-point arithmetic *Interval arithmet ...
. By decomposing in this a large integer into a set of smaller integers, a large calculation can be performed as a series of smaller calculations that can be performed independently and in parallel.


See also

*
Covering system In mathematics, a covering system (also called a complete residue system) is a collection :\ of finitely many residue classes : a_i\pmod = \, whose union contains every integer. Examples and definitions The notion of covering system was i ...
*
Reduced residue system In mathematics, a subset ''R'' of the integers is called a reduced residue system modulo ''n'' if: #gcd(''r'', ''n'') = 1 for each ''r'' in ''R'', #''R'' contains φ(''n'') elements, #no two elements of ''R'' are congruent modulo ''n''. Here φ ...


References


Further reading

* * (viii+418+6 pages) *Chervyakov, N. I.; Molahosseini, A. S.; Lyakhov, P. A. (2017)
Residue-to-binary conversion for general moduli sets based on approximate Chinese remainder theorem
International Journal of Computer Mathematics The ''International Journal of Computer Mathematics'' is a monthly peer-reviewed scientific journal covering numerical analysis and scientific computing. It was established in 1964 and is published by Taylor & Francis. The editors-in-chief are Choi ...
, 94:9, 1833-1849, doi: 10.1080/00207160.2016.1247439. * *Chervyakov, N. I.; Lyakhov, P. A.; Deryabin, M. A. (2020)
Residue Number System-Based Solution for Reducing the Hardware Cost of a Convolutional Neural Network
Neurocomputing Computational neuroscience (also known as theoretical neuroscience or mathematical neuroscience) is a branch of neuroscience which employs mathematics, computer science, theoretical analysis and abstractions of the brain to understand the ...
, 407, 439-453, doi: 10.1016/j.neucom.2020.04.018. * (1+7 pages) * (296 pages) * (351 pages) * (389 pages) * * * * * * * * * * {{cite journal , author-last1=Yokoyama , author-first1=Kazuhiro , author-last2=Noro , author-first2=Masayuki , author-last3=Takeshima , author-first3=Taku , date=1994 , title=Multi-Modular Approach to Polynomial-Time Factorization of Bivariate Integral Polynomials , journal=
Journal of Symbolic Computation The ''Journal of Symbolic Computation'' is a Peer review, peer-reviewed monthly scientific journal covering all aspects of symbolic computation published by Academic Press and then by Elsevier. It is targeted to both mathematicians and computer sc ...
, volume=17 , issue=6 , pages=545–563, doi=10.1006/jsco.1994.1034 , doi-access=free *Isupov, Konstantin (2021). "High-Performance Computation in Residue Number System Using Floating-Point Arithmetic".
Computation
'. 9 (2): 9
doi:10.3390/computation9020009
ISSN 2079-3197. Modular arithmetic Computer arithmetic