1 #ifndef __JACOUSTICS__JMODEL__
2 #define __JACOUSTICS__JMODEL__
27 namespace JACOUSTICS {}
28 namespace JPP {
using namespace JACOUSTICS; }
30 namespace JACOUSTICS {
48 public JMath <JString>,
78 static inline size_t getN()
166 const double precision = std::numeric_limits<double>::min())
const
168 return (fabs(
tx -
string.
tx) <= precision &&
169 fabs(
ty -
string.
ty) <= precision);
202 return atan2(
ty,
tx);
214 return (
tx *
string.
tx +
228 return in >>
string.tx >>
string.ty;
244 return out <<
FIXED(10,7) <<
string.tx <<
' '
245 <<
FIXED(10,7) <<
string.ty;
258 public JMath <JEmitter>,
367 const double precision = std::numeric_limits<double>::min())
const
369 return (fabs(t1 - emitter.
t1) <= precision);
385 return out <<
FIXED(20,6) << emitter.
t1;
401 public JMath <JModel>,
442 for (
T hit = __begin; hit != __end; ++hit) {
444 if (!this->
string.has(hit->getString())) {
445 this->
string[hit->getString()] =
JString();
448 if (!this->emitter.has(hit->getEKey())) {
449 this->emitter[hit->getEKey()] =
JEmitter();
571 const double precision = std::numeric_limits<double>::min())
const
573 return (
equals(this->
string, model.
string, precision) &&
591 out <<
"string: " << setw(4) << i->first <<
' ' << i->second << endl;
595 out <<
"emitter: " << setw(2) << i->first <<
' ' << i->second << endl;
609 return emitter.getN() +
string.getN();
655 if (i < emitter.getN()) {
return getParameter(emitter, i); }
675 if (i < emitter.getN()) {
return getParameter(emitter, i); }
783 return ((
double*) &(__p__->*p) - (
double*) __p__);
794 template<
class JKey_t,
class JValue_t,
class JEvaluator_t>
800 const JValue_t& value = buffer.data()[pos].second;
802 return ((
const double*) &value)[offset];
813 template<
class JKey_t,
class JValue_t,
class JEvaluator_t>
819 JValue_t& value = buffer.data()[pos].second;
821 return ((
double*) &value)[offset];
size_t getN() const
Get number of fit parameters.
JModel & negate()
Negate model.
int getParameter(const std::string &text)
Get parameter number from text string.
JString & mul(const double factor)
Scale string.
JEmitter & sub(const JEmitter &emitter)
Subtract emitter.
Auxiliary base class for aritmetic operations of derived class types.
void clear()
Clear parameters.
double getAngle() const
Get angle.
JModel & mul(const double factor)
Scale model.
JEmitter(const double t1)
Constructor.
bool equals(const JEmitter &emitter, const double precision=std::numeric_limits< double >::min()) const
Check equality.
General purpose class for hash map of unique elements.
bool equals(const JModel &model, const double precision=std::numeric_limits< double >::min()) const
Check equality.
JModel(T __begin, T __end)
Constructor.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
JEmitter & mul(const double factor)
Scale emitter.
JEmitter & div(const double factor)
Scale emitter.
static const JZero zero
Function object to assign zero value.
JMODEL::JEmitter JEmitter
friend std::istream & operator>>(std::istream &in, JString &string)
Read string parameters from input stream.
Auxiliary data structure for floating point format specification.
friend std::ostream & operator<<(std::ostream &out, const JString &string)
Write string parameters to output stream.
Definition of zero value for any class.
JHashMapHelper operator[](int id)
Get helper corresponding to emitter identifier (i.e. first part of JEKey).
double operator[](const size_t index) const
Read access to fit parameter value by index.
Auxiliary class for multiple associative map operators.
static size_t getIndex(double T::*p)
Get index of fit parameter in given data structure.
friend std::ostream & operator<<(std::ostream &out, const JEmitter &emitter)
Write emitter parameters to output stream.
static size_t getN()
Get number of fit parameters.
friend std::ostream & operator<<(std::ostream &out, const JModel &model)
Write model parameters to output stream.
Model for fit to acoustics data.
size_t parameter_type
Type definition of fit parameter.
bool equals(const JString &string, const double precision=std::numeric_limits< double >::min()) const
Check equality.
static double & getParameter(JHashMap< JKey_t, JValue_t, JEvaluator_t > &buffer, const size_t index)
Get read/write access to fit parameter value at given index in buffer.
JString & sub(const JString &string)
Subtract string.
Auxiliary class to assign zero value.
static double getParameter(const JHashMap< JKey_t, JValue_t, JEvaluator_t > &buffer, const size_t index)
Get read access to fit parameter value at given index in buffer.
JEmitter & add(const JEmitter &emitter)
Add emitter.
do set_variable OUTPUT_DIRECTORY $WORKDIR T
JString & add(const JString &string)
Add string.
Template definition of auxiliary base class for comparison of data structures.
JString & negate()
Negate string.
static size_t getN()
Get number of fit parameters.
JHashMap< JEKey, JEmitter > & map
double getLengthSquared() const
Get length squared.
size_t getIndex(const JEKey &id, double JEmitter::*p) const
Get index of fit parameter for given emitter.
int getIndex()
Get index for user I/O manipulation.
JEmitter()
Default constructor.
size_t getIndex(int id, double JString::*p) const
Get index of fit parameter for given string.
JModel & sub(const JModel &model)
Subtract model.
JACOUSTICS::JModel::string_type string
JString & div(const double factor)
Scale string.
double & operator[](const size_t index)
Read/write access to fit parameter value by index.
JACOUSTICS::JModel::emitter_type emitter
JModel & div(const double factor)
Scale model.
Map emitter key to model parameters of emitter.
size_t getN() const
Get number of fit parameters.
JModel()
Default constructor.
JString(const double tx, const double ty)
Constructor.
JModel & add(const JModel &model)
Add model.
size_t getN() const
Get number of fit parameters.
Base class for data structures with artithmetic capabilities.
Exception for accessing a value in a collection that is outside of its range.
Exception for accessing an index in a collection that is outside of its range.
JEmitter & negate()
Negate emitter.
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
void reset()
Reset parameters.
JString()
Default constructor.
double getDot(const JString &string) const
Get dot product.
JEmitter & operator[](const int counter)
Get value corresponding to event counter (i.e. second part of JEKey).
double getLength() const
Get length.
JHashMapHelper(JHashMap< JEKey, JEmitter > &map, int id)
Constructor.
Map string identifier to model parameters of string.
JModel & operator=(const JMATH::JZero &zero)
Reset parameters.