1 #ifndef __JACOUSTICS__JMODEL__
2 #define __JACOUSTICS__JMODEL__
26 namespace JACOUSTICS {}
27 namespace JPP {
using namespace JACOUSTICS; }
29 namespace JACOUSTICS {
169 const double precision = std::numeric_limits<double>::min())
const
171 return (fabs(
tx -
string.
tx) <= precision &&
172 fabs(
ty -
string.
ty) <= precision);
184 return (
tx *
string.
tx +
200 return out <<
FIXED(10,7) <<
string.tx <<
' '
201 <<
FIXED(10,7) <<
string.ty;
312 const double precision = std::numeric_limits<double>::min())
const
314 return (fabs(t1 - emitter.
t1) <= precision);
330 return out <<
FIXED(20,6) << emitter.
t1;
361 for (
T hit = __begin; hit != __end; ++hit) {
363 if (!this->
string.has(hit->getString())) {
364 this->
string[hit->getString()] =
JString();
417 set(this->
string, model.
string, static_cast<const JString&> (value));
504 const double precision = std::numeric_limits<double>::min())
const
506 return (
equals(this->
string, model.
string, precision) &&
524 out <<
"string: " << setw(4) << i->first <<
' ' << i->second << endl;
528 out <<
"emitter: " << setw(2) << i->first <<
' ' << i->second << endl;
556 return string.getIndex(
id) * getN<JString>() +
getIndex(p);
693 return sizeof(
T) /
sizeof(
double);
703 template<
class JKey_t,
class JValue_t,
class JEvaluator_t>
706 return buffer.size() * getN<JValue_t>();
721 return ((
double*) &(__p__->*p) - (
double*) __p__);
732 template<
class JKey_t,
class JValue_t,
class JEvaluator_t>
735 const size_t pos = index / getN<JValue_t>();
736 const size_t offset = index % getN<JValue_t>();
738 const JValue_t& value = buffer.data()[pos].second;
740 return ((
const double*) &value)[offset];
751 template<
class JKey_t,
class JValue_t,
class JEvaluator_t>
754 const size_t pos = index / getN<JValue_t>();
755 const size_t offset = index % getN<JValue_t>();
757 JValue_t& value = buffer.data()[pos].second;
759 return ((
double*) &value)[offset];
JString()
Default constructor.
size_t getN() const
Get number of fit parameters.
JModel & negate()
Negate model.
JEmitter & operator[](const int counter)
Get value corresponding to event counter (i.e. second part of JEKey).
Auxiliary base class for aritmetic operations of derived class types.
void clear()
Clear parameters.
Map emitter key to model parameters of emitter.
JModel & mul(const double factor)
Scale model.
friend std::ostream & operator<<(std::ostream &out, const JEmitter &emitter)
Write emitter parameters to output stream.
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.
JEmitter & add(const JEmitter &emitter)
Add emitter.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
void set(const JModel &model, const T &value)
Set parameters.
JEmitter(const double t1)
Constructor.
Map string identifier to model parameters of string.
static const JZero zero
Function object to assign zero value.
Auxiliary data structure for floating point format specification.
Definition of zero value for any class.
double operator[](const size_t index) const
Read/write access to fit parameter value by index.
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.
JEmitter & mul(const double factor)
Scale emitter.
JACOUSTICS::JModel::emitter_map emitter
Auxiliary class for multiple associative map operators.
JHashMap< JEKey, JEmitter > & map
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.
JACOUSTICS::JModel::string_map string
static double & getParameter(JHashMap< JKey_t, JValue_t, JEvaluator_t > &buffer, const size_t index)
Get fit parameter value at given index in buffer.
static size_t getN()
Get number of fit parameters corresponding to given data structure.
bool equals(const JEmitter &emitter, const double precision=std::numeric_limits< double >::min()) const
Check equality.
I/O formatting auxiliaries.
Auxiliary class to assign zero value.
JString(const double tx, const double ty)
Constructor.
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.
do set_variable OUTPUT_DIRECTORY $WORKDIR T
Template definition of auxiliary base class for comparison of data structures.
JEmitter()
Default constructor.
size_t getIndex(const JEKey &id, double JEmitter::*p) const
Get index of fir parameter for given emitter.
JEmitter & sub(const JEmitter &emitter)
Subtract emitter.
size_t getIndex(int id, double JString::*p) const
Get index of fit parameter for given string.
JString & div(const double factor)
Scale string.
double getDot(const JString &string) const
Get dot product.
JModel & sub(const JModel &model)
Subtract model.
JHashMapHelper(JHashMap< JEKey, JEmitter > &map, int id)
Constructor.
JString & add(const JString &string)
Add string.
double & operator[](const size_t index)
Read/write access to fit parameter value by index.
JModel & div(const double factor)
Scale model.
JModel()
Default constructor.
friend std::ostream & operator<<(std::ostream &out, const JString &string)
Write string parameters to output stream.
JString & negate()
Negate string.
JString & sub(const JString &string)
Subtract string.
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.
JEmitter & negate()
Negate emitter.
JEmitter & div(const double factor)
Scale emitter.
Exception for accessing an index in a collection that is outside of its range.
bool equals(const JString &string, const double precision=std::numeric_limits< double >::min()) const
Check equality.
JString & mul(const double factor)
Scale string.
JHashMapHelper operator[](int id)
Get helper corresponding to emitter identifier (i.e. first part of JEKey).
void reset()
Reset parameters.
JModel & operator=(const JMATH::JZero &zero)
Reset.