Jpp  17.2.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JAcoustics/JModel.hh
Go to the documentation of this file.
1 #ifndef __JACOUSTICS__JMODEL__
2 #define __JACOUSTICS__JMODEL__
3 
4 #include <istream>
5 #include <ostream>
6 #include <iomanip>
7 #include <limits>
8 #include <cmath>
9 
10 #include "JMath/JMath.hh"
11 #include "JMath/JZero.hh"
12 #include "JLang/JEquals.hh"
13 #include "JLang/JException.hh"
14 #include "JLang/JManip.hh"
15 #include "JTools/JHashMap.hh"
16 
17 #include "JAcoustics/JEKey.hh"
18 
19 
20 /**
21  * \file
22  *
23  * Model for fit to acoutsics data.
24  * \author mdejong
25  */
26 namespace JACOUSTICS {}
27 namespace JPP { using namespace JACOUSTICS; }
28 
29 namespace JACOUSTICS {
30 
31  using JMATH::JMath;
32  using JLANG::JEquals;
35  using JTOOLS::JHashMap;
36 
37 
38  /**
39  * Auxiliary namespace to encapsulate different model parameters.\n
40  */
41  namespace JMODEL {
42 
43  /**
44  * Fit options.
45  */
46  enum JOption_t {
47  fit_undefined_t = -1, //!< fit undefined
48  fit_emitters_only_t = 0, //!< fit only times of emission of emitters
49  fit_emitters_and_strings_1st_order_t = 1, //!< fit times of emission of emitters and tilt angles of strings
50  fit_emitters_and_strings_2nd_order_t = 2, //!< fit times of emission of emitters and tilt angles of strings with second order correction
51  fit_emitters_and_strings_2nd_order_and_stretching_t = 3 //!< fit times of emission of emitters and tilt angles of strings with second order correction and stretching of string
52  };
53 
54 
55  /**
56  * String parameters.
57  */
58  struct JString :
59  public JMath <JString>,
60  public JEquals<JString>
61  {
62  /**
63  * Default constructor.
64  */
65  JString() :
66  tx (0.0),
67  ty (0.0),
68  tx2(0.0),
69  ty2(0.0),
70  vs (0.0)
71  {}
72 
73 
74  /**
75  * Constructor.
76  *
77  * \param tx slope dx/dz
78  * \param ty slope dy/dz
79  * \param tx2 2nd order correction of slope dx/dz
80  * \param ty2 2nd order correction of slope dy/dz
81  * \param vs stretching factor
82  */
83  JString(const double tx,
84  const double ty,
85  const double tx2 = 0.0,
86  const double ty2 = 0.0,
87  const double vs = 0.0) :
88  tx (tx),
89  ty (ty),
90  tx2(tx2),
91  ty2(ty2),
92  vs (vs)
93  {}
94 
95 
96  /**
97  * Get number of fit parameters.
98  *
99  * \param option option
100  * \return number of parameters
101  */
102  static inline size_t getN(const JMODEL::JOption_t option)
103  {
104  switch (option) {
105 
106  case fit_undefined_t:
107  case fit_emitters_only_t:
108  return 0;
109 
111  return 2;
112 
114  return 4;
115 
117  return 5;
118 
119  default:
120  THROW(JValueOutOfRange, "Invalid option " << option);
121  }
122  }
123 
124 
125  /**
126  * Negate string.
127  *
128  * \return this string
129  */
131  {
132  tx = -tx;
133  ty = -ty;
134  tx2 = -tx2;
135  ty2 = -ty2;
136  vs = -vs;
137 
138  return *this;
139  }
140 
141 
142  /**
143  * Add string.
144  *
145  * \param string string
146  * \return this string
147  */
148  JString& add(const JString& string)
149  {
150  tx += string.tx;
151  ty += string.ty;
152  tx2 += string.tx2;
153  ty2 += string.ty2;
154  vs += string.vs;
155 
156  return *this;
157  }
158 
159 
160  /**
161  * Subtract string.
162  *
163  * \param string string
164  * \return this string
165  */
166  JString& sub(const JString& string)
167  {
168  tx -= string.tx;
169  ty -= string.ty;
170  tx2 -= string.tx2;
171  ty2 -= string.ty2;
172  vs -= string.vs;
173 
174  return *this;
175  }
176 
177 
178  /**
179  * Scale string.
180  *
181  * \param factor multiplication factor
182  * \return this string
183  */
184  JString& mul(const double factor)
185  {
186  tx *= factor;
187  ty *= factor;
188  tx2 *= factor;
189  ty2 *= factor;
190  vs *= factor;
191 
192  return *this;
193  }
194 
195 
196  /**
197  * Scale string.
198  *
199  * \param factor division factor
200  * \return this string
201  */
202  JString& div(const double factor)
203  {
204  tx /= factor;
205  ty /= factor;
206  tx2 /= factor;
207  ty2 /= factor;
208  vs /= factor;
209 
210  return *this;
211  }
212 
213 
214  /**
215  * Check equality.
216  *
217  * \param string string
218  * \param precision precision
219  * \return true if strings are equal; else false
220  */
221  bool equals(const JString& string,
222  const double precision = std::numeric_limits<double>::min()) const
223  {
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);
229  }
230 
231 
232  /**
233  * Get length squared.
234  *
235  * \return square of length
236  */
237  double getLengthSquared() const
238  {
239  return tx*tx + ty*ty;
240  }
241 
242 
243  /**
244  * Get length.
245  *
246  * \return length
247  */
248  double getLength() const
249  {
250  return sqrt(getLengthSquared());
251  }
252 
253 
254  /**
255  * Get angle.
256  *
257  * \return angle [rad]
258  */
259  double getAngle() const
260  {
261  return atan2(ty, tx);
262  }
263 
264 
265  /**
266  * Get dot product.
267  *
268  * \param string string
269  * \return dot product
270  */
271  double getDot(const JString& string) const
272  {
273  return (tx * string.tx +
274  ty * string.ty +
275  tx2 * string.tx2 +
276  ty2 * string.ty2 +
277  vs * string.vs);
278  }
279 
280 
281  /**
282  * Read string parameters from input stream.
283  *
284  * \param in input stream
285  * \param string string
286  * \return input stream
287  */
288  friend inline std::istream& operator>>(std::istream& in, JString& string)
289  {
290  return in >> string.tx >> string.ty >> string.tx2 >> string.ty2 >> string.vs;
291  }
292 
293 
294  /**
295  * Write string parameters to output stream.
296  *
297  * \param out output stream
298  * \param string string
299  * \return output stream
300  */
301  friend inline std::ostream& operator<<(std::ostream& out, const JString& string)
302  {
303  using namespace std;
304  using namespace JPP;
305 
306  return out << FIXED(10,7) << string.tx << ' '
307  << FIXED(10,7) << string.ty << ' '
308  << SCIENTIFIC(12,3) << string.tx2 << ' '
309  << SCIENTIFIC(12,3) << string.ty2 << ' '
310  << FIXED(8,5) << string.vs;
311  }
312 
313 
314  double tx;
315  double ty;
316  double tx2;
317  double ty2;
318  double vs;
319  };
320 
321 
322  /**
323  * Emitter parameters.
324  */
325  struct JEmitter :
326  public JMath <JEmitter>,
327  public JEquals<JEmitter>
328  {
329  /**
330  * Default constructor.
331  */
333  t1(0.0)
334  {}
335 
336 
337  /**
338  * Constructor.
339  *
340  * \param t1 time-of-emission [s]
341  */
342  JEmitter(const double t1) :
343  t1(t1)
344  {}
345 
346 
347  /**
348  * Get number of fit parameters.
349  *
350  * \param option option
351  * \return number of parameters
352  */
353  static inline size_t getN(const JMODEL::JOption_t option)
354  {
355  switch (option) {
356 
357  case fit_undefined_t:
358  return 0;
359 
360  default:
361  return 1;
362  }
363  }
364 
365 
366  /**
367  * Negate emitter.
368  *
369  * \return this emitter
370  */
372  {
373  t1 = -t1;
374 
375  return *this;
376  }
377 
378 
379  /**
380  * Add emitter.
381  *
382  * \param emitter emitter
383  * \return this emitter
384  */
385  JEmitter& add(const JEmitter& emitter)
386  {
387  t1 += emitter.t1;
388 
389  return *this;
390  }
391 
392 
393  /**
394  * Subtract emitter.
395  *
396  * \param emitter emitter
397  * \return this emitter
398  */
399  JEmitter& sub(const JEmitter& emitter)
400  {
401  t1 -= emitter.t1;
402 
403  return *this;
404  }
405 
406 
407  /**
408  * Scale emitter.
409  *
410  * \param factor multiplication factor
411  * \return this emitter
412  */
413  JEmitter& mul(const double factor)
414  {
415  t1 *= factor;
416 
417  return *this;
418  }
419 
420 
421  /**
422  * Scale emitter.
423  *
424  * \param factor division factor
425  * \return this emitter
426  */
427  JEmitter& div(const double factor)
428  {
429  t1 /= factor;
430 
431  return *this;
432  }
433 
434 
435  /**
436  * Check equality.
437  *
438  * \param emitter emitter
439  * \param precision precision
440  * \return true if emitters are equal; else false
441  */
442  bool equals(const JEmitter& emitter,
443  const double precision = std::numeric_limits<double>::min()) const
444  {
445  return (fabs(t1 - emitter.t1) <= precision);
446  }
447 
448 
449  /**
450  * Write emitter parameters to output stream.
451  *
452  * \param out output stream
453  * \param emitter emitter
454  * \return output stream
455  */
456  friend inline std::ostream& operator<<(std::ostream& out, const JEmitter& emitter)
457  {
458  using namespace std;
459  using namespace JPP;
460 
461  return out << FIXED(20,6) << emitter.t1;
462  }
463 
464 
465  double t1;
466  };
467  }
468 
469 
470  /**
471  * Model for fit to acoustics data.
472  *
473  * The model consists of string parameters and emitter parameters.\n
474  * These parameters relate to the string identifer and emitter key, respectively.
475  */
476  struct JModel :
477  public JMath <JModel>,
478  public JEquals<JModel>
479  {
482 
483 
484  /**
485  * Type definition of fit parameter.
486  */
487  typedef size_t parameter_type;
488 
489 
490  /**
491  * Default constructor.
492  */
493  JModel() :
494  option(JMODEL::fit_undefined_t)
495  {}
496 
497 
498  /**
499  * Constructor.
500  *
501  * This constructor can be used to set up a default model (i.e. all values at zero) for the given set of hits.\n
502  * The data type corresponding to the hits should provide for the following policy methods.
503  * <pre>
504  * int getString(); // get string identifier
505  * JEKey getEKey(); // get emitter key
506  * </pre>
507  *
508  * \param __begin begin of hits
509  * \param __end end of hits
510  */
511  template<class T>
512  JModel(T __begin, T __end) :
513  option(JMODEL::fit_undefined_t)
514  {
515  for (T hit = __begin; hit != __end; ++hit) {
516 
517  if (!this->string.has(hit->getString())) {
518  this->string[hit->getString()] = JString();
519  }
520 
521  if (!this->emitter.has(hit->getEKey())) {
522  this->emitter[hit->getEKey()] = JEmitter();
523  }
524  }
525  }
526 
527 
528  /**
529  * Reset parameters.
530  *
531  * \param zero zero
532  * \return this model
533  */
535  {
536  this->reset();
537 
538  return *this;
539  }
540 
541 
542  /**
543  * Get fit option.
544  *
545  * \return option
546  */
548  {
549  return option;
550  }
551 
552 
553  /**
554  * Set fit option.
555  *
556  * \param option option
557  */
558  void setOption(const int option)
559  {
560  using namespace JMODEL;
561 
562  switch (option) {
563 
564  case fit_emitters_only_t:
568  this->option = static_cast<JOption_t>(option);
569  break;
570 
571  default:
572  THROW(JValueOutOfRange, "Invalid option " << option);
573  }
574  }
575 
576 
577  /**
578  * Clear parameters.
579  */
580  void clear()
581  {
582  string .clear();
583  emitter.clear();
584  }
585 
586 
587  /**
588  * Reset parameters.
589  */
590  void reset()
591  {
592  string .reset();
593  emitter.reset();
594  }
595 
596 
597  /**
598  * Negate model.
599  *
600  * \return this model
601  */
603  {
604  this->string .evaluate(&JString ::negate);
605  this->emitter.evaluate(&JEmitter::negate);
606 
607  return *this;
608  }
609 
610 
611  /**
612  * Add model.
613  *
614  * \param model model
615  * \return this model
616  */
617  JModel& add(const JModel& model)
618  {
619  this->string .evaluate(model.string, &JString ::add);
620  this->emitter.evaluate(model.emitter, &JEmitter::add);
621 
622  return *this;
623  }
624 
625 
626  /**
627  * Subtract model.
628  *
629  * \param model model
630  * \return this model
631  */
632  JModel& sub(const JModel& model)
633  {
634  this->string .evaluate(model.string, &JString ::sub);
635  this->emitter.evaluate(model.emitter, &JEmitter::sub);
636 
637  return *this;
638  }
639 
640 
641  /**
642  * Scale model.
643  *
644  * \param factor multiplication factor
645  * \return this model
646  */
647  JModel& mul(const double factor)
648  {
649  this->string .evaluate(&JString ::mul, factor);
650  this->emitter.evaluate(&JEmitter::mul, factor);
651 
652  return *this;
653  }
654 
655 
656  /**
657  * Scale model.
658  *
659  * \param factor division factor
660  * \return this model
661  */
662  JModel& div(const double factor)
663  {
664  this->string .evaluate(&JString ::div, factor);
665  this->emitter.evaluate(&JEmitter::div, factor);
666 
667  return *this;
668  }
669 
670 
671  /**
672  * Check equality.
673  *
674  * \param model model
675  * \param precision precision
676  * \return true if models are equal; else false
677  */
678  bool equals(const JModel& model,
679  const double precision = std::numeric_limits<double>::min()) const
680  {
681  return (this->string .equals(model.string, precision) &&
682  this->emitter.equals(model.emitter, precision));
683  }
684 
685 
686  /**
687  * Write model parameters to output stream.
688  *
689  * \param out output stream
690  * \param model model
691  * \return output stream
692  */
693  friend inline std::ostream& operator<<(std::ostream& out, const JModel& model)
694  {
695  using namespace std;
696  using namespace JPP;
697 
698  for (hash_map<int, JString>::const_iterator i = model.string.begin(); i != model.string.end(); ++i) {
699  out << "string: " << setw(4) << i->first << ' ' << i->second << endl;
700  }
701 
702  for (hash_map<JEKey, JEmitter>::const_iterator i = model.emitter.begin(); i != model.emitter.end(); ++i) {
703  out << "emitter: " << setw(3) << i->first << ' ' << i->second << endl;
704  }
705 
706  return out;
707  }
708 
709 
710  /**
711  * Get number of fit parameters.
712  *
713  * \return number of parameters
714  */
715  size_t getN() const
716  {
717  return emitter.getN(this->option) + string.getN(this->option);
718  }
719 
720 
721  /**
722  * Get index of fit parameter for given string.
723  *
724  * \param id string identifier
725  * \param p pointer to data member
726  * \return parameter
727  */
728  size_t getIndex(int id, double JString::*p) const
729  {
730  return emitter.getN(this->option) + string.getIndex(id, p, this->option);
731  }
732 
733 
734  /**
735  * Get index of fit parameter for given emitter.
736  *
737  * \param id emitter key
738  * \param p pointer to data member
739  * \return parameter
740  */
741  size_t getIndex(const JEKey& id, double JEmitter::*p) const
742  {
743  return emitter.getIndex(id, p, this->option);
744  }
745 
746 
747  /**
748  * Read access to fit parameter value by index.
749  *
750  * \param index index
751  * \return value
752  */
753  inline double operator[](const size_t index) const
754  {
755  size_t i = index;
756 
757  if (i < emitter.getN(this->option)) { return emitter.getParameter(i, this->option); }
758 
759  i -= emitter.getN(this->option);
760 
761  if (i < string .getN(this->option)) { return string .getParameter(i, this->option); }
762 
763  THROW(JIndexOutOfRange, "Invalid index " << index << " >= " << getN());
764  }
765 
766 
767  /**
768  * Read/write access to fit parameter value by index.
769  *
770  * \param index index
771  * \return value
772  */
773  inline double& operator[](const size_t index)
774  {
775  size_t i = index;
776 
777  if (i < emitter.getN(this->option)) { return emitter.getParameter(i, this->option); }
778 
779  i -= emitter.getN(this->option);
780 
781  if (i < string .getN(this->option)) { return string .getParameter(i, this->option); }
782 
783  THROW(JIndexOutOfRange, "Invalid index " << index << " >= " << getN());
784  }
785 
786 
787  /**
788  * Auxiliary data structure with extended functionality of hash-map.
789  */
790  template<class key_type, class value_type>
791  struct hash_map :
792  public JHashMap<key_type, value_type>
793  {
794  /**
795  * Get number of fit parameters.
796  *
797  * \param option option
798  * \return number of parameters
799  */
800  size_t getN(const JMODEL::JOption_t option) const
801  {
802  return this->size() * value_type::getN(option);
803  }
804 
805 
806  /**
807  * Get index of parameter.
808  *
809  * \param key key
810  * \param p pointer to data member
811  * \param option option
812  * \return index
813  */
814  size_t getIndex(const key_type key, double value_type::*p, const JMODEL::JOption_t option) const
815  {
816  value_type* __p__ = NULL;
817 
818  if (this->has(key))
819  return static_cast<const JHashMap<key_type, value_type>&>(*this).getIndex(key) * value_type::getN(option) + ((double*) &(__p__->*p) - (double*) __p__);
820  else
821  THROW(JValueOutOfRange, "Invalid key " << key);
822  }
823 
824 
825  /**
826  * Get read access to fit parameter value at given index in buffer.
827  *
828  * \param index index
829  * \param option option
830  * \return value
831  */
832  double getParameter(const size_t index, const JMODEL::JOption_t option) const
833  {
834  const size_t pos = index / value_type::getN(option); // position of element in buffer
835  const size_t offset = index % value_type::getN(option); // offset of parameter in element
836 
837  const value_type& value = this->data()[pos].second; // value of element at given position
838 
839  return ((const double*) &value)[offset]; // parameter at given offset
840  }
841 
842 
843  /**
844  * Get read/write access to fit parameter value at given index in buffer.
845  *
846  * \param index index
847  * \param option option
848  * \return value
849  */
850  double& getParameter(const size_t index, const JMODEL::JOption_t option)
851  {
852  const size_t pos = index / value_type::getN(option); // position of element in buffer
853  const size_t offset = index % value_type::getN(option); // offset of parameter in element
854 
855  value_type& value = this->data()[pos].second; // value of element at given position
856 
857  return ((double*) &value)[offset]; // parameter at given offset
858  }
859 
860 
861  /**
862  * Evaluate arithmetic operation.
863  *
864  * \param f1 operation
865  */
867  {
868  for (typename JHashMap<key_type, value_type>::iterator i = this->begin(); i != this->end(); ++i) {
869  (i->second.*f1)();
870  }
871  }
872 
873 
874  /**
875  * Evaluate arithmetic operation.
876  *
877  * \param buffer buffer
878  * \param f1 operation
879  */
880  void evaluate(const hash_map& buffer, value_type& (value_type::*f1)(const value_type&))
881  {
882  for (typename JHashMap<key_type, value_type>::const_iterator i = buffer.begin(); i != buffer.end(); ++i) {
883  ((*this)[i->first].*f1)(i->second);
884  }
885  }
886 
887 
888  /**
889  * Evaluate arithmetic operation.
890  *
891  * \param f1 operation
892  * \param factor factor
893  */
894  void evaluate(value_type& (value_type::*f1)(const double), const double factor)
895  {
896  for (typename JHashMap<key_type, value_type>::iterator i = this->begin(); i != this->end(); ++i) {
897  (i->second.*f1)(factor);
898  }
899  }
900 
901 
902  /**
903  * Check equality of hash map.
904  *
905  * \param buffer buffer
906  * \return true if hash map is equal; else false
907  */
908  bool equals(const hash_map& buffer) const
909  {
911  p = this->begin(),
912  q = buffer.begin(); ; ++p, ++q) {
913 
914  if (p != this->end() && q != buffer.end()) {
915 
916  if (p->first != q->first || p->second != q->second) {
917  return false;
918  }
919 
920  } else if (p == this->end() && q == buffer.end()) {
921 
922  return true;
923 
924  } else {
925 
926  return false;
927  }
928  }
929  }
930 
931 
932  /**
933  * Check equality of has map.
934  *
935  * \param buffer buffer
936  * \param precision precision
937  * \return true if hash map is equal; else false
938  */
939  bool equals(const hash_map& buffer, const double precision) const
940  {
942  p = this->begin(),
943  q = buffer.begin(); ; ++p, ++q) {
944 
945  if (p != this->end() && q != buffer.end()) {
946 
947  if (p->first != q->first || !p->second.equals(q->second, precision)) {
948  return false;
949  }
950 
951  } else if (p == this->end() && q == buffer.end()) {
952 
953  return true;
954 
955  } else {
956 
957  return false;
958  }
959  }
960  }
961  };
962 
963 
964  /**
965  * Map emitter key to model parameters of emitter.
966  */
967  struct emitter_type :
968  public hash_map<JEKey, JEmitter>
969  {
970  private:
971  /**
972  * Auxiliary class for multiple associative map operators.
973  */
974  struct helper {
975  /**
976  * Constructor.
977  *
978  * \param map map
979  * \param id emitter identifier
980  */
982  map(map),
983  id (id)
984  {}
985 
986 
987  /**
988  * Get value corresponding to event counter (i.e.\ second part of JEKey).
989  *
990  * \param counter event counter
991  * \return emitter
992  */
993  JEmitter& operator[](const int counter)
994  {
995  return map[JEKey(id, counter)];
996  }
997 
998  private:
1000  const int id;
1001  };
1002 
1003  public:
1004 
1006 
1007 
1008  /**
1009  * Get helper corresponding to emitter identifier (i.e.\ first part of JEKey).
1010  *
1011  * \param id emitter identifier
1012  * \return helper
1013  */
1015  {
1016  return helper(*this, id);
1017  }
1018 
1019  } emitter;
1020 
1021 
1022  /**
1023  * Map string identifier to model parameters of string.
1024  */
1025  struct string_type :
1026  public hash_map<int, JString>
1027  {} string;
1028 
1029  private:
1031  };
1032 }
1033 
1034 #endif
JMODEL::JOption_t option
fit times of emission of emitters and tilt angles of strings with second order correction and stretch...
JKey_t key_type
Definition: JHashMap.hh:78
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.
Exceptions.
helper(hash_map< JEKey, JEmitter > &map, int id)
Constructor.
Auxiliary class for multiple associative map operators.
double getN(const JRange< T > &range, const double R)
Get expected number of occurrences due to given rate within specified interval.
Definition: JRange.hh:713
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.
Definition: JMath.hh:109
void clear()
Clear parameters.
double getAngle() const
Get angle.
General purpose class for hash map of unique keys.
Definition: JHashMap.hh:72
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.
Definition: JException.hh:696
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.
Definition: JZero.hh:105
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.
Definition: JManip.hh:446
int getIndex(const T &value) const
Get index of given value.
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
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.
Definition: JZero.hh:81
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.
JMODEL::JString JString
Template definition of auxiliary base class for comparison of data structures.
Definition: JEquals.hh:24
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 ...
I/O manipulators.
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.
Emitter hash key.
JACOUSTICS::JModel::string_type string
JString & div(const double factor)
Scale string.
void reset(T &value)
Reset value.
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.
Emitter key.
Definition: JEKey.hh:32
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.
Definition: JException.hh:162
Exception for accessing an index in a collection that is outside of its range.
Definition: JException.hh:90
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
Definition: JCanberra.sh:46
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:484
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.