AdaptableFunctor computes both integral quotient and remainder of division with remainder. The quotient and remainder are computed such that and with respect to the proper integer norm of the represented ring. 1 In particular, is chosen to be if possible. Moreover, we require to be minimized with respect to the proper integer norm.
Note that the last condition is needed to ensure a unique computation of the pair . However, an other option is to require minimality for , with the advantage that a mod(x,y) operation would return the unique representative of the residue class of with respect to , e.g. should return . But this conflicts with nearly all current implementation of integer types. From there, we decided to stay conform with common implementations and require to be computed as rounded towards zero.
The following truth table illustrates the behavior for integers:
|
- |
|
| |
Is AlgebraicStructureTraits::Type.
| |
| |
Is AlgebraicStructureTraits::Type.
| |
| |
Is AlgebraicStructureTraits::Type.
| |
| |
Is AlgebraicStructureTraits::Type&.
| |
| |
Is AlgebraicStructureTraits::Type&.
|
|
| |||
computes the quotient and remainder , such that and minimal with respect to the Euclidean Norm on Type. | ||||
| ||||
|
| |||
This operator is well defined if NT1 and NT2 are ExplicitInteroperable with coercion type AlgebraicStructureTraits::Type. |
AlgebraicStructureTraits
AlgebraicStructureTraits::Mod
AlgebraicStructureTraits::Div
1 |
For integers this norm is the absolute value. For univariate polynomials this norm is the degree. |