Public Member Functions | Protected Attributes | List of all members
o2scl::gen_test_number< tot > Class Template Reference

Generate number sequence for testing. More...

#include <misc.h>

Public Member Functions

double gen ()
 Return the next number in the sequence.
 

Protected Attributes

int n
 Count number of numbers generated.
 
double fact
 A constant factor for the argument to tanh(), equal to tot divided by 20.
 

Detailed Description

template<size_t tot>
class o2scl::gen_test_number< tot >

A class which generates tot numbers from -1 to 1, making sure to include -1, 1, 0, and numbers near -1, 0 and 1 (so long as tot is sufficiently large). If gen() is called more than tot times, it just recycles through the list again.

This class is used to generate combinations of coefficients for testing the polynomial solvers.

For example, the first 15 numbers generated by an object of type gen_test_number<10> are:

0  -1.000000e+00
1  -9.975274e-01
2  -8.807971e-01
3  -1.192029e-01
4  -2.472623e-03
5  +0.000000e+00
6  +2.472623e-03
7  +1.192029e-01
8  +8.807971e-01
9  +1.000000e+00
10 -1.000000e+00
11 -9.975274e-01
12 -8.807971e-01
13 -1.192029e-01
14 -2.472623e-03

This function is used in src/other/poly_ts.cpp which tests the polynomial solvers.

Idea for Future:
Document what happens if tot is pathologically small.

Definition at line 267 of file misc.h.


The documentation for this class was generated from the following file:

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).