Jpp  16.0.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JTransformableMultiHistogram.hh
Go to the documentation of this file.
1 #ifndef __JTOOLS__JTRANSFORMABLEMULTIHISTOGRAM__
2 #define __JTOOLS__JTRANSFORMABLEMULTIHISTOGRAM__
3 
4 #include "JIO/JSerialisable.hh"
6 
7 #include "JTools/JMultiMap.hh"
10 #include "JTools/JArray.hh"
11 #include "JIO/JSerialisable.hh"
12 
13 
14 /**
15  * \author mdejong
16  */
17 
18 namespace JTOOLS {}
19 namespace JPP { using namespace JTOOLS; }
20 
21 namespace JTOOLS {
22 
23  using JIO::JReader;
24  using JIO::JWriter;
25 
26 
27  /**
28  * Transformable multidimensional histogram.
29  *
30  * This class implements the JTransformable interface.
31  */
32  template<class JHistogram_t,
33  class JMaplist_t,
36  public JMultiHistogram<JHistogram_t, JMaplist_t, JDistance_t>,
37  public JTransformable<JMapLength<JMaplist_t>::value, typename JHistogram_t::abscissa_type>
38  {
39  public:
40 
41  typedef JMultiHistogram<JHistogram_t,
42  JMaplist_t,
43  JDistance_t> JMultiHistogram_t;
44 
46 
47  typedef JHistogram_t histogram_type;
48 
49  typedef typename histogram_type::contents_type contents_type;
50  typedef typename histogram_type::value_type value_type;
51 
54 
59 
62 
65 
66 
67  /**
68  * Default constructor.
69  */
71  transformer(transformer_type::getClone())
72  {}
73 
74 
75  /**
76  * Get transformable multidimensional histogram.
77  *
78  * \return this transformable multidimensional histogram
79  */
81  {
82  return static_cast<const JTransformableMultiHistogram&>(*this);
83  }
84 
85 
86  /**
87  * Get transformable multidimensional histogram.
88  *
89  * \return this transformable multidimensional histogram
90  */
92  {
93  return static_cast<JTransformableMultiHistogram&>(*this);
94  }
95 
96 
97  /**
98  * Application of weight function and coordinate transformation.
99  *
100  * \param transformer function transformer
101  */
102  virtual void transform(const transformer_type& transformer) override
103  {
104  typedef typename transformer_type::array_type array_type;
105 
106  for (super_iterator i = this->super_begin(); i != this->super_end(); ++i) {
107 
108  const array_type array = (*i).getKey();
109  histogram_type& histogram = (*i).getValue();
110 
111  const JMultiMapGetTransformer<NUMBER_OF_DIMENSIONS - 1, value_type> get(*(this->transformer), array);
112  const JMultiMapPutTransformer<NUMBER_OF_DIMENSIONS - 1, value_type> put( transformer, array);
113 
114  histogram.transform(get);
115  histogram.transform(put);
116  }
117 
118  this->transformer.reset(transformer.clone());
119  }
120 
121 
122  /**
123  * Read transformable multidimensional histogram.
124  *
125  * \param in reader
126  * \param object transformable multidimensional histogram.
127  * \return reader
128  */
130  {
131  in >> static_cast<JMultiHistogram_t&>(object);
132 
133  return object.transformer->read(in);
134  }
135 
136 
137  /**
138  * Write transformable multidimensional histogram.
139  *
140  * \param out writer
141  * \param object transformable multidimensional histogram
142  * \return writer
143  */
144  friend inline JWriter& operator<<(JWriter& out, const JTransformableMultiHistogram& object)
145  {
146  out << static_cast<const JMultiHistogram_t&>(object);
147 
148  return object.transformer->write(out);
149  }
150 
151 
153 
154  protected:
155  /**
156  * Termination method for filling histogram.
157  *
158  * \param i index
159  * \param x abscissa value
160  * \param w weight
161  */
162  virtual void __fill__(const int i, const abscissa_type x, const contents_type w) override
163  {
164  this->buffer[NUMBER_OF_DIMENSIONS - 1] = transformer->putXn(this->buffer, this->buffer[NUMBER_OF_DIMENSIONS - 1]);
165 
166  const double z = transformer->putXn(this->buffer, 1.0) - transformer->putXn(this->buffer, 0.0);
167  const double W = transformer->getWeight(this->buffer);
168 
169  this->evaluate(this->buffer.begin(), w * z / W);
170 
171  this->evaluate(this->buffer.begin(), w);
172  }
173  };
174 }
175 
176 #endif
data_type w[N+1][M+1]
Definition: JPolint.hh:757
friend JReader & operator>>(JReader &in, JTransformableMultiHistogram &object)
Read transformable multidimensional histogram.
JMultiMapTransformer< JMapLength< JMaplist_t >::value, abscissa_type > transformer_type
Interface for binary output.
JMultiMap is a general purpose multidimensional map based on a type list of maps. ...
const_iterator begin() const
get iterator to begin of data
Definition: JArray.hh:207
Template class for distance evaluation.
Definition: JDistance.hh:24
friend JWriter & operator<<(JWriter &out, const JTransformableMultiHistogram &object)
Write transformable multidimensional histogram.
JMultiHistogram_t::reverse_iterator reverse_iterator
JLANG::JSharedPointer< transformer_type > transformer
JMultiHistogram_t::abscissa_type abscissa_type
multimap_type::super_iterator super_iterator
virtual int write(const char *buffer, const int length)=0
Write byte array.
multimap_type::super_const_iterator super_const_iterator
Auxiliary class to convert JMultiMapTransformer to JCollectionElementTransformer. ...
JMultiHistogram_t::ordinate_type ordinate_type
virtual clone_type clone() const override
Get clone of this object.
Definition: JClonable.hh:69
JMultiHistogram< JHistogram_t, JMaplist_t, JDistance_t > JMultiHistogram_t
JMultiHistogram_t::const_iterator const_iterator
The template JSharedPointer class can be used to share a pointer to an object.
Abstract interface for transformable multidimensional map.
Transformable multidimensional histogram.
virtual void __fill__(const int i, const abscissa_type x, const contents_type w) override
Termination method for filling histogram.
multimap_type::const_reverse_iterator const_reverse_iterator
Interface for binary input.
JArray< NUMBER_OF_DIMENSIONS, abscissa_type > buffer
virtual void transform(const transformer_type &transformer) override
Application of weight function and coordinate transformation.
JHistogram_t::contents_type contents_type
One dimensional array of template objects with fixed length.
Definition: JArray.hh:40
JMultiHistogram_t::const_reverse_iterator const_reverse_iterator
multimap_type::const_iterator const_iterator
JMultiHistogram_t::super_const_iterator super_const_iterator
multimap_type::abscissa_type abscissa_type
Multidimensional histogram.
const JTransformableMultiHistogram & getTransformableMultiHistogram() const
Get transformable multidimensional histogram.
JMultiHistogram_t::super_iterator super_iterator
Interface for weight application and coordinate transformation of function.
multimap_type::reverse_iterator reverse_iterator
Auxiliary class to convert JMultiMapTransformer to JCollectionElementTransformer. ...
multimap_type::ordinate_type ordinate_type
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 source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:42
multimap_type::iterator iterator
JTransformableMultiHistogram & getTransformableMultiHistogram()
Get transformable multidimensional histogram.