Jpp  18.0.0-rc.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Types | Public Member Functions | Public Attributes | Private Attributes | Friends | List of all members
JACOUSTICS::JModel Struct Reference

Model for fit to acoustics data. More...

#include <JModel.hh>

Inheritance diagram for JACOUSTICS::JModel:
JMATH::JMath< JFirst_t, JSecond_t > JLANG::JEquals< JFirst_t, JSecond_t > JACOUSTICS::getModel

Classes

struct  emission_type
 Map emission key to model parameters of emission. More...
 
struct  hash_map
 Auxiliary data structure with extended functionality of hash-map. More...
 
struct  string_type
 Map string identifier to model parameters of string. More...
 

Public Types

typedef JMODEL::JString JString
 
typedef JMODEL::JEmission JEmission
 
typedef size_t parameter_type
 Type definition of fit parameter. More...
 

Public Member Functions

 JModel ()
 Default constructor. More...
 
template<class T >
 JModel (T __begin, T __end)
 Constructor. More...
 
JModeloperator= (const JMATH::JZero &zero)
 Reset parameters. More...
 
JMODEL::JOption_t getOption () const
 Get fit option. More...
 
void setOption (const int option)
 Set fit option. More...
 
void clear ()
 Clear parameters. More...
 
void reset ()
 Reset parameters. More...
 
JModelnegate ()
 Negate model. More...
 
JModeladd (const JModel &model)
 Add model. More...
 
JModelsub (const JModel &model)
 Subtract model. More...
 
JModelmul (const double factor)
 Scale model. More...
 
JModeldiv (const double factor)
 Scale model. More...
 
bool equals (const JModel &model, const double precision=std::numeric_limits< double >::min()) const
 Check equality. More...
 
size_t getN () const
 Get number of fit parameters. More...
 
size_t getIndex (int id, double JString::*p) const
 Get index of fit parameter for given string. More...
 
size_t getIndex (const JEKey &id, double JEmission::*p) const
 Get index of fit parameter for given emission. More...
 
double operator[] (const size_t index) const
 Read access to fit parameter value by index. More...
 
double & operator[] (const size_t index)
 Read/write access to fit parameter value by index. More...
 
JFirst_t & mul (const JSecond_t &object)
 Multiply with object. More...
 

Public Attributes

JACOUSTICS::JModel::emission_type emission
 
JACOUSTICS::JModel::string_type string
 

Private Attributes

JMODEL::JOption_t option
 

Friends

std::ostream & operator<< (std::ostream &out, const JModel &model)
 Write model parameters to output stream. More...
 

Detailed Description

Model for fit to acoustics data.

The model consists of string parameters and emission parameters.
These parameters relate to the string identifer and emission key, respectively.

Definition at line 476 of file JAcoustics/JModel.hh.

Member Typedef Documentation

Definition at line 480 of file JAcoustics/JModel.hh.

Definition at line 481 of file JAcoustics/JModel.hh.

Type definition of fit parameter.

Definition at line 487 of file JAcoustics/JModel.hh.

Constructor & Destructor Documentation

JACOUSTICS::JModel::JModel ( )
inline

Default constructor.

Definition at line 493 of file JAcoustics/JModel.hh.

template<class T >
JACOUSTICS::JModel::JModel ( T  __begin,
T  __end 
)
inline

Constructor.

This constructor can be used to set up a default model (i.e. all values at zero) for the given set of hits.
The data type corresponding to the hits should provide for the following policy methods.

   int      getString();        // get string identifier
   JEKey    getEKey();          // get emission key
Parameters
__beginbegin of hits
__endend of hits

Definition at line 512 of file JAcoustics/JModel.hh.

512  :
514  {
515  for (T hit = __begin; hit != __end; ++hit) {
516 
517  if (!this->string.has(hit->getString())) {
518  this->string[hit->getString()] = JString();
519  }
520 
521  if (!this->emission.has(hit->getEKey())) {
522  this->emission[hit->getEKey()] = JEmission();
523  }
524  }
525  }
JMODEL::JOption_t option
JMODEL::JEmission JEmission
do set_variable OUTPUT_DIRECTORY $WORKDIR T
JMODEL::JString JString
JACOUSTICS::JModel::emission_type emission
bool has(const T &value) const
Test whether given value is present.

Member Function Documentation

JModel& JACOUSTICS::JModel::operator= ( const JMATH::JZero zero)
inline

Reset parameters.

Parameters
zerozero
Returns
this model

Definition at line 534 of file JAcoustics/JModel.hh.

535  {
536  this->reset();
537 
538  return *this;
539  }
void reset()
Reset parameters.
JMODEL::JOption_t JACOUSTICS::JModel::getOption ( ) const
inline

Get fit option.

Returns
option

Definition at line 547 of file JAcoustics/JModel.hh.

548  {
549  return option;
550  }
JMODEL::JOption_t option
void JACOUSTICS::JModel::setOption ( const int  option)
inline

Set fit option.

Parameters
optionoption

Definition at line 558 of file JAcoustics/JModel.hh.

559  {
560  using namespace JMODEL;
561 
562  switch (option) {
563 
564  case fit_emitters_only_t:
568  this->option = static_cast<JOption_t>(option);
569  break;
570 
571  default:
572  THROW(JValueOutOfRange, "Invalid option " << option);
573  }
574  }
JMODEL::JOption_t option
fit times of emission of emitters and tilt angles of strings with second order correction and stretch...
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
fit times of emission of emitters and tilt angles of strings
fit times of emission of emitters and tilt angles of strings with second order correction ...
fit only times of emission of emitters
void JACOUSTICS::JModel::clear ( )
inline

Clear parameters.

Definition at line 580 of file JAcoustics/JModel.hh.

581  {
582  string .clear();
583  emission.clear();
584  }
virtual void clear() override
Clear.
Definition: JHashMap.hh:107
JACOUSTICS::JModel::emission_type emission
void JACOUSTICS::JModel::reset ( )
inline

Reset parameters.

Definition at line 590 of file JAcoustics/JModel.hh.

591  {
592  string .reset();
593  emission.reset();
594  }
void reset()
Reset values.
Definition: JHashMap.hh:116
JACOUSTICS::JModel::emission_type emission
JModel& JACOUSTICS::JModel::negate ( )
inline

Negate model.

Returns
this model

Definition at line 602 of file JAcoustics/JModel.hh.

603  {
604  this->string .evaluate(&JString ::negate);
606 
607  return *this;
608  }
JEmission & negate()
Negate emission.
JString & negate()
Negate string.
JACOUSTICS::JModel::emission_type emission
void evaluate(value_type &(value_type::*f1)())
Evaluate arithmetic operation.
JModel& JACOUSTICS::JModel::add ( const JModel model)
inline

Add model.

Parameters
modelmodel
Returns
this model

Definition at line 617 of file JAcoustics/JModel.hh.

618  {
619  this->string .evaluate(model.string, &JString ::add);
620  this->emission.evaluate(model.emission, &JEmission::add);
621 
622  return *this;
623  }
JEmission & add(const JEmission &emission)
Add emission.
JString & add(const JString &string)
Add string.
JACOUSTICS::JModel::emission_type emission
JACOUSTICS::JModel::string_type string
void evaluate(value_type &(value_type::*f1)())
Evaluate arithmetic operation.
JModel& JACOUSTICS::JModel::sub ( const JModel model)
inline

Subtract model.

Parameters
modelmodel
Returns
this model

Definition at line 632 of file JAcoustics/JModel.hh.

633  {
634  this->string .evaluate(model.string, &JString ::sub);
635  this->emission.evaluate(model.emission, &JEmission::sub);
636 
637  return *this;
638  }
JString & sub(const JString &string)
Subtract string.
JACOUSTICS::JModel::emission_type emission
JEmission & sub(const JEmission &emission)
Subtract emission.
JACOUSTICS::JModel::string_type string
void evaluate(value_type &(value_type::*f1)())
Evaluate arithmetic operation.
JModel& JACOUSTICS::JModel::mul ( const double  factor)
inline

Scale model.

Parameters
factormultiplication factor
Returns
this model

Definition at line 647 of file JAcoustics/JModel.hh.

648  {
649  this->string .evaluate(&JString ::mul, factor);
650  this->emission.evaluate(&JEmission::mul, factor);
651 
652  return *this;
653  }
JString & mul(const double factor)
Scale string.
JACOUSTICS::JModel::emission_type emission
JEmission & mul(const double factor)
Scale emission.
void evaluate(value_type &(value_type::*f1)())
Evaluate arithmetic operation.
JModel& JACOUSTICS::JModel::div ( const double  factor)
inline

Scale model.

Parameters
factordivision factor
Returns
this model

Definition at line 662 of file JAcoustics/JModel.hh.

663  {
664  this->string .evaluate(&JString ::div, factor);
665  this->emission.evaluate(&JEmission::div, factor);
666 
667  return *this;
668  }
JACOUSTICS::JModel::emission_type emission
JString & div(const double factor)
Scale string.
JEmission & div(const double factor)
Scale emission.
void evaluate(value_type &(value_type::*f1)())
Evaluate arithmetic operation.
bool JACOUSTICS::JModel::equals ( const JModel model,
const double  precision = std::numeric_limits<double>::min() 
) const
inline

Check equality.

Parameters
modelmodel
precisionprecision
Returns
true if models are equal; else false

Definition at line 678 of file JAcoustics/JModel.hh.

680  {
681  return (this->string .equals(model.string, precision) &&
682  this->emission.equals(model.emission, precision));
683  }
bool equals(const JModel &model, const double precision=std::numeric_limits< double >::min()) const
Check equality.
then usage $script< detector file >< detectorfile > nIf the range of floors is the first detector file is aligned to the second before the comparison nIn this
JACOUSTICS::JModel::emission_type emission
JACOUSTICS::JModel::string_type string
size_t JACOUSTICS::JModel::getN ( ) const
inline

Get number of fit parameters.

Returns
number of parameters

Definition at line 715 of file JAcoustics/JModel.hh.

716  {
717  return emission.getN(this->option) + string.getN(this->option);
718  }
JMODEL::JOption_t option
JACOUSTICS::JModel::emission_type emission
size_t getN(const JMODEL::JOption_t option) const
Get number of fit parameters.
size_t JACOUSTICS::JModel::getIndex ( int  id,
double JString::*  p 
) const
inline

Get index of fit parameter for given string.

Parameters
idstring identifier
ppointer to data member
Returns
parameter

Definition at line 728 of file JAcoustics/JModel.hh.

729  {
730  return emission.getN(this->option) + string.getIndex(id, p, this->option);
731  }
JMODEL::JOption_t option
JACOUSTICS::JModel::emission_type emission
size_t getN(const JMODEL::JOption_t option) const
Get number of fit parameters.
size_t JACOUSTICS::JModel::getIndex ( const JEKey id,
double JEmission::*  p 
) const
inline

Get index of fit parameter for given emission.

Parameters
idemission key
ppointer to data member
Returns
parameter

Definition at line 741 of file JAcoustics/JModel.hh.

742  {
743  return emission.getIndex(id, p, this->option);
744  }
JMODEL::JOption_t option
size_t getIndex(const key_type key, double value_type::*p, const JMODEL::JOption_t option) const
Get index of parameter.
JACOUSTICS::JModel::emission_type emission
double JACOUSTICS::JModel::operator[] ( const size_t  index) const
inline

Read access to fit parameter value by index.

Parameters
indexindex
Returns
value

Definition at line 753 of file JAcoustics/JModel.hh.

754  {
755  size_t i = index;
756 
757  if (i < emission.getN(this->option)) { return emission.getParameter(i, this->option); }
758 
759  i -= emission.getN(this->option);
760 
761  if (i < string .getN(this->option)) { return string .getParameter(i, this->option); }
762 
763  THROW(JIndexOutOfRange, "Invalid index " << index << " >= " << getN());
764  }
JMODEL::JOption_t option
size_t getN() const
Get number of fit parameters.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
then usage $script< detector file >< detectorfile > nIf the range of floors is the first detector file is aligned to the second before the comparison nIn this
JACOUSTICS::JModel::emission_type emission
size_t getN(const JMODEL::JOption_t option) const
Get number of fit parameters.
double getParameter(const size_t index, const JMODEL::JOption_t option) const
Get read access to fit parameter value at given index in buffer.
double& JACOUSTICS::JModel::operator[] ( const size_t  index)
inline

Read/write access to fit parameter value by index.

Parameters
indexindex
Returns
value

Definition at line 773 of file JAcoustics/JModel.hh.

774  {
775  size_t i = index;
776 
777  if (i < emission.getN(this->option)) { return emission.getParameter(i, this->option); }
778 
779  i -= emission.getN(this->option);
780 
781  if (i < string .getN(this->option)) { return string .getParameter(i, this->option); }
782 
783  THROW(JIndexOutOfRange, "Invalid index " << index << " >= " << getN());
784  }
JMODEL::JOption_t option
size_t getN() const
Get number of fit parameters.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
then usage $script< detector file >< detectorfile > nIf the range of floors is the first detector file is aligned to the second before the comparison nIn this
JACOUSTICS::JModel::emission_type emission
size_t getN(const JMODEL::JOption_t option) const
Get number of fit parameters.
double getParameter(const size_t index, const JMODEL::JOption_t option) const
Get read access to fit parameter value at given index in buffer.
template<class JFirst_t, class JSecond_t = JNullType>
JFirst_t& JMATH::JMath< JFirst_t, JSecond_t >::mul ( const JSecond_t &  object)
inlineinherited

Multiply with object.

Parameters
objectobject
Returns
result object

Definition at line 354 of file JMath.hh.

355  {
356  return static_cast<JFirst_t&>(*this) = JFirst_t().mul(static_cast<const JFirst_t&>(*this), object);
357  }

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
const JModel model 
)
friend

Write model parameters to output stream.

Parameters
outoutput stream
modelmodel
Returns
output stream

Definition at line 693 of file JAcoustics/JModel.hh.

694  {
695  using namespace std;
696  using namespace JPP;
697 
698  for (hash_map<int, JString>::const_iterator i = model.string.begin(); i != model.string.end(); ++i) {
699  out << "string: " << setw(4) << i->first << ' ' << i->second << endl;
700  }
701 
702  for (hash_map<JEKey, JEmission>::const_iterator i = model.emission.begin(); i != model.emission.end(); ++i) {
703  out << "emission: " << setw(3) << i->first << ' ' << i->second << endl;
704  }
705 
706  return out;
707  }
JACOUSTICS::JModel::emission_type emission
JACOUSTICS::JModel::string_type string
container_type::const_iterator const_iterator
Definition: JHashMap.hh:86

Member Data Documentation

JACOUSTICS::JModel::emission_type JACOUSTICS::JModel::emission
JACOUSTICS::JModel::string_type JACOUSTICS::JModel::string
JMODEL::JOption_t JACOUSTICS::JModel::option
private

Definition at line 1030 of file JAcoustics/JModel.hh.


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