ldas-tools-filters  2.6.4
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
Filters::Resample< TIn > Class Template Reference

#include <Resample.hh>

Inheritance diagram for Filters::Resample< TIn >:
Filters::ResampleBase Filters::ResampleBase Filters::ResampleBase

Public Types

typedef ResampleTraits< TIn >::OutType TOut
 
typedef ResampleTraits< TIn >::OutType TOut
 
typedef ResampleTraits< TIn >::OutType TOut
 

Public Member Functions

 Resample (const int p, const int q, const int n=10, const double beta=5.0L)
 General purpose constructor. More...
 
 Resample (const int p, const int q, const std::valarray< double > &b)
 Special purpose constructor. More...
 
 Resample (const Resample &rhs)
 Copy constructor. More...
 
virtual ~Resample ()
 Virtual destructor. More...
 
const Resampleoperator= (const Resample &rhs)
 Assignment, needed because class has pointer members. More...
 
bool operator== (const Resample &rhs)
 Comparison operator. More...
 
virtual ResampleClone () const
 Virtual constructor. More...
 
void getB (std::valarray< double > &b) const
 Filter coefficents accessor. More...
 
virtual void reset ()
 Reset the internal state to its initial condition. More...
 
void apply (TOut *const out, const TIn *const in, const size_t inlen)
 Resamples "in" by the factor p/q and returns the result in "out". More...
 
void apply (std::valarray< TOut > &out, const std::valarray< TIn > &in)
 Resamples "in" by the factor p/q and returns the result in "out". More...
 
 Resample (const int p, const int q, const int n=10, const double beta=5.0L)
 General purpose constructor. More...
 
 Resample (const int p, const int q, const std::valarray< double > &b)
 Special purpose constructor. More...
 
 Resample (const Resample &rhs)
 Copy constructor. More...
 
virtual ~Resample ()
 Virtual destructor. More...
 
const Resampleoperator= (const Resample &rhs)
 Assignment, needed because class has pointer members. More...
 
bool operator== (const Resample &rhs)
 Comparison operator. More...
 
virtual ResampleClone () const
 Virtual constructor. More...
 
void getB (std::valarray< double > &b) const
 Filter coefficents accessor. More...
 
virtual void reset ()
 Reset the internal state to its initial condition. More...
 
void apply (TOut *const out, const TIn *const in, const size_t inlen)
 Resamples "in" by the factor p/q and returns the result in "out". More...
 
void apply (std::valarray< TOut > &out, const std::valarray< TIn > &in)
 Resamples "in" by the factor p/q and returns the result in "out". More...
 
 Resample (const int p, const int q, const int n=10, const double beta=5.0L)
 General purpose constructor. More...
 
 Resample (const int p, const int q, const std::valarray< double > &b)
 Special purpose constructor. More...
 
 Resample (const Resample &rhs)
 Copy constructor. More...
 
virtual ~Resample ()
 Virtual destructor. More...
 
const Resampleoperator= (const Resample &rhs)
 Assignment, needed because class has pointer members. More...
 
bool operator== (const Resample &rhs)
 Comparison operator. More...
 
virtual ResampleClone () const
 Virtual constructor. More...
 
void getB (std::valarray< double > &b) const
 Filter coefficents accessor. More...
 
virtual void reset ()
 Reset the internal state to its initial condition. More...
 
void apply (TOut *const out, const TIn *const in, const size_t inlen)
 Resamples "in" by the factor p/q and returns the result in "out". More...
 
void apply (std::valarray< TOut > &out, const std::valarray< TIn > &in)
 Resamples "in" by the factor p/q and returns the result in "out". More...
 
int getP () const
 Gets the resample numerator. More...
 
int getP () const
 Gets the resample numerator. More...
 
int getP () const
 Gets the resample numerator. More...
 
int getQ () const
 Gets the resample numerator. More...
 
int getQ () const
 Gets the resample numerator. More...
 
int getQ () const
 Gets the resample numerator. More...
 
int getN () const
 Gets anti-aliasing filter parameters. More...
 
int getN () const
 Gets anti-aliasing filter parameters. More...
 
int getN () const
 Gets anti-aliasing filter parameters. More...
 
int getNOrder () const
 Gets anti-aliasing filter parameters. More...
 
int getNOrder () const
 Gets anti-aliasing filter parameters. More...
 
int getNOrder () const
 Gets anti-aliasing filter parameters. More...
 
double getBeta () const
 Gets anti-aliasing filter parameters. More...
 
double getBeta () const
 Gets anti-aliasing filter parameters. More...
 
double getBeta () const
 Gets anti-aliasing filter parameters. More...
 
double getDelay () const
 Gets the delay due to the filtering action. More...
 
double getDelay () const
 Gets the delay due to the filtering action. More...
 
double getDelay () const
 Gets the delay due to the filtering action. More...
 
bool operator== (const ResampleBase &rhs)
 Comparison operator. More...
 

Private Types

typedef LinFilt< double, TOutlft_type
 
typedef lft_typelfd_type
 
typedef std::vector< lfd_typelf_type
 
typedef LinFilt< double, TOutlft_type
 
typedef lft_typelfd_type
 
typedef std::vector< lfd_typelf_type
 
typedef LinFilt< double, TOutlft_type
 
typedef lft_typelfd_type
 
typedef std::vector< lfd_typelf_type
 

Private Member Functions

void initFilters (const std::valarray< double > &b)
 Initialise the filter bank. More...
 
LinFilt< double, TOut > & getFilter (const int p, const int q) const
 Obtain the filter at position (p, q) More...
 
void initFilters (const std::valarray< double > &b)
 Initialise the filter bank. More...
 
LinFilt< double, TOut > & getFilter (const int p, const int q) const
 Obtain the filter at position (p, q) More...
 
void initFilters (const std::valarray< double > &b)
 Initialise the filter bank. More...
 
LinFilt< double, TOut > & getFilter (const int p, const int q) const
 Obtain the filter at position (p, q) More...
 

Private Attributes

std::valarray< TOutm_orphan
 Pointer to partial sum saved for split input purposes. More...
 
lf_type m_lf
 Storage for anti-aliasing filters. More...
 

Member Typedef Documentation

◆ lf_type [1/3]

template<class TIn >
typedef std::vector< lfd_type > Filters::Resample< TIn >::lf_type
private

◆ lf_type [2/3]

template<class TIn >
typedef std::vector< lfd_type > Filters::Resample< TIn >::lf_type
private

◆ lf_type [3/3]

template<class TIn >
typedef std::vector< lfd_type > Filters::Resample< TIn >::lf_type
private

◆ lfd_type [1/3]

template<class TIn >
typedef lft_type* Filters::Resample< TIn >::lfd_type
private

◆ lfd_type [2/3]

template<class TIn >
typedef lft_type* Filters::Resample< TIn >::lfd_type
private

◆ lfd_type [3/3]

template<class TIn >
typedef lft_type* Filters::Resample< TIn >::lfd_type
private

◆ lft_type [1/3]

template<class TIn >
typedef LinFilt< double, TOut > Filters::Resample< TIn >::lft_type
private

◆ lft_type [2/3]

template<class TIn >
typedef LinFilt< double, TOut > Filters::Resample< TIn >::lft_type
private

◆ lft_type [3/3]

template<class TIn >
typedef LinFilt< double, TOut > Filters::Resample< TIn >::lft_type
private

◆ TOut [1/3]

template<class TIn >
typedef ResampleTraits< TIn >::OutType Filters::Resample< TIn >::TOut

◆ TOut [2/3]

template<class TIn >
typedef ResampleTraits< TIn >::OutType Filters::Resample< TIn >::TOut

◆ TOut [3/3]

template<class TIn >
typedef ResampleTraits< TIn >::OutType Filters::Resample< TIn >::TOut

Constructor & Destructor Documentation

◆ Resample() [1/9]

template<class TIn >
Filters::Resample< TIn >::Resample ( const int  p,
const int  q,
const int  n = 10,
const double  beta = 5.0L 
)

General purpose constructor.

Parameters
[in]pupsampling ratio
[in]qdownsampling ratio
[in]n= 10 filter order: 2*n*max(p, q) is the length of the filter
[in]beta= 5 the beta parameter of the Kaiser Window
Exceptions
invalid_argumentif p or q or n < 1 or beta < 0.0

◆ Resample() [2/9]

template<class TIn >
Filters::Resample< TIn >::Resample ( const int  p,
const int  q,
const std::valarray< double > &  b 
)

Special purpose constructor.

Parameters
[in]pupsampling ratio
[in]qdownsampling ratio
[in]bfilter to use
Exceptions
invalid_argumentb.size() == 0

◆ Resample() [3/9]

template<class TIn >
Filters::Resample< TIn >::Resample ( const Resample< TIn > &  rhs)

Copy constructor.

Parameters
[in]rhsinstance to be copied

◆ ~Resample() [1/3]

template<class TIn >
Filters::Resample< TIn >::~Resample ( )
virtual

Virtual destructor.

◆ Resample() [4/9]

template<class TIn >
Filters::Resample< TIn >::Resample ( const int  p,
const int  q,
const int  n = 10,
const double  beta = 5.0L 
)

General purpose constructor.

Parameters
[in]pupsampling ratio
[in]qdownsampling ratio
[in]n= 10 filter order: 2*n*max(p, q) is the length of the filter
[in]beta= 5 the beta parameter of the Kaiser Window
Exceptions
invalid_argumentif p or q or n < 1 or beta < 0.0

◆ Resample() [5/9]

template<class TIn >
Filters::Resample< TIn >::Resample ( const int  p,
const int  q,
const std::valarray< double > &  b 
)

Special purpose constructor.

Parameters
[in]pupsampling ratio
[in]qdownsampling ratio
[in]bfilter to use
Exceptions
invalid_argumentb.size() == 0

◆ Resample() [6/9]

template<class TIn >
Filters::Resample< TIn >::Resample ( const Resample< TIn > &  rhs)

Copy constructor.

Parameters
[in]rhsinstance to be copied

◆ ~Resample() [2/3]

template<class TIn >
virtual Filters::Resample< TIn >::~Resample ( )
virtual

Virtual destructor.

◆ Resample() [7/9]

template<class TIn >
Filters::Resample< TIn >::Resample ( const int  p,
const int  q,
const int  n = 10,
const double  beta = 5.0L 
)

General purpose constructor.

Parameters
[in]pupsampling ratio
[in]qdownsampling ratio
[in]n= 10 filter order: 2*n*max(p, q) is the length of the filter
[in]beta= 5 the beta parameter of the Kaiser Window
Exceptions
invalid_argumentif p or q or n < 1 or beta < 0.0

◆ Resample() [8/9]

template<class TIn >
Filters::Resample< TIn >::Resample ( const int  p,
const int  q,
const std::valarray< double > &  b 
)

Special purpose constructor.

Parameters
[in]pupsampling ratio
[in]qdownsampling ratio
[in]bfilter to use
Exceptions
invalid_argumentb.size() == 0

◆ Resample() [9/9]

template<class TIn >
Filters::Resample< TIn >::Resample ( const Resample< TIn > &  rhs)

Copy constructor.

Parameters
[in]rhsinstance to be copied

◆ ~Resample() [3/3]

template<class TIn >
virtual Filters::Resample< TIn >::~Resample ( )
virtual

Virtual destructor.

Member Function Documentation

◆ apply() [1/6]

template<class TIn >
void Filters::Resample< TIn >::apply ( TOut *const  out,
const TIn *const  in,
const size_t  inlen 
)

Resamples "in" by the factor p/q and returns the result in "out".

The first call to apply initialises the internal state of Resample so that the input data is treated as if it were preceded by an infinite number of zeroes. After the first apply(), the Resampler is in a non-default state and it will assume that the next call to apply() is on a segment of data that is contiguous with the preceding input. In this way, a long data set can be broken up into smaller segments which can be resampled individually. The recombined data is identical resampling the original long data set.

This function is not const to remind users that its use modifies the internal state of Resample.

Parameters
[out]outpointer to result of resampling the "in" data
[in]inpointer to data to be resampled
[in]inlenlength of in
Exceptions
invalid_argumentInput length must be a multiple of q

◆ apply() [2/6]

template<class TIn >
void Filters::Resample< TIn >::apply ( TOut *const  out,
const TIn *const  in,
const size_t  inlen 
)

Resamples "in" by the factor p/q and returns the result in "out".

The first call to apply initialises the internal state of Resample so that the input data is treated as if it were preceded by an infinite number of zeroes. After the first apply(), the Resampler is in a non-default state and it will assume that the next call to apply() is on a segment of data that is contiguous with the preceding input. In this way, a long data set can be broken up into smaller segments which can be resampled individually. The recombined data is identical resampling the original long data set.

This function is not const to remind users that its use modifies the internal state of Resample.

Parameters
[out]outpointer to result of resampling the "in" data
[in]inpointer to data to be resampled
[in]inlenlength of in
Exceptions
invalid_argumentInput length must be a multiple of q

◆ apply() [3/6]

template<class TIn >
void Filters::Resample< TIn >::apply ( TOut *const  out,
const TIn *const  in,
const size_t  inlen 
)

Resamples "in" by the factor p/q and returns the result in "out".

The first call to apply initialises the internal state of Resample so that the input data is treated as if it were preceded by an infinite number of zeroes. After the first apply(), the Resampler is in a non-default state and it will assume that the next call to apply() is on a segment of data that is contiguous with the preceding input. In this way, a long data set can be broken up into smaller segments which can be resampled individually. The recombined data is identical resampling the original long data set.

This function is not const to remind users that its use modifies the internal state of Resample.

Parameters
[out]outpointer to result of resampling the "in" data
[in]inpointer to data to be resampled
[in]inlenlength of in
Exceptions
invalid_argumentInput length must be a multiple of q

◆ apply() [4/6]

template<class TIn >
void Filters::Resample< TIn >::apply ( std::valarray< TOut > &  out,
const std::valarray< TIn > &  in 
)

Resamples "in" by the factor p/q and returns the result in "out".

The first call to apply initialises the internal state of Resample so that the input data is treated as if it were preceded by an infinite number of zeroes. After the first apply(), the Resampler is in a non-default state and it will assume that the next call to apply() is on a segment of data that is contiguous with the preceding input. In this way, a long data set can be broken up into smaller segments which can be resampled individually. The recombined data is identical resampling the original long data set.

This function is not const to remind users that its use modifies the internal state of Resample.

Parameters
[out]outresult of resampling the "in" data
[in]indata to be resampled
Exceptions
invalid_argumentInput length must be a multiple of q

◆ apply() [5/6]

template<class TIn >
void Filters::Resample< TIn >::apply ( std::valarray< TOut > &  out,
const std::valarray< TIn > &  in 
)

Resamples "in" by the factor p/q and returns the result in "out".

The first call to apply initialises the internal state of Resample so that the input data is treated as if it were preceded by an infinite number of zeroes. After the first apply(), the Resampler is in a non-default state and it will assume that the next call to apply() is on a segment of data that is contiguous with the preceding input. In this way, a long data set can be broken up into smaller segments which can be resampled individually. The recombined data is identical resampling the original long data set.

This function is not const to remind users that its use modifies the internal state of Resample.

Parameters
[out]outresult of resampling the "in" data
[in]indata to be resampled
Exceptions
invalid_argumentInput length must be a multiple of q

◆ apply() [6/6]

template<class TIn >
void Filters::Resample< TIn >::apply ( std::valarray< TOut > &  out,
const std::valarray< TIn > &  in 
)

Resamples "in" by the factor p/q and returns the result in "out".

The first call to apply initialises the internal state of Resample so that the input data is treated as if it were preceded by an infinite number of zeroes. After the first apply(), the Resampler is in a non-default state and it will assume that the next call to apply() is on a segment of data that is contiguous with the preceding input. In this way, a long data set can be broken up into smaller segments which can be resampled individually. The recombined data is identical resampling the original long data set.

This function is not const to remind users that its use modifies the internal state of Resample.

Parameters
[out]outresult of resampling the "in" data
[in]indata to be resampled
Exceptions
invalid_argumentInput length must be a multiple of q

◆ Clone() [1/3]

template<class TIn >
virtual Resample* Filters::Resample< TIn >::Clone ( ) const
virtual

Virtual constructor.

Returns
pointer to new Resample object

Implements Filters::ResampleBase.

◆ Clone() [2/3]

template<class TIn >
virtual Resample* Filters::Resample< TIn >::Clone ( ) const
virtual

Virtual constructor.

Returns
pointer to new Resample object

Implements Filters::ResampleBase.

◆ Clone() [3/3]

template<class TIn >
Resample< TIn > * Filters::Resample< TIn >::Clone ( ) const
virtual

Virtual constructor.

Returns
pointer to new Resample object

Implements Filters::ResampleBase.

◆ getB() [1/3]

template<class TIn >
void Filters::Resample< TIn >::getB ( std::valarray< double > &  b) const

Filter coefficents accessor.

Parameters
[in]bFIR filter coefficents array

◆ getB() [2/3]

template<class TIn >
void Filters::Resample< TIn >::getB ( std::valarray< double > &  b) const

Filter coefficents accessor.

Parameters
[in]bFIR filter coefficents array

◆ getB() [3/3]

template<class TIn >
void Filters::Resample< TIn >::getB ( std::valarray< double > &  b) const

Filter coefficents accessor.

Parameters
[in]bFIR filter coefficents array

◆ getBeta() [1/3]

double Filters::ResampleBase::getBeta ( ) const
inherited

Gets anti-aliasing filter parameters.

Returns
Kaiser Window beta parameter

◆ getBeta() [2/3]

double Filters::ResampleBase::getBeta ( ) const
inherited

Gets anti-aliasing filter parameters.

Returns
Kaiser Window beta parameter

◆ getBeta() [3/3]

double Filters::ResampleBase::getBeta ( ) const
inherited

Gets anti-aliasing filter parameters.

Returns
Kaiser Window beta parameter

◆ getDelay() [1/3]

double Filters::ResampleBase::getDelay ( ) const
inherited

Gets the delay due to the filtering action.

Returns
returns the group delay of the impulse due to filtering

◆ getDelay() [2/3]

double Filters::ResampleBase::getDelay ( ) const
inherited

Gets the delay due to the filtering action.

Returns
returns the group delay of the impulse due to filtering

◆ getDelay() [3/3]

double Filters::ResampleBase::getDelay ( ) const
inherited

Gets the delay due to the filtering action.

Returns
returns the group delay of the impulse due to filtering
Note
might need to be changed for general resampling

◆ getFilter() [1/3]

template<class TIn >
LinFilt< double, typename ResampleTraits< TIn >::OutType > & Filters::Resample< TIn >::getFilter ( const int  p,
const int  q 
) const
private

Obtain the filter at position (p, q)

◆ getFilter() [2/3]

template<class TIn >
LinFilt< double, TOut >& Filters::Resample< TIn >::getFilter ( const int  p,
const int  q 
) const
private

Obtain the filter at position (p, q)

◆ getFilter() [3/3]

template<class TIn >
LinFilt< double, TOut >& Filters::Resample< TIn >::getFilter ( const int  p,
const int  q 
) const
private

Obtain the filter at position (p, q)

◆ getN() [1/3]

int Filters::ResampleBase::getN ( ) const
inherited

Gets anti-aliasing filter parameters.

Returns
filter length param

◆ getN() [2/3]

int Filters::ResampleBase::getN ( ) const
inherited

Gets anti-aliasing filter parameters.

Returns
filter length param

◆ getN() [3/3]

int Filters::ResampleBase::getN ( ) const
inherited

Gets anti-aliasing filter parameters.

Returns
filter length param

◆ getNOrder() [1/3]

int Filters::ResampleBase::getNOrder ( ) const
inherited

Gets anti-aliasing filter parameters.

Returns
filter order

◆ getNOrder() [2/3]

int Filters::ResampleBase::getNOrder ( ) const
inherited

Gets anti-aliasing filter parameters.

Returns
filter order

◆ getNOrder() [3/3]

int Filters::ResampleBase::getNOrder ( ) const
inherited

Gets anti-aliasing filter parameters.

Returns
filter order

◆ getP() [1/3]

int Filters::ResampleBase::getP ( ) const
inlineinherited

Gets the resample numerator.

Returns
upsample factor

◆ getP() [2/3]

int Filters::ResampleBase::getP ( ) const
inherited

Gets the resample numerator.

Returns
upsample factor

◆ getP() [3/3]

int Filters::ResampleBase::getP ( ) const
inherited

Gets the resample numerator.

Returns
upsample factor

◆ getQ() [1/3]

int Filters::ResampleBase::getQ ( ) const
inherited

Gets the resample numerator.

Returns
downsample factor

◆ getQ() [2/3]

int Filters::ResampleBase::getQ ( ) const
inlineinherited

Gets the resample numerator.

Returns
downsample factor

◆ getQ() [3/3]

int Filters::ResampleBase::getQ ( ) const
inherited

Gets the resample numerator.

Returns
downsample factor

◆ initFilters() [1/3]

template<class TIn >
void Filters::Resample< TIn >::initFilters ( const std::valarray< double > &  b)
private

Initialise the filter bank.

◆ initFilters() [2/3]

template<class TIn >
void Filters::Resample< TIn >::initFilters ( const std::valarray< double > &  b)
private

Initialise the filter bank.

◆ initFilters() [3/3]

template<class TIn >
void Filters::Resample< TIn >::initFilters ( const std::valarray< double > &  b)
private

Initialise the filter bank.

◆ operator=() [1/3]

template<class TIn >
const Resample& Filters::Resample< TIn >::operator= ( const Resample< TIn > &  rhs)

Assignment, needed because class has pointer members.

Parameters
[in]rhsinstance to be assigned from
Returns
reference to *this

◆ operator=() [2/3]

template<class TIn >
const Resample< TIn > & Filters::Resample< TIn >::operator= ( const Resample< TIn > &  rhs)

Assignment, needed because class has pointer members.

Parameters
[in]rhsinstance to be assigned from
Returns
reference to *this

◆ operator=() [3/3]

template<class TIn >
const Resample& Filters::Resample< TIn >::operator= ( const Resample< TIn > &  rhs)

Assignment, needed because class has pointer members.

Parameters
[in]rhsinstance to be assigned from
Returns
reference to *this

◆ operator==() [1/4]

bool Filters::ResampleBase::operator== ( const ResampleBase rhs)
inherited

Comparison operator.

Parameters
[in]rhsinstance to be assigned from
Returns
true if data is the same, false otherwise

◆ operator==() [2/4]

template<class TIn >
bool Filters::Resample< TIn >::operator== ( const Resample< TIn > &  rhs)

Comparison operator.

Parameters
[in]rhsinstance to be assigned from
Returns
true if data is the same, false otherwise

◆ operator==() [3/4]

template<class TIn >
bool Filters::Resample< TIn >::operator== ( const Resample< TIn > &  rhs)

Comparison operator.

Parameters
[in]rhsinstance to be assigned from
Returns
true if data is the same, false otherwise

◆ operator==() [4/4]

template<class TIn >
bool Filters::Resample< TIn >::operator== ( const Resample< TIn > &  rhs)

Comparison operator.

Parameters
[in]rhsinstance to be assigned from
Returns
true if data is the same, false otherwise

◆ reset() [1/3]

template<class TIn >
void Filters::Resample< TIn >::reset ( )
virtual

Reset the internal state to its initial condition.

Implements Filters::ResampleBase.

◆ reset() [2/3]

template<class TIn >
virtual void Filters::Resample< TIn >::reset ( )
virtual

Reset the internal state to its initial condition.

Implements Filters::ResampleBase.

◆ reset() [3/3]

template<class TIn >
virtual void Filters::Resample< TIn >::reset ( )
virtual

Reset the internal state to its initial condition.

Implements Filters::ResampleBase.

Member Data Documentation

◆ m_lf

template<class TIn >
lf_type Filters::Resample< TIn >::m_lf
private

Storage for anti-aliasing filters.

◆ m_orphan

template<class TIn >
std::valarray< TOut > Filters::Resample< TIn >::m_orphan
private

Pointer to partial sum saved for split input purposes.


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