#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"
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 > &) |
Definition in file MatrixOps.C.
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().
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().
flip horizontally
Definition at line 259 of file MatrixOps.C.
References Image< T >::begin(), Image< T >::beginw(), Image< T >::getHeight(), Image< T >::getWidth(), and NO_INIT.
Referenced by GSlocalizer::getBeliefImage(), Beobot2_GistSalLocalizerMasterI::getBeliefImage(), and RetinaAdapter::getOutput().
flip vertically
Definition at line 279 of file MatrixOps.C.
References Image< T >::begin(), Image< T >::beginw(), Image< T >::getHeight(), Image< T >::getWidth(), and NO_INIT.
Referenced by HippocampusI::displayMap(), RetinaAdapter::getOutput(), linePlot(), main(), and multilinePlot().
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().
Image<typename promote_trait<T, float>::TP> matrixInv | ( | const Image< T > & | M | ) | [inline] |
Inverse a nonsingular square matrix.
Definition at line 373 of file MatrixOps.C.
References ASSERT, Image< T >::getArrayPtr(), Image< T >::getWidth(), Image< T >::isSquare(), matrixPivot(), and SRC_POS.
Referenced by TaskRelevanceMapGistClassify::computeGistDist(), UKF::getLikelihood(), getLikelyhoodImage(), naiveUnstablePseudoInv(), UKF::update(), and HippocampusI::updateParticleSlamObservation().
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...
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.
Image<typename promote_trait<T,T>::TP> matrixMult | ( | const Image< T > & | A, | |
const Image< T > & | B | |||
) | [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).
Definition at line 179 of file MatrixOps.C.
Referenced by FeedForwardNetwork::backprop(), FeedForwardNetwork::backprop3L(), Environment::classifySegNum(), TaskRelevanceMapGistClassify::computeGistDist(), Gist_Navigation::evolve(), featureClusterVision< FLOAT >::fCVrunStandAloneMSBatchTest(), UKF::getLikelihood(), getLikelyhoodImage(), VisualObjectMatch::getSpatialDist(), naiveUnstablePseudoInv(), UKF::predictObservation(), UKF::predictState(), FeedForwardNetwork::run(), FeedForwardNetwork::run3L(), svdPseudoInv(), svdPseudoInvf(), UKF::update(), and HippocampusI::updateParticleSlamObservation().
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().
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().
transpose matrix M
Definition at line 235 of file MatrixOps.C.
References Image< T >::begin(), Image< T >::beginw(), Image< T >::getHeight(), Image< T >::getWidth(), and NO_INIT.
Referenced by FeedForwardNetwork::backprop(), FeedForwardNetwork::backprop3L(), TaskRelevanceMapGistClassify::computeGistDist(), GSlocalizer::getBeliefImage(), Beobot2_GistSalLocalizerMasterI::getBeliefImage(), UKF::getLikelihood(), getLikelyhoodImage(), AudioGrabber::grab(), FeedForwardNetwork::init(), KalmanFilter::init(), FeedForwardNetwork::init3L(), TaskRelevanceMapTigs2::inputFrame(), linePlot(), multilinePlot(), naiveUnstablePseudoInv(), UKF::predictObservation(), UKF::predictState(), svdPseudoInv(), svdPseudoInvf(), UKF::update(), HippocampusI::updateParticleSlamObservation(), FeedForwardNetwork::write(), and FeedForwardNetwork::write3L().
Image<typename promote_trait<T,T>::TP> vmMult | ( | const Image< T > & | v, | |
const Image< T > & | M | |||
) | [inline] |
Vector-Matrix Multiplication: y = v * M.
v | row vector (w x h == n x 1), | |
M | matrix with (w x h == p x n) |
Definition at line 151 of file MatrixOps.C.
Referenced by getLikelyhoodImage().