Public Types | Public Member Functions | Private Attributes | List of all members
CompactRealDftData< F > Class Template Reference

#include <CompactRealDftData.h>

Inheritance diagram for CompactRealDftData< F >:
RealDftData< F >

Public Types

using FloatVector = std::vector< F >
 
using Norm = RealDftNormalization
 
- Public Types inherited from RealDftData< F >
using Float = F
 
using Index = unsigned int
 

Public Member Functions

 CompactRealDftData ()=default
 
 CompactRealDftData (Norm norm)
 
 CompactRealDftData (Norm norm, Index nsam)
 
 CompactRealDftData (Norm norm, const FloatVector &amps, const FloatVector &phas)
 
 CompactRealDftData (const FloatVector &amps, const FloatVector &phas)
 
 CompactRealDftData (const RealDftData< F > &rhs)
 
const Normnormalization () const override
 
void clear () override
 
void reset (Index nsam) override
 
int moveIn (FloatVector &amps, FloatVector &phas)
 
int copyIn (const FloatVector &amps, const FloatVector &phas)
 
int setAmplitude (Index ifrq, F val)
 
int setPhase (Index ifrq, F val)
 
int moveOut (FloatVector &amps, FloatVector &phas)
 
int copyOut (FloatVector &amps, FloatVector &phas) const
 
Index nSample () const override
 
Index nCompact () const override
 
amplitude (Index ifrq) const override
 
phase (Index ifrq) const override
 
real (Index ifrq) const override
 
imag (Index ifrq) const override
 
Index nAmplitude () const
 
Index nPhase () const
 
compactAmplitude (Index ifrq) const
 
compactPhase (Index ifrq) const
 
- Public Member Functions inherited from RealDftData< F >
Index size () const
 
bool isEven () const
 
bool isOdd () const
 
virtual bool isValid () const
 
bool inRange (Index ifrq) const
 
bool isZero (Index ifrq) const
 
bool isNyquist (Index ifrq) const
 
bool isNotAliased (Index ifrq) const
 
bool isAliased (Index ifrq) const
 
virtual F badValue () const
 
convAmplitude (Index ifrq) const
 
compactPower (Index ifrq) const
 
power () const
 

Private Attributes

Norm m_norm
 
FloatVector m_amps
 
FloatVector m_phas
 

Detailed Description

template<typename F>
class CompactRealDftData< F >

Definition at line 16 of file CompactRealDftData.h.

Member Typedef Documentation

template<typename F >
using CompactRealDftData< F >::FloatVector = std::vector<F>

Definition at line 21 of file CompactRealDftData.h.

template<typename F >
using CompactRealDftData< F >::Norm = RealDftNormalization

Definition at line 22 of file CompactRealDftData.h.

Constructor & Destructor Documentation

template<typename F >
CompactRealDftData< F >::CompactRealDftData ( )
default
template<typename F >
CompactRealDftData< F >::CompactRealDftData ( Norm  norm)
inlineexplicit

Definition at line 28 of file CompactRealDftData.h.

29  : m_norm(norm) { }
auto norm(Vector const &v)
Return norm of the specified vector.
template<typename F >
CompactRealDftData< F >::CompactRealDftData ( Norm  norm,
Index  nsam 
)
inline

Definition at line 32 of file CompactRealDftData.h.

33  : m_norm(norm) {
34  reset(nsam);
35  }
void reset(Index nsam) override
auto norm(Vector const &v)
Return norm of the specified vector.
template<typename F >
CompactRealDftData< F >::CompactRealDftData ( Norm  norm,
const FloatVector amps,
const FloatVector phas 
)
inline

Definition at line 40 of file CompactRealDftData.h.

41  : m_norm(norm), m_amps(amps), m_phas(phas) {
42  Index namp = amps.size();
43  Index npha = phas.size();
44  if ( namp < npha || namp > npha + 1 ) clear();
45  }
void clear() override
unsigned int Index
auto norm(Vector const &v)
Return norm of the specified vector.
template<typename F >
CompactRealDftData< F >::CompactRealDftData ( const FloatVector amps,
const FloatVector phas 
)
inline

Definition at line 50 of file CompactRealDftData.h.

51  : m_amps(amps), m_phas(phas) {
52  Index namp = amps.size();
53  Index npha = phas.size();
54  if ( namp < npha || namp > npha + 1 ) clear();
55  }
void clear() override
unsigned int Index
template<typename F >
CompactRealDftData< F >::CompactRealDftData ( const RealDftData< F > &  rhs)
inline

Definition at line 58 of file CompactRealDftData.h.

58  {
59  if ( &rhs == this ) return;
60  if ( ! rhs.isValid() ) return;
61  Index nsam = rhs.nSample();
62  if ( nsam == 0 ) return;
63  Index namp = rhs.nCompact();
64  Index npha = nsam - namp + 1;
65  if ( namp < npha || namp > npha + 1 ) { clear(); return; }
66  m_amps.resize(namp);
67  m_phas.resize(npha);
68  if ( nsam == 0 ) return;
69  F gfac = 1.0;
70  if ( rhs.isPower() ) gfac *= sqrt(nsam);
71  if ( rhs.isBin() ) gfac *= nsam;
72  if ( this->isPower() ) gfac /= sqrt(nsam);
73  if ( this->isBin() ) gfac /= nsam;
74  F tfac = 1.0;
75  if ( rhs.isUnit() && ! this->isUnit() ) tfac = 1/sqrt(2.0);
76  if ( ! rhs.isUnit() && this->isUnit() ) tfac = sqrt(2.0);
77  for ( Index ifrq=0; ifrq<namp; ++ifrq ) {
78  F amp = gfac*rhs.amplitude(ifrq);
79  if ( this->isAliased(ifrq) ) amp *= tfac;
80  m_amps[ifrq] = amp;
81  if ( ifrq < npha ) m_phas[ifrq] = rhs.phase(ifrq);
82  }
83  }
virtual F phase(Index ifrq) const =0
virtual F amplitude(Index ifrq) const =0
void clear() override
unsigned int Index
virtual bool isValid() const
Definition: RealDftData.h:42
virtual Index nSample() const =0
bool isAliased(Index ifrq) const
Definition: RealDftData.h:56
virtual Index nCompact() const
Definition: RealDftData.h:36

Member Function Documentation

template<typename F >
F CompactRealDftData< F >::amplitude ( Index  ifrq) const
inlineoverridevirtual

Implements RealDftData< F >.

Definition at line 161 of file CompactRealDftData.h.

161  {
162  return ifrq < this->nAmplitude() ? this->compactAmplitude(ifrq) :
163  ifrq < this->size() ? this->compactAmplitude(this->size()-ifrq) :
164  this->badValue();
165  }
Index size() const
Definition: RealDftData.h:35
F compactAmplitude(Index ifrq) const
Index nAmplitude() const
virtual F badValue() const
Definition: RealDftData.h:59
template<typename F >
void CompactRealDftData< F >::clear ( )
inlineoverridevirtual

Implements RealDftData< F >.

Definition at line 89 of file CompactRealDftData.h.

89  {
90  m_amps.clear();
91  m_phas.clear();
92  }
template<typename F >
F CompactRealDftData< F >::compactAmplitude ( Index  ifrq) const
inline

Definition at line 186 of file CompactRealDftData.h.

186  {
187  return this->inRange(ifrq) ? m_amps[ifrq] : this->badValue();
188  }
bool inRange(Index ifrq) const
Definition: RealDftData.h:52
virtual F badValue() const
Definition: RealDftData.h:59
template<typename F >
F CompactRealDftData< F >::compactPhase ( Index  ifrq) const
inline

Definition at line 189 of file CompactRealDftData.h.

189  {
190  return this->inRange(ifrq) ? m_phas[ifrq] : this->badValue();
191  }
bool inRange(Index ifrq) const
Definition: RealDftData.h:52
virtual F badValue() const
Definition: RealDftData.h:59
template<typename F >
int CompactRealDftData< F >::copyIn ( const FloatVector amps,
const FloatVector phas 
)
inline

Definition at line 118 of file CompactRealDftData.h.

118  {
119  Index namp = amps.size();
120  Index npha = phas.size();
121  if ( namp < npha || namp > npha + 1 ) {
122  clear();
123  return 1;
124  }
125  m_amps = amps;
126  m_phas = phas;
127  return 0;
128  }
void clear() override
unsigned int Index
template<typename F >
int CompactRealDftData< F >::copyOut ( FloatVector amps,
FloatVector phas 
) const
inline

Definition at line 150 of file CompactRealDftData.h.

150  {
151  amps = m_amps;
152  phas = m_phas;
153  return 0;
154  }
template<typename F >
F CompactRealDftData< F >::imag ( Index  ifrq) const
inlineoverridevirtual

Implements RealDftData< F >.

Definition at line 176 of file CompactRealDftData.h.

176  {
177  return ifrq < this->nPhase() ? amplitude(ifrq)*sin(phase(ifrq)) :
178  2*ifrq == this->size() ? 0.0 :
179  ifrq < this->size() ? -amplitude(ifrq)*sin(phase(ifrq)) :
180  this->badValue();
181  }
F amplitude(Index ifrq) const override
Index size() const
Definition: RealDftData.h:35
F phase(Index ifrq) const override
virtual F badValue() const
Definition: RealDftData.h:59
template<typename F >
int CompactRealDftData< F >::moveIn ( FloatVector amps,
FloatVector phas 
)
inline

Definition at line 105 of file CompactRealDftData.h.

105  {
106  Index namp = amps.size();
107  Index npha = phas.size();
108  if ( namp < npha || namp > npha + 1 ) {
109  clear();
110  return 1;
111  }
112  m_amps = std::move(amps);
113  m_phas = std::move(phas);
114  return 0;
115  }
void clear() override
unsigned int Index
def move(depos, offset)
Definition: depos.py:107
template<typename F >
int CompactRealDftData< F >::moveOut ( FloatVector amps,
FloatVector phas 
)
inline

Definition at line 143 of file CompactRealDftData.h.

143  {
144  amps = std::move(m_amps);
145  phas = std::move(m_phas);
146  return 0;
147  }
def move(depos, offset)
Definition: depos.py:107
template<typename F >
Index CompactRealDftData< F >::nAmplitude ( ) const
inline

Definition at line 184 of file CompactRealDftData.h.

184 { return m_amps.size(); }
template<typename F >
Index CompactRealDftData< F >::nCompact ( ) const
inlineoverridevirtual

Reimplemented from RealDftData< F >.

Definition at line 158 of file CompactRealDftData.h.

158 { return nAmplitude(); }
Index nAmplitude() const
template<typename F >
const Norm& CompactRealDftData< F >::normalization ( ) const
inlineoverridevirtual

Implements RealDftData< F >.

Definition at line 86 of file CompactRealDftData.h.

86 { return m_norm; }
template<typename F >
Index CompactRealDftData< F >::nPhase ( ) const
inline

Definition at line 185 of file CompactRealDftData.h.

185 { return m_phas.size(); }
template<typename F >
Index CompactRealDftData< F >::nSample ( ) const
inlineoverridevirtual

Implements RealDftData< F >.

Definition at line 157 of file CompactRealDftData.h.

157 { return nCompact() ? nCompact() + nPhase() - 1 : 0; }
Index nCompact() const override
template<typename F >
F CompactRealDftData< F >::phase ( Index  ifrq) const
inlineoverridevirtual

Implements RealDftData< F >.

Definition at line 166 of file CompactRealDftData.h.

166  {
167  return ifrq < this->nPhase() ? this->compactPhase(ifrq) :
168  2*ifrq == this->size() ? 0.0 :
169  ifrq < this->size() ? -this->compactPhase(this->size()-ifrq) :
170  this->badValue();
171  }
Index size() const
Definition: RealDftData.h:35
F compactPhase(Index ifrq) const
virtual F badValue() const
Definition: RealDftData.h:59
template<typename F >
F CompactRealDftData< F >::real ( Index  ifrq) const
inlineoverridevirtual

Implements RealDftData< F >.

Definition at line 172 of file CompactRealDftData.h.

172  {
173  return ifrq < this->size() ? amplitude(ifrq)*cos(phase(ifrq)) :
174  this->badValue();
175  }
F amplitude(Index ifrq) const override
Index size() const
Definition: RealDftData.h:35
F phase(Index ifrq) const override
virtual F badValue() const
Definition: RealDftData.h:59
template<typename F >
void CompactRealDftData< F >::reset ( Index  nsam)
inlineoverridevirtual

Implements RealDftData< F >.

Definition at line 95 of file CompactRealDftData.h.

95  {
96  Index namp = nsam > 0 ? nsam/2 + 1 : 0;
97  Index npha = (nsam + 1)/2;
98  m_amps.resize(namp);
99  m_phas.resize(npha);
100  for ( F& amp : m_amps ) amp = 0.0;
101  for ( F& pha : m_phas ) pha = 0.0;
102  }
unsigned int Index
template<typename F >
int CompactRealDftData< F >::setAmplitude ( Index  ifrq,
val 
)
inline

Definition at line 131 of file CompactRealDftData.h.

131  {
132  if ( ifrq >= nAmplitude() ) return 1;
133  m_amps[ifrq] = val;
134  return 0;
135  }
Index nAmplitude() const
template<typename F >
int CompactRealDftData< F >::setPhase ( Index  ifrq,
val 
)
inline

Definition at line 136 of file CompactRealDftData.h.

136  {
137  if ( ifrq >= nPhase() ) return 1;
138  m_phas[ifrq] = val;
139  return 0;
140  }

Member Data Documentation

template<typename F >
FloatVector CompactRealDftData< F >::m_amps
private

Definition at line 197 of file CompactRealDftData.h.

template<typename F >
Norm CompactRealDftData< F >::m_norm
private

Definition at line 196 of file CompactRealDftData.h.

template<typename F >
FloatVector CompactRealDftData< F >::m_phas
private

Definition at line 198 of file CompactRealDftData.h.


The documentation for this class was generated from the following file: