linbox
test-field.h File Reference

tests ring and field operations More...

#include <iostream>
#include <sstream>
#include <vector>
#include <cstdio>
#include "linbox/util/commentator.h"
#include "linbox/util/field-axpy.h"
#include <givaro/givranditer.h>
#include "linbox/integer.h"
#include "test-common.h"

Namespaces

namespace  field_subtests
 Tests of algebraic properties of rings and fields.
 

Functions

template<class Field>
Field::Elementexpt (const Field &F, typename Field::Element &res, const typename Field::Element &a, LinBox::integer &n)
 
bool reportError (string rep, bool &flag)
 
template<class Ring>
bool testRing (Ring &F, const char *title, bool fieldp=true, bool runInitConvertIdentity=true)
 Check each field or ring operation.
 
template<class Field>
bool testField (Field &F, const char *title, bool fieldp=true, bool runInitConvertIdentity=true)
 
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)
 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 testRingArithmeticConsistency (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 testInvDivConsistency (const Field &F, const char *name, unsigned int iterations)
 
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.
 
template<class Ring>
bool runBasicRingTests (const Ring &F, const char *desc, unsigned int iterations=1, bool runCharacteristicTest=true, bool runInitConvertIdentity=true)
 
template<class Ring>
bool runPIRTests (const Ring &R, const char *desc, unsigned int iterations=1, bool runCharacteristicTest=true, bool runInitConvertIdentity=true)
 
template<class Field>
bool testRandomIteratorStep (const Field &F, const char *text, unsigned int num_trials, unsigned int num_categories, unsigned int hist_len)
 
template<class Field>
bool runFieldTests (const Field &F, const char *desc, unsigned int iterations=1, size_t n=0, bool runCharacteristicTest=true, bool runInitConvertIdentity=true)
 
Commentator & commentator ()
 
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.
 

Detailed Description

tests ring and field operations

Test
tests ring and field operations

Function Documentation

◆ expt()

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

◆ reportError()

bool reportError ( string rep,
bool & flag )

◆ testRing()

template<class Ring>
bool testRing ( Ring & F,
const char * title,
bool fieldp = true,
bool runInitConvertIdentity = 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

Todo
untested so far :
  • ostream &write (ostream &os) const
  • istream &read (istream &is)
  • ostream &write (ostream &os, const Element &x) const
  • istream &read (istream &is, Element &x) const
  • FieldArchetype (FieldAbstract*, ElementAbstract*, RandIterAbstract* = 0)

◆ testField()

template<class Field>
bool testField ( Field & F,
const char * title,
bool fieldp = true,
bool runInitConvertIdentity = true )

◆ runBasicRingTests()

template<class Ring>
bool runBasicRingTests ( const Ring & F,
const char * desc,
unsigned int iterations = 1,
bool runCharacteristicTest = true,
bool runInitConvertIdentity = true )

◆ runPIRTests()

template<class Ring>
bool runPIRTests ( const Ring & R,
const char * desc,
unsigned int iterations = 1,
bool runCharacteristicTest = true,
bool runInitConvertIdentity = true )

◆ runFieldTests()

template<class Field>
bool runFieldTests ( const Field & F,
const char * desc,
unsigned int iterations = 1,
size_t n = 0,
bool runCharacteristicTest = true,
bool runInitConvertIdentity = true )

◆ testRandomIterator()

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.

Test that the random iterator over the given field works.

Test up to two times, accepting either one, to reduce probability of failing statistical tests.

◆ commentator()