finite modulo-N arithmetic. More...
#include <vnl_finite.h>
Public Member Functions | |
| vnl_finite_int (int x=0) | |
| Creates a finite int element. More... | |
| vnl_finite_int (Base const &x) | |
| ~vnl_finite_int ()=default | |
| operator int () const | |
| operator int () | |
| operator long () const | |
| operator long () | |
| operator short () const | |
| operator short () | |
| Base & | operator= (Base const &x) |
| Assignment. More... | |
| Base & | operator= (int x) |
| bool | operator== (Base const &x) const |
| Comparison of finite int numbers. More... | |
| bool | operator!= (Base const &x) const |
| bool | operator== (int x) const |
| bool | operator!= (int x) const |
| Base | operator- () const |
| Unary minus - returns the additive inverse. More... | |
| Base | operator+ () const |
| Unary plus - returns the current number. More... | |
| bool | operator! () const |
| Unary not - returns true if finite int number is equal to zero. More... | |
| Base & | operator+= (Base const &r) |
| Plus&assign: replace lhs by lhs + rhs. More... | |
| Base & | operator+= (int r) |
| Base & | operator-= (Base const &r) |
| Minus&assign: replace lhs by lhs - rhs. More... | |
| Base & | operator-= (int r) |
| Base & | operator *= (int r) |
| Multiply&assign: replace lhs by lhs * rhs. More... | |
| Base & | operator *= (Base const &r) |
| Multiply&assign: replace lhs by lhs * rhs. More... | |
| Base | reciproc () const |
| Multiplicative inverse. More... | |
| Base & | operator/= (Base const &r) |
| Divide&assign. Uses r.reciproc() for efficient computation. More... | |
| Base & | operator++ () |
| Pre-increment (++r). More... | |
| Base & | operator-- () |
| Pre-decrement (–r). More... | |
| Base | operator++ (int) |
| Post-increment (r++). More... | |
| Base | operator-- (int) |
| Post-decrement (r–). More... | |
| bool | is_unit () const |
| Return true only when x is a unit in this ring. More... | |
| bool | is_zero_divisor () const |
| Return true only when x is a zero divisor, i.e., is not a unit. More... | |
| unsigned int | additive_order () const |
| The additive order of x is the smallest nonnegative r such that r*x == 0. More... | |
| unsigned int | multiplicative_order () const |
| The multiplicative order of x is the smallest r (>0) such that x^r == 1. More... | |
| Base | pow (int r) |
| Return the r-th power of this number. More... | |
| unsigned int | log () const |
| Return the smallest nonnegative exponent r for which x=g^r, where g is the smallest generator. More... | |
Static Public Member Functions | |
| static unsigned int | cardinality () |
| The number of different finite_int numbers of this type. More... | |
| static unsigned int | totient () |
| Return the Euler totient function, i.e., the number of units of this ring. More... | |
| static std::vector< unsigned int > | decompose () |
| Write N as the unique product of prime factors. More... | |
| static bool | is_field () |
| Return true when N is a prime number, i.e., when this ring is a field. More... | |
| static Base | smallest_generator () |
| Return the smallest multiplicative generator of the units in this ring. More... | |
| static Base | exp (int r) |
| Return the inverse of log(), i.e., return g^r where g is the smallest generator. More... | |
| static unsigned int | gcd (unsigned int l, unsigned int n) |
| Calculate the greatest common divisor of l and N. More... | |
| static unsigned int | gcd (unsigned int l) |
Private Types | |
| typedef vnl_finite_int< N > | Base |
Private Member Functions | |
| void | set_log (unsigned int r) const |
| private function to set cached value of lp1_ when available. More... | |
Private Attributes | |
| int | val_ |
| value of this number (smallest nonnegative representation) More... | |
| unsigned int | mo_ |
| cached value for multiplicative order More... | |
| unsigned int | lp1_ |
| cached value for 1+log() More... | |
Related Functions | |
(Note that these are not member functions.) | |
| template<int N> | |
| std::ostream & | operator<< (std::ostream &s, vnl_finite_int< N > const &r) |
| formatted output. More... | |
| template<int N> | |
| std::istream & | operator>> (std::istream &s, vnl_finite_int< N > &r) |
| simple input. More... | |
| template<int N> | |
| vnl_finite_int< N > | operator+ (vnl_finite_int< N > const &r1, vnl_finite_int< N > const &r2) |
| Returns the sum of two finite int numbers. More... | |
| template<int N> | |
| vnl_finite_int< N > | operator+ (vnl_finite_int< N > const &r1, int r2) |
| Returns the sum of two finite int numbers. More... | |
| template<int N> | |
| vnl_finite_int< N > | operator+ (int r2, vnl_finite_int< N > const &r1) |
| Returns the sum of two finite int numbers. More... | |
| template<int N> | |
| vnl_finite_int< N > | operator- (vnl_finite_int< N > const &r1, vnl_finite_int< N > const &r2) |
| Returns the difference of two finite int numbers. More... | |
| template<int N> | |
| vnl_finite_int< N > | operator- (vnl_finite_int< N > const &r1, int r2) |
| Returns the difference of two finite int numbers. More... | |
| template<int N> | |
| vnl_finite_int< N > | operator- (int r2, vnl_finite_int< N > const &r1) |
| Returns the difference of two finite int numbers. More... | |
| template<int N> | |
| vnl_finite_int< N > | operator * (vnl_finite_int< N > const &r1, vnl_finite_int< N > const &r2) |
| Returns the product of two finite int numbers. More... | |
| template<int N> | |
| vnl_finite_int< N > | operator * (vnl_finite_int< N > const &r1, int r2) |
| Returns the product of two finite int numbers. More... | |
| template<int N> | |
| vnl_finite_int< N > | operator * (int r2, vnl_finite_int< N > const &r1) |
| Returns the product of two finite int numbers. More... | |
| template<int N> | |
| vnl_finite_int< N > | operator/ (vnl_finite_int< N > const &r1, vnl_finite_int< N > const &r2) |
| Returns the quotient of two finite int numbers. More... | |
| template<int N> | |
| vnl_finite_int< N > | operator/ (vnl_finite_int< N > const &r1, int r2) |
| Returns the quotient of two finite int numbers. More... | |
| template<int N> | |
| vnl_finite_int< N > | operator/ (int r1, vnl_finite_int< N > const &r2) |
| Returns the quotient of two finite int numbers. More... | |
| template<int N> | |
| bool | operator== (int r1, vnl_finite_int< N > const &r2) |
| template<int N> | |
| bool | operator!= (int r1, vnl_finite_int< N > const &r2) |
| template<int N> | |
| vnl_finite_int< N > | squared_magnitude (vnl_finite_int< N > const &x) |
| template<int N> | |
| vnl_finite_int< N > | sqr (vnl_finite_int< N > const &x) |
| template<int N> | |
| bool | isnan (vnl_finite_int< N > const &) |
| template<int N> | |
| bool | isfinite (vnl_finite_int< N > const &) |
finite modulo-N arithmetic.
The templated vnl_finite_int<N> provides arithmetic "modulo N", i.e., arithmetic in the finite (Galois) field GF(N) in case N is a prime or just in the finite ring (or semi-field) of integers modulo N otherwise. In that case division makes no sense (unless no zero divisor is involved), but all other operations remain valid.
Definition at line 52 of file vnl_finite.h.
|
private |
Definition at line 57 of file vnl_finite.h.
|
inline |
Creates a finite int element.
Default constructor gives 0. Also serves as automatic cast from int to vnl_finite_int.
Definition at line 65 of file vnl_finite.h.
|
inline |
Definition at line 67 of file vnl_finite.h.
|
inlinedefault |
|
inline |
The additive order of x is the smallest nonnegative r such that r*x == 0.
Definition at line 191 of file vnl_finite.h.
|
inlinestatic |
The number of different finite_int numbers of this type.
Definition at line 60 of file vnl_finite.h.
|
inlinestatic |
Write N as the unique product of prime factors.
Definition at line 166 of file vnl_finite.h.
|
inlinestatic |
Return the inverse of log(), i.e., return g^r where g is the smallest generator.
Definition at line 247 of file vnl_finite.h.
|
inlinestatic |
Calculate the greatest common divisor of l and N.
Definition at line 254 of file vnl_finite.h.
|
inlinestatic |
Definition at line 259 of file vnl_finite.h.
|
inlinestatic |
Return true when N is a prime number, i.e., when this ring is a field.
Definition at line 177 of file vnl_finite.h.
|
inline |
Return true only when x is a unit in this ring.
In a field, all numbers except 0 are units. The total number of units is given by the Euler totient function.
Definition at line 185 of file vnl_finite.h.
|
inline |
Return true only when x is a zero divisor, i.e., is not a unit.
Definition at line 188 of file vnl_finite.h.
|
inline |
Return the smallest nonnegative exponent r for which x=g^r, where g is the smallest generator.
Definition at line 233 of file vnl_finite.h.
|
inline |
The multiplicative order of x is the smallest r (>0) such that x^r == 1.
Definition at line 194 of file vnl_finite.h.
|
inline |
Multiply&assign: replace lhs by lhs * rhs.
Definition at line 103 of file vnl_finite.h.
|
inline |
Multiply&assign: replace lhs by lhs * rhs.
Definition at line 110 of file vnl_finite.h.
|
inline |
Definition at line 71 of file vnl_finite.h.
|
inline |
Definition at line 72 of file vnl_finite.h.
|
inline |
Definition at line 73 of file vnl_finite.h.
|
inline |
Definition at line 74 of file vnl_finite.h.
|
inline |
Definition at line 75 of file vnl_finite.h.
|
inline |
Definition at line 76 of file vnl_finite.h.
|
inline |
Unary not - returns true if finite int number is equal to zero.
Definition at line 94 of file vnl_finite.h.
|
inline |
Definition at line 85 of file vnl_finite.h.
|
inline |
Definition at line 87 of file vnl_finite.h.
|
inline |
Unary plus - returns the current number.
Definition at line 92 of file vnl_finite.h.
|
inline |
Pre-increment (++r).
Definition at line 157 of file vnl_finite.h.
|
inline |
Post-increment (r++).
Definition at line 161 of file vnl_finite.h.
|
inline |
Plus&assign: replace lhs by lhs + rhs.
Definition at line 97 of file vnl_finite.h.
|
inline |
Definition at line 98 of file vnl_finite.h.
|
inline |
Unary minus - returns the additive inverse.
Definition at line 90 of file vnl_finite.h.
|
inline |
Pre-decrement (–r).
Definition at line 159 of file vnl_finite.h.
|
inline |
Post-decrement (r–).
Definition at line 163 of file vnl_finite.h.
|
inline |
Minus&assign: replace lhs by lhs - rhs.
Definition at line 100 of file vnl_finite.h.
|
inline |
Definition at line 101 of file vnl_finite.h.
|
inline |
Divide&assign. Uses r.reciproc() for efficient computation.
Definition at line 151 of file vnl_finite.h.
|
inline |
Assignment.
Definition at line 79 of file vnl_finite.h.
|
inline |
Definition at line 80 of file vnl_finite.h.
|
inline |
Comparison of finite int numbers.
Note that finite ints have no order, so < and > make no sense.
Definition at line 84 of file vnl_finite.h.
|
inline |
Definition at line 86 of file vnl_finite.h.
|
inline |
Return the r-th power of this number.
Definition at line 224 of file vnl_finite.h.
|
inline |
Multiplicative inverse.
Uses exp() and log() for efficient computation, unless log() is not defined.
Definition at line 138 of file vnl_finite.h.
|
inlineprivate |
private function to set cached value of lp1_ when available.
Definition at line 263 of file vnl_finite.h.
|
inlinestatic |
Return the smallest multiplicative generator of the units in this ring.
This is only possible if the units form a cyclic group for multiplication. If not, smallest_generator() returns 1 to indicate this fact. Note that the multiplication group of a finite field is always cyclic.
Definition at line 206 of file vnl_finite.h.
|
inlinestatic |
Return the Euler totient function, i.e., the number of units of this ring.
This number also equals the periodicity of the exponent: every unit, when raised to this power, yields 1.
Definition at line 122 of file vnl_finite.h.
|
related |
Definition at line 412 of file vnl_finite.h.
|
related |
Definition at line 407 of file vnl_finite.h.
|
related |
Returns the product of two finite int numbers.
Definition at line 336 of file vnl_finite.h.
|
related |
Returns the product of two finite int numbers.
Definition at line 344 of file vnl_finite.h.
|
related |
Returns the product of two finite int numbers.
Definition at line 352 of file vnl_finite.h.
|
related |
Definition at line 390 of file vnl_finite.h.
|
related |
Returns the sum of two finite int numbers.
Definition at line 288 of file vnl_finite.h.
|
related |
Returns the sum of two finite int numbers.
Definition at line 296 of file vnl_finite.h.
|
related |
Returns the sum of two finite int numbers.
Definition at line 304 of file vnl_finite.h.
|
related |
Returns the difference of two finite int numbers.
Definition at line 312 of file vnl_finite.h.
|
related |
Returns the difference of two finite int numbers.
Definition at line 320 of file vnl_finite.h.
|
related |
Returns the difference of two finite int numbers.
Definition at line 328 of file vnl_finite.h.
|
related |
Returns the quotient of two finite int numbers.
Uses r2.reciproc() for efficient computation.
Definition at line 361 of file vnl_finite.h.
|
related |
Returns the quotient of two finite int numbers.
Definition at line 369 of file vnl_finite.h.
|
related |
Returns the quotient of two finite int numbers.
Definition at line 377 of file vnl_finite.h.
|
related |
formatted output.
Definition at line 272 of file vnl_finite.h.
|
related |
Definition at line 385 of file vnl_finite.h.
|
related |
simple input.
Definition at line 280 of file vnl_finite.h.
|
related |
Definition at line 402 of file vnl_finite.h.
|
related |
Definition at line 397 of file vnl_finite.h.
|
mutableprivate |
cached value for 1+log()
Definition at line 266 of file vnl_finite.h.
|
mutableprivate |
cached value for multiplicative order
Definition at line 265 of file vnl_finite.h.
|
private |
value of this number (smallest nonnegative representation)
Definition at line 55 of file vnl_finite.h.
1.8.15