Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

test-generic.h File Reference

#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <cstdio>
#include "linbox/util/commentator.h"
#include "linbox/util/field-axpy.h"
#include "linbox/vector/stream.h"
#include "linbox/vector/vector-domain.h"
#include "linbox/blackbox/dense.h"
#include "linbox/integer.h"
#include "test-common.h"

Generic field tests

template<class Field> bool testField (Field &F, const char *title)
template<class Field> bool testFieldNegation (const Field &F, const char *name, unsigned int iterations)
template<class Field> bool testFieldInversion (const Field &F, const char *name, unsigned int iterations)
template<class Field> bool testFieldAxioms (const Field &F, const char *name, unsigned int iterations)
template<class Field> bool testFieldAssociativity (const Field &F, const char *name, unsigned int iterations)
template<class Field> bool testGeometricSummation (const Field &F, const char *name, unsigned int iterations, unsigned int n)
template<class Field> bool testFieldCharacteristic (const Field &F, const char *name, unsigned int iterations)
template<class Field> bool testFreshmansDream (const Field &F, const char *name, unsigned int iterations)
template<class Field> bool testArithmeticConsistency (const Field &F, const char *name, unsigned int iterations)
template<class Field> bool testAxpyConsistency (const Field &F, const char *name, unsigned int iterations)
template<class Field> bool testRanditerBasic (const Field &F, const char *name, unsigned int iterations)
template<class Field> bool runFieldTests (const Field &F, const char *desc, unsigned int iterations, size_t n, bool runCharacteristicTest)

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)
template<class Field> bool testRandomIteratorStep (const Field &F, const char *text, unsigned int num_trials, unsigned int num_categories, unsigned int hist_len)

Functions

template<class Field> Field::Element expt (const Field &F, typename Field::Element &res, const typename Field::Element &a, LinBox::integer &n)

Function Documentation

Field::Element expt const Field   F,
typename Field::Element   res,
const typename Field::Element   a,
LinBox::integer   n
 

bool runFieldTests const Field   F,
const char *    desc,
unsigned int    iterations,
size_t    n,
bool    runCharacteristicTest
 

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

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 testField Field   F,
const char *    title
 

Generic test 1: Test of field operations

Test various field oeprations

F - Field over which to perform computations title - String to use as the descriptive title of this test

Return true on success and false on failure

bool testFieldAssociativity const Field   F,
const char *    name,
unsigned int    iterations
 

Generic test 7: 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 testFieldAxioms const Field   F,
const char *    name,
unsigned int    iterations
 

@memo Generic test 7: Commutativity and distributivity of addition and multiplication @doc Given random field elements 'a', 'b', and 'c', checks that (a + b) * c = a * c + b * c = c * (a + b) = b * c + a * c

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 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 testFieldNegation const Field   F,
const char *    name,
unsigned int    iterations
 

Tests of algebraic properties of fields

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 with an error if the field is of characteristic 0.

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 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
 


Generated on Mon Jun 20 09:16:51 2005 for linbox by doxygen1.2.18