Misplaced Pages

Residue number system

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
(Redirected from Residue numeral system) Multi-modular arithmetic
This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these messages)
This article is missing information about many aspects of the subject (see the talk page). Please expand the article to include this information. Further details may exist on the talk page. (July 2018)
This article relies largely or entirely on a single source. Relevant discussion may be found on the talk page. Please help improve this article by introducing citations to additional sources.
Find sources: "Residue number system" – news · newspapers · books · scholar · JSTOR (July 2018)
This article includes a list of references, related reading, or external links, but its sources remain unclear because it lacks inline citations. Please help improve this article by introducing more precise citations. (July 2018) (Learn how and when to remove this message)

(Learn how and when to remove this message)

A 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

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

{ m 1 , m 2 , m 3 , , m k } , {\displaystyle \{m_{1},m_{2},m_{3},\ldots ,m_{k}\},}

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. Therefore, they will not be considered in the remainder of this article.

An integer x is represented in the residue numeral system by the set of its remainders

{ x 1 , x 2 , x 3 , , x k } {\displaystyle \{x_{1},x_{2},x_{3},\ldots ,x_{k}\}}

under Euclidean division by the moduli. That is

x i = x mod m i , {\displaystyle x_{i}=x\operatorname {mod} m_{i},}

and

0 x i < m i {\displaystyle 0\leq x_{i}<m_{i}}

for every i

Let M be the product of all the m i {\displaystyle m_{i}} . 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 {\displaystyle X} in the interval 0 , , M 1 {\displaystyle 0,\dots ,M-1} . For signed numbers, the dynamic range is M / 2 X ( M 1 ) / 2 {\textstyle {-\lfloor M/2\rfloor }\leq X\leq \lfloor (M-1)/2\rfloor } (when M {\displaystyle 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

[ m 1 , , m k ] {\displaystyle }

is the list of moduli, the sum of the integers x and y, respectively represented by the residues [ x 1 , , x k ] {\displaystyle } and [ y 1 , , y k ] , {\displaystyle ,} is the integer z represented by [ z 1 , , z k ] , {\displaystyle ,} such that

z i = ( x i + y i ) mod m i , {\displaystyle z_{i}=(x_{i}+y_{i})\operatorname {mod} m_{i},}

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.

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 their differences is 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

Division in residue numeral systems is problematic. On the other hand, if B {\displaystyle B} is coprime with M {\displaystyle M} (that is b i 0 {\displaystyle b_{i}\not =0} ) then

C = A B 1 mod M {\displaystyle C=A\cdot B^{-1}\mod M}

can be easily calculated by

c i = a i b i 1 mod m i , {\displaystyle c_{i}=a_{i}\cdot b_{i}^{-1}\mod m_{i},}

where B 1 {\displaystyle B^{-1}} is multiplicative inverse of B {\displaystyle B} modulo M {\displaystyle M} , and b i 1 {\displaystyle b_{i}^{-1}} is multiplicative inverse of b i {\displaystyle b_{i}} modulo m i {\displaystyle m_{i}} .

Applications

This section needs expansion. You can help by adding to it. (July 2018)

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

References

  1. Parhami, Behrooz (2010). Computer Arithmetic: Algorithms and Hardware Designs (2 ed.). New York, USA: Oxford University Press. ISBN 978-0-19-532848-6. Archived from the original on 2020-08-04. Retrieved 2021-01-23. (xxv+641 pages)
  2. Hung, C.Y.; Parhami, B. (1994-02-01). "An approximate sign detection method for residue numbers and its application to RNS division" (PDF). Computers & Mathematics with Applications. 27 (4): 23–35. doi:10.1016/0898-1221(94)90052-3.
  3. Isupov, Konstantin (2020-04-07) . "Using Floating-Point Intervals for Non-Modular Computations in Residue Number System". IEEE Access. 8: 58603–58619. Bibcode:2020IEEEA...858603I. doi:10.1109/ACCESS.2020.2982365. ISSN 2169-3536.

Further reading

Categories: