Residue number system

From Wikipedia, the free encyclopedia
(Redirected from Multi-modular arithmetic)
Jump to navigation Jump to search

A residue number system or residue numeral system (RNS) is a numeral system representing integers by their values modulo several pairwise coprime integers called the moduli. This representation is allowed by the Chinese remainder theorem, which asserts that, if M is the product of the moduli, there is, in an interval of length M, exactly one integer having any given set of modular values. Using a residue numeral system for arithmetic operations is also called multi-modular arithmetic.

Multi-modular arithmetic is widely used for computation with large integers, typically in linear algebra, 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, Gröbner basis computation and cryptography.

Definition

[edit | edit source]

A residue numeral system is defined by a set of k integers

{m1,m2,m3,,mk},

called the moduli, which are generally supposed to be pairwise coprime (that is, any two of them have a greatest common divisor equal to one). Residue number systems have been defined for non-coprime moduli, but are not commonly used because of worse properties.[1]

An integer x is represented in the residue numeral system by the family of its remainders (indexed by the moduli of the indexes of the moduli)

{x1,x2,x3,,xk}

under Euclidean division by the moduli. That is

xi=xmodmi,

and

0xi<mi

for every i

Let M be the product of all the mi. Two integers whose difference is a multiple of M have the same representation in the residue numeral system defined by the mis. More precisely, the Chinese remainder theorem asserts that each of the M different sets of possible residues represents exactly one residue class modulo M. That is, each set of residues represents exactly one integer X in the interval 0,,M1. For signed numbers, the dynamic range is M/2X(M1)/2 (when M is even, generally an extra negative value is represented).[2]

Arithmetic operations

[edit | edit source]

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

[m1,,mk]

is the list of moduli, the sum of the integers x and y, respectively represented by the residues [x1,,xk] and [y1,,yk], is the integer z represented by [z1,,zk], such that

zi=(xi+yi)modmi,

for i = 1, ..., k (as usual, mod denotes the modulo operation consisting of taking the remainder of the Euclidean division 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.[3]

Comparison

[edit | edit source]

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 M. It follows that testing equality is easy.

At the opposite, testing inequalities (x < y) 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 and Euclidean algorithm.

Division

[edit | edit source]

Division in residue numeral systems is problematic. On the other hand, if B is coprime with M (that is bi=0) then

C=AB1modM

can be easily calculated by

ci=aibi1modmi,

where B1 is multiplicative inverse of B modulo M, and bi1 is multiplicative inverse of bi modulo mi.

Applications

[edit | edit source]

RNS have applications in the field of digital computer arithmetic. 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

[edit | edit source]

References

[edit | edit source]
  1. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value). (xxv+641 pages)
  2. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  3. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).

Further reading

[edit | edit source]
  • Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  • Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value). (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, 94:9, 1833-1849, doi: 10.1080/00207160.2016.1247439.
  • Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  • 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, 407, 439-453, doi: 10.1016/j.neucom.2020.04.018.
  • Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value). (1+7 pages)
  • Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value). (296 pages)
  • Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value). (351 pages)
  • Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value). (389 pages)
  • Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  • Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  • Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  • Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  • Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  • Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  • Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  • Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  • Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  • Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  • 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.