GPLIB++
MTSampleGenerator.cpp
Go to the documentation of this file.
1 #include "MTSampleGenerator.h"
2 #include <algorithm>
3 #include <ctime>
4 
5 using namespace std;
6 namespace gplib
7  {
8 
9  MTSampleGenerator::MTSampleGenerator(boost::function<
10  double(const MTTensor*)> f, const MTTensor &Z, const double errorlevel) :
11  generator(static_cast<unsigned int> (std::time(0))), Zxxr_dist(
12  Z.GetZxx().real(), max(Z.GetdZxx(), Z.GetZxx().real() * errorlevel)),
13  Zxxi_dist(Z.GetZxx().imag(), max(Z.GetdZxx(), Z.GetZxx().imag()
14  * errorlevel)), Zxyr_dist(Z.GetZxy().real(), max(Z.GetdZxy(),
15  Z.GetZxy().real() * errorlevel)), Zxyi_dist(Z.GetZxy().imag(),
16  max(Z.GetdZxy(), Z.GetZxy().imag() * errorlevel)), Zyxr_dist(
17  Z.GetZyx().real(), max(Z.GetdZyx(), Z.GetZyx().real()
18  * errorlevel)), Zyxi_dist(Z.GetZyx().imag(), max(Z.GetdZyx(),
19  Z.GetZyx().imag() * errorlevel)), Zyyr_dist(Z.GetZyy().real(),
20  max(Z.GetdZyy(), Z.GetZyy().real() * errorlevel)), Zyyi_dist(
21  Z.GetZyy().imag(), max(Z.GetdZyy(), Z.GetZyy().imag()
22  * errorlevel)), Zxxr(generator, Zxxr_dist), Zxxi(generator,
23  Zxxi_dist), Zxyr(generator, Zxyr_dist),
24  Zxyi(generator, Zxyi_dist), Zyxr(generator, Zyxr_dist), Zyxi(
25  generator, Zyxi_dist), Zyyr(generator, Zyyr_dist), Zyyi(
26  generator, Zyyi_dist), func(f), Data(Z)
27  {
28  }
29 
31  {
32  }
33 
35  {
36  MTTensor Point(std::complex<double>(Zxxr(), Zxxi()), std::complex<
37  double>(Zxyr(), Zxyi()), std::complex<double>(Zyxr(), Zyxi()),
38  std::complex<double>(Zyyr(), Zyyi()), Data.GetFrequency());
39  return func(&Point);
40  }
41  }
void f(vector< double > &v1, vector< double > &v2, vector< double > &v3, vector< double > &v4)
Definition: perftest.cpp:17
double GetFrequency() const
Get the frequency for the impedance.
Definition: MTTensor.h:113
double operator()()
each call to operator() returns a new random sample
Stores MT-Tensor components at a single frequency, calculates derived quantities. ...
Definition: MTTensor.h:16