EvenlySpaced.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2007 by Willem van Straten
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 // psrchive/More/General/Pulsar/EvenlySpaced.h
10 
11 #ifndef __Pulsar_EvenlySpaced_h
12 #define __Pulsar_EvenlySpaced_h
13 
14 #include "Pulsar/Divided.h"
15 
16 namespace Pulsar {
17 
18  template<class C>
19  class Integrate<C>::EvenlySpaced : public Integrate<C>::Divided
20  {
21 
23  void initialize (Integrate*, C*);
24 
26  unsigned get_nrange () { return output_ndivide; }
27 
29  void get_range (unsigned irange, unsigned& start, unsigned& stop);
30 
31  protected:
32 
34  unsigned input_size;
36  unsigned output_ndivide;
38  unsigned output_nintegrate;
39 
40  };
41 
42 }
43 
44 template<class C>
45 void Pulsar::Integrate<C>::EvenlySpaced::initialize (Integrate*, C* container)
46 {
47  input_size = this->get_size (container);
48  this->divide (input_size, output_ndivide, output_nintegrate);
49 }
50 
51 template<class C>
53  unsigned& start,
54  unsigned& stop)
55 {
56  if (irange >= output_ndivide)
57  throw Error (InvalidParam,
58  "Pulsar::Integrate::EvenlySpaced::get_range",
59  "irange=%u >= output_ndivide=%u", irange, output_ndivide);
60 
61  start = irange * output_nintegrate;
62  stop = start + output_nintegrate;
63 
64  if (stop > input_size)
65  stop = input_size;
66 
67 #if _DEBUG
68  std::cerr << "Pulsar::Integrate::EvenlySpaced::get_range\n "
69  " irange=" << irange << " output_nintegrate=" << output_nintegrate <<
70  " input_size=" << input_size <<
71  " start=" << start << " stop=" << stop << std::endl;
72 #endif
73 }
74 
75 
76 
77 #endif
Profile integration algorithms.
Definition: Integrate.h:41
Defines the PSRCHIVE library.
Definition: CalSource.h:17

Generated using doxygen 1.8.17