LatticeConvolver.h

Classes

ConvEnums -- Lists the different types of Convolutions that can be done (full description)
LatticeConvolver -- A class for doing multi-dimensional convolution (full description)

class ConvEnums

Types

enum ConvType

LINEAR
Linear convolution
CIRCULAR
Circular Convolution

Interface

Description

Synopsis

This enumerator is brought out as a separate class because g++ currently cannot handle enumerators in a templated class. When it can this class will go away and this enumerator moved into the Convolver class

Member Description

enum ConvType


template<class T> class LatticeConvolver

Interface

Public Members
LatticeConvolver()
LatticeConvolver(const Lattice<T> & psf, Bool doFast=False)
LatticeConvolver(const Lattice<T> & psf, const IPosition & modelShape, Bool doFast=False)
LatticeConvolver(const Lattice<T> & psf, const IPosition & modelShape, IPosition::ConvType type, Bool doFast=False)
LatticeConvolver(const LatticeConvolver<T> & other)
LatticeConvolver<T> & operator=(const LatticeConvolver<T> & other)
~LatticeConvolver()
void linear(Lattice<T> & result, const Lattice<T> & model)
void linear(Lattice<T> & modelAndResult)
void circular(Lattice<T> & result, const Lattice<T> & model)
void circular(Lattice<T> & modelAndResult)
void convolve(Lattice<T> & modelAndResult) const
void convolve(Lattice<T> & result, const Lattice<T> & model) const
void getPsf(Lattice<T> & psf) const
void resize(const IPosition & modelShape, ConvEnums::ConvType type)
IPosition shape() const
IPosition psfShape() const
ConvEnums::ConvType type() const
IPosition fftShape() const
void setFastConvolve()
Private Members
static void pad(Lattice<T> & paddedLat, const Lattice<T> & inLat)
static void unpad(Lattice<T> & result, const Lattice<T> & paddedResult)
void makeXfr(const Lattice<T> & psf)
void makePsf(Lattice<T> & psf) const
static IPosition calcFFTShape(const IPosition & psfShape, const IPosition & modelShape, ConvEnums::ConvType type)

Description

Review Status

Date Reviewed:
yyyy/mm/dd
Programs:
Tests:

Prerequisite

Etymology

The LatticeConvolver class will convolve Lattices. This class complements the Convolver class which will convolve Arrays.

Synopsis

This class performs linear or circular convolution on Lattices. See the Convolver class description of the difference between linear and circular convolution.

This class does convolutions by multiplying the Fourier transforms of the supplied Lattices and returning the inverse transform of the product. This is the best algorithm to use when the point spread function is large. This class does all the padding with zeros necessary to implement this algorithm. Hence the

Example

 

Motivation

Thrown Exceptions

To Do

Member Description

LatticeConvolver()

The default constructor creates a LatticeConvolver that will convolve your data with a point spread function (psf) that zero everywhere except at the centre where it is one. Convolving with this psf will not change your data.

LatticeConvolver(const Lattice<T> & psf, Bool doFast=False)

Create a convolver that is initialised to do circular convolution with the specified point spread function. It is assumed that the supplied model will be the same shape as the point spread function.

LatticeConvolver(const Lattice<T> & psf, const IPosition & modelShape, Bool doFast=False)

Create a convolver that is initialised to do linear convolution with the specified point spread function. The size of the model you will convolve with must be specified.

LatticeConvolver(const Lattice<T> & psf, const IPosition & modelShape, IPosition::ConvType type, Bool doFast=False)

Create a convolver that is initialised to do the specified type of convolution with the specified point spread function. The size of the model you expect to convolve with must be specified.

LatticeConvolver(const LatticeConvolver<T> & other)

The copy constructor uses reference semantics

LatticeConvolver<T> & operator=(const LatticeConvolver<T> & other)

The assignment operator also uses reference semantics

~LatticeConvolver()

The destructor does nothing special.

void linear(Lattice<T> & result, const Lattice<T> & model)

Perform linear convolution of the model with the previously specified psf. The supplied Lattices must be the same shape.

void linear(Lattice<T> & modelAndResult)

Perform in-place linear convolution of the model with the previously specified psf. Return the result in the same Lattice as the model.

void circular(Lattice<T> & result, const Lattice<T> & model)

Perform circular convolution of the model with the previously specified psf. Return the answer in result.

void circular(Lattice<T> & modelAndResult)

Perform in-place linear convolution of the model with the previously specified psf. Return the result in the same Lattice as the model.

void convolve(Lattice<T> & modelAndResult) const
void convolve(Lattice<T> & result, const Lattice<T> & model) const

Perform convolution on the specified model using the currently initialised convolution type (linear or circular). These functions will not resize the LatticeConvolver if the supplied Lattice is the wrong shape.

If the LatticeConvolver is setup for circular Convolution then the size of the supplied model must be less than or equal to the shape returned by the fftshape() function, which is usually the same as the shape of the psf.

If the LatticeConvolver is setup to do linear convolution the the input and output Lattices must have the same shape as the result from the shape() member function. The convolution may be either in-place or not.

void getPsf(Lattice<T> & psf) const

Return the psf currently used by this convolver. The supplied Lattice must be the correct shape ie., the same as returned by the psfShape member function.

void resize(const IPosition & modelShape, ConvEnums::ConvType type)

Resize the LatticeConvolver to do convolutions of the specified type and shape. The supplied function must always have the same number of dimensions as the internal point spread function (which can be found using the shape member function). The LatticeConvolver will be set up to do circular or linear convolutions depending on the supplied type

IPosition shape() const

Returns the shape of the Lattices that the convolver will convolve. This shape will always have as many dimensions as the psf that was used to initialise the LatticeConvolver. If the LatticeConvolver is setup to do circular convolutions then every axis of the returned IPosition will be zero length. If the LatticeConvolver is setup to do linear convolutions then the returned IPosition will have a positive values on each axis that indicate the expected shape of the input model.

IPosition psfShape() const

Returns the shape of the point spread function that the LatticeConvolver was initialised with.

ConvEnums::ConvType type() const

Returns the type of convolution the LatticeConvolver is currently set up to do.

IPosition fftShape() const

Returns the shape of the FFT's that the LatticeConvolver will do when performing the convolution. Not really useful except as a diagnostic tool. If the shape contains a lot of poorly factorisable lengths then the convolution will be slow.

void setFastConvolve()

Set usage of fast convolve with lesser flips

static void pad(Lattice<T> & paddedLat, const Lattice<T> & inLat)

static void unpad(Lattice<T> & result, const Lattice<T> & paddedResult)

void makeXfr(const Lattice<T> & psf)

void makePsf(Lattice<T> & psf) const

static IPosition calcFFTShape(const IPosition & psfShape, const IPosition & modelShape, ConvEnums::ConvType type)