ProfileAmps.h
1//-*-C++-*-
2/***************************************************************************
3 *
4 * Copyright (C) 2002 by Willem van Straten
5 * Licensed under the Academic Free License version 2.1
6 *
7 ***************************************************************************/
8
9// psrchive/Base/Classes/Pulsar/ProfileAmps.h
10
11#ifndef __Pulsar_ProfileAmps_h
12#define __Pulsar_ProfileAmps_h
13
14#include "Pulsar/Container.h"
15
16namespace Pulsar {
17
19
23 class ProfileAmps : public Container {
24
25 public:
26
28 static bool no_amps;
29
31 ProfileAmps (unsigned nbin = 0);
32
34 virtual ~ProfileAmps ();
35
37 ProfileAmps (const ProfileAmps&);
38
40 unsigned get_nbin () const { return nbin; }
41
43 virtual void resize (unsigned nbin);
44
46 const float* get_amps () const;
47
49 float* get_amps ();
50
52 template <typename T> void set_amps (const T* data);
53
55 template <typename T> void set_amps (const std::vector<T>& data);
56
58 template <typename T> void get_amps (std::vector<T>& data) const;
59
61
62 void remove (const std::vector<unsigned>& indeces);
63
65 class Expert;
66
67 private:
68
69 friend class Expert;
70
72 unsigned nbin;
73
75 float *amps;
76
78 unsigned amps_size;
79
80 };
81
82}
83
88template <typename T>
90{
91 for (unsigned ibin=0; ibin<nbin; ibin++)
92 amps[ibin] = static_cast<float>( data[ibin] );
93}
94
98template <typename T>
99void Pulsar::ProfileAmps::set_amps (const std::vector<T>& data)
100{
101 resize (data.size());
102 for (unsigned ibin=0; ibin<nbin; ibin++)
103 amps[ibin] = static_cast<float>( data[ibin] );
104}
105
109template <typename T>
110void Pulsar::ProfileAmps::get_amps (std::vector<T>& data) const
111{
112 data.resize (nbin);
113 for (unsigned ibin=0; ibin<nbin; ibin++)
114 data[ibin] = static_cast<T>( amps[ibin] );
115}
116
117#endif // !defined __Pulsar_ProfileAmps_h
Data storage implementations.
Definition Container.h:19
void set_amps(const T *data)
set the amplitudes array equal to the contents of the data array
Definition ProfileAmps.h:89
unsigned get_nbin() const
Return the number of bins.
Definition ProfileAmps.h:40
const float * get_amps() const
Return a pointer to the amplitudes array.
Definition ProfileAmps.C:141
virtual void resize(unsigned nbin)
Resize the data area.
Definition ProfileAmps.C:104
void remove(const std::vector< unsigned > &indeces)
remove the elements specified in the array of indeces
Definition ProfileAmps.C:161
virtual ~ProfileAmps()
Destructor destroys the data array.
Definition ProfileAmps.C:89
ProfileAmps(unsigned nbin=0)
Constructor initializes the data array.
Definition ProfileAmps.C:56
static bool no_amps
When true, no memory is allocated for amps.
Definition ProfileAmps.h:28
Defines the PSRCHIVE library.
Definition CalSource.h:17

Generated using doxygen 1.14.0