gpufilter
GPU-Efficient Recursive Filtering and Summed-Area Tables
gpufilter::Matrix< T, M, N > Class Template Reference

Matrix class. More...

#include <util.h>

List of all members.

Public Member Functions

__host__ __device__ int rows () const
 Get number of rows of this matrix.
__host__ __device__ int cols () const
 Get number of columns of this matrix.
__host__ __device__ const
Vector< T, N > & 
operator[] (int i) const
 Access (constant) operator.
__host__ __device__ Vector< T,
N > & 
operator[] (int i)
 Access operator.
template<int P, int Q>
__host__ __device__ Matrix< T,
M, Q > 
operator* (const Matrix< T, P, Q > &rhs) const
 Multiply operator.
__host__ __device__ Matrixoperator*= (T val)
 Multiply-then-assign operator.
__host__ __device__ Vector< T, M > col (int j) const
 Get column j of this matrix.
__host__ __device__ void set_col (int j, const Vector< T, M > &c)
 Set column j of this matrix.
__host__ __device__ Matrixoperator+= (const Matrix &rhs)
 Add-then-assign operator.
__host__ __device__ Matrixoperator-= (const Matrix &rhs)
 Subtract-then-assign operator.

Private Attributes

Vector< T, N > m_data [M]
 Matrix values.

Friends

std::ostream & operator<< (std::ostream &out, const Matrix &m)
 Output stream operator.
__host__ __device__ friend Matrix operator* (const Matrix &m, T val)
 Multiply operator.
__host__ __device__ friend Matrix operator* (T val, const Matrix &m)
 Multiply operator.
__host__ __device__ friend Matrix operator+ (const Matrix &lhs, const Matrix &rhs)
 Add operator.
__host__ __device__ friend Matrix operator- (const Matrix &lhs, const Matrix &rhs)
 Subtract operator.

Related Functions

(Note that these are not member functions.)

template<class T , int M, int N>
__host__ __device__ Vector< T, N > operator* (const Vector< T, M > &v, const Matrix< T, M, N > &m)
 Multiply vector-to-matrix operator.
template<class T , int M, int N>
__host__ __device__ Matrix< T,
M, N > 
zeros ()
 Instantiate a matrix with zeros.
template<class T , int M, int N>
Matrix< T, M, N > identity ()
 Instantiate an identity matrix.
template<class T , int M, int N>
__host__ __device__ Matrix< T,
N, M > 
transp (const Matrix< T, M, N > &m)
 Instantiate the transposed version of a given matrix.
template<class T , int M, int N, int R>
void fwd_inplace (const Matrix< T, M, R > &p, Matrix< T, M, N > &b, const Vector< T, R+1 > &w)
 Computes the forward operator on matrices (in-place)
template<class T , int M, int N, int R>
Matrix< T, M, N > fwd (const Matrix< T, M, R > &p, const Matrix< T, M, N > &b, const Vector< T, R+1 > &w)
 Computes the forward operator on matrices.
template<class T , int M, int N, int R>
void fwd_inplace (const Matrix< T, R, N > &p, Matrix< T, M, N > &b, const Vector< T, R+1 > &w)
 Computes the forward operator on matrices (in-place)
template<class T , int M, int N, int R>
Matrix< T, M, N > fwdT (const Matrix< T, R, N > &pT, const Matrix< T, M, N > &b, const Vector< T, R+1 > &w)
 Computes the forward-transposed operator on matrices.
template<class T , int M, int N, int R>
void rev_inplace (Matrix< T, M, N > &b, const Matrix< T, M, R > &e, const Vector< T, R+1 > &w)
 Computes the reverse operator on matrices (in-place)
template<class T , int M, int N, int R>
Matrix< T, M, N > rev (const Matrix< T, M, N > &b, const Matrix< T, M, R > &e, const Vector< T, R+1 > &w)
 Computes the reverse operator on matrices.
template<class T , int M, int N, int R>
void rev_inplace (Matrix< T, M, N > &b, const Matrix< T, R, N > &e, const Vector< T, R+1 > &w)
 Computes the reverse operator on matrices (in-place)
template<class T , int M, int N, int R>
Matrix< T, M, N > revT (const Matrix< T, M, N > &b, const Matrix< T, R, N > &eT, const Vector< T, R+1 > &w)
 Computes the reverse-transposed operator on matrices.
template<int R, int M, int N, class T >
Matrix< T, M, R > head (const Matrix< T, M, N > &mat)
 Computes the head operator on matrices.
template<int R, int M, int N, class T >
Matrix< T, R, N > headT (const Matrix< T, M, N > &mat)
 Computes the head-transposed operator on matrices.
template<int R, int M, int N, class T >
Matrix< T, M, R > tail (const Matrix< T, M, N > &mat)
 Computes the tail operator on matrices.
template<int R, int M, int N, class T >
Matrix< T, R, N > tailT (const Matrix< T, M, N > &mat)
 Computes the tail-transposed operator on matrices.

Detailed Description

template<class T, int M, int N = M>
class gpufilter::Matrix< T, M, N >

Matrix class.

Matrix class to represent special small matrices, such as $A_{FB}$ and $A_{RB}$ described in the paper ([Nehab:2011] cited in alg5()).

Template Parameters:
TMatrix value type
MNumber of rows
NNumber of columns

Member Function Documentation

template<class T, int M, int N = M>
__host__ __device__ Vector<T,M> gpufilter::Matrix< T, M, N >::col ( int  j) const [inline]

Get column j of this matrix.

Parameters:
[in]jIndex of column to get
Returns:
Column j as a vector
template<class T, int M, int N = M>
__host__ __device__ int gpufilter::Matrix< T, M, N >::cols ( ) const [inline]

Get number of columns of this matrix.

Returns:
Number of columns
template<class T, int M, int N = M>
template<int P, int Q>
__host__ __device__ Matrix<T,M,Q> gpufilter::Matrix< T, M, N >::operator* ( const Matrix< T, P, Q > &  rhs) const [inline]

Multiply operator.

Parameters:
[in]rhsRight-hand-side matrix to multiply
Returns:
Resulting matrix from multiplication
Template Parameters:
PNumber of rows of other matrix
QNumber of columns of other matrix
template<class T, int M, int N = M>
__host__ __device__ Matrix& gpufilter::Matrix< T, M, N >::operator*= ( val) [inline]

Multiply-then-assign operator.

Parameters:
[in]valScalar value to multilpy matrix to
Returns:
Resulting matrix from multiplication
template<class T, int M, int N = M>
__host__ __device__ Matrix& gpufilter::Matrix< T, M, N >::operator+= ( const Matrix< T, M, N > &  rhs) [inline]

Add-then-assign operator.

Parameters:
[in]rhsRight-hand-side matrix in addition
Returns:
Resulting matrix from the addition
template<class T, int M, int N = M>
__host__ __device__ Matrix& gpufilter::Matrix< T, M, N >::operator-= ( const Matrix< T, M, N > &  rhs) [inline]

Subtract-then-assign operator.

Parameters:
[in]rhsRight-hand-side matrix in subtraction
Returns:
Resulting matrix from the subtraction
template<class T, int M, int N = M>
__host__ __device__ const Vector<T,N>& gpufilter::Matrix< T, M, N >::operator[] ( int  i) const [inline]

Access (constant) operator.

Parameters:
[in]iRow of the matrix to access
Returns:
Vector (constant) of the corresponding row
template<class T, int M, int N = M>
__host__ __device__ Vector<T,N>& gpufilter::Matrix< T, M, N >::operator[] ( int  i) [inline]

Access operator.

Parameters:
[in]iRow of the matrix to access
Returns:
Vector of the corresponding row
template<class T, int M, int N = M>
__host__ __device__ int gpufilter::Matrix< T, M, N >::rows ( ) const [inline]

Get number of rows of this matrix.

Returns:
Number of rows
template<class T, int M, int N = M>
__host__ __device__ void gpufilter::Matrix< T, M, N >::set_col ( int  j,
const Vector< T, M > &  c 
) [inline]

Set column j of this matrix.

Parameters:
[in]jIndex of column to set
[in]cVector to place in matrix column

Friends And Related Function Documentation

template<class T , int M, int N, int R>
Matrix< T, M, N > fwd ( const Matrix< T, M, R > &  p,
const Matrix< T, M, N > &  b,
const Vector< T, R+1 > &  w 
) [related]

Computes the forward operator on matrices.

Computes the matrix resulting from applying the forward operator $F$ (causal filter) given a prologue $R \times N$ matrix $p$ (i.e. initial conditions) and an input $M \times N$ matrix $b$ (where M is the number of rows $h$ and N is the number of columns $w$ as described in section 2 of [Nehab:2011] cited in alg5()). The resulting matrix is $M \times N$ and it has the same size as the input $b$.

Parameters:
[in]pPrologue $R \times N$ matrix ( $R$ is the filter order)
[in]bInput $M \times N$ matrix
[in]wFilter weights with $R+1$ size ( $R$ feedback coefficients)
Template Parameters:
MNumber of rows
NNumber of columns
RNumber of feedback coefficients
TMatrix value type
template<class T , int M, int N, int R>
void fwd_inplace ( const Matrix< T, M, R > &  p,
Matrix< T, M, N > &  b,
const Vector< T, R+1 > &  w 
) [related]

Computes the forward operator on matrices (in-place)

For more information see rev().

Parameters:
[in]pPrologue $M \times R$ matrix ( $R$ is the filter order)
[in,out]bIn(out)put $M \times N$ matrix
[in]wFilter weights with $R+1$ size ( $R$ feedback coefficients)
Template Parameters:
MNumber of rows
NNumber of columns
RNumber of feedback coefficients
TMatrix value type
template<class T , int M, int N, int R>
void fwd_inplace ( const Matrix< T, R, N > &  p,
Matrix< T, M, N > &  b,
const Vector< T, R+1 > &  w 
) [related]

Computes the forward operator on matrices (in-place)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. For more information see fwd().

Parameters:
[in]pPrologue $R \times N$ matrix ( $R$ is the filter order)
[in,out]bIn(out)put $M \times N$ matrix
[in]wFilter weights with $R+1$ size ( $R$ feedback coefficients)
Template Parameters:
MNumber of rows
NNumber of columns
RNumber of feedback coefficients
TMatrix value type
template<class T , int M, int N, int R>
Matrix< T, M, N > fwdT ( const Matrix< T, R, N > &  pT,
const Matrix< T, M, N > &  b,
const Vector< T, R+1 > &  w 
) [related]

Computes the forward-transposed operator on matrices.

Computes the matrix resulting from applying the forward-transposed operator $F^{T}$ (causal filter on rows) given a prologue $M \times R$ matrix $p^{T}$ (i.e. initial conditions) and an input $M \times N$ matrix $b$ (where M is the number of rows $h$ and N is the number of columns $w$ as described in section 2 of [Nehab:2011] cited in alg5()). The resulting matrix is $M \times N$ and it has the same size as the input $b$.

Parameters:
[in]pTPrologue transposed $M \times R$ matrix ( $R$ is the filter order)
[in]bInput $M \times N$ matrix
[in]wFilter weights with $R+1$ size ( $R$ feedback coefficients)
Template Parameters:
MNumber of rows
NNumber of columns
RNumber of feedback coefficients
TMatrix value type
template<int R, int M, int N, class T >
Matrix< T, M, R > head ( const Matrix< T, M, N > &  mat) [related]

Computes the head operator on matrices.

Computes the matrix resulting from applying the head operator $H$ given an input $M \times N$ matrix $mat$. The operator extracts the $R \times N$ submatrix in the same shape and position as the column-epilogue of the input matrix, considering filter order $R$ (see [Nehab:2011] cited in alg5() function). The following image illustrates the concept:

blocks-2d.png
2D Block Notation

2D block notation showing a block and its boundary data from adjacent blocks. Note that the column-epilogue $E_{m+1,n}$ has to be extracted from the next block $B_{m+1,n}$ in column $n$ using the head operator on that block.

Parameters:
[in]matInput $M \times N$ matrix
Template Parameters:
RNumber of rows to extract (feedback coefficients)
MNumber of rows in input matrix
NNumber of columns in input matrix
TMatrix value type
template<int R, int M, int N, class T >
Matrix< T, R, N > headT ( const Matrix< T, M, N > &  mat) [related]

Computes the head-transposed operator on matrices.

Computes the matrix resulting from applying the head-transposed operator $H^{T}$ given an input $M \times N$ matrix $mat$. The operator extracts the $M \times R$ submatrix in the same shape and position as the row-epilogue of the input matrix, considering filter order $R$ (see [Nehab:2011] cited in alg5() function).

Note that, as shown in figure in head() function, the row-epilogue $E^{T}_{m,n+1}$ has to be extracted from the next block $B_{m,n+1}$ in row $m$ using the head-transposed operator on that block.

Parameters:
[in]matInput $M \times N$ matrix
Template Parameters:
RNumber of columns to extract (feedback coefficients)
MNumber of rows in input matrix
NNumber of columns in input matrix
TMatrix value type
template<class T , int M, int N>
Matrix< T, M, N > identity ( ) [related]

Instantiate an identity matrix.

Template Parameters:
TMatrix value type
MNumber of rows
NNumber of columns
template<class T, int M, int N = M>
__host__ __device__ friend Matrix operator* ( const Matrix< T, M, N > &  m,
val 
) [friend]

Multiply operator.

Parameters:
[in]mMatrix to multiply
[in]valScalar value to multiply matrix to
Returns:
Resulting matrix from the multiplication
template<class T, int M, int N = M>
__host__ __device__ friend Matrix operator* ( val,
const Matrix< T, M, N > &  m 
) [friend]

Multiply operator.

Parameters:
[in]valScalar value to multiply matrix to
[in]mMatrix to multiply
Returns:
Resulting matrix from the multiplication
template<class T , int M, int N>
__host__ __device__ Vector< T, N > operator* ( const Vector< T, M > &  v,
const Matrix< T, M, N > &  m 
) [related]

Multiply vector-to-matrix operator.

Parameters:
[in]vVector to multiply the matrix
[in]mMatrix to be multiplied by vector
Returns:
Resulting vector from the multiplication
template<class T, int M, int N = M>
__host__ __device__ friend Matrix operator+ ( const Matrix< T, M, N > &  lhs,
const Matrix< T, M, N > &  rhs 
) [friend]

Add operator.

Parameters:
[in]lhsLeft-hand-side matrix in addition
[in]rhsRight-hand-side matrix in addition
Returns:
Resulting matrix from the addition
template<class T, int M, int N = M>
__host__ __device__ friend Matrix operator- ( const Matrix< T, M, N > &  lhs,
const Matrix< T, M, N > &  rhs 
) [friend]

Subtract operator.

Parameters:
[in]lhsLeft-hand-side matrix in subtraction
[in]rhsRight-hand-side matrix in subtraction
Returns:
Resulting matrix from the subtraction
template<class T, int M, int N = M>
std::ostream& operator<< ( std::ostream &  out,
const Matrix< T, M, N > &  m 
) [friend]

Output stream operator.

Parameters:
[in,out]outOutput stream
[in]mMatrix to output values from
Returns:
Output stream
template<class T , int M, int N, int R>
Matrix< T, M, N > rev ( const Matrix< T, M, N > &  b,
const Matrix< T, M, R > &  e,
const Vector< T, R+1 > &  w 
) [related]

Computes the reverse operator on matrices.

Computes the matrix resulting from applying the reverse operator $R$ (anticausal filter) given an epilogue $R \times N$ matrix $e$ (i.e. initial conditions) and an input $M \times N$ matrix $b$ (where M is the number of rows $h$ and N is the number of columns $w$ as described in section 2 of [Nehab:2011] cited in alg5()). The resulting matrix is $M \times N$ and it has the same size as the input $b$.

Parameters:
[in]bInput $M \times N$ matrix
[in]eEpilogue $M \times R$ matrix ( $R$ is the filter order)
[in]wFilter weights with $R+1$ size ( $R$ feedback coefficients)
Returns:
Matrix resulting from applying the reverse operator
Template Parameters:
MNumber of rows
NNumber of columns
RNumber of feedback coefficients
TMatrix value type
template<class T , int M, int N, int R>
void rev_inplace ( Matrix< T, M, N > &  b,
const Matrix< T, M, R > &  e,
const Vector< T, R+1 > &  w 
) [related]

Computes the reverse operator on matrices (in-place)

For more information see rev().

Parameters:
[in,out]bIn(out)put $M \times N$ matrix
[in]eEpilogue $M \times R$ matrix ( $R$ is the filter order)
[in]wFilter weights with $R+1$ size ( $R$ feedback coefficients)
Template Parameters:
MNumber of rows
NNumber of columns
RNumber of feedback coefficients
TMatrix value type
template<class T , int M, int N, int R>
void rev_inplace ( Matrix< T, M, N > &  b,
const Matrix< T, R, N > &  e,
const Vector< T, R+1 > &  w 
) [related]

Computes the reverse operator on matrices (in-place)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. For more information see rev().

Parameters:
[in,out]bIn(out)put $M \times N$ matrix
[in]eEpilogue $R \times N$ matrix ( $R$ is the filter order)
[in]wFilter weights with $R+1$ size ( $R$ feedback coefficients)
Template Parameters:
MNumber of rows
NNumber of columns
RNumber of feedback coefficients
TMatrix value type
template<class T , int M, int N, int R>
Matrix< T, M, N > revT ( const Matrix< T, M, N > &  b,
const Matrix< T, R, N > &  eT,
const Vector< T, R+1 > &  w 
) [related]

Computes the reverse-transposed operator on matrices.

Computes the matrix resulting from applying the reverse-transposed operator $R^{T}$ (anticausal filter on rows) given an epilogue $M \times R$ matrix $e^{T}$ (i.e. initial conditions) and an input $M \times N$ matrix $b$ (where M is the number of rows $h$ and N is the number of columns $w$ as described in section 2 of [Nehab:2011] cited in alg5()). The resulting matrix is $M \times N$ and it has the same size as the input $b$.

Parameters:
[in]bInput $M \times N$ matrix
[in]eTEpilogue $R \times N$ matrix ( $R$ is the filter order)
[in]wFilter weights with $R+1$ size ( $R$ feedback coefficients)
Template Parameters:
MNumber of rows
NNumber of columns
RNumber of feedback coefficients
TMatrix value type
template<int R, int M, int N, class T >
Matrix< T, M, R > tail ( const Matrix< T, M, N > &  mat) [related]

Computes the tail operator on matrices.

Computes the matrix resulting from applying the tail operator $T$ given an input $M \times N$ matrix $mat$. The operator extracts the $R \times N$ submatrix in the same shape and position as the column-prologue of the input matrix, considering filter order $R$ (see [Nehab:2011] cited in alg5() function).

Note that, as shown in figure in head() function, the column-prologue $P_{m-1,n}$ has to be extracted from the previous block $B_{m-1,n}$ in column $n$ using the tail operator on that block.

Parameters:
[in]matInput $M \times N$ matrix
Template Parameters:
RNumber of rows to extract (feedback coefficients)
MNumber of rows in input matrix
NNumber of columns in input matrix
TMatrix value type
template<int R, int M, int N, class T >
Matrix< T, R, N > tailT ( const Matrix< T, M, N > &  mat) [related]

Computes the tail-transposed operator on matrices.

Computes the matrix resulting from applying the tail-transposed operator $T^{T}$ given an input $M \times N$ matrix $mat$. The operator extracts the $M \times R$ submatrix in the same shape and position as the row-prologue of the input matrix, considering filter order $R$ (see [Nehab:2011] cited in alg5() function).

Note that, as shown in figure in head() function, the row-prologue $P^{T}_{m,n-1}$ has to be extracted from the previous block $B_{m,n-1}$ in row $m$ using the tail-transposed operator on that block.

Parameters:
[in]matInput $M \times N$ matrix
Template Parameters:
RNumber of rows to extract (feedback coefficients)
MNumber of rows in input matrix
NNumber of columns in input matrix
TMatrix value type
template<class T , int M, int N>
__host__ __device__ Matrix< T, N, M > transp ( const Matrix< T, M, N > &  m) [related]

Instantiate the transposed version of a given matrix.

Parameters:
[in]mGiven matrix
Template Parameters:
TMatrix value type
MNumber of rows
NNumber of columns
template<class T , int M, int N>
__host__ __device__ Matrix< T, M, N > zeros ( ) [related]

Instantiate a matrix with zeros.

Template Parameters:
TMatrix value type
MNumber of rows
NNumber of columns

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