#include <SimSeqs.h>
Inheritance diagram for LDSqBase:

Public Methods | |
| LDSqBase (long *b=NULL, long dm=0, long iterations=0, long genau=0, double genau1=0., char *ex="",char *nm="") | |
| virtual | ~LDSqBase () |
| virtual long | GetDimension () |
| virtual long | GetLength () |
| virtual char* | GetName () |
| virtual char* | GetExtension () |
| virtual long | SetBases (long *b, long dm, long genau, double genau1) |
| virtual long | GetBases (long *b, long dm) |
| virtual long | NextElement (double *buffer, long bufflen, long nr=-1) |
| virtual bool | CreateNumbers () |
| virtual void | SetNames (char *ex="",char *nm="") |
| virtual void | SetSeed (long int status) |
| double | ran1 (long *idum) |
| double | ran2 (long *idum) |
| double | ran3 (long *idum) |
Public Attributes | |
| long | lastnr |
| bool | qmc |
Protected Methods | |
| virtual void | InitMethod (long *b=NULL, long dm=0, long iterations=0, long genau=0, double genau1=0., char *ex="",char *nm="") |
| virtual long | CalculateNextElement (long nr, double *buffer, long bufflen) |
| virtual long | InitData (long genau, double genau1) |
| virtual long | ExitData () |
| virtual long* | InitGenericBases (long dm) |
Protected Attributes | |
| char* | name |
| char * | ext |
| long | dim |
| long | len |
| long* | bases |
| double* | numbers |
| bool | created |
| long | state |
| long | iy |
| long | iv [NTAB] |
| long | type |
If you intend to use MC / QMC sequences in your program, use an object of LDSqBase* type, so that you can later determine which sequence you really want. To initialize the sequence, just initialize a subclass and type-cast it to LDSqBase*. To get the next element, use the method NextElement(double*buffer, long bufflen, long nr=-1); To get the name of the sequence use GetName() or GetExtension() You probably won't need any other methods.
If you decide you want any other sequence, just use a diffent constructor, you don't have to change anything else. e.g.
void docalc() {
// definition of vars, memory for buffer, get bases etc.
// ...
LDSqBase*numbers;
numbers=(LDSqBase*)new MonteCarlo();
//numbers=(LDSqBase*)new Halton(bases, 5); // uncomment this if you want to use the Halton -sequence. This is the only place where you need to change something if you want a different sequence.
numbers->NextElement(buffer, bufflen); // This is the same, whatever sequence you use!!!
// .. do whatever you want
numbers->NextElement(buffer, bufflen, 271); // returns the 271. element of the sequence
//.. some more code,
delete numbers; // This is the same for all sequences, too
//free mem etc.
}
So, you see, to use different sequences, just initialize a differen object, but since all use LDSqBase as base class (which supplies the framework and the virtual functions that are implemented by the other sequence classes), the rest of the program, where you really work with the sequence just stays the same.
|
|
Constructor, initializes the sequence.
|
|
|
|
|
|
Calculates the next element and stores it to the buffer. If bufflen>dim, the remaining dimensions are pseudo-random numbers (i.e. the sequence is a hybrid sequence) This function should never be called directly! Use NextElement(..) instead!!!
Reimplemented in LDSqMonteCarlo, LDSqAfflerbach, LDSqNAlpha, LDSqHalton, LDSqAtanassov, LDSqHammersley, LDSqSobol, LDSqFaure, LDSqNetz, and LDSqNiederreiter. |
|
|
Creates all the numbers (len defines how many are needed) and stores them in the array numbers, so that NextElement(..) can just copy them from the array and does not have to calcualate them.
|
|
|
Do class-specific freeing of memory etc. Called by the destructor Reimplemented in LDSqMonteCarlo, LDSqHalton, LDSqAtanassov, LDSqSobol, LDSqFaure, LDSqNetz, and LDSqNiederreiter. |
|
|
Returns the bases used for this sequence into the buffer b, at most dm of them and returns how many bases have been copied to b.
|
|
|
Returns the dimension of the LD sequence (stored in the member variable dim).
|
|
|
|
|
|
Returns len (the number of points of this point set or sequence).
|
|
|
|
|
|
initialize the method specific data.
Reimplemented in LDSqMonteCarlo, LDSqHalton, LDSqAtanassov, LDSqSobol, LDSqFaure, LDSqNetz, and LDSqNiederreiter. |
|
|
If no array of bases was given in the constructor, but the sequence needs them, this creates generic bases, e.g. most of the time these are the dm lowest prime numbers, but you can override this by reimplementing InitGenericBases in your subclass Reimplemented in LDSqNAlpha, LDSqHalton, LDSqAtanassov, and LDSqNetz. |
|
|
Initializes the method, allocates memory needed,sets default values for the variables needed and calls InitData to do class-specific initialization...
|
|
|
Writes the nr-th element (if nr=-1 or not given, it writes the next element) of the sequence in a buffer. If bufflen>dim, the remaining dimensions are pseudo-random numbers (i.e. the sequence is a hybrid sequence). This is the method you should call from within your program. If the number have been pre-created (because CreateNumbers() has been called to create them), it just copies the appropriate element to the buffer, otherwise it will really calculate it. |
|
|
Set the bases for the sequence (or change them if they were already given in the constructor).
|
|
|
Changes the name of the sequence and the default extension (return value of GetName() and GetExtension()). They are initialized by the constructor |
|
|
Sets the seed for the ran1, ran2 and ran3 pseudo-number generators.
|
|
|
ran1 pseudo-Random number generator from the "Numerical Recipies in C": "minimal" random number generator of Park and Miller with Bays-Durham shuffle and added safeguards.
|
|
|
ran2 improved pseudo-Random number generator from the "Numerical Recipies in C" long period rng of L'Ecuyer with Bays-Durham shuffle and added safeguards.
|
|
|
ran3 improved pseudo-Random number generator from the "Numerical Recipies in C" Knuth's subtractive method rng.
|
|
|
long-field that stores the bases (if needed), e.g. for the Halton/Hammersley sequence |
|
|
flag to show whether the elements are pre-created into the field numbers already and just need to be copied from there. If false, the element needs to be calculated. |
|
|
number of dimensions (also the length of long* bases).
|
|
|
Strings, which contain the name and the 3-letter name of the sequence, e.g. name="Halton", ext="hal" |
|
|
|
|
|
|
|
|
store the index of the last created element, to use lastnr+1 as default... Some sequences can be calculated recursively (like the Halton sequences), so compare if the number needed is lastnr+1 (if yes, use the previous element to create the next one much faster |
|
|
Number of points of this point set (for sequences this has no important meaning, but for the Hammersley set this is vital).
|
|
|
Strings, which contain the name and the 3-letter name of the sequence, e.g. name="Halton", ext="hal" |
|
|
If all the numbers should be created at the beginning, this field stores all the elements. This can be quite effective if you need the same elements quite often in your code, since they are created just once at the beginning and not on the fly when needed (as it is the default |
|
|
Determines whether the sequence is a Low Discrepancy Sequence or not. This is a flag that is set once in the constructor. Your Program can check if (numberObject->qmc) {Do for QMC-sequence} else {Do for pseudo-random sequence} |
|
|
|
|
|
|
1.2.7 written by Dimitri van Heesch,
© 1997-2001