1 #ifndef __JACOUSTICS__JMODEL__
2 #define __JACOUSTICS__JMODEL__
26 namespace JACOUSTICS {}
27 namespace JPP {
using namespace JACOUSTICS; }
29 namespace JACOUSTICS {
59 public JMath <JString>,
85 const double tx2 = 0.0,
86 const double ty2 = 0.0,
87 const double vs = 0.0) :
222 const double precision = std::numeric_limits<double>::min())
const
224 return (fabs(
tx -
string.
tx) <= precision &&
225 fabs(
ty -
string.
ty) <= precision &&
226 fabs(
tx2 -
string.
tx2) <= precision &&
227 fabs(
ty2 -
string.
ty2) <= precision &&
228 fabs(
vs -
string.
vs) <= precision);
261 return atan2(
ty,
tx);
273 return (
tx *
string.
tx +
290 return in >>
string.tx >>
string.ty >>
string.tx2 >>
string.ty2 >>
string.vs;
306 return out <<
FIXED(10,7) <<
string.tx <<
' '
307 <<
FIXED(10,7) <<
string.ty <<
' '
310 <<
FIXED(8,5) <<
string.vs;
326 public JMath <JEmission>,
443 const double precision = std::numeric_limits<double>::min())
const
445 return (fabs(t1 - emission.
t1) <= precision);
461 return out <<
FIXED(20,6) << emission.
t1;
477 public JMath <JModel>,
515 for (
T hit = __begin; hit != __end; ++hit) {
517 if (!this->
string.has(hit->getString())) {
518 this->
string[hit->getString()] =
JString();
521 if (!this->emission.has(hit->getEKey())) {
522 this->emission[hit->getEKey()] =
JEmission();
560 using namespace JMODEL;
568 this->option =
static_cast<JOption_t>(option);
679 const double precision = std::numeric_limits<double>::min())
const
681 return (this->
string .
equals(model.
string, precision) &&
699 out <<
"string: " << setw(4) << i->first <<
' ' << i->second << endl;
703 out <<
"emission: " << setw(3) << i->first <<
' ' << i->second << endl;
717 return emission.getN(this->option) +
string.getN(this->option);
730 return emission.getN(this->option) +
string.getIndex(
id, p, this->option);
743 return emission.getIndex(
id, p, this->option);
757 if (i < emission.getN(
this->option)) {
return emission.getParameter(i, this->option); }
759 i -= emission.getN(this->option);
761 if (i <
string .
getN(this->option)) {
return string .getParameter(i, this->option); }
777 if (i < emission.getN(
this->option)) {
return emission.getParameter(i, this->option); }
779 i -= emission.getN(this->option);
781 if (i <
string .
getN(this->option)) {
return string .getParameter(i, this->option); }
790 template<
class key_type,
class value_type>
792 public JHashMap<key_type, value_type>
839 return ((
const double*) &value)[offset];
857 return ((
double*) &value)[offset];
883 ((*this)[i->first].*
f1)(i->second);
897 (i->second.*
f1)(factor);
912 q = buffer.begin(); ; ++p, ++q) {
914 if (p != this->end() && q != buffer.end()) {
916 if (p->first != q->first || p->second != q->second) {
920 }
else if (p == this->end() && q == buffer.end()) {
943 q = buffer.begin(); ; ++p, ++q) {
945 if (p != this->end() && q != buffer.end()) {
947 if (p->first != q->first || !p->second.equals(q->second, precision)) {
951 }
else if (p == this->end() && q == buffer.end()) {
1016 return helper(*
this,
id);
fit times of emission of emitters and tilt angles of strings with second order correction and stretch...
size_t getN() const
Get number of fit parameters.
JModel & negate()
Negate model.
void setOption(const int option)
Set fit option.
JString & mul(const double factor)
Scale string.
JEmission()
Default constructor.
Auxiliary base class for aritmetic operations of derived class types.
void clear()
Clear parameters.
double getAngle() const
Get angle.
JEmission & operator[](const int counter)
Get value corresponding to event counter (i.e. second part of JEKey).
JModel & mul(const double factor)
Scale model.
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.
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
static const JZero zero
Function object to assign zero value.
static size_t getN(const JMODEL::JOption_t option)
Get number of fit parameters.
friend std::istream & operator>>(std::istream &in, JString &string)
Read string parameters from input stream.
Auxiliary data structure for floating point format specification.
helper operator[](int id)
Get helper corresponding to emission identifier (i.e. first part of JEKey).
friend std::ostream & operator<<(std::ostream &out, const JString &string)
Write string parameters to output stream.
Definition of zero value for any class.
double operator[](const size_t index) const
Read access to fit parameter value by index.
fit times of emission of emitters and tilt angles of strings
size_t getIndex(const JEKey &id, double JEmission::*p) const
Get index of fit parameter for given emission.
JEmission & add(const JEmission &emission)
Add emission.
static size_t getN(const JMODEL::JOption_t option)
Get number of fit parameters.
friend std::ostream & operator<<(std::ostream &out, const JModel &model)
Write model parameters to output stream.
const JPolynome f1(1.0, 2.0, 3.0)
Function.
Model for fit to acoustics data.
Map emission key to model parameters of emission.
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.
JString & sub(const JString &string)
Subtract string.
Auxiliary class to assign zero value.
size_t getIndex(const key_type key, double value_type::*p, const JMODEL::JOption_t option) const
Get index of parameter.
JEmission & negate()
Negate emission.
double & getParameter(const size_t index, const JMODEL::JOption_t option)
Get read/write access to fit parameter value at given index in buffer.
JMODEL::JEmission JEmission
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.
JACOUSTICS::JModel::emission_type emission
void evaluate(value_type &(value_type::*f1)(const double), const double factor)
Evaluate arithmetic operation.
JMODEL::JOption_t getOption() const
Get fit option.
double getLengthSquared() const
Get length squared.
JEmission & sub(const JEmission &emission)
Subtract emission.
fit times of emission of emitters and tilt angles of strings with second order correction ...
friend std::ostream & operator<<(std::ostream &out, const JEmission &emission)
Write emission parameters to output stream.
bool equals(const JEmission &emission, const double precision=std::numeric_limits< double >::min()) const
Check equality.
size_t getIndex(int id, double JString::*p) const
Get index of fit parameter for given string.
void evaluate(const hash_map &buffer, value_type &(value_type::*f1)(const value_type &))
Evaluate arithmetic operation.
JEmission & mul(const double factor)
Scale emission.
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.
JEmission & div(const double factor)
Scale emission.
JModel & div(const double factor)
Scale model.
hash_map< JEKey, JEmission > & map
JModel()
Default constructor.
JString(const double tx, const double ty, const double tx2=0.0, const double ty2=0.0, const double vs=0.0)
Constructor.
size_t getN(const JMODEL::JOption_t option) const
Get number of fit parameters.
Auxiliary class for multiple associative map operators.
JModel & add(const JModel &model)
Add model.
Auxiliary data structure with extended functionality of hash-map.
void evaluate(value_type &(value_type::*f1)())
Evaluate arithmetic operation.
Base class for data structures with artithmetic capabilities.
bool equals(const hash_map &buffer) const
Check equality of hash map.
JEmission(const double t1)
Constructor.
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.
fit only times of emission of emitters
helper(hash_map< JEKey, JEmission > &map, int id)
Constructor.
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 JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Auxiliary data structure for floating point format specification.
void reset()
Reset parameters.
JString()
Default constructor.
double getDot(const JString &string) const
Get dot product.
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 getLength() const
Get length.
Map string identifier to model parameters of string.
JModel & operator=(const JMATH::JZero &zero)
Reset parameters.
bool equals(const hash_map &buffer, const double precision) const
Check equality of has map.