1 #ifndef __JACOUSTICS__JMODEL__
2 #define __JACOUSTICS__JMODEL__
27 namespace JACOUSTICS {}
28 namespace JPP {
using namespace JACOUSTICS; }
30 namespace JACOUSTICS {
48 public JMath <JString>,
155 const double precision = std::numeric_limits<double>::min())
const
157 return (fabs(
tx -
string.
tx) <= precision &&
158 fabs(
ty -
string.
ty) <= precision);
191 return atan2(
ty,
tx);
203 return (
tx *
string.
tx +
217 return in >>
string.tx >>
string.ty;
233 return out <<
FIXED(10,7) <<
string.tx <<
' '
234 <<
FIXED(10,7) <<
string.ty;
247 public JMath <JEmitter>,
345 const double precision = std::numeric_limits<double>::min())
const
347 return (fabs(t1 - emitter.
t1) <= precision);
363 return out <<
FIXED(20,6) << emitter.
t1;
379 public JMath <JModel>,
420 for (
T hit = __begin; hit != __end; ++hit) {
422 if (!this->
string.has(hit->getString())) {
423 this->
string[hit->getString()] =
JString();
426 if (!this->emitter.has(hit->getEKey())) {
427 this->emitter[hit->getEKey()] =
JEmitter();
549 const double precision = std::numeric_limits<double>::min())
const
551 return (
equals(this->
string, model.
string, precision) &&
569 out <<
"string: " << setw(4) << i->first <<
' ' << i->second << endl;
573 out <<
"emitter: " << setw(2) << i->first <<
' ' << i->second << endl;
587 return getN(
string) + getN(emitter);
601 return string.getIndex(
id) * getN<JString>() +
getIndex(p);
617 return getN(
string) + emitter.getIndex(
id) * getN<JEmitter>() +
getIndex(p);
633 if (i < getN(
string)) {
return getParameter(
string, i); }
637 if (i < getN(emitter)) {
return getParameter(emitter, i); }
653 if (i < getN(
string)) {
return getParameter(
string, i); }
657 if (i < getN(emitter)) {
return getParameter(emitter, i); }
738 return sizeof(
T) /
sizeof(
double);
748 template<
class JKey_t,
class JValue_t,
class JEvaluator_t>
751 return buffer.size() * getN<JValue_t>();
766 return ((
double*) &(__p__->*p) - (
double*) __p__);
777 template<
class JKey_t,
class JValue_t,
class JEvaluator_t>
780 const size_t pos = index / getN<JValue_t>();
781 const size_t offset = index % getN<JValue_t>();
783 const JValue_t& value = buffer.data()[pos].second;
785 return ((
const double*) &value)[offset];
796 template<
class JKey_t,
class JValue_t,
class JEvaluator_t>
799 const size_t pos = index / getN<JValue_t>();
800 const size_t offset = index % getN<JValue_t>();
802 JValue_t& value = buffer.data()[pos].second;
804 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/write 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.
static size_t getN(const JHashMap< JKey_t, JValue_t, JEvaluator_t > &buffer)
Get number of fit parameters corresponding to given buffer.
friend std::ostream & operator<<(std::ostream &out, const JEmitter &emitter)
Write emitter parameters to output stream.
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 fit parameter value at given index in buffer.
JString & sub(const JString &string)
Subtract string.
static size_t getN()
Get number of fit parameters corresponding to given data structure.
Auxiliary class to assign zero value.
static double getParameter(const JHashMap< JKey_t, JValue_t, JEvaluator_t > &buffer, const size_t index)
Get 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.
JHashMap< JEKey, JEmitter > & map
double getLengthSquared() const
Get length squared.
size_t getIndex(const JEKey &id, double JEmitter::*p) const
Get index of fir 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.
JModel()
Default constructor.
JString(const double tx, const double ty)
Constructor.
JModel & add(const JModel &model)
Add model.
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.