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