MatrixOps.C File Reference

#include "Image/MatrixOps.H"
#include "Image/Image.H"
#include "Image/Pixels.H"
#include "Image/lapack.H"
#include "Util/Assert.H"
#include "Util/MathFunctions.H"
#include "rutz/trace.h"
#include "inst/Image/MatrixOps.I"
Include dependency graph for MatrixOps.C:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define ARR_IDX(arrptr, i, j)   ((arrptr)[(i) + ((j)*siz)])

Functions

template<class T >
Image< typename promote_trait
< T, T >::TP > 
vmMult (const Image< T > &v, const Image< T > &M)
 Vector-Matrix Multiplication: y = v * M.
template<>
Image< double > vmMult (const Image< double > &v, const Image< double > &M)
template<>
Image< float > vmMult (const Image< float > &v, const Image< float > &M)
template<class T >
Image< typename promote_trait
< T, T >::TP > 
matrixMult (const Image< T > &A, const Image< T > &B)
 Matrix-Matrix Multiplication: C = A * B.
template<>
Image< double > matrixMult (const Image< double > &A, const Image< double > &B)
template<>
Image< float > matrixMult (const Image< float > &A, const Image< float > &B)
template<class T >
Image< typename promote_trait
< T, T >::TP > 
matrixMult (const Image< T > &A, const Image< T > &B, const uint beginAX, const uint endAX, const uint beginBX, const uint endBX, const uint beginAY, const uint endAY)
 Matrix-Matrix Multiplication: C = A * B.
template<class T_or_RGB >
Image< T_or_RGB > transpose (const Image< T_or_RGB > &M)
 transpose matrix M
template<class T_or_RGB >
Image< T_or_RGB > flipHoriz (const Image< T_or_RGB > &img)
 flip horizontally
template<class T_or_RGB >
Image< T_or_RGB > flipVertic (const Image< T_or_RGB > &img)
 flip vertically
template<class T >
Image< T > eye (const uint size)
 return the identity matrix of dimensions (size x size)
template<class T >
promote_trait< T, T >::TP trace (const Image< T > &M)
 Compute the trace of a square matrix, i.e., sum of its diagonal elements.
template<class T >
int matrixPivot (Image< T > &M, const int y)
 Get a partial pivot and pivote a square matrix, at y.
template<class T >
Image< typename promote_trait
< T, float >::TP > 
matrixInv (const Image< T > &M)
 Inverse a nonsingular square matrix.
template<class T >
promote_trait< T, T >::TP dotprod (const Image< T > &A, const Image< T > &B)
 Compute dot product between two images.
template<class T >
promote_trait< T, float >::TP matrixDet (const Image< T > &M)
 Compute the determinant of a square matrix.
template Image< double > transpose (const Image< double > &)
template Image< short > transpose (const Image< short > &)
template Image< unsigned short > transpose (const Image< unsigned short > &)
template promote_trait< double,
double >::TP 
trace (const Image< double > &)
template Image< promote_trait
< double, float >::TP > 
matrixInv (const Image< double > &)

Detailed Description

Matrix operations on Image

Definition in file MatrixOps.C.


Function Documentation

template<class T >
promote_trait<T,T>::TP dotprod ( const Image< T > &  A,
const Image< T > &  B 
) [inline]

Compute dot product between two images.

The two images must have same dims. This is just the sum of all pointwise products.

Definition at line 453 of file MatrixOps.C.

References ASSERT, Image< T >::begin(), Image< T >::end(), and Image< T >::isSameSize().

template<class T >
Image<T> eye ( const uint  size  )  [inline]

return the identity matrix of dimensions (size x size)

Definition at line 301 of file MatrixOps.C.

References Image< T >::beginw(), and ZEROS.

Referenced by SimulationViewerCompress::getTraj(), WinnerTakeAllGreedy::integrate(), main(), and SimulationViewerEyeSim::onSimEventWTAwinner().

template<class T_or_RGB >
Image<T_or_RGB> flipHoriz ( const Image< T_or_RGB > &  img  )  [inline]
template<class T_or_RGB >
Image<T_or_RGB> flipVertic ( const Image< T_or_RGB > &  img  )  [inline]
template<class T >
promote_trait<T, float>::TP matrixDet ( const Image< T > &  M  )  [inline]

Compute the determinant of a square matrix.

Definition at line 468 of file MatrixOps.C.

References ASSERT, Image< T >::getVal(), Image< T >::getWidth(), Image< T >::isSquare(), matrixPivot(), and Image< T >::setVal().

template<class T >
Image<typename promote_trait<T, float>::TP> matrixInv ( const Image< T > &  M  )  [inline]
template<class T >
Image<typename promote_trait<T,T>::TP> matrixMult ( const Image< T > &  A,
const Image< T > &  B,
const uint  beginAX,
const uint  endAX,
const uint  beginBX,
const uint  endBX,
const uint  beginAY,
const uint  endAY 
) [inline]

Matrix-Matrix Multiplication: C = A * B.

The images A and B are interpreted as matrices. For multiplying a (m x n) with a (n x p) matrix, this is the generic matrix multiplication with complexity (m * n * p). This version will allow you to multiply values in a matrix that lie between index endA/B and beginA/B. The destination matrix will be the same size as: (endAX - beginAX) x (endAX - beginAX) per usual the width of A (indexed between beginAX and endAX) and height of B MUST be equal. If not then perhaps use transpose...

Parameters:
A input matrix 1
B input matrix 2
beginAX starting (width) index in matrix A
endAX ending (width) index in matrix A
beginBX starting (width) index in matrix B
endBX ending (width) index in matrix B
beginAY starting (height) index in matrix A
endAY ending (height) index in matrix A

Definition at line 207 of file MatrixOps.C.

References ASSERT, Image< T >::beginw(), Image< T >::getHeight(), Image< T >::getVal(), Image< T >::initialized(), and ZEROS.

template<class T >
Image<typename promote_trait<T,T>::TP> matrixMult ( const Image< T > &  A,
const Image< T > &  B 
) [inline]
template<class T >
int matrixPivot ( Image< T > &  M,
const int  y 
) [inline]

Get a partial pivot and pivote a square matrix, at y.

returns -1 if we can't find one

Definition at line 338 of file MatrixOps.C.

References abs(), ASSERT, Image< T >::getArrayPtr(), Image< T >::getVal(), Image< T >::getWidth(), and Image< T >::isSquare().

Referenced by matrixDet(), and matrixInv().

template<class T >
promote_trait<T,T>::TP trace ( const Image< T > &  M  )  [inline]

Compute the trace of a square matrix, i.e., sum of its diagonal elements.

Definition at line 319 of file MatrixOps.C.

References ASSERT, Image< T >::begin(), Image< T >::getWidth(), and Image< T >::isSquare().

Referenced by getEllipseFromCov(), getTensorEigen(), and TensorField::setMax().

template<class T_or_RGB >
Image<T_or_RGB> transpose ( const Image< T_or_RGB > &  M  )  [inline]
template<class T >
Image<typename promote_trait<T,T>::TP> vmMult ( const Image< T > &  v,
const Image< T > &  M 
) [inline]

Vector-Matrix Multiplication: y = v * M.

Parameters:
v row vector (w x h == n x 1),
M matrix with (w x h == p x n)
Returns:
row vector (w x h == p x 1)

Definition at line 151 of file MatrixOps.C.

Referenced by getLikelyhoodImage().

Generated on Sun May 8 08:42:42 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3