libfbm
0.3
Simulation of multi-dimensional stationary Gaussian processes and fractional Brownian motion.
|
Gaussian process field. More...
#include <libfbm.hpp>
Public Member Functions | |
Field (SGPContext &context, bool allowCorrelated=false) | |
Construct the field using given context. | |
~Field () | |
void | setBufferSize (size_t bufferSize) |
Set the internal buffer size used when reading cached precomputed data from the HD. | |
void | generate () |
Generate the next random process. | |
void | generate (GaussianGenerator &rng) |
Generate the field using random generator rng. | |
void | clear () |
Release all memory this object holds. | |
double | operator() (const zvec &p) const |
Access field value at given point. | |
double | operator() (size_t x) const |
double | operator() (size_t x, size_t y) const |
double | operator() (size_t x, size_t y, size_t z) const |
double | operator() (size_t x, size_t y, size_t z, size_t u) const |
double | operator() (size_t x, size_t y, size_t z, size_t u, size_t v) const |
void | integrate () |
Sum the generated field in each dimension. | |
const zvec & | getDim () const |
Get the usable dimensions of this field. | |
double & | at (const zvec &p) |
Return a reference to the internal array element at point p. | |
const double & | at (const zvec &p) const |
const size_t * | getStrides () const |
Get the strides array. | |
Public Member Functions inherited from libfbm::AbstractField | |
AbstractField () | |
virtual | ~AbstractField () |
Additional Inherited Members | |
Protected Attributes inherited from libfbm::AbstractField | |
std::vector< double > | Z |
double * | datap |
size_t | muls [LIBFBM_MAX_DIM] |
Gaussian process field.
This class holds the resulting data. Note that when accessing the data you must be sure the indexes are correct as no internal checking is done here (the same as for a general C/C++ array/vector).
Definition at line 799 of file libfbm.hpp.
libfbm::Field::Field | ( | SGPContext & | context, |
bool | allowCorrelated = false |
||
) |
Construct the field using given context.
Actual memory allocation is done at generate(). At each generate() two groups of random fields are generated, each group containing 2^d cross-correlated processes. So at each generate() we get exactly two uncorrelated random processes. One of them is cached and switched in at the next call to generate(). However, if you want to also use the correlated fields, set allowCorrelated to true. So for 2D we get 4 instances, for 3D 8 instances, etc. Note that the field holds onto the context object pointer, so it must stick around until the field is destroyed.
libfbm::Field::~Field | ( | ) |
|
inline |
Return a reference to the internal array element at point p.
Reimplemented from libfbm::AbstractField.
Definition at line 873 of file libfbm.hpp.
|
inline |
Reimplemented from libfbm::AbstractField.
Definition at line 881 of file libfbm.hpp.
|
virtual |
Release all memory this object holds.
Implements libfbm::AbstractField.
|
virtual |
Generate the next random process.
At first calling this function allocates the necessary memory. Note that multiple instances of random processes are generated at one calculation, which are quickly pulled in at next call to generate(). See the constructor for more information. The memory allocation size is 2*(2*d1)*(2*d2)*...*(2*dn) doubles, where d1..dn are the dimensions of the generated process. Note that the precomputed eigenvalue cache size (if kept in memory) additionally adds half of that.
Implements libfbm::AbstractField.
|
virtual |
Generate the field using random generator rng.
The random generator should produce normally distributed numbers.
Implements libfbm::AbstractField.
|
inlinevirtual |
Get the usable dimensions of this field.
Implements libfbm::AbstractField.
Definition at line 870 of file libfbm.hpp.
|
inline |
Get the strides array.
Internally, the data is kept in a huge single array of doubles. You can get addresses into this array using the at() member functions. If you want to quickly move to the next or previous element in a given dimension d, you can add or substract the strides[d] value to the address.
Reimplemented from libfbm::AbstractField.
Definition at line 894 of file libfbm.hpp.
void libfbm::Field::integrate | ( | ) |
Sum the generated field in each dimension.
Can be used to generate 1D fractional Brownian motion from the 1D fractional Gaussian noise. For 2D case a strange fractional Wiener surface is produced (not very useful). Note that FWSContext calls this automatically.
|
inline |
Access field value at given point.
Note that you are responsible for correct point indices. No checking is done internally and invalid values can lead to crashes.
Reimplemented from libfbm::AbstractField.
Definition at line 844 of file libfbm.hpp.
|
inline |
Reimplemented from libfbm::AbstractField.
Definition at line 851 of file libfbm.hpp.
|
inline |
Reimplemented from libfbm::AbstractField.
Definition at line 853 of file libfbm.hpp.
|
inline |
Reimplemented from libfbm::AbstractField.
Definition at line 855 of file libfbm.hpp.
|
inline |
Reimplemented from libfbm::AbstractField.
Definition at line 857 of file libfbm.hpp.
|
inline |
Reimplemented from libfbm::AbstractField.
Definition at line 859 of file libfbm.hpp.
void libfbm::Field::setBufferSize | ( | size_t | bufferSize | ) |
Set the internal buffer size used when reading cached precomputed data from the HD.
This is 65536 by default. Don't worry, your OS is supposed to cache often-used files in memory anyway, so probably there are no actual file reads involved if you run your program properly. Just fast memor-to-memory copies.