linbox
Functions
field_subtests Namespace Reference

Tests of algebraic properties of rings and fields. More...

Functions

template<class Field >
bool testFieldInversion (const Field &F, const char *name, unsigned int iterations)
 Generic test 5: Inversion of elements. More...
 
template<class Field >
bool testFieldDistributivity (const Field &F, const char *name, unsigned int iterations)
 Generic test 7a: Distributivity of multiplication over addition. More...
 
template<class Field >
bool testFieldCommutativity (const Field &F, const char *name, unsigned int iterations)
 Generic test 7b: Commutativity of multiplication and addition. More...
 
template<class Field >
bool testFieldAssociativity (const Field &F, const char *name, unsigned int iterations)
 Generic test 7c: Associativity of addition and multiplication. More...
 
template<class Field >
bool testGeometricSummation (const Field &F, const char *name, unsigned int iterations, unsigned int n)
 Generic test 2: Geometric summation. More...
 
template<class Field >
bool testFieldCharacteristic (const Field &F, const char *name, unsigned int iterations)
 Generic test 3: Test of field characteristic. More...
 
template<class Field >
bool testFreshmansDream (const Field &F, const char *name, unsigned int iterations)
 Generic test 4: The Freshman's Dream. More...
 
template<class Field >
bool testRingArithmeticConsistency (const Field &F, const char *name, unsigned int iterations)
 Generic test 7: Consistency of in-place and out-of-place arithmetic. More...
 
template<class Field >
bool testRingTrivia (const Field &F, const char *name)
 
template<class Field >
bool testAxpyConsistency (const Field &F, const char *name, unsigned int iterations)
 Generic test 8: Consistency of axpy. More...
 
template<class Field >
bool testRanditerBasic (const Field &F, const char *name, unsigned int iterations)
 Generic test 9: Basic concept check of RandIter. More...
 

Detailed Description

Tests of algebraic properties of rings and fields.

Function Documentation

◆ testFieldInversion()

bool field_subtests::testFieldInversion ( const Field &  F,
const char *  name,
unsigned int  iterations 
)

Generic test 5: Inversion of elements.

Inverts random elements and checks that they are true inverses

◆ testFieldDistributivity()

bool field_subtests::testFieldDistributivity ( const Field &  F,
const char *  name,
unsigned int  iterations 
)

Generic test 7a: Distributivity of multiplication over addition.

Given random field elements 'a', 'b', and 'c', checks that (a + b) * c = a * c + b * c and c * (a + b) = c * a + c * b

◆ testFieldCommutativity()

bool field_subtests::testFieldCommutativity ( const Field &  F,
const char *  name,
unsigned int  iterations 
)

Generic test 7b: Commutativity of multiplication and addition.

Given random field elements 'a', 'b', checks that a*b = b*a a+b = b+a

◆ testFieldAssociativity()

bool field_subtests::testFieldAssociativity ( const Field &  F,
const char *  name,
unsigned int  iterations 
)

Generic test 7c: Associativity of addition and multiplication.

Given random field elements 'a', 'b', and 'c', checks that (a * b) * c = a * (b * c) and (a + b) + c = a + (b + c)

◆ testGeometricSummation()

bool field_subtests::testGeometricSummation ( const Field &  F,
const char *  name,
unsigned int  iterations,
unsigned int  n 
)

Generic test 2: Geometric summation.

Generates a random field element 'a' and raises it through repeated exponentiation to the power n. Takes the sum k of all intermediate values and checks that a^n = (k-1)/(a-1).

◆ testFieldCharacteristic()

bool field_subtests::testFieldCharacteristic ( const Field &  F,
const char *  name,
unsigned int  iterations 
)

Generic test 3: Test of field characteristic.

Take random field elements and add them p times, where p is the characteristic of the field. Checks that the sum is 0. The test is not too useful when the characteristic of the field is 0, but it should still work correctly.

◆ testFreshmansDream()

bool field_subtests::testFreshmansDream ( const Field &  F,
const char *  name,
unsigned int  iterations 
)

Generic test 4: The Freshman's Dream.

Generates two random field elements 'a' and 'b', and checks whether (a + b)^p = a^p + b^p, where p is the characteristic of the field. Bails out (returning true) if the field is of characteristic 0.

◆ testRingArithmeticConsistency()

bool field_subtests::testRingArithmeticConsistency ( const Field &  F,
const char *  name,
unsigned int  iterations 
)

Generic test 7: Consistency of in-place and out-of-place arithmetic.

Generates random elements 'a' and 'b' and performs all basic arithmetic operations in-place and out-of-place, checking for consistency.

Div and inv are checked in a separate function.

◆ testRingTrivia()

bool field_subtests::testRingTrivia ( const Field &  F,
const char *  name 
)
Bug:
BlockRing does not know about 0 and 1 !
Todo:
enable init with 1UL et -1L pour GMPRationalElement

◆ testAxpyConsistency()

bool field_subtests::testAxpyConsistency ( const Field &  F,
const char *  name,
unsigned int  iterations 
)

Generic test 8: Consistency of axpy.

Generates random elements 'a', 'x', and 'y' and checks that a * x + y is the same for axpy, axpyin, add/mul

◆ testRanditerBasic()

bool field_subtests::testRanditerBasic ( const Field &  F,
const char *  name,
unsigned int  iterations 
)

Generic test 9: Basic concept check of RandIter.

In a loop, generates random element 'a', and fails if it is always zero.