linbox
|
tests field operations More...
#include <iostream>
#include <sstream>
#include <vector>
#include <cstdio>
#include "linbox/util/commentator.h"
#include "linbox/util/field-axpy.h"
#include "linbox/randiter/nonzero.h"
#include "linbox/integer.h"
#include "test-common.h"
Functions | |
template<class Field > | |
bool | testField (Field &F, const char *title, bool fieldp=true) |
Check each field or ring operation. | |
template<class Field > | |
bool | testFieldNegation (const Field &F, const char *name, unsigned int iterations) |
Tests of algebraic properties of fields. | |
template<class Field > | |
bool | testFieldInversion (const Field &F, const char *name, unsigned int iterations) |
Generic test 5: Inversion of elements. | |
template<class Field > | |
bool | testFieldDistributivity (const Field &F, const char *name, unsigned int iterations) |
Generic test 7a: Distributivity of multiplication over addition. | |
template<class Field > | |
bool | testFieldCommutativity (const Field &F, const char *name, unsigned int iterations) |
Generic test 7b: Commutativity of multiplication and addition. | |
template<class Field > | |
bool | testFieldAssociativity (const Field &F, const char *name, unsigned int iterations) |
Generic test 7c: Associativity of addition and multiplication. | |
template<class Field > | |
bool | testGeometricSummation (const Field &F, const char *name, unsigned int iterations, unsigned int n) |
Generic test 2: Geometric summation. | |
template<class Field > | |
bool | testFieldCharacteristic (const Field &F, const char *name, unsigned int iterations) |
Generic test 3: Test of field characteristic. | |
template<class Field > | |
bool | testFreshmansDream (const Field &F, const char *name, unsigned int iterations) |
Generic test 4: The Freshman's Dream. | |
template<class Field > | |
bool | testArithmeticConsistency (const Field &F, const char *name, unsigned int iterations) |
Generic test 7: Consistency of in-place and out-of-place arithmetic. | |
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. | |
template<class Field > | |
bool | testRanditerBasic (const Field &F, const char *name, unsigned int iterations) |
Generic test 9: Basic concept check of RandIter. | |
Generic field tests | |
template<class Field > | |
bool | testRandomIterator (const Field &F, const char *text, unsigned int num_trials, unsigned int num_categories, unsigned int hist_len) |
Random number test. | |
template<class Field > | |
bool | testRandomIteratorStep (const Field &F, const char *text, unsigned int num_trials, unsigned int num_categories, unsigned int hist_len) |
Random number test. |
tests field operations
bool testField | ( | Field & | F, |
const char * | title, | ||
bool | fieldp = true |
||
) |
Check each field or ring operation.
Test various field operations
F - Field over which to perform computations title - String to use as the descriptive title of this test fieldp - use true if inv and div must work for all nonzero denominators
Return true on success and false on failure
- ostream &write (ostream &os) const
bool 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
bool 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
bool 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
bool 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)
bool 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).
bool 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.
bool 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.
bool testArithmeticConsistency | ( | 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.
bool testRingTrivia | ( | const Field & | F, |
const char * | name | ||
) |
bool 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
bool 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.
bool testRandomIterator | ( | const Field & | F, |
const char * | text, | ||
unsigned int | num_trials, | ||
unsigned int | num_categories, | ||
unsigned int | hist_len | ||
) |
Random number test.
Test that the random iterator over the given field works.
Test up to five times, accepting any one, to increase probability of passing statistical tests.
bool testRandomIteratorStep | ( | const Field & | F, |
const char * | text, | ||
unsigned int | num_trials, | ||
unsigned int | num_categories, | ||
unsigned int | hist_len | ||
) |
Random number test.
Test that the random iterator over the given field works.
Test up to five times, accepting any one, to increase probability of passing statistical tests.