309 #ifndef __libfbm_hpp__
310 #define __libfbm_hpp__
321 #define LIBFBM_MAX_DIM 8
323 #define LIBFBM_VERSION 0.3
336 virtual void setSeed(uint32_t seed) = 0;
337 virtual void setSeed(
const unsigned char *seed_array,
size_t len) = 0;
340 virtual void getDouble(
double *array,
size_t len) = 0;
343 #define _LIBFBM_GG_POOL_SIZE (312*4)
362 void setSeed(
const unsigned char *seed_array,
size_t len);
365 void getDouble(
double *array,
size_t len);
369 uint64_t ipool[_LIBFBM_GG_POOL_SIZE];
370 double opool[_LIBFBM_GG_POOL_SIZE];
374 void fill(
double *array,
size_t len);
396 void seed(uint32_t index);
398 inline size_t size()
const {
return sizeof(buf); }
399 inline operator const unsigned char *()
const {
return (
const unsigned char *)buf; }
402 unsigned char buf[256];
414 inline zvec(
size_t dim) : clen(dim) { }
417 inline const int&
operator[](
size_t i)
const {
return c[i]; }
419 inline size_t size()
const {
return clen; }
425 for (
size_t i = 0; i <
size(); i++ )
427 if ( c[i] < base - 1 )
429 for (
size_t j = 0; j < i; j++ )
443 for (
size_t i = 0; i <
size(); i++ )
445 if ( c[i] < dim[i] - 1 )
447 for (
size_t j = 0; j < i; j++ )
461 for (
size_t i = 0; i <
size(); i++ )
465 if ( c[i] < dim[i] - 1 )
467 for (
size_t j = 0; j < i; j++ )
477 inline size_t index(
size_t base)
const
481 for (
size_t i = 0; i <
size(); i++ )
494 for (
size_t i = 0; i <
size(); i++ )
505 for (
size_t i = 0; i <
size(); i++ )
512 for (
size_t i = 0; i < l.
size(); i++ )
513 ret[i] = l[i] + r[i];
520 for (
size_t i = 0; i < l.
size(); i++ )
521 ret[i] = l[i] - r[i];
528 for (
size_t i = 0; i < v.
size(); i++ )
536 for (
size_t i = 0; i < v.
size(); i++ )
542 int c[LIBFBM_MAX_DIM];
552 _Cache(
const std::string& cacheDir,
const std::string& cacheName,
size_t cacheSize);
556 void store(
const std::vector<double>& data);
558 size_t size()
const {
return cacheSize; }
560 bool inMemory()
const {
return !data.empty(); }
563 std::vector<double> data;
565 std::string cacheDir;
566 std::string cacheName;
569 _Cache(
const _Cache& copy);
570 const _Cache& operator=(
const _Cache& copy);
572 friend class _CacheReader;
580 _CacheReader(_Cache& cache,
size_t bufferSize);
582 inline double operator[](
size_t i)
584 if ( !buf.empty() && (i < bufpos || i - bufpos >= buf.size()) )
586 return data[i - bufpos];
591 std::vector<double> buf;
609 void init(
const libfbm::zvec& dim,
double *data, edir_t direction);
642 virtual double cov(
const zvec& p) = 0;
660 bool initCache(
bool forceRecalc =
false);
677 zvec fieldDim, userDim;
679 std::string cacheDir;
680 std::string cacheName;
735 virtual void clear() = 0;
744 size_t index = (size_t)2 * p[0];
745 for (
size_t i = 1; i < p.
size(); i++ )
746 index +=
muls[i] * p[i];
750 {
return datap[2 * x]; }
755 inline double operator()(
size_t x,
size_t y,
size_t z,
size_t u)
const
757 inline double operator()(
size_t x,
size_t y,
size_t z,
size_t u,
size_t v)
const
763 size_t index = 2 * p[0];
764 for (
size_t i = 1; i < p.
size(); i++ )
765 index +=
muls[i] * p[i];
769 inline const double&
at(
const zvec& p)
const
771 size_t index = 2 * p[0];
772 for (
size_t i = 1; i < p.
size(); i++ )
773 index +=
muls[i] * p[i];
785 std::vector<double>
Z;
846 size_t index = (size_t)2 * p[0];
847 for (
size_t i = 1; i < p.
size(); i++ )
848 index +=
muls[i] * p[i];
852 {
return datap[2 * x]; }
857 inline double operator()(
size_t x,
size_t y,
size_t z,
size_t u)
const
859 inline double operator()(
size_t x,
size_t y,
size_t z,
size_t u,
size_t v)
const
875 size_t index = 2 * p[0];
876 for (
size_t i = 1; i < p.
size(); i++ )
877 index +=
muls[i] * p[i];
881 inline const double&
at(
const zvec& p)
const
883 size_t index = 2 * p[0];
884 for (
size_t i = 1; i < p.
size(); i++ )
885 index +=
muls[i] * p[i];
899 bool allowCorrelated;
950 FBMSteinContext(
double H,
size_t dim,
size_t size,
double Rhint = -1,
bool mapDim =
true);
961 double getR()
const {
return R; }
982 static double getRForH(
double H,
size_t dim,
double Rhint = -1);
1043 std::vector<double> cache;
1053 #endif // !__libfbm_hpp__