Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

MatrixOps.H File Reference


Detailed Description

Matrix operations on Image

Definition in file MatrixOps.H.

#include "Image/Image.H"
#include "Util/Promotions.H"
#include "rutz/error.h"

Include dependency graph for MatrixOps.H:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  SingularMatrixException
 Exception class thrown if a singular matrix is encountered. More...

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<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<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.


Function Documentation

template<class T>
promote_trait<T,T>::TP dotprod const Image< T > &  A,
const Image< T > &  B
 

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(), GVX_TRACE, Image< T >::isSameSize(), and lobot::stop().

Referenced by main().

template<class T>
Image<T> eye const uint  size  ) 
 

return the identity matrix of dimensions (size x size)

Definition at line 301 of file MatrixOps.C.

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

Referenced by SwpeScorer::accum(), AffineTransform::computeTransform(), SimulationViewerCompress::getTraj(), WinnerTakeAllGreedy::integrate(), main(), SimulationViewerEyeSim::onSimEventWTAwinner(), and submain().

template<class T_or_RGB>
Image<T_or_RGB> flipHoriz const Image< T_or_RGB > &  img  ) 
 

flip horizontally

Definition at line 259 of file MatrixOps.C.

References Image< T >::begin(), Image< T >::beginw(), Image< T >::getHeight(), Image< T >::getWidth(), GVX_TRACE, h, NO_INIT, w, x, and y.

Referenced by GSlocalizer::getBeliefImage(), Beobot2_GistSalLocalizerMasterI::getBeliefImage(), RetinaStd::getOutput(), RetinaSpaceVariant::getOutput(), and replicateHemifield().

template<class T_or_RGB>
Image<T_or_RGB> flipVertic const Image< T_or_RGB > &  img  ) 
 

flip vertically

Definition at line 279 of file MatrixOps.C.

References Image< T >::begin(), Image< T >::beginw(), Image< T >::getHeight(), Image< T >::getWidth(), GVX_TRACE, h, NO_INIT, w, and y.

Referenced by Geons3D::calcGeonLikelihood(), TwoHalfDSketch::calcSketchLikelihood(), HippocampusI::displayMap(), BeeStemSim::getImage(), RetinaStd::getOutput(), RetinaSpaceVariant::getOutput(), linePlot(), main(), replicateHemifield(), IRobotI::run(), BeoBotSim::simLoop(), SubSim::simLoop(), IRobotSim::simLoop(), SeaBee3Simulator::simLoop(), and SeaBee3Simulator::updateSensors().

template<class T>
promote_trait<T,float>::TP matrixDet const Image< T > &  M  ) 
 

Compute the determinant of a square matrix.

Definition at line 468 of file MatrixOps.C.

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

Referenced by Image_xx_matrixDet_xx_1(), Image_xx_matrixDet_xx_2(), and Image_xx_matrixDet_xx_3().

template<class T>
Image<typename promote_trait<T, float>::TP> matrixInv const Image< T > &  M  ) 
 

Inverse a nonsingular square matrix.

Definition at line 373 of file MatrixOps.C.

References ASSERT, Image< T >::getArrayPtr(), Image< T >::getWidth(), GVX_TRACE, i, Image< T >::isSquare(), matrixPivot(), and SRC_POS.

Referenced by TaskRelevanceMapGistClassify::computeGistDist(), getLikelyhoodImage(), Image_xx_matrixInv_xx_1(), Image_xx_matrixInv_xx_2(), Image_xx_matrixInv_xx_3(), naiveUnstablePseudoInv(), and HippocampusI::updateParticleSlamObservation().

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.

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(), GVX_TRACE, Image< T >::initialized(), and ZEROS.

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.

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).

Definition at line 179 of file MatrixOps.C.

References basic_mm_mul().

template<class T>
int matrixPivot Image< T > &  M,
const int  y
 

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(), GVX_TRACE, i, and Image< T >::isSquare().

Referenced by matrixDet(), and matrixInv().

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.

Definition at line 319 of file MatrixOps.C.

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

Referenced by invdiag().

template<class T_or_RGB>
Image<T_or_RGB> transpose const Image< T_or_RGB > &  M  ) 
 

transpose matrix M

Definition at line 235 of file MatrixOps.C.

References Image< T >::begin(), Image< T >::beginw(), Image< T >::getHeight(), Image< T >::getWidth(), GVX_TRACE, h, NO_INIT, w, x, and y.

Referenced by FeedForwardNetwork::backprop(), FeedForwardNetwork::backprop3L(), TaskRelevanceMapGistClassify::computeGistDist(), GSlocalizer::getBeliefImage(), Beobot2_GistSalLocalizerMasterI::getBeliefImage(), BackpropLearner::getBiasMap(), TaskRelevanceMapTigs2::getGistPCAMatrix(), TaskRelevanceMapTigs2::getImgPCAMatrix(), getLikelyhoodImage(), TaskRelevanceMapGistClassify::getPCAMatrix(), TaskRelevanceMapTigs::getPCAMatrix(), TaskRelevanceMapTigs::getTigsMatrix(), TaskRelevanceMapTigs2::getTigsMatrix(), Image_xx_svd_lapack_xx_2(), ImageInfo::ImageInfo(), FeedForwardNetwork::init(), KalmanFilter::init(), FeedForwardNetwork::init3L(), TaskRelevanceMapTigs2::inputFrame(), linePlot(), main(), naiveUnstablePseudoInv(), lapack::svd(), lapack::svdf(), svdIdent(), svdPseudoInv(), svdPseudoInvf(), BackpropNetwork::train(), HippocampusI::updateParticleSlamObservation(), FeedForwardNetwork::write(), and FeedForwardNetwork::write3L().

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.

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.

References basic_vm_mul().


Generated on Sun Nov 22 13:44:08 2009 for iLab Neuromorphic Vision Toolkit by  doxygen 1.4.4