libfbm  0.1
Simulation of multi-dimensional stationary Gaussian processes and fractional Brownian motion.
 All Classes Namespaces Functions Friends
Public Member Functions
libfbm::Field Class Reference

Gaussian process field. More...

#include <libfbm.hpp>

List of all members.

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 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 zvecgetDim () 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.

Detailed Description

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 624 of file libfbm.hpp.


Constructor & Destructor Documentation

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

Member Function Documentation

double& libfbm::Field::at ( const zvec p)
inline

Return a reference to the internal array element at point p.

Definition at line 697 of file libfbm.hpp.

const double& libfbm::Field::at ( const zvec p) const
inline

Definition at line 705 of file libfbm.hpp.

void libfbm::Field::clear ( )

Release all memory this object holds.

void libfbm::Field::generate ( )

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.

const zvec& libfbm::Field::getDim ( ) const
inline

Get the usable dimensions of this field.

Definition at line 694 of file libfbm.hpp.

const size_t* libfbm::Field::getStrides ( ) const
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.

Definition at line 718 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.

double libfbm::Field::operator() ( const zvec p) const
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.

Definition at line 668 of file libfbm.hpp.

double libfbm::Field::operator() ( size_t  x) const
inline

Definition at line 675 of file libfbm.hpp.

double libfbm::Field::operator() ( size_t  x,
size_t  y 
) const
inline

Definition at line 677 of file libfbm.hpp.

double libfbm::Field::operator() ( size_t  x,
size_t  y,
size_t  z 
) const
inline

Definition at line 679 of file libfbm.hpp.

double libfbm::Field::operator() ( size_t  x,
size_t  y,
size_t  z,
size_t  u 
) const
inline

Definition at line 681 of file libfbm.hpp.

double libfbm::Field::operator() ( size_t  x,
size_t  y,
size_t  z,
size_t  u,
size_t  v 
) const
inline

Definition at line 683 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.


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