---
---
libfbm

libfbm is a C++ library for fast and accurate simulation of multi-dimensional (1D, 2D, 3D, 4D, etc.) Gaussian stationary processes, fractional Brownian motion and noise with power-law power spectrum. For more information please see the HTML documentation. Code should work with any modern C++ compiler, but is packaged for use on a Linux/UNIX system. It is dependant on FFTW for FFT functionality.

Older releases:

This example shows how to simulate a two-dimensional 64x64 stationary gaussian surface with an unisotropic exponential covariance function:

#include <stdio.h>
#include <math.h>
#include <libfbm.hpp>
struct MyContext : public libfbm::SGPContext
{
MyContext(const libfbm::zvec& dim) : libfbm::SGPContext(dim, dim, "myctx") { }
double cov(const libfbm::zvec& r)
{
double xp = 0;
for ( size_t i = 0; i < r.size(); i++ )
xp += -fabs(r[i]) / (5 + i * 17);
return exp(xp);
}
};
int main()
{
libfbm::zvec dim(2);
dim[0] = 64;
dim[1] = 64;
MyContext ctx(dim);
libfbm::Field fbm(ctx, true);
fbm.generate();
for ( int y = 0; y < dim[1]; y++ )
{
for ( int x = 0; x < dim[0]; x++ )
printf("%s%g", x ? " " : "", fbm(x, y));
printf("\n");
}
return 0;
}
 
---
Copyright © 2001-2024 Indrek Mandre