1 #ifndef __JACOUSTICS__JKATOOMBA__ 
    2 #define __JACOUSTICS__JKATOOMBA__ 
   29 namespace JACOUSTICS {}
 
   30 namespace JPP { 
using namespace JACOUSTICS; }
 
   32 namespace JACOUSTICS {
 
   77     template<
class JPDF_t>
 
  182   template<
template<
class T> 
class JMinimiser_t>
 
  218     template<
class JPDF_t>
 
  221       const double toa_s = this->getToA(model, hit);
 
  222       const double u     = (toa_s - hit.getValue()) / hit.sigma;
 
  224       return estimator->getRho(u);
 
  278       using namespace JGEOMETRY;
 
  280       value = 
JModel(__begin, __end);                 
 
  289       for (
T hit = __begin; hit != __end; ++hit) {
 
  293         const double      Vi       = velocity.getInverseVelocity(hit->getDistance(position), hit->getZ(), position.
getZ());
 
  295         const double      h1 = 
string.getHeight(hit->getFloor());
 
  296         const JPosition3D p1 = 
string.getPosition()  -  hit->getPosition();
 
  298         const double      y  = hit->getValue()  -  Vi*ds;
 
  299         const double      W  = sqrt(hit->getWeight());
 
  302         H.tx  =  W * Vi * p1.
getX() * h1 / ds;
 
  303         H.ty  =  W * Vi * p1.
getY() * h1 / ds;
 
  305         i.t1  =  value.getIndex(hit->getEKey(),   &H_t::t1);
 
  306         i.tx  =  value.getIndex(hit->getString(), &H_t::tx);
 
  307         i.ty  =  value.getIndex(hit->getString(), &H_t::ty);
 
  309         V(i.t1, i.t1) += 
H.t1 * 
H.t1;  V(i.t1, i.tx) += 
H.t1 * 
H.tx;  V(i.t1, i.ty) += 
H.t1 * 
H.ty;
 
  310         V(i.tx, i.t1) += 
H.tx * 
H.t1;
 
  311         V(i.ty, i.t1) += 
H.ty * 
H.t1;
 
  313         V(i.tx, i.tx) += 
H.tx * 
H.tx;  V(i.tx, i.ty) += 
H.tx * 
H.ty;
 
  314         V(i.ty, i.tx) += 
H.ty * 
H.tx;
 
  316         V(i.ty, i.ty) += 
H.ty * 
H.ty;
 
  318         Y[i.t1] += W * 
H.t1 * y;
 
  319         Y[i.tx] += W * 
H.tx * y;
 
  320         Y[i.ty] += W * 
H.ty * y;
 
  327       for (
size_t row = 0; row != value.getN(); ++row) {
 
  328         for (
size_t col = 0; col != value.getN(); ++col) {
 
  329           value[row] += V(row,col) * Y[col];
 
  369     template<
class JPDF_t>
 
  372       const double toa_s = this->getToA(model, hit);
 
  373       const double u     = (toa_s - hit.getValue()) / hit.sigma;
 
  375       return estimator->getRho(u);
 
  397         this->step.push_back(model);
 
  401         this->step.push_back(model);
 
  410         this->step.push_back(model);
 
  457       const int N = value.getN();
 
  465       result_type precessor = numeric_limits<double>::max();
 
  467       for (numberOfIterations = 0; numberOfIterations != MAXIMUM_ITERATIONS; ++numberOfIterations) {
 
  469         DEBUG(
"step:     " << numberOfIterations << endl);
 
  471         evaluate(__begin, __end);
 
  473         DEBUG(
"lambda:   " << 
FIXED(12,5) << lambda    << endl);
 
  474         DEBUG(
"chi2:     " << 
FIXED(12,5) << successor << endl);
 
  476         if (successor < precessor) {
 
  478           if (numberOfIterations != 0) {
 
  480             if (fabs(precessor - successor) < EPSILON*fabs(precessor)) {
 
  484             if (lambda > LAMBDA_MIN) {
 
  485               lambda /= LAMBDA_DOWN;
 
  489           precessor = successor;
 
  497           if (lambda > LAMBDA_MAX) {
 
  501           evaluate(__begin, __end);
 
  507         for (
int i = 0; i != 
N; ++i) {
 
  509           if (V(i,i) < PIVOT) {
 
  513           h[i] = 1.0 / sqrt(V(i,i));
 
  519         for (
int i = 0; i != 
N; ++i) {
 
  520           for (
int j = 0; 
j != i; ++
j) {
 
  521             V(
j,i) *= h[i] * h[
j];
 
  526         for (
int i = 0; i != 
N; ++i) {
 
  527           V(i,i) = 1.0 + lambda;
 
  535           ERROR(
"JKatoomb<JGandalf>: " << error.
what() << endl);
 
  540         for (
int i = 0; i != 
N; ++i) {
 
  542           DEBUG(
"u[" << noshowpos << i << 
"] = " << showpos << 
FIXED(15,5) << value[i]);
 
  546           for (
int j = 0; 
j != 
N; ++
j) {
 
  547             y += V(i,
j) * 
Y[
j] * h[i] * h[
j];
 
  552           DEBUG(
' ' << 
FIXED(15,5) << y << noshowpos << endl);
 
  594       for (
T hit = __begin; hit != __end; ++hit) {
 
  600         const double D     = hit->getDistance(position);
 
  601         const double Vi    = velocity.getInverseVelocity(D, hit->getZ(), position.
getZ());
 
  602         const double toa_s = value.emitter[hit->getEKey()].t1  +  D * Vi;
 
  604         const double u     = (toa_s - hit->getValue()) / hit->sigma;
 
  605         const double W     = sqrt(hit->getWeight());
 
  607         successor += (W*W) * estimator->getRho(u);
 
  609         H_t H(1.0, 
string.getGradient(parameters, hit->getPosition(), hit->getFloor()) * Vi);
 
  611         H    *= W * estimator->getPsi(u) / hit->sigma;
 
  615         i.
t1  =  value.getIndex(hit->getEKey(),   &H_t::t1);
 
  616         i.
tx  =  value.getIndex(hit->getString(), &H_t::tx);
 
  617         i.
ty  =  value.getIndex(hit->getString(), &H_t::ty);
 
Auxiliary base class for fit function of acoustic model. 
 
JKatoomba(const JDetector &detector, const JSoundVelocity &velocity)
Constructor. 
 
JKatoomba(const JDetector &detector, const JSoundVelocity &velocity)
Constructor. 
 
JFit_t
Enumeration for fit algorithms. 
 
General purpose data regression method. 
 
do echo Generating $dir eval D
 
JString & mul(const double factor)
Scale string. 
 
Wrapper class around STL string class. 
 
Auxiliary base class for aritmetic operations of derived class types. 
 
int getFloor() const 
Get floor number. 
 
static double LAMBDA_UP
multiplication factor control parameter 
 
Interface for maximum likelihood estimator (M-estimator). 
 
result_type operator()(const JFunction_t &fit, T __begin, T __end)
Get chi2. 
 
I_t(const int t1, const int tx, const int ty)
Constructor. 
 
Indices of H-equation in global model. 
 
static const double H
Planck constant [eV s]. 
 
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
 
JEmitter & mul(const double factor)
Scale emitter. 
 
then for HISTOGRAM in h0 h1
 
double operator()(const JModel &model, const JHit< JPDF_t > &hit) const 
Fit function. 
 
I_t()
Default constructor. 
 
then fatal Wrong number of arguments fi set_variable STRING $argv[1] set_variable DETECTORXY_TXT $WORKDIR $DETECTORXY_TXT tail read X Y CHI2 RMS printf optimum n $X $Y $CHI2 $RMS awk v Y
 
Auxiliary data structure for floating point format specification. 
 
JEKey getEKey() const 
Get emitter hash key of this hit. 
 
Template definition of linear fit. 
 
double getDistance(const JVector3D &pos) const 
Get distance to point. 
 
Model for fit to acoustics data. 
 
H_t(const JMODEL::JEmitter &emitter, const JMODEL::JString &string)
Constructor. 
 
virtual double getInverseVelocity(const double D_m, const double z1, const double z2) const 
Get inverse velocity of sound. 
 
static double EPSILON
maximal distance to minimum 
 
The template JSharedPointer class can be used to share a pointer to an object. 
 
result_type operator()(T __begin, T __end)
Fit. 
 
JLANG::JSharedPointer< JMEstimator > estimator
M-Estimator function. 
 
JKatoomba_t(const JDetector &detector, const JSoundVelocity &velocity)
Constructor. 
 
static double LAMBDA_MIN
minimal value control parameter 
 
void evaluate(T __begin, T __end)
Evaluation of fit. 
 
JKatoomba(const JDetector &detector, const JSoundVelocity &velocity)
Constructor. 
 
static int debug
debug level 
 
do set_variable OUTPUT_DIRECTORY $WORKDIR T
 
double operator()(T __begin, T __end)
Fit. 
 
result_type operator()(const JModel &model, const JHit< JPDF_t > &hit) const 
Fit function. 
 
double getY() const 
Get y position. 
 
const JPosition3D & getPosition() const 
Get position. 
 
double getLengthSquared() const 
Get length squared. 
 
General purpose messaging. 
 
Implementation for velocity of sound. 
 
static double LAMBDA_MAX
maximal value control parameter 
 
static int MAXIMUM_ITERATIONS
maximal number of iterations 
 
double operator()(const JFunction_t &fit, T __begin, T __end)
Multi-dimensional fit. 
 
JACOUSTICS::JModel::string_type string
 
JACOUSTICS::JModel::emitter_type emitter
 
int getString() const 
Get string number. 
 
virtual const char * what() const override
Get error message. 
 
const JModel & operator()(T __begin, T __end) const 
Get start values of string parameters. 
 
static double LAMBDA_DOWN
multiplication factor control parameter 
 
Simple fit method based on Powell's algorithm, see reference: Numerical Recipes in C++...
 
result_type operator()(const JModel &model, T __begin, T __end)
Fit. 
 
H_t()
Default constructor. 
 
static double PIVOT
minimal value diagonal element of matrix 
 
double getToA(const JModel &model, const JHit< JPDF_t > &hit) const 
Get estimated time-of-arrival for given hit. 
 
double getX() const 
Get x position. 
 
H_t & mul(const double factor)
Scale H-equation. 
 
Data structure for position in three dimensions. 
 
const JDetector & detector
 
Model for fit to acoutsics data. 
 
then usage $script[input file[working directory[option]]] nWhere option can be N
 
double getZ() const 
Get z position. 
 
Maximum likelihood estimator (M-estimators). 
 
JKatoomba(const JDetector &detector, const JSoundVelocity &velocity)
Constructor. 
 
Template definition of fit function of acoustic model. 
 
#define DEBUG(A)
Message macros.