VTK  9.2.20230201
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | List of all members
vtkFFT Class Reference

perform Discrete Fourier Transforms More...

#include <vtkFFT.h>

Inheritance diagram for vtkFFT:
[legend]
Collaboration diagram for vtkFFT:
[legend]

Classes

struct  isFftType
 
struct  isFftType< vtkFFT::ComplexNumber >
 
struct  isFftType< vtkFFT::ScalarNumber >
 

Public Types

enum  Scaling : int { Density = 0 , Spectrum }
 Scaling modes for Spectrogram and Csd functions. More...
 
enum  SpectralMode : int { STFT = 0 , PSD }
 Spectral modes for Spectrogram and Csd functions. More...
 
typedef vtkObject Superclass
 
using ScalarNumber = kiss_fft_scalar
 Useful type definitions and utilities. More...
 
using ComplexNumber = kiss_fft_cpx
 Useful type definitions and utilities. More...
 
using vtkScalarNumberArray = vtkAOSDataArrayTemplate< vtkFFT::ScalarNumber >
 Useful type definitions and utilities. More...
 

Public Member Functions

virtual vtkTypeBool IsA (const char *type)
 Return 1 if this class is the same type of (or a subclass of) the named class. More...
 
vtkFFTNewInstance () const
 
void PrintSelf (ostream &os, vtkIndent indent) override
 Methods invoked by print to print information about the object including superclasses. More...
 
template<typename T >
constexpr T Zero ()
 
template<>
constexpr vtkFFT::ComplexNumber Zero ()
 
- Public Member Functions inherited from vtkObject
 vtkBaseTypeMacro (vtkObject, vtkObjectBase)
 
virtual void DebugOn ()
 Turn debugging output on. More...
 
virtual void DebugOff ()
 Turn debugging output off. More...
 
bool GetDebug ()
 Get the value of the debug flag. More...
 
void SetDebug (bool debugFlag)
 Set the value of the debug flag. More...
 
virtual void Modified ()
 Update the modification time for this object. More...
 
virtual vtkMTimeType GetMTime ()
 Return this object's modified time. More...
 
void RemoveObserver (unsigned long tag)
 
void RemoveObservers (unsigned long event)
 
void RemoveObservers (const char *event)
 
void RemoveAllObservers ()
 
vtkTypeBool HasObserver (unsigned long event)
 
vtkTypeBool HasObserver (const char *event)
 
int InvokeEvent (unsigned long event)
 
int InvokeEvent (const char *event)
 
std::string GetObjectDescription () const override
 The object description printed in messages and PrintSelf output. More...
 
unsigned long AddObserver (unsigned long event, vtkCommand *, float priority=0.0f)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
unsigned long AddObserver (const char *event, vtkCommand *, float priority=0.0f)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
vtkCommandGetCommand (unsigned long tag)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
void RemoveObserver (vtkCommand *)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
void RemoveObservers (unsigned long event, vtkCommand *)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
void RemoveObservers (const char *event, vtkCommand *)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
vtkTypeBool HasObserver (unsigned long event, vtkCommand *)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
vtkTypeBool HasObserver (const char *event, vtkCommand *)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
template<class U , class T >
unsigned long AddObserver (unsigned long event, U observer, void(T::*callback)(), float priority=0.0f)
 Overloads to AddObserver that allow developers to add class member functions as callbacks for events. More...
 
template<class U , class T >
unsigned long AddObserver (unsigned long event, U observer, void(T::*callback)(vtkObject *, unsigned long, void *), float priority=0.0f)
 Overloads to AddObserver that allow developers to add class member functions as callbacks for events. More...
 
template<class U , class T >
unsigned long AddObserver (unsigned long event, U observer, bool(T::*callback)(vtkObject *, unsigned long, void *), float priority=0.0f)
 Allow user to set the AbortFlagOn() with the return value of the callback method. More...
 
int InvokeEvent (unsigned long event, void *callData)
 This method invokes an event and return whether the event was aborted or not. More...
 
int InvokeEvent (const char *event, void *callData)
 This method invokes an event and return whether the event was aborted or not. More...
 
virtual void SetObjectName (const std::string &objectName)
 Set/get the name of this object for reporting purposes. More...
 
virtual std::string GetObjectName () const
 Set/get the name of this object for reporting purposes. More...
 
- Public Member Functions inherited from vtkObjectBase
const char * GetClassName () const
 Return the class name as a string. More...
 
virtual vtkIdType GetNumberOfGenerationsFromBase (const char *name)
 Given the name of a base class of this class type, return the distance of inheritance between this class type and the named class (how many generations of inheritance are there between this class and the named class). More...
 
virtual void Delete ()
 Delete a VTK object. More...
 
virtual void FastDelete ()
 Delete a reference to this object. More...
 
void InitializeObjectBase ()
 
void Print (ostream &os)
 Print an object to an ostream. More...
 
virtual void Register (vtkObjectBase *o)
 Increase the reference count (mark as used by another object). More...
 
virtual void UnRegister (vtkObjectBase *o)
 Decrease the reference count (release by another object). More...
 
int GetReferenceCount ()
 Return the current reference count of this object. More...
 
void SetReferenceCount (int)
 Sets the reference count. More...
 
bool GetIsInMemkind () const
 A local state flag that remembers whether this object lives in the normal or extended memory space. More...
 
virtual void PrintHeader (ostream &os, vtkIndent indent)
 Methods invoked by print to print information about the object including superclasses. More...
 
virtual void PrintTrailer (ostream &os, vtkIndent indent)
 Methods invoked by print to print information about the object including superclasses. More...
 
virtual bool UsesGarbageCollector () const
 Indicate whether the class uses vtkGarbageCollector or not. More...
 

Static Public Member Functions

static std::vector< ComplexNumberIFft (const std::vector< ComplexNumber > &in)
 Compute the inverse of Fft. More...
 
static std::vector< ScalarNumberIRFft (const std::vector< ComplexNumber > &in)
 Compute the inverse of RFft. More...
 
static ScalarNumber Abs (const ComplexNumber &in)
 Return the absolute value (also known as norm, modulus, or magnitude) of complex number. More...
 
static ScalarNumber SquaredAbs (const ComplexNumber &in)
 Return the squared absolute value of the complex number. More...
 
static ComplexNumber Conjugate (const ComplexNumber &in)
 Return the conjugate of the given complex number. More...
 
static std::vector< ScalarNumberFftFreq (int windowLength, double sampleSpacing)
 Return the DFT sample frequencies. More...
 
static std::vector< ScalarNumberRFftFreq (int windowLength, double sampleSpacing)
 Return the DFT sample frequencies for the real version of the dft (see Rfft). More...
 
template<typename T >
static void Transpose (T *data, unsigned int *shape)
 Transpose in place an inlined 2D matrix. More...
 
template<typename T >
static void GenerateKernel1D (T *kernel, std::size_t n, WindowGenerator generator)
 Given a window generator function, create a symmetric 1D kernel. More...
 
template<typename T >
static void GenerateKernel2D (T *kernel, std::size_t n, std::size_t m, WindowGenerator generator)
 Given a window generator function, create a symmetric 2D kernel. More...
 
static vtkFFTNew ()
 
static vtkTypeBool IsTypeOf (const char *type)
 
static vtkFFTSafeDownCast (vtkObjectBase *o)
 
static std::vector< ComplexNumberFft (const std::vector< ScalarNumber > &in)
 Compute the one-dimensional DFT for complex input. More...
 
static void Fft (ScalarNumber *input, std::size_t size, ComplexNumber *result)
 Compute the one-dimensional DFT for complex input. More...
 
static std::vector< ComplexNumberFft (const std::vector< ComplexNumber > &in)
 Compute the one-dimensional DFT for complex input. More...
 
static void Fft (ComplexNumber *input, std::size_t size, ComplexNumber *result)
 Compute the one-dimensional DFT for complex input. More...
 
static vtkSmartPointer< vtkScalarNumberArrayFft (vtkScalarNumberArray *input)
 Compute the one-dimensional DFT for complex input. More...
 
static std::vector< ComplexNumberRFft (const std::vector< ScalarNumber > &in)
 Compute the one-dimensional DFT for real input. More...
 
static void RFft (ScalarNumber *input, std::size_t size, ComplexNumber *result)
 Compute the one-dimensional DFT for real input. More...
 
static vtkSmartPointer< vtkScalarNumberArrayRFft (vtkScalarNumberArray *input)
 Compute the one-dimensional DFT for real input. More...
 
template<typename T , typename TW , typename std::enable_if< isFftType< T >::value >::type * = nullptr>
static std::vector< ComplexNumberOverlappingFft (const std::vector< T > &signal, const std::vector< TW > &window, std::size_t noverlap, bool detrend, bool onesided, unsigned int *shape=nullptr)
 Compute consecutive Fourier transforms Welch method without averaging nor scaling the result. More...
 
template<typename TW >
static vtkFFT::ComplexNumberOverlappingFft (vtkFFT::vtkScalarNumberArray *signal, const std::vector< TW > &window, std::size_t noverlap, bool detrend, bool onesided, unsigned int *shape=nullptr)
 Compute consecutive Fourier transforms Welch method without averaging nor scaling the result. More...
 
template<typename T , typename TW , typename std::enable_if< isFftType< T >::value >::type * = nullptr>
static std::vector< ComplexNumberSpectrogram (const std::vector< T > &signal, const std::vector< TW > &window, double sampleRate, int noverlap, bool detrend, bool onesided, vtkFFT::Scaling scaling, vtkFFT::SpectralMode mode, unsigned int *shape=nullptr, bool transpose=false)
 Compute a spectrogram with consecutive Fourier transforms using Welch method. More...
 
template<typename TW >
static vtkSmartPointer< vtkFFT::vtkScalarNumberArraySpectrogram (vtkFFT::vtkScalarNumberArray *signal, const std::vector< TW > &window, double sampleRate, int noverlap, bool detrend, bool onesided, vtkFFT::Scaling scaling, vtkFFT::SpectralMode mode, unsigned int *shape=nullptr, bool transpose=false)
 Compute a spectrogram with consecutive Fourier transforms using Welch method. More...
 
template<typename T , typename TW , typename std::enable_if< isFftType< T >::value >::type * = nullptr>
static std::vector< vtkFFT::ScalarNumberCsd (const std::vector< T > &signal, const std::vector< TW > &window, double sampleRate, int noverlap, bool detrend, bool onesided, vtkFFT::Scaling scaling)
 Compute the Cross Spectral Density of a given signal. More...
 
template<typename TW >
static vtkSmartPointer< vtkFFT::vtkScalarNumberArrayCsd (vtkScalarNumberArray *signal, const std::vector< TW > &window, double sampleRate, int noverlap, bool detrend, bool onesided, vtkFFT::Scaling scaling)
 Compute the Cross Spectral Density of a given signal. More...
 
- Static Public Member Functions inherited from vtkObject
static vtkObjectNew ()
 Create an object with Debug turned off, modified time initialized to zero, and reference counting on. More...
 
static void BreakOnError ()
 This method is called when vtkErrorMacro executes. More...
 
static void SetGlobalWarningDisplay (int val)
 This is a global flag that controls whether any debug, warning or error messages are displayed. More...
 
static void GlobalWarningDisplayOn ()
 This is a global flag that controls whether any debug, warning or error messages are displayed. More...
 
static void GlobalWarningDisplayOff ()
 This is a global flag that controls whether any debug, warning or error messages are displayed. More...
 
static int GetGlobalWarningDisplay ()
 This is a global flag that controls whether any debug, warning or error messages are displayed. More...
 
- Static Public Member Functions inherited from vtkObjectBase
static vtkTypeBool IsTypeOf (const char *name)
 Return 1 if this class type is the same type of (or a subclass of) the named class. More...
 
static vtkIdType GetNumberOfGenerationsFromBaseType (const char *name)
 Given a the name of a base class of this class type, return the distance of inheritance between this class type and the named class (how many generations of inheritance are there between this class and the named class). More...
 
static vtkObjectBaseNew ()
 Create an object with Debug turned off, modified time initialized to zero, and reference counting on. More...
 
static void SetMemkindDirectory (const char *directoryname)
 The name of a directory, ideally mounted -o dax, to memory map an extended memory space within. More...
 
static bool GetUsingMemkind ()
 A global state flag that controls whether vtkObjects are constructed in the usual way (the default) or within the extended memory space. More...
 

Protected Member Functions

virtual vtkObjectBaseNewInstanceInternal () const
 
 vtkFFT ()=default
 
 ~vtkFFT () override=default
 
- Protected Member Functions inherited from vtkObject
 vtkObject ()
 
 ~vtkObject () override
 
void RegisterInternal (vtkObjectBase *, vtkTypeBool check) override
 
void UnRegisterInternal (vtkObjectBase *, vtkTypeBool check) override
 
void InternalGrabFocus (vtkCommand *mouseEvents, vtkCommand *keypressEvents=nullptr)
 These methods allow a command to exclusively grab all events. More...
 
void InternalReleaseFocus ()
 These methods allow a command to exclusively grab all events. More...
 
- Protected Member Functions inherited from vtkObjectBase
 vtkObjectBase ()
 
virtual ~vtkObjectBase ()
 
virtual void ReportReferences (vtkGarbageCollector *)
 
 vtkObjectBase (const vtkObjectBase &)
 
void operator= (const vtkObjectBase &)
 

Static Protected Member Functions

template<typename T >
constexpr static T Zero ()
 Templated zero value, specialized for vtkFFT::ComplexNumber. More...
 
template<typename InputIt >
static std::iterator_traits< InputIt >::value_type ComputeScaling (InputIt begin, InputIt end, Scaling scaling, double fs)
 For a given window defined by begin and end, compute the scaling needed to apply to the resulting FFT. More...
 
template<typename T , typename TW >
static void PreprocessAndDispatchFft (const T *segment, const std::vector< TW > &window, bool detrend, bool onesided, vtkFFT::ComplexNumber *result)
 Dispatch the signal to the right FFT function according to the given parameters. More...
 
static void RFft (ComplexNumber *input, std::size_t size, ComplexNumber *result)
 XXX(c++17): This function should NOT exist and is here just for the sake template unfolding purposes. More...
 
template<typename TW >
static void ScaleFft (ComplexNumber *fft, unsigned int shape[2], const std::vector< TW > &window, double sampleRate, bool onesided, vtkFFT::Scaling scaling, vtkFFT::SpectralMode mode)
 Scale a fft according to its window and some mode. More...
 
- Static Protected Member Functions inherited from vtkObjectBase
static vtkMallocingFunction GetCurrentMallocFunction ()
 
static vtkReallocingFunction GetCurrentReallocFunction ()
 
static vtkFreeingFunction GetCurrentFreeFunction ()
 
static vtkFreeingFunction GetAlternateFreeFunction ()
 
using WindowGenerator = ScalarNumber(*)(std::size_t, std::size_t)
 Window generator functions. More...
 
static ScalarNumber HanningGenerator (std::size_t x, std::size_t size)
 Window generator functions. More...
 
static ScalarNumber BartlettGenerator (std::size_t x, std::size_t size)
 Window generator functions. More...
 
static ScalarNumber SineGenerator (std::size_t x, std::size_t size)
 Window generator functions. More...
 
static ScalarNumber BlackmanGenerator (std::size_t x, std::size_t size)
 Window generator functions. More...
 
static ScalarNumber RectangularGenerator (std::size_t x, std::size_t size)
 Window generator functions. More...
 

Additional Inherited Members

- Protected Attributes inherited from vtkObject
bool Debug
 
vtkTimeStamp MTime
 
vtkSubjectHelper * SubjectHelper
 
std::string ObjectName
 
- Protected Attributes inherited from vtkObjectBase
std::atomic< int32_t > ReferenceCount
 
vtkWeakPointerBase ** WeakPointers
 

Detailed Description

perform Discrete Fourier Transforms

vtkFFT provides methods to perform Discrete Fourier Transforms (DFT). These include providing forward and reverse Fourier transforms. The current implementation uses the third-party library kissfft.

The terminology tries to follow the Numpy terminology, that is :

Some functions provides pointer-based version of themself in order to prevent copying memory when possible.

Tests:
vtkFFT (Tests)

Definition at line 58 of file vtkFFT.h.

Member Typedef Documentation

◆ ScalarNumber

using vtkFFT::ScalarNumber = kiss_fft_scalar

Useful type definitions and utilities.

ScalarNumber is defined as a floating point number.

ComplexNumber is defined as a struct that contains two ScalarNumber. These 2 numbers should be contiguous in memory. First one should be named r and represent the real part, while second one should be named i and represent the imaginary part. This specification is important for the implementation of functions accepting and returning values from vtkDataArrays as it allows to do some zero-copy operations.

A vtkScalarNumberArray is a data array with a layout memory compatible with the underlying library for zero copy operations.

isFftType is a trait to tell templates if Type is either ScalarNumber or ComplexNumber.

Common operators such as +,-,*,/ between ScalarNumber and ComplexNumber are included in this header.

Definition at line 84 of file vtkFFT.h.

◆ ComplexNumber

using vtkFFT::ComplexNumber = kiss_fft_cpx

Useful type definitions and utilities.

ScalarNumber is defined as a floating point number.

ComplexNumber is defined as a struct that contains two ScalarNumber. These 2 numbers should be contiguous in memory. First one should be named r and represent the real part, while second one should be named i and represent the imaginary part. This specification is important for the implementation of functions accepting and returning values from vtkDataArrays as it allows to do some zero-copy operations.

A vtkScalarNumberArray is a data array with a layout memory compatible with the underlying library for zero copy operations.

isFftType is a trait to tell templates if Type is either ScalarNumber or ComplexNumber.

Common operators such as +,-,*,/ between ScalarNumber and ComplexNumber are included in this header.

Definition at line 85 of file vtkFFT.h.

◆ vtkScalarNumberArray

Useful type definitions and utilities.

ScalarNumber is defined as a floating point number.

ComplexNumber is defined as a struct that contains two ScalarNumber. These 2 numbers should be contiguous in memory. First one should be named r and represent the real part, while second one should be named i and represent the imaginary part. This specification is important for the implementation of functions accepting and returning values from vtkDataArrays as it allows to do some zero-copy operations.

A vtkScalarNumberArray is a data array with a layout memory compatible with the underlying library for zero copy operations.

isFftType is a trait to tell templates if Type is either ScalarNumber or ComplexNumber.

Common operators such as +,-,*,/ between ScalarNumber and ComplexNumber are included in this header.

Definition at line 89 of file vtkFFT.h.

◆ WindowGenerator

using vtkFFT::WindowGenerator = ScalarNumber (*)(std::size_t, std::size_t)

Window generator functions.

Implementation only needs to be valid for x E [0; size / 2] because kernels are symmetric by definitions. This point is very important for some kernels like Bartlett for example.

Warning
Most generators need size > 1 !

Can be used with GenerateKernel1D and GenerateKernel2D for generating full kernels.

Definition at line 327 of file vtkFFT.h.

◆ Superclass

Definition at line 351 of file vtkFFT.h.

Member Enumeration Documentation

◆ Scaling

enum vtkFFT::Scaling : int

Scaling modes for Spectrogram and Csd functions.

Enumerator
Density 

Cross Spectral Density scaling (V^2/Hz)

Spectrum 

Cross Spectrum scaling (V^2)

Definition at line 211 of file vtkFFT.h.

◆ SpectralMode

Spectral modes for Spectrogram and Csd functions.

Enumerator
STFT 

Short-Time Fourier Transform, for local sections.

PSD 

Power Spectral Density.

Definition at line 220 of file vtkFFT.h.

Constructor & Destructor Documentation

◆ vtkFFT()

vtkFFT::vtkFFT ( )
protecteddefault

◆ ~vtkFFT()

vtkFFT::~vtkFFT ( )
overrideprotecteddefault

Member Function Documentation

◆ Fft() [1/5]

static std::vector<ComplexNumber> vtkFFT::Fft ( const std::vector< ScalarNumber > &  in)
static

Compute the one-dimensional DFT for complex input.

If input is scalars then the imaginary part is set to 0

input has n complex points output has n complex points in case of success and empty in case of failure

◆ Fft() [2/5]

static void vtkFFT::Fft ( ScalarNumber input,
std::size_t  size,
ComplexNumber result 
)
static

Compute the one-dimensional DFT for complex input.

If input is scalars then the imaginary part is set to 0

input has n complex points output has n complex points in case of success and empty in case of failure

◆ Fft() [3/5]

static std::vector<ComplexNumber> vtkFFT::Fft ( const std::vector< ComplexNumber > &  in)
static

Compute the one-dimensional DFT for complex input.

If input is scalars then the imaginary part is set to 0

input has n complex points output has n complex points in case of success and empty in case of failure

◆ Fft() [4/5]

static void vtkFFT::Fft ( ComplexNumber input,
std::size_t  size,
ComplexNumber result 
)
static

Compute the one-dimensional DFT for complex input.

If input is scalars then the imaginary part is set to 0

input has n complex points output has n complex points in case of success and empty in case of failure

◆ Fft() [5/5]

static vtkSmartPointer<vtkScalarNumberArray> vtkFFT::Fft ( vtkScalarNumberArray input)
static

Compute the one-dimensional DFT for complex input.

If input is scalars then the imaginary part is set to 0

input has n complex points output has n complex points in case of success and empty in case of failure

◆ RFft() [1/4]

static std::vector<ComplexNumber> vtkFFT::RFft ( const std::vector< ScalarNumber > &  in)
static

Compute the one-dimensional DFT for real input.

input has n scalar points output has (n/2) + 1 complex points in case of success and empty in case of failure

◆ RFft() [2/4]

static void vtkFFT::RFft ( ScalarNumber input,
std::size_t  size,
ComplexNumber result 
)
static

Compute the one-dimensional DFT for real input.

input has n scalar points output has (n/2) + 1 complex points in case of success and empty in case of failure

◆ RFft() [3/4]

static vtkSmartPointer<vtkScalarNumberArray> vtkFFT::RFft ( vtkScalarNumberArray input)
static

Compute the one-dimensional DFT for real input.

input has n scalar points output has (n/2) + 1 complex points in case of success and empty in case of failure

◆ IFft()

static std::vector<ComplexNumber> vtkFFT::IFft ( const std::vector< ComplexNumber > &  in)
static

Compute the inverse of Fft.

The input should be ordered in the same way as is returned by Fft, i.e.,

  • in[0] should contain the zero frequency term,
  • in[1:n//2] should contain the positive-frequency terms,
  • in[n//2 + 1:] should contain the negative-frequency terms.

input has n complex points output has n scalar points in case of success and empty in case of failure

◆ IRFft()

static std::vector<ScalarNumber> vtkFFT::IRFft ( const std::vector< ComplexNumber > &  in)
static

Compute the inverse of RFft.

The input is expected to be in the form returned by Rfft, i.e. the real zero-frequency term followed by the complex positive frequency terms in order of increasing frequency.

input has (n/2) + 1 complex points output has n scalar points in case of success and empty in case of failure

◆ Abs()

vtkFFT::ScalarNumber vtkFFT::Abs ( const ComplexNumber in)
inlinestatic

Return the absolute value (also known as norm, modulus, or magnitude) of complex number.

Definition at line 462 of file vtkFFT.h.

◆ SquaredAbs()

vtkFFT::ScalarNumber vtkFFT::SquaredAbs ( const ComplexNumber in)
inlinestatic

Return the squared absolute value of the complex number.

Definition at line 468 of file vtkFFT.h.

◆ Conjugate()

vtkFFT::ComplexNumber vtkFFT::Conjugate ( const ComplexNumber in)
inlinestatic

Return the conjugate of the given complex number.

Definition at line 474 of file vtkFFT.h.

◆ FftFreq()

static std::vector<ScalarNumber> vtkFFT::FftFreq ( int  windowLength,
double  sampleSpacing 
)
static

Return the DFT sample frequencies.

Output has windowLength size.

◆ RFftFreq()

static std::vector<ScalarNumber> vtkFFT::RFftFreq ( int  windowLength,
double  sampleSpacing 
)
static

Return the DFT sample frequencies for the real version of the dft (see Rfft).

Output has (windowLength / 2) + 1 size.

◆ OverlappingFft() [1/2]

template<typename T , typename TW , typename std::enable_if< isFftType< T >::value >::type * = nullptr>
static std::vector<ComplexNumber> vtkFFT::OverlappingFft ( const std::vector< T > &  signal,
const std::vector< TW > &  window,
std::size_t  noverlap,
bool  detrend,
bool  onesided,
unsigned int *  shape = nullptr 
)
static

Compute consecutive Fourier transforms Welch method without averaging nor scaling the result.

Parameters
[in]signalthe input signal
[in]windowthe window to use per segment. Its size defines the size of FFT and thus the size of the output.
[in]noverlapnumber of samples that will overlap between two segment
[in]detrendif true then each segment will be detrend using the mean value of the segment before applying the FFT.
[in]onesidedif true return a one-sided spectrum for real data. If input is copmlex then this option will be ignored.
[out]shapeif not nullptr, return the shape (n,m) of the result. n is the number of segment and m the number of samples per segment.
Returns
a 1D array that stores all resulting segment. For a shape (N,M), layout is (segment0_sample0, segment0_sample1, ..., segment0_sampleM, segment1_sample0, ... segmentN_sampleM)

◆ OverlappingFft() [2/2]

template<typename TW >
static vtkFFT::ComplexNumber* vtkFFT::OverlappingFft ( vtkFFT::vtkScalarNumberArray signal,
const std::vector< TW > &  window,
std::size_t  noverlap,
bool  detrend,
bool  onesided,
unsigned int *  shape = nullptr 
)
static

Compute consecutive Fourier transforms Welch method without averaging nor scaling the result.

Parameters
[in]signalthe input signal
[in]windowthe window to use per segment. Its size defines the size of FFT and thus the size of the output.
[in]noverlapnumber of samples that will overlap between two segment
[in]detrendif true then each segment will be detrend using the mean value of the segment before applying the FFT.
[in]onesidedif true return a one-sided spectrum for real data. If input is copmlex then this option will be ignored.
[out]shapeif not nullptr, return the shape (n,m) of the result. n is the number of segment and m the number of samples per segment.
Returns
a 1D array that stores all resulting segment. For a shape (N,M), layout is (segment0_sample0, segment0_sample1, ..., segment0_sampleM, segment1_sample0, ... segmentN_sampleM)

◆ Spectrogram() [1/2]

template<typename T , typename TW , typename std::enable_if< isFftType< T >::value >::type * = nullptr>
static std::vector<ComplexNumber> vtkFFT::Spectrogram ( const std::vector< T > &  signal,
const std::vector< TW > &  window,
double  sampleRate,
int  noverlap,
bool  detrend,
bool  onesided,
vtkFFT::Scaling  scaling,
vtkFFT::SpectralMode  mode,
unsigned int *  shape = nullptr,
bool  transpose = false 
)
static

Compute a spectrogram with consecutive Fourier transforms using Welch method.

Parameters
[in]signalthe input signal
[in]windowthe window to use per segment. Its size defines the size of FFT and thus the size of the output.
[in]sampleRatesample rate of the input signal
[in]noverlapnumber of samples that will overlap between two segment
[in]detrendif true then each segment will be detrend using the mean value of the segment before applying the FFT.
[in]onesidedif true return a one-sided spectrum for real data. If input is copmlex then this option will be ignored.
[in]scalingcan be either Cross Spectral Density (V^2/Hz) or Cross Spectrum (V^2)
[in]modedetermine which type of value ares returned. It is very dependent to how you want to use the result afterwards.
[out]shapeif not nullptr, return the shape (n,m) of the result. n is the number of segment and m the number of samples per segment. Shape is inverted if transpose is true.
[in]transposeallows to transpose the resulting the resulting matrix into something of shape (m, n)
Returns
a 1D array that stores all resulting segment. For a shape (N,M), layout is (segment0_sample0, segment0_sample1, ..., segment0_sampleM, segment1_sample0, ... segmentN_sampleM)

◆ Spectrogram() [2/2]

template<typename TW >
static vtkSmartPointer<vtkFFT::vtkScalarNumberArray> vtkFFT::Spectrogram ( vtkFFT::vtkScalarNumberArray signal,
const std::vector< TW > &  window,
double  sampleRate,
int  noverlap,
bool  detrend,
bool  onesided,
vtkFFT::Scaling  scaling,
vtkFFT::SpectralMode  mode,
unsigned int *  shape = nullptr,
bool  transpose = false 
)
static

Compute a spectrogram with consecutive Fourier transforms using Welch method.

Parameters
[in]signalthe input signal
[in]windowthe window to use per segment. Its size defines the size of FFT and thus the size of the output.
[in]sampleRatesample rate of the input signal
[in]noverlapnumber of samples that will overlap between two segment
[in]detrendif true then each segment will be detrend using the mean value of the segment before applying the FFT.
[in]onesidedif true return a one-sided spectrum for real data. If input is copmlex then this option will be ignored.
[in]scalingcan be either Cross Spectral Density (V^2/Hz) or Cross Spectrum (V^2)
[in]modedetermine which type of value ares returned. It is very dependent to how you want to use the result afterwards.
[out]shapeif not nullptr, return the shape (n,m) of the result. n is the number of segment and m the number of samples per segment. Shape is inverted if transpose is true.
[in]transposeallows to transpose the resulting the resulting matrix into something of shape (m, n)
Returns
a 1D array that stores all resulting segment. For a shape (N,M), layout is (segment0_sample0, segment0_sample1, ..., segment0_sampleM, segment1_sample0, ... segmentN_sampleM)

◆ Csd() [1/2]

template<typename T , typename TW , typename std::enable_if< isFftType< T >::value >::type * = nullptr>
static std::vector<vtkFFT::ScalarNumber> vtkFFT::Csd ( const std::vector< T > &  signal,
const std::vector< TW > &  window,
double  sampleRate,
int  noverlap,
bool  detrend,
bool  onesided,
vtkFFT::Scaling  scaling 
)
static

Compute the Cross Spectral Density of a given signal.

This is the optimized version for computing the csd of a single signal with itself. It uses Spectrogram behind the hood, and then average all resulting segments of the spectrogram.

Parameters
[in]signalthe input signal
[in]windowthe window to use per segment. Its size defines the size of FFT and thus the size of the output.
[in]sampleRatesample rate of the input signal
[in]noverlapnumber of samples that will overlap between two segment
[in]detrendif true then each segment will be detrend using the mean value of the segment before applying the FFT.
[in]onesidedif true return a one-sided spectrum for real data. If input is copmlex then this option will be ignored.
[in]scalingcan be either Cross Spectral Density (V^2/Hz) or Cross Spectrum (V^2)
Returns
a 1D array containing the resulting cross spectral density or spectrum.

See vtkFFT::Spectrogram

◆ Csd() [2/2]

template<typename TW >
static vtkSmartPointer<vtkFFT::vtkScalarNumberArray> vtkFFT::Csd ( vtkScalarNumberArray signal,
const std::vector< TW > &  window,
double  sampleRate,
int  noverlap,
bool  detrend,
bool  onesided,
vtkFFT::Scaling  scaling 
)
static

Compute the Cross Spectral Density of a given signal.

This is the optimized version for computing the csd of a single signal with itself. It uses Spectrogram behind the hood, and then average all resulting segments of the spectrogram.

Parameters
[in]signalthe input signal
[in]windowthe window to use per segment. Its size defines the size of FFT and thus the size of the output.
[in]sampleRatesample rate of the input signal
[in]noverlapnumber of samples that will overlap between two segment
[in]detrendif true then each segment will be detrend using the mean value of the segment before applying the FFT.
[in]onesidedif true return a one-sided spectrum for real data. If input is copmlex then this option will be ignored.
[in]scalingcan be either Cross Spectral Density (V^2/Hz) or Cross Spectrum (V^2)
Returns
a 1D array containing the resulting cross spectral density or spectrum.

See vtkFFT::Spectrogram

◆ Transpose()

template<typename T >
static void vtkFFT::Transpose ( T *  data,
unsigned int *  shape 
)
static

Transpose in place an inlined 2D matrix.

This algorithm is not optimized for square matrices but is generic. This will also effectively swap shape values. Worst case complexity is : O( (shape[0]*shape[1])^3/2 )

XXX: some fft librairies such as FFTW already propose functions to do that. This should be taken into account if the backend is changed at some point.

XXX: An optimized version could be implemented for square matrices

◆ HanningGenerator()

double vtkFFT::HanningGenerator ( std::size_t  x,
std::size_t  size 
)
inlinestatic

Window generator functions.

Implementation only needs to be valid for x E [0; size / 2] because kernels are symmetric by definitions. This point is very important for some kernels like Bartlett for example.

Warning
Most generators need size > 1 !

Can be used with GenerateKernel1D and GenerateKernel2D for generating full kernels.

Definition at line 480 of file vtkFFT.h.

◆ BartlettGenerator()

double vtkFFT::BartlettGenerator ( std::size_t  x,
std::size_t  size 
)
inlinestatic

Window generator functions.

Implementation only needs to be valid for x E [0; size / 2] because kernels are symmetric by definitions. This point is very important for some kernels like Bartlett for example.

Warning
Most generators need size > 1 !

Can be used with GenerateKernel1D and GenerateKernel2D for generating full kernels.

Definition at line 486 of file vtkFFT.h.

◆ SineGenerator()

double vtkFFT::SineGenerator ( std::size_t  x,
std::size_t  size 
)
inlinestatic

Window generator functions.

Implementation only needs to be valid for x E [0; size / 2] because kernels are symmetric by definitions. This point is very important for some kernels like Bartlett for example.

Warning
Most generators need size > 1 !

Can be used with GenerateKernel1D and GenerateKernel2D for generating full kernels.

Definition at line 492 of file vtkFFT.h.

◆ BlackmanGenerator()

double vtkFFT::BlackmanGenerator ( std::size_t  x,
std::size_t  size 
)
inlinestatic

Window generator functions.

Implementation only needs to be valid for x E [0; size / 2] because kernels are symmetric by definitions. This point is very important for some kernels like Bartlett for example.

Warning
Most generators need size > 1 !

Can be used with GenerateKernel1D and GenerateKernel2D for generating full kernels.

Definition at line 498 of file vtkFFT.h.

◆ RectangularGenerator()

double vtkFFT::RectangularGenerator ( std::size_t  x,
std::size_t  size 
)
inlinestatic

Window generator functions.

Implementation only needs to be valid for x E [0; size / 2] because kernels are symmetric by definitions. This point is very important for some kernels like Bartlett for example.

Warning
Most generators need size > 1 !

Can be used with GenerateKernel1D and GenerateKernel2D for generating full kernels.

Definition at line 505 of file vtkFFT.h.

◆ GenerateKernel1D()

template<typename T >
void vtkFFT::GenerateKernel1D ( T *  kernel,
std::size_t  n,
WindowGenerator  generator 
)
static

Given a window generator function, create a symmetric 1D kernel.

kernel is the pointer to the raw data array

Definition at line 512 of file vtkFFT.h.

◆ GenerateKernel2D()

template<typename T >
void vtkFFT::GenerateKernel2D ( T *  kernel,
std::size_t  n,
std::size_t  m,
WindowGenerator  generator 
)
static

Given a window generator function, create a symmetric 2D kernel.

kernel is the pointer to the raw 2D data array.

Definition at line 523 of file vtkFFT.h.

◆ New()

static vtkFFT* vtkFFT::New ( )
static

◆ IsTypeOf()

static vtkTypeBool vtkFFT::IsTypeOf ( const char *  type)
static

◆ IsA()

virtual vtkTypeBool vtkFFT::IsA ( const char *  name)
virtual

Return 1 if this class is the same type of (or a subclass of) the named class.

Returns 0 otherwise. This method works in combination with vtkTypeMacro found in vtkSetGet.h.

Reimplemented from vtkObjectBase.

◆ SafeDownCast()

static vtkFFT* vtkFFT::SafeDownCast ( vtkObjectBase o)
static

◆ NewInstanceInternal()

virtual vtkObjectBase* vtkFFT::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkFFT* vtkFFT::NewInstance ( ) const

◆ PrintSelf()

void vtkFFT::PrintSelf ( ostream &  os,
vtkIndent  indent 
)
overridevirtual

Methods invoked by print to print information about the object including superclasses.

Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes.

Reimplemented from vtkObject.

◆ Zero() [1/3]

template<typename T >
constexpr static T vtkFFT::Zero ( )
staticconstexprprotected

Templated zero value, specialized for vtkFFT::ComplexNumber.

◆ ComputeScaling()

template<typename InputIt >
static std::iterator_traits<InputIt>::value_type vtkFFT::ComputeScaling ( InputIt  begin,
InputIt  end,
Scaling  scaling,
double  fs 
)
staticprotected

For a given window defined by begin and end, compute the scaling needed to apply to the resulting FFT.

Used in the Spectrogram function.

◆ PreprocessAndDispatchFft()

template<typename T , typename TW >
static void vtkFFT::PreprocessAndDispatchFft ( const T *  segment,
const std::vector< TW > &  window,
bool  detrend,
bool  onesided,
vtkFFT::ComplexNumber result 
)
staticprotected

Dispatch the signal to the right FFT function according to the given parameters.

Also detrend the signal and multiply it by the window. Used in the OverlappingFft function.

◆ RFft() [4/4]

static void vtkFFT::RFft ( ComplexNumber input,
std::size_t  size,
ComplexNumber result 
)
staticprotected

XXX(c++17): This function should NOT exist and is here just for the sake template unfolding purposes.

As long we don't have constexrp if this is the easier way to deal with it.

Warning
this function will always throw an error
See also
PreprocessAndDispatchFft

◆ ScaleFft()

template<typename TW >
static void vtkFFT::ScaleFft ( ComplexNumber fft,
unsigned int  shape[2],
const std::vector< TW > &  window,
double  sampleRate,
bool  onesided,
vtkFFT::Scaling  scaling,
vtkFFT::SpectralMode  mode 
)
staticprotected

Scale a fft according to its window and some mode.

Used in the Spectrogram function.

◆ Zero() [2/3]

template<typename T >
constexpr T vtkFFT::Zero ( )
constexpr

Definition at line 416 of file vtkFFT.h.

◆ Zero() [3/3]

template<>
constexpr vtkFFT::ComplexNumber vtkFFT::Zero ( )
constexpr

Definition at line 421 of file vtkFFT.h.


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