| [28c025] | 1 | /* | 
|---|
|  | 2 | * SamplingGrid.hpp | 
|---|
|  | 3 | * | 
|---|
|  | 4 | *  Created on: 25.07.2012 | 
|---|
|  | 5 | *      Author: heber | 
|---|
|  | 6 | */ | 
|---|
|  | 7 |  | 
|---|
|  | 8 | #ifndef SAMPLINGGRID_HPP_ | 
|---|
|  | 9 | #define SAMPLINGGRID_HPP_ | 
|---|
|  | 10 |  | 
|---|
|  | 11 | // include config.h | 
|---|
|  | 12 | #ifdef HAVE_CONFIG_H | 
|---|
|  | 13 | #include <config.h> | 
|---|
|  | 14 | #endif | 
|---|
|  | 15 |  | 
|---|
| [fb3485] | 16 | #include <boost/function.hpp> | 
|---|
| [c889b7] | 17 | #include <iosfwd> | 
|---|
| [28c025] | 18 | #include <vector> | 
|---|
|  | 19 |  | 
|---|
|  | 20 | #include "boost/serialization/export.hpp" | 
|---|
|  | 21 | #include "boost/serialization/vector.hpp" | 
|---|
|  | 22 |  | 
|---|
| [5b1e5e] | 23 | #include "LinearAlgebra/defs.hpp" | 
|---|
|  | 24 |  | 
|---|
| [fbf143] | 25 | #include "Fragmentation/Summation/SetValues/SamplingGridProperties.hpp" | 
|---|
| [955051] | 26 | #include "Fragmentation/Summation/ZeroInstance.hpp" | 
|---|
| [28c025] | 27 |  | 
|---|
|  | 28 | class MPQCData; | 
|---|
| [c889b7] | 29 | class SamplingGridTest; | 
|---|
| [28c025] | 30 |  | 
|---|
|  | 31 | /** This class stores a sample function on a three-dimensional grid. | 
|---|
| [3d9a8d] | 32 | * | 
|---|
|  | 33 | *  \note We do not use boost::multi_array because it is not trivial to serialize. | 
|---|
| [28c025] | 34 | * | 
|---|
|  | 35 | */ | 
|---|
| [c889b7] | 36 | class SamplingGrid : public SamplingGridProperties | 
|---|
|  | 37 | { | 
|---|
|  | 38 | //!> grant unit test access to private parts | 
|---|
|  | 39 | friend class SamplingGridTest; | 
|---|
|  | 40 | //!> grant output operator access | 
|---|
|  | 41 | friend std::ostream & operator<<(std::ostream &ost, const SamplingGrid& other); | 
|---|
| [28c025] | 42 | public: | 
|---|
| [c889b7] | 43 | //!> typedef for sampled values | 
|---|
|  | 44 | typedef std::vector< double > sampledvalues_t; | 
|---|
|  | 45 |  | 
|---|
| [c6355f] | 46 | /** Constructor for class SamplingGrid for full window. | 
|---|
|  | 47 | * | 
|---|
|  | 48 | * Here, the window of sampled values spans the given domain. | 
|---|
| [28c025] | 49 | * | 
|---|
| [3d9a8d] | 50 | * \param _begin offset for grid per axis | 
|---|
|  | 51 | * \param _end edge length of grid per axis | 
|---|
|  | 52 | * \param _level number of grid points in \f$2^{\mathrm{level}}\f$ | 
|---|
| [28c025] | 53 | * \param _sampled_grid sample points | 
|---|
|  | 54 | */ | 
|---|
| [5b1e5e] | 55 | SamplingGrid(const double _begin[NDIM], | 
|---|
|  | 56 | const double _end[NDIM], | 
|---|
| [28c025] | 57 | const int _level, | 
|---|
| [c889b7] | 58 | const sampledvalues_t &_sampled_grid); | 
|---|
| [28c025] | 59 |  | 
|---|
| [c6355f] | 60 | /** Constructor for class SamplingGrid for empty window. | 
|---|
| [28c025] | 61 | * | 
|---|
| [c6355f] | 62 | * Here, the window is initially of size zero. | 
|---|
|  | 63 | * | 
|---|
|  | 64 | * \param _begin offset for grid per axis | 
|---|
|  | 65 | * \param _end edge length of grid per axis | 
|---|
| [c91572] | 66 | * \param _level number of grid points in \f$2^{\mathrm{level}}\f$ | 
|---|
| [28c025] | 67 | */ | 
|---|
| [5b1e5e] | 68 | SamplingGrid(const double _begin[NDIM], | 
|---|
|  | 69 | const double _end[NDIM], | 
|---|
| [c6355f] | 70 | const int _level); | 
|---|
| [28c025] | 71 |  | 
|---|
| [c6355f] | 72 | /** Copy constructor for class SamplingGrid with full window from SamplingGridProperties. | 
|---|
|  | 73 | * | 
|---|
|  | 74 | * Here, the window is initially empty. | 
|---|
| [28c025] | 75 | * | 
|---|
|  | 76 | * \param _props properties to copy | 
|---|
|  | 77 | */ | 
|---|
|  | 78 | SamplingGrid(const SamplingGridProperties &_props); | 
|---|
|  | 79 |  | 
|---|
| [c6355f] | 80 | /** Copy constructor for class SamplingGrid with empty window from SamplingGridProperties. | 
|---|
|  | 81 | * | 
|---|
|  | 82 | * Here, the window must span the whole domain | 
|---|
| [c889b7] | 83 | * | 
|---|
|  | 84 | * \param _props properties to copy | 
|---|
|  | 85 | * \param _sampled_grid sample points | 
|---|
|  | 86 | */ | 
|---|
|  | 87 | SamplingGrid( | 
|---|
|  | 88 | const SamplingGridProperties &_props, | 
|---|
|  | 89 | const sampledvalues_t &_sampled_grid); | 
|---|
|  | 90 |  | 
|---|
| [c6355f] | 91 | /** Copy constructor for class SamplingGrid. | 
|---|
|  | 92 | * | 
|---|
|  | 93 | * The window of sampled values corresponds to the one on \a _grid. | 
|---|
|  | 94 | * | 
|---|
|  | 95 | * \param _grid grid to copy | 
|---|
|  | 96 | */ | 
|---|
|  | 97 | SamplingGrid(const SamplingGrid &_grid); | 
|---|
|  | 98 |  | 
|---|
| [28c025] | 99 | /** default cstor. | 
|---|
|  | 100 | */ | 
|---|
| [1a00bb] | 101 | SamplingGrid(); | 
|---|
| [28c025] | 102 |  | 
|---|
|  | 103 | virtual ~SamplingGrid(); | 
|---|
|  | 104 |  | 
|---|
| [c0e8fb] | 105 | /** Checks whether another instance is consistent with this one. | 
|---|
|  | 106 | * | 
|---|
|  | 107 | *  \note Conistency is stronger as grids must have the same window. | 
|---|
|  | 108 | * | 
|---|
|  | 109 | * \param _props other properties to check against | 
|---|
|  | 110 | * \return true - are consistent, false - else | 
|---|
|  | 111 | */ | 
|---|
|  | 112 | bool isCongruent(const SamplingGrid &_props) const; | 
|---|
|  | 113 |  | 
|---|
| [c889b7] | 114 | /** Assignment operator. | 
|---|
|  | 115 | * | 
|---|
|  | 116 | * \param other other instance to assign ourselves to | 
|---|
|  | 117 | */ | 
|---|
|  | 118 | SamplingGrid& operator=(const SamplingGrid& other); | 
|---|
|  | 119 |  | 
|---|
|  | 120 | /** Addition operator with another SamplingGrid instance \a other. | 
|---|
|  | 121 | * | 
|---|
|  | 122 | * \param other other instance to sum onto this one. | 
|---|
|  | 123 | * \return ref to this instance | 
|---|
|  | 124 | */ | 
|---|
|  | 125 | SamplingGrid& operator+=(const SamplingGrid& other) | 
|---|
|  | 126 | { | 
|---|
|  | 127 | superposeOtherGrids(other, +1.); | 
|---|
|  | 128 | return *this; | 
|---|
|  | 129 | } | 
|---|
|  | 130 |  | 
|---|
| [a1fcc6] | 131 | /** Element-wise multiplication operator with another SamplingGrid instance \a other. | 
|---|
| [313f83] | 132 | * | 
|---|
|  | 133 | * With non-zero windows we have to pay some more attention here. | 
|---|
|  | 134 | * Now, the windows may not be congruent but we have to find the intersection | 
|---|
|  | 135 | * of the two windows and then construct the new window only of this size and | 
|---|
|  | 136 | * multiply. The trick then is not to copy&change the other grid but to | 
|---|
|  | 137 | * access it properly. | 
|---|
| [a1fcc6] | 138 | * | 
|---|
|  | 139 | * \param other other instance to sum onto this one. | 
|---|
|  | 140 | * \return ref to this instance | 
|---|
|  | 141 | */ | 
|---|
|  | 142 | SamplingGrid& operator*=(const SamplingGrid& other); | 
|---|
|  | 143 |  | 
|---|
| [8eafd6] | 144 | /** Scaling values in SamplingGrid instance by \a _value. | 
|---|
|  | 145 | * | 
|---|
|  | 146 | * With non-zero windows we have to pay some more attention here. | 
|---|
|  | 147 | * Now, the windows may not be congruent but we have to find the intersection | 
|---|
|  | 148 | * of the two windows and then construct the new window only of this size and | 
|---|
|  | 149 | * multiply. The trick then is not to copy&change the other grid but to | 
|---|
|  | 150 | * access it properly. | 
|---|
|  | 151 | * | 
|---|
|  | 152 | * \param other other instance to sum onto this one. | 
|---|
|  | 153 | * \return ref to this instance | 
|---|
|  | 154 | */ | 
|---|
|  | 155 | SamplingGrid& operator*=(const double _value); | 
|---|
|  | 156 |  | 
|---|
| [c889b7] | 157 | /** Subtraction operator with another SamplingGrid instance \a other. | 
|---|
|  | 158 | * | 
|---|
|  | 159 | * \param other other instance to subtract from this one. | 
|---|
|  | 160 | * \return ref to this instance | 
|---|
|  | 161 | */ | 
|---|
|  | 162 | SamplingGrid& operator-=(const SamplingGrid& other) | 
|---|
|  | 163 | { | 
|---|
|  | 164 | superposeOtherGrids(other, -1.); | 
|---|
|  | 165 | return *this; | 
|---|
|  | 166 | } | 
|---|
|  | 167 |  | 
|---|
| [06653a] | 168 | /** Sample a given grid \a other down to grid level \a _level and store | 
|---|
|  | 169 | * in \a instance. | 
|---|
|  | 170 | * | 
|---|
|  | 171 | * \param instance given instance to store downsampled grid in | 
|---|
|  | 172 | * \param other instance to get grid from | 
|---|
|  | 173 | * \param _level level to sample down to | 
|---|
|  | 174 | */ | 
|---|
|  | 175 | static void downsample(SamplingGrid& instance, const SamplingGrid& other, const int _level); | 
|---|
|  | 176 |  | 
|---|
| [cb3363] | 177 | /** Returns the numeric integral over the grid. | 
|---|
|  | 178 | * | 
|---|
|  | 179 | * @return sum of grid values times volume element | 
|---|
|  | 180 | */ | 
|---|
|  | 181 | double integral() const; | 
|---|
|  | 182 |  | 
|---|
| [e72c61] | 183 | /** Returns the numeric integral over the grid where the grid is element-wise multiplied with \a weight. | 
|---|
|  | 184 | * | 
|---|
|  | 185 | * @param weight grid of weights | 
|---|
|  | 186 | * @return sum of grid values weighted by respective element in weight times volume element | 
|---|
|  | 187 | */ | 
|---|
|  | 188 | double integral(const SamplingGrid &weight) const; | 
|---|
|  | 189 |  | 
|---|
| [98f8fe] | 190 | /** Returns the total number of gridpoints of the discrete mesh covering the (window) volume. | 
|---|
|  | 191 | * | 
|---|
|  | 192 | * @return number of gridpoints sampled_values should have | 
|---|
|  | 193 | */ | 
|---|
| [1a00bb] | 194 | const size_t getWindowGridPoints() const; | 
|---|
|  | 195 |  | 
|---|
| [620517] | 196 | /** Returns the number of gridpoints of the discrete mesh for the current | 
|---|
|  | 197 | * window size for given axis \axis. | 
|---|
|  | 198 | * | 
|---|
|  | 199 | * \param axis axis to calculate number of gridpoints for | 
|---|
|  | 200 | * \return number of gridpoints along this axis | 
|---|
|  | 201 | */ | 
|---|
|  | 202 | const size_t getWindowGridPointsPerAxis(const size_t axis) const; | 
|---|
|  | 203 |  | 
|---|
|  | 204 | /** Returns the length of the window for the given \a axis. | 
|---|
|  | 205 | * | 
|---|
|  | 206 | * \param axis axis for which to get step length | 
|---|
|  | 207 | * \return window length for the given axis, i.e. end - begin | 
|---|
|  | 208 | */ | 
|---|
|  | 209 | const double getWindowLengthPerAxis(const size_t axis) const; | 
|---|
|  | 210 |  | 
|---|
| [c1948c] | 211 | /** Returns the discrete length in grid cells of the window for the given \a axis. | 
|---|
|  | 212 | * | 
|---|
|  | 213 | * \param axis axis for which to get step length | 
|---|
|  | 214 | * \return window length in grid cells for the given axis | 
|---|
|  | 215 | */ | 
|---|
|  | 216 | const size_t getDiscreteWindowLengthPerAxis(const size_t axis) const; | 
|---|
|  | 217 |  | 
|---|
| [1a00bb] | 218 | /** Returns the volume of the domain covered by the current window. | 
|---|
|  | 219 | * | 
|---|
|  | 220 | * @return volume of window | 
|---|
|  | 221 | */ | 
|---|
|  | 222 | const double getWindowVolume() const; | 
|---|
|  | 223 |  | 
|---|
|  | 224 | /** Sets the size of the window. | 
|---|
|  | 225 | * | 
|---|
|  | 226 | * \note also resets the sampled points so far. | 
|---|
|  | 227 | * | 
|---|
|  | 228 | * \param _begin_window start of new window | 
|---|
|  | 229 | * \param _end_window end of window | 
|---|
|  | 230 | */ | 
|---|
| [5b1e5e] | 231 | void setWindow(const double _begin_window[NDIM], const double _end_window[NDIM]); | 
|---|
| [1a00bb] | 232 |  | 
|---|
| [3f64ee] | 233 | /** Helper function to convert begin_window and end_window that are w.r.t. | 
|---|
|  | 234 | * to domain [begin:end] to indices that can be used when traversing the grid. | 
|---|
|  | 235 | * | 
|---|
|  | 236 | * \param larger_wbegin begin of domain | 
|---|
|  | 237 | * \param larger_wend end of domain | 
|---|
|  | 238 | * \param smaller_wbegin begin of window | 
|---|
|  | 239 | * \param smaller_wend end of window | 
|---|
|  | 240 | * \param pre_offset discrete length from 0 to start of window | 
|---|
|  | 241 | * \param post_offset discrete length from end of window to end | 
|---|
|  | 242 | * \param length discrete length of window | 
|---|
|  | 243 | * \param total total number of points for checking, should be sum of other three | 
|---|
|  | 244 | */ | 
|---|
| [e51f2c] | 245 | void getDiscreteWindowCopyIndices( | 
|---|
| [3f64ee] | 246 | const double *larger_wbegin, | 
|---|
|  | 247 | const double *larger_wend, | 
|---|
|  | 248 | const double *smaller_wbegin, | 
|---|
|  | 249 | const double *smaller_wend, | 
|---|
|  | 250 | size_t *pre_offset, | 
|---|
|  | 251 | size_t *post_offset, | 
|---|
|  | 252 | size_t *length, | 
|---|
|  | 253 | size_t *total) const; | 
|---|
|  | 254 |  | 
|---|
| [c1948c] | 255 | /** Returns begin, length and end of window relative to the full domain in discrete | 
|---|
|  | 256 | * grid points, i.e. begin gives the first grid points with the window and end its | 
|---|
|  | 257 | * last plus 1. | 
|---|
|  | 258 | */ | 
|---|
|  | 259 | void getDiscreteWindowIndices( | 
|---|
|  | 260 | size_t _wbegin[NDIM], | 
|---|
|  | 261 | size_t _wlength[NDIM], | 
|---|
|  | 262 | size_t _wend[NDIM]) const; | 
|---|
|  | 263 |  | 
|---|
| [336da8] | 264 | /** Returns number of grid points before the window, during the window, and | 
|---|
|  | 265 | * after the window including the total length of the domain for check. | 
|---|
|  | 266 | * | 
|---|
|  | 267 | * \param _pre_offset grid points before start of window | 
|---|
|  | 268 | * \param _post_offset grid points after end of window | 
|---|
|  | 269 | * \param _length grid points in window | 
|---|
|  | 270 | * \param _total grid points in domain | 
|---|
|  | 271 | */ | 
|---|
|  | 272 | void getDiscreteWindowOffsets( | 
|---|
|  | 273 | size_t _pre_offset[NDIM], | 
|---|
|  | 274 | size_t _post_offset[NDIM], | 
|---|
|  | 275 | size_t _length[NDIM], | 
|---|
|  | 276 | size_t _total[NDIM]) const; | 
|---|
|  | 277 |  | 
|---|
| [955051] | 278 | /** Equality operator. | 
|---|
|  | 279 | * | 
|---|
|  | 280 | * @param other other instance to check against | 
|---|
|  | 281 | * @return true - both are equal, false - grids differ | 
|---|
|  | 282 | */ | 
|---|
|  | 283 | bool operator==(const SamplingGrid& other) const; | 
|---|
|  | 284 |  | 
|---|
|  | 285 | bool operator!=(const SamplingGrid& other) const | 
|---|
|  | 286 | { | 
|---|
|  | 287 | return (!(*this == other)); | 
|---|
|  | 288 | } | 
|---|
|  | 289 |  | 
|---|
| [8f3cdd] | 290 | private: | 
|---|
| [d56e21] | 291 | /** Extend the window such that the number of sample points stored is an | 
|---|
|  | 292 | * even number per axis. This is used by downsample() | 
|---|
|  | 293 | */ | 
|---|
|  | 294 | void padWithZerosForEvenNumberedSamples(); | 
|---|
|  | 295 |  | 
|---|
| [e2404f] | 296 | /** Sets the size of the domain. | 
|---|
|  | 297 | * | 
|---|
|  | 298 | * \note also resets the sampled points so far and the window. | 
|---|
|  | 299 | * | 
|---|
|  | 300 | * \param _begin start of new window | 
|---|
|  | 301 | * \param _end end of window | 
|---|
|  | 302 | */ | 
|---|
| [5b1e5e] | 303 | void setDomain(const double _begin[NDIM], const double _end[NDIM]); | 
|---|
| [e2404f] | 304 |  | 
|---|
|  | 305 | /** Sets the size of the domain. | 
|---|
|  | 306 | * | 
|---|
|  | 307 | * \note this is just internally used for easing the array setting. | 
|---|
|  | 308 | * | 
|---|
|  | 309 | * \param _begin start of domain | 
|---|
|  | 310 | * \param _end end of domain | 
|---|
|  | 311 | */ | 
|---|
| [5b1e5e] | 312 | void setDomainSize(const double _begin[NDIM], const double _end[NDIM]); | 
|---|
| [e2404f] | 313 |  | 
|---|
| [1a00bb] | 314 | /** Extends the window while keeping the values. | 
|---|
|  | 315 | * | 
|---|
|  | 316 | * \param _begin_window new start of window | 
|---|
|  | 317 | * \param _end_window new end of window | 
|---|
|  | 318 | */ | 
|---|
| [5b1e5e] | 319 | void extendWindow(const double _begin_window[NDIM], const double _end_window[NDIM]); | 
|---|
| [1a00bb] | 320 |  | 
|---|
| [313f83] | 321 | /** Shrinks the window while keeping the values. | 
|---|
|  | 322 | * | 
|---|
|  | 323 | * \param _begin_window new start of window | 
|---|
|  | 324 | * \param _end_window new end of window | 
|---|
|  | 325 | */ | 
|---|
| [5b1e5e] | 326 | void shrinkWindow(const double _begin_window[NDIM], const double _end_window[NDIM]); | 
|---|
| [313f83] | 327 |  | 
|---|
|  | 328 | /** Adds another (smaller) window onto the one in this instance. | 
|---|
| [1a00bb] | 329 | * | 
|---|
|  | 330 | * \note We assume here that the given window fits on the this one. | 
|---|
|  | 331 | * | 
|---|
|  | 332 | * \param _begin_window start of other window | 
|---|
|  | 333 | * \param _end_window end of other window | 
|---|
|  | 334 | * \param _sampled_grid other set of sampled values | 
|---|
| [de6dfb] | 335 | * @param prefactor +1. is then addition, -1. is subtraction. | 
|---|
| [1a00bb] | 336 | */ | 
|---|
|  | 337 | void addOntoWindow( | 
|---|
| [5b1e5e] | 338 | const double _begin_window[NDIM], | 
|---|
|  | 339 | const double _end_window[NDIM], | 
|---|
| [de6dfb] | 340 | const sampledvalues_t &_sampled_grid, | 
|---|
|  | 341 | const double prefactor); | 
|---|
| [98f8fe] | 342 |  | 
|---|
| [313f83] | 343 | /** Adds another (larger) window into the one in this instance. | 
|---|
|  | 344 | * | 
|---|
|  | 345 | * \note We assume here that the given window is larger than this one. | 
|---|
|  | 346 | * | 
|---|
|  | 347 | * \param _begin_window start of other window | 
|---|
|  | 348 | * \param _end_window end of other window | 
|---|
|  | 349 | * \param _sampled_grid other set of sampled values | 
|---|
|  | 350 | * @param prefactor +1. is then addition, -1. is subtraction. | 
|---|
|  | 351 | */ | 
|---|
|  | 352 | void addIntoWindow( | 
|---|
| [5b1e5e] | 353 | const double _begin_window[NDIM], | 
|---|
|  | 354 | const double _end_window[NDIM], | 
|---|
| [313f83] | 355 | const sampledvalues_t &_sampled_grid, | 
|---|
|  | 356 | const double prefactor); | 
|---|
|  | 357 |  | 
|---|
| [fb3485] | 358 | /** Enum to help in addWindowOntoWindow() decide which iterator needs to be | 
|---|
|  | 359 | * advanced. | 
|---|
|  | 360 | */ | 
|---|
| [313f83] | 361 | enum eLargerWindow { | 
|---|
|  | 362 | destwindow, | 
|---|
|  | 363 | sourcewindow | 
|---|
| [fb3485] | 364 | }; | 
|---|
|  | 365 |  | 
|---|
|  | 366 | /** Helper function to copy one (larger) window into a (smaller) window. | 
|---|
|  | 367 | * | 
|---|
|  | 368 | * \note Why do we need the extra \a choice? We need to know which window | 
|---|
|  | 369 | * tuples is associated with which sampled values that are constrained by | 
|---|
|  | 370 | * one of them being constant, hence the source values | 
|---|
|  | 371 | * | 
|---|
| [313f83] | 372 | * \param larger_wbegin start of larger window | 
|---|
|  | 373 | * \param larger_wend end of larger window | 
|---|
|  | 374 | * \param smaller_wbegin start of smaller window | 
|---|
|  | 375 | * \param smaller_wend end of smaller window | 
|---|
|  | 376 | * \param dest_sampled_grid larger set of sampled values | 
|---|
|  | 377 | * \param source_sampled_grid smaller set of sampled values | 
|---|
| [fb3485] | 378 | * \param op operation to perform with the two elements | 
|---|
| [313f83] | 379 | * \param larger_window indicates which is the larger window | 
|---|
| [fb3485] | 380 | */ | 
|---|
|  | 381 | void addWindowOntoWindow( | 
|---|
| [5b1e5e] | 382 | const double larger_wbegin[NDIM], | 
|---|
|  | 383 | const double larger_wend[NDIM], | 
|---|
|  | 384 | const double smaller_wbegin[NDIM], | 
|---|
|  | 385 | const double smaller_wend[NDIM], | 
|---|
| [313f83] | 386 | sampledvalues_t &dest_sampled_grid, | 
|---|
|  | 387 | const sampledvalues_t &source_sampled_grid, | 
|---|
| [fb3485] | 388 | boost::function<void (double &, const double &)> op, | 
|---|
| [313f83] | 389 | enum eLargerWindow larger_window); | 
|---|
| [fb3485] | 390 |  | 
|---|
| [c889b7] | 391 | /** Helper function that contains all the logic of how to superpose two | 
|---|
|  | 392 | * grids. | 
|---|
|  | 393 | * | 
|---|
|  | 394 | * Is called by SamplingGrid::operator+=() and SamplingGrid::operator-=() | 
|---|
|  | 395 | * | 
|---|
|  | 396 | * @param other other histogram | 
|---|
|  | 397 | * @param prefactor +1. is then addition, -1. is subtraction. | 
|---|
|  | 398 | */ | 
|---|
|  | 399 | void superposeOtherGrids(const SamplingGrid &other, const double prefactor); | 
|---|
|  | 400 |  | 
|---|
| [1a00bb] | 401 | /** Sets the size of the window. | 
|---|
|  | 402 | * | 
|---|
|  | 403 | * \note also resets the sampled points so far. | 
|---|
|  | 404 | * | 
|---|
|  | 405 | * \param _begin_window start of new window | 
|---|
|  | 406 | * \param _end_window end of window | 
|---|
|  | 407 | */ | 
|---|
| [5b1e5e] | 408 | void setWindowSize(const double _begin_window[NDIM], const double _end_window[NDIM]); | 
|---|
| [1a00bb] | 409 |  | 
|---|
| [28c025] | 410 | public: | 
|---|
| [1a00bb] | 411 | /// We do not store the whole grid if many entries are actually zero | 
|---|
|  | 412 | /// but only a window wherein the sampled function is non-zero. | 
|---|
|  | 413 |  | 
|---|
|  | 414 | //!> sample points of the window | 
|---|
| [c889b7] | 415 | sampledvalues_t sampled_grid; | 
|---|
| [28c025] | 416 |  | 
|---|
| [1a00bb] | 417 | //!> start of the window relative to SamplingGridProperties::begin and SamplingGridProperties::size | 
|---|
| [5b1e5e] | 418 | double begin_window[NDIM]; | 
|---|
| [1a00bb] | 419 | //!> end of the window relative to SamplingGridProperties::begin and SamplingGridProperties::size | 
|---|
| [5b1e5e] | 420 | double end_window[NDIM]; | 
|---|
| [1a00bb] | 421 |  | 
|---|
| [28c025] | 422 | private: | 
|---|
|  | 423 | friend class MPQCData; | 
|---|
|  | 424 |  | 
|---|
|  | 425 | friend class boost::serialization::access; | 
|---|
|  | 426 | // serialization | 
|---|
|  | 427 | template <typename Archive> | 
|---|
|  | 428 | void serialize(Archive& ar, const unsigned int version) | 
|---|
|  | 429 | { | 
|---|
|  | 430 | ar & boost::serialization::base_object<SamplingGridProperties>(*this); | 
|---|
| [c889b7] | 431 | ar & const_cast< sampledvalues_t &>(sampled_grid); | 
|---|
| [5b1e5e] | 432 | for(size_t i=0;i<NDIM;++i) { | 
|---|
| [1a00bb] | 433 | ar & begin_window[i]; | 
|---|
|  | 434 | ar & end_window[i]; | 
|---|
|  | 435 | } | 
|---|
| [28c025] | 436 | } | 
|---|
| [1a00bb] | 437 |  | 
|---|
|  | 438 | //!> static typedef to use in cstor when no initial values are given | 
|---|
| [5b1e5e] | 439 | static const double zeroOffset[NDIM]; | 
|---|
| [28c025] | 440 | }; | 
|---|
|  | 441 |  | 
|---|
| [c889b7] | 442 | /** Output operator for class SamplingGrid. | 
|---|
|  | 443 | * | 
|---|
|  | 444 | * \param ost output stream to print to | 
|---|
|  | 445 | * \param other instance to print | 
|---|
|  | 446 | * \return ref to stream for concatenation | 
|---|
|  | 447 | */ | 
|---|
|  | 448 | std::ostream & operator<<(std::ostream &ost, const SamplingGrid& other); | 
|---|
|  | 449 |  | 
|---|
| [beb16e] | 450 | template<> SamplingGrid ZeroInstance<SamplingGrid>(); | 
|---|
|  | 451 |  | 
|---|
| [28c025] | 452 | // we need to give this class a unique key for serialization | 
|---|
|  | 453 | // its is only serialized through its base class FragmentJob | 
|---|
|  | 454 | BOOST_CLASS_EXPORT_KEY(SamplingGrid) | 
|---|
|  | 455 |  | 
|---|
| [620517] | 456 | // define inline functions | 
|---|
|  | 457 | #include "SamplingGrid_inline.hpp" | 
|---|
|  | 458 |  | 
|---|
| [28c025] | 459 | #endif /* SAMPLINGGRID_HPP_ */ | 
|---|