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 <JEmitter>,
443 const double precision = std::numeric_limits<double>::min())
const
445 return (fabs(t1 - emitter.
t1) <= precision);
461 return out <<
FIXED(20,6) << emitter.
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->emitter.has(hit->getEKey())) {
522 this->emitter[hit->getEKey()] =
JEmitter();
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 <<
"emitter: " << setw(3) << i->first <<
' ' << i->second << endl;
717 return emitter.getN(this->option) +
string.getN(this->option);
730 return emitter.getN(this->option) +
string.getIndex(
id, p, this->option);
743 return emitter.getIndex(
id, p, this->option);
757 if (i < emitter.getN(
this->option)) {
return emitter.getParameter(i, this->option); }
759 i -= emitter.getN(this->option);
761 if (i <
string .
getN(this->option)) {
return string .getParameter(i, this->option); }
777 if (i < emitter.getN(
this->option)) {
return emitter.getParameter(i, this->option); }
779 i -= emitter.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>
837 const value_type& value = this->data()[pos].second;
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...
JEmitter & operator[](const int counter)
Get value corresponding to event counter (i.e. second part of JEKey).
size_t getN() const
Get number of fit parameters.
JModel & negate()
Negate model.
void setOption(const int option)
Set fit option.
helper(hash_map< JEKey, JEmitter > &map, int id)
Constructor.
Auxiliary class for multiple associative map operators.
JString & mul(const double factor)
Scale string.
static size_t getN(const JMODEL::JOption_t option)
Get number of fit parameters.
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.
helper operator[](int id)
Get helper corresponding to emitter identifier (i.e. first part of JEKey).
JEmitter & mul(const double factor)
Scale emitter.
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
JEmitter & div(const double factor)
Scale emitter.
static const JZero zero
Function object to assign zero value.
static size_t getN(const JMODEL::JOption_t option)
Get number of fit parameters.
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.
hash_map< JEKey, JEmitter > & map
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
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.
const JPolynome f1(1.0, 2.0, 3.0)
Function.
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.
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.
double & getParameter(const size_t index, const JMODEL::JOption_t option)
Get read/write 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.
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.
size_t getIndex(const JEKey &id, double JEmitter::*p) const
Get index of fit parameter for given emitter.
JEmitter()
Default constructor.
fit times of emission of emitters and tilt angles of strings with second order correction ...
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.
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, 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.
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.
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
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 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.