ViSP  2.10.0
vpPoseVector Class Reference

#include <vpPoseVector.h>

+ Inheritance diagram for vpPoseVector:

Public Types

enum  vpDetMethod { LU_DECOMPOSITION }
 

Public Member Functions

 vpPoseVector ()
 
 vpPoseVector (const double tx, const double ty, const double tz, const double tux, const double tuy, const double tuz)
 
 vpPoseVector (const vpHomogeneousMatrix &M)
 
 vpPoseVector (const vpTranslationVector &t, const vpThetaUVector &tu)
 
 vpPoseVector (const vpTranslationVector &t, const vpRotationMatrix &R)
 
vpPoseVector buildFrom (const vpHomogeneousMatrix &M)
 
vpPoseVector buildFrom (const vpTranslationVector &t, const vpThetaUVector &tu)
 
vpPoseVector buildFrom (const vpTranslationVector &t, const vpRotationMatrix &R)
 
double & operator[] (unsigned int i)
 
const double & operator[] (unsigned int i) const
 
void load (std::ifstream &f)
 
void save (std::ofstream &f) const
 
void print ()
 
void insert (unsigned int i, const vpColVector &v)
 
void insert (const vpMatrix &A, const unsigned int r, const unsigned int c)
 
void resize (const unsigned int i, const bool flagNullify=true)
 
vpColVectoroperator<< (const vpColVector &v)
 
vpColVectoroperator<< (double *)
 
vpColVector operator+ (const vpColVector &v) const
 
vpColVector operator- (const vpColVector &v) const
 
vpColVector operator- () const
 
double operator* (const vpColVector &x) const
 
vpMatrix operator* (const vpRowVector &x) const
 
vpColVector operator* (const double x) const
 
vpColVector rows (unsigned int first_row, unsigned int last_row)
 
void reshape (vpMatrix &m, const unsigned int &nrows, const unsigned int &ncols)
 
vpMatrix reshape (const unsigned int &nrows, const unsigned int &ncols)
 
void stack (const double &b)
 
void stack (const vpColVector &B)
 
vpRowVector t () const
 
vpColVectornormalize ()
 
void rad2deg ()
 
void deg2rad ()
 
unsigned int size () const
 
void kill ()
 
void eye (unsigned int n)
 
void eye (unsigned int m, unsigned int n)
 
void setIdentity (const double &val=1.0)
 
void stackMatrices (const vpMatrix &A)
 
Set/get Matrix size
void resize (const unsigned int nrows, const unsigned int ncols, const bool nullify=true)
 
unsigned int getRows () const
 
unsigned int getCols () const
 
double getMinValue () const
 
double getMaxValue () const
 
Matrix operations
vpMatrix operator+ (const vpMatrix &B) const
 
vpMatrix operator- (const vpMatrix &B) const
 
vpMatrix operator* (const vpMatrix &B) const
 
vpMatrix operator* (const vpHomography &H) const
 
vpTranslationVector operator* (const vpTranslationVector &b) const
 
vpMatrixoperator+= (const vpMatrix &B)
 
vpMatrixoperator+= (const double x)
 
vpMatrixoperator-= (const vpMatrix &B)
 
vpMatrixoperator-= (const double x)
 
vpMatrixoperator*= (const double x)
 
vpMatrixoperator/= (double x)
 
vpMatrix operator/ (const double x) const
 
double sum () const
 
double sumSquare () const
 
double det (vpDetMethod method=LU_DECOMPOSITION) const
 
vpMatrix expm ()
 
Columns, Rows extraction, Submatrix
void init (const vpMatrix &M, unsigned int r, unsigned int c, unsigned int nrows, unsigned int ncols)
 
vpRowVector getRow (const unsigned int i) const
 
vpRowVector getRow (const unsigned int i, const unsigned int j_begin, const unsigned int size) const
 
vpColVector getCol (const unsigned int j) const
 
vpColVector getCol (const unsigned int j, const unsigned int i_begin, const unsigned int size) const
 
Printing
int print (std::ostream &s, unsigned int length, char const *intro=0)
 
std::ostream & matlabPrint (std::ostream &os) const
 
std::ostream & maplePrint (std::ostream &os) const
 
std::ostream & csvPrint (std::ostream &os) const
 
std::ostream & cppPrint (std::ostream &os, const char *matrixName=NULL, bool octet=false) const
 
void printSize ()
 
Copy / assignment
void diag (const vpColVector &A)
 
Kronecker product
void kron (const vpMatrix &m1, vpMatrix &out)
 
vpMatrix kron (const vpMatrix &m1)
 
void stackColumns (vpColVector &out)
 
vpColVector stackColumns ()
 
void stackRows (vpRowVector &out)
 
vpRowVector stackRows ()
 
Transpose, Identity
vpMatrix transpose () const
 
void transpose (vpMatrix &C) const
 
vpMatrix AAt () const
 
void AAt (vpMatrix &B) const
 
vpMatrix AtA () const
 
void AtA (vpMatrix &B) const
 
Matrix inversion
vpMatrix inverseByLU () const
 
vpMatrix inverseByCholesky () const
 
vpMatrix inverseByCholeskyLapack () const
 
vpMatrix inverseByQR () const
 
vpMatrix inverseByQRLapack () const
 
vpMatrix pseudoInverse (double svThreshold=1e-6) const
 
unsigned int pseudoInverse (vpMatrix &Ap, double svThreshold=1e-6) const
 
unsigned int pseudoInverse (vpMatrix &Ap, vpColVector &sv, double svThreshold=1e-6) const
 
unsigned int pseudoInverse (vpMatrix &Ap, vpColVector &sv, double svThreshold, vpMatrix &ImA, vpMatrix &ImAt) const
 
unsigned int pseudoInverse (vpMatrix &Ap, vpColVector &sv, double svThreshold, vpMatrix &ImA, vpMatrix &ImAt, vpMatrix &kerA) const
 
SVD decomposition
void svd (vpColVector &w, vpMatrix &v)
 
void solveBySVD (const vpColVector &B, vpColVector &x) const
 
vpColVector solveBySVD (const vpColVector &B) const
 
unsigned int kernel (vpMatrix &KerA, double svThreshold=1e-6)
 
double cond ()
 
Eigen values
vpColVector eigenValues ()
 
void eigenValues (vpColVector &evalue, vpMatrix &evector)
 
Norms
double euclideanNorm () const
 
double infinityNorm () const
 
Deprecated functions
vp_deprecated vpRowVector row (const unsigned int i)
 
vp_deprecated vpColVector column (const unsigned int j)
 

Static Public Member Functions

static vpMatrix insert (const vpMatrix &A, const vpMatrix &B, const unsigned int r, const unsigned int c)
 
static void insert (const vpMatrix &A, const vpMatrix &B, vpMatrix &C, const unsigned int r, const unsigned int c)
 
static vpColVector stack (const vpColVector &A, const vpColVector &B)
 
static void stack (const vpColVector &A, const vpColVector &B, vpColVector &C)
 
static vpColVector crossProd (const vpColVector &a, const vpColVector &b)
 
static vpColVector cross (const vpColVector &a, const vpColVector &b)
 
static vpMatrix skew (const vpColVector &v)
 
static double dotProd (const vpColVector &a, const vpColVector &b)
 
static vpColVector sort (const vpColVector &v)
 
static vpColVector invSort (const vpColVector &v)
 
static double median (const vpColVector &v)
 
static double mean (const vpColVector &v)
 
static void add2Matrices (const vpMatrix &A, const vpMatrix &B, vpMatrix &C)
 
static void add2WeightedMatrices (const vpMatrix &A, const double &wA, const vpMatrix &B, const double &wB, vpMatrix &C)
 
static vpMatrix computeCovarianceMatrix (const vpMatrix &A, const vpColVector &x, const vpColVector &b)
 
static vpMatrix computeCovarianceMatrix (const vpMatrix &A, const vpColVector &x, const vpColVector &b, const vpMatrix &w)
 
static void computeHLM (const vpMatrix &H, const double &alpha, vpMatrix &HLM)
 
static void createDiagonalMatrix (const vpColVector &A, vpMatrix &DA)
 
static vpMatrix juxtaposeMatrices (const vpMatrix &A, const vpMatrix &B)
 
static void juxtaposeMatrices (const vpMatrix &A, const vpMatrix &B, vpMatrix &C)
 
static void kron (const vpMatrix &m1, const vpMatrix &m2, vpMatrix &out)
 
static vpMatrix kron (const vpMatrix &m1, const vpMatrix &m2)
 
static bool loadMatrix (std::string filename, vpMatrix &M, const bool binary=false, char *Header=NULL)
 
static bool loadMatrix (const char *filename, vpMatrix &M, const bool binary=false, char *Header=NULL)
 
static void mult2Matrices (const vpMatrix &A, const vpMatrix &B, vpMatrix &C)
 
static void multMatrixVector (const vpMatrix &A, const vpColVector &b, vpColVector &c)
 
static void negateMatrix (const vpMatrix &A, vpMatrix &C)
 
static bool saveMatrix (std::string filename, const vpMatrix &M, const bool binary=false, const char *Header="")
 
static bool saveMatrix (const char *filename, const vpMatrix &M, const bool binary=false, const char *Header="")
 
static bool saveMatrixYAML (std::string filename, const vpMatrix &M, const char *header="")
 
static bool saveMatrixYAML (const char *filename, const vpMatrix &M, const char *header="")
 
static bool loadMatrixYAML (std::string filename, vpMatrix &M, char *header=NULL)
 
static bool loadMatrixYAML (const char *filename, vpMatrix &M, char *header=NULL)
 
static vpMatrix stackMatrices (const vpMatrix &A, const vpMatrix &B)
 
static void stackMatrices (const vpMatrix &A, const vpMatrix &B, vpMatrix &C)
 
static void sub2Matrices (const vpMatrix &A, const vpMatrix &B, vpMatrix &C)
 

Public Attributes

double * data
 

Protected Attributes

unsigned int rowNum
 
unsigned int colNum
 
double ** rowPtrs
 
unsigned int dsize
 
unsigned int trsize
 

Related Functions

(Note that these are not member functions.)

vpColVector operator* (const double &x, const vpColVector &B)
 
vpMatrix operator* (const double &x, const vpMatrix &B)
 
void skew (const vpTranslationVector &t, vpMatrix &M)
 
enum  vpGEMMmethod
 
void vpGEMM (const vpMatrix &A, const vpMatrix &B, const double &alpha, const vpMatrix &C, const double &beta, vpMatrix &D, const unsigned int &ops=0)
 

Detailed Description

The pose is a complete representation of every rigid motion in the euclidian space.

It is composed of a translation and a rotation minimaly represented by a 6 dimension pose vector as:

\[ ^{a}{\bf r}_b = [^{a}{\bf t}_{b},\Theta {\bf u}]^\top \in R^6\]

where $ ^{a}{\bf r}_b $ is the pose from frame $ a $ to frame $ b $, with $ ^{a}{\bf t}_{b} $ being the translation vector between these frames along the x,y,z axis and $\Theta \bf u $, the $\Theta \bf u $ representation of the rotation $^{a}\bf{R}_{b}$ between these frames.

To know more about the $\Theta \bf u$ rotation representation, see vpThetaUVector documentation.

Examples:
servoMomentImage.cpp, servoSimu3D_cdMc_CamVelocity.cpp, servoSimu3D_cdMc_CamVelocityWithoutVpServo.cpp, servoSimu3D_cMcd_CamVelocity.cpp, servoSimu3D_cMcd_CamVelocityWithoutVpServo.cpp, servoSimuPoint2DhalfCamVelocity1.cpp, servoSimuPoint2DhalfCamVelocity2.cpp, servoSimuPoint2DhalfCamVelocity3.cpp, servoSimuThetaUCamVelocity.cpp, simulateCircle2DCamVelocity.cpp, simulateFourPoints2DCartesianCamVelocity.cpp, simulateFourPoints2DPolarCamVelocity.cpp, testFindMatch.cpp, testPose.cpp, testPoseFeatures.cpp, and testPoseRansac.cpp.

Definition at line 92 of file vpPoseVector.h.

Member Enumeration Documentation

enum vpMatrix::vpDetMethod
inherited

Method used to compute the determinant of a square matrix.

See also
det()
Enumerator
LU_DECOMPOSITION 

LU decomposition method.

Definition at line 105 of file vpMatrix.h.

Constructor & Destructor Documentation

vpPoseVector::vpPoseVector ( )

Default constructor.

Construct a 6 dimension pose vector $ [\bf t, \Theta \bf u]^\top$ where $ \Theta \bf u$ is a rotation vector $[\Theta u_x, \Theta u_y, \Theta u_z]^\top$ and $ \bf t $ is a translation vector $[t_x, t_y, t_z]^\top$.

The pose vector is initialized to zero.

Definition at line 78 of file vpPoseVector.cpp.

vpPoseVector::vpPoseVector ( const double  tx,
const double  ty,
const double  tz,
const double  tux,
const double  tuy,
const double  tuz 
)

Construct a 6 dimension pose vector $ [\bf{t}, \Theta \bf{u}]^\top$ from 3 translations and 3 $ \Theta \bf{u}$ angles.

Translations are expressed in meters, while rotations in radians.

Parameters
tx,ty,tz: Translations $[t_x, t_y, t_z]^\top$ respectively along the x, y and z axis (in meters).
tux,tuy,tuz: Rotations $[\Theta u_x, \Theta u_y, \Theta u_z]^\top$ respectively around the x, y and z axis (in radians).

Definition at line 98 of file vpPoseVector.cpp.

vpPoseVector::vpPoseVector ( const vpHomogeneousMatrix M)

Construct a 6 dimension pose vector $ [\bf t, \Theta \bf u]^\top$ from an homogeneous matrix $ \bf M $.

Parameters
M: Homogeneous matrix $ \bf M $ from which translation $ \bf t $ and $\Theta \bf u $ vectors are extracted to initialize the pose vector.

Definition at line 162 of file vpPoseVector.cpp.

References buildFrom().

vpPoseVector::vpPoseVector ( const vpTranslationVector tv,
const vpThetaUVector tu 
)

Construct a 6 dimension pose vector $ [\bf t, \Theta \bf u]^\top$ from a translation vector $ \bf t $ and a $\Theta \bf u$ vector.

Parameters
tv: Translation vector $ \bf t $.
tu: $\Theta \bf u$ rotation vector.

Definition at line 126 of file vpPoseVector.cpp.

References buildFrom().

vpPoseVector::vpPoseVector ( const vpTranslationVector tv,
const vpRotationMatrix R 
)

Construct a 6 dimension pose vector $ [\bf t, \Theta \bf u]^\top$ from a translation vector $ \bf t $ and a rotation matrix $ \bf R $.

Parameters
tv: Translation vector $ \bf t $.
R: Rotation matrix $ \bf R $ from which $\Theta \bf u$ vector is extracted to initialise the pose vector.

Definition at line 145 of file vpPoseVector.cpp.

References buildFrom().

Member Function Documentation

vpMatrix vpMatrix::AAt ( ) const
inherited

Computes the $AA^T$ operation $B = A*A^T$

Returns
$A*A^T$
See also
AAt(vpMatrix &) const

Definition at line 1368 of file vpMatrix.cpp.

void vpMatrix::AAt ( vpMatrix B) const
inherited

Compute the AAt operation such as $B = A*A^T$.

The result is placed in the parameter B and not returned.

A new matrix won't be allocated for every use of the function. This results in a speed gain if used many times with the same result matrix size.

See also
AAt()

Definition at line 1388 of file vpMatrix.cpp.

References vpMatrix::colNum, vpMatrix::resize(), vpMatrix::rowNum, vpMatrix::rowPtrs, vpCERROR, and vpERROR_TRACE.

void vpMatrix::add2Matrices ( const vpMatrix A,
const vpMatrix B,
vpMatrix C 
)
staticinherited

Operation C = A + B.

The result is placed in the third parameter C and not returned. A new matrix won't be allocated for every use of the function (Speed gain if used many times with the same result matrix size).

See also
operator+()

Definition at line 602 of file vpMatrix.cpp.

References vpMatrix::colNum, vpMatrix::getCols(), vpMatrix::getRows(), vpMatrixException::incorrectMatrixSizeError, vpMatrix::resize(), vpMatrix::rowNum, vpMatrix::rowPtrs, and vpERROR_TRACE.

Referenced by vpMatrix::operator+().

void vpMatrix::add2WeightedMatrices ( const vpMatrix A,
const double &  wA,
const vpMatrix B,
const double &  wB,
vpMatrix C 
)
staticinherited

Operation C = A*wA + B*wB

The result is placed in the third parameter C and not returned. A new matrix won't be allocated for every use of the function (Speed gain if used many times with the same result matrix size).

See also
operator+()

Definition at line 563 of file vpMatrix.cpp.

References vpMatrix::colNum, vpMatrix::getCols(), vpMatrix::getRows(), vpMatrixException::incorrectMatrixSizeError, vpMatrix::resize(), vpMatrix::rowNum, vpMatrix::rowPtrs, and vpERROR_TRACE.

void vpMatrix::AtA ( vpMatrix B) const
inherited

Compute the AtA operation such as $B = A^T*A$.

The result is placed in the parameter B and not returned.

A new matrix won't be allocated for every use of the function. This results in a speed gain if used many times with the same result matrix size.

See also
AtA()

Definition at line 1431 of file vpMatrix.cpp.

References vpMatrix::colNum, vpMatrix::data, vpMatrix::resize(), vpMatrix::rowNum, vpCERROR, and vpERROR_TRACE.

vpPoseVector vpPoseVector::buildFrom ( const vpHomogeneousMatrix M)

Build a 6 dimension pose vector $ [\bf t, \Theta \bf u]^\top$ from an homogeneous matrix $ \bf M $.

Parameters
M: Homogeneous matrix $ \bf M $ from which translation $ \bf t $ and $\Theta \bf u $ vectors are extracted to initialize the pose vector.
Returns
The build pose vector.
Examples:
servoMomentImage.cpp, and testPoseFeatures.cpp.

Definition at line 180 of file vpPoseVector.cpp.

References vpHomogeneousMatrix::extract().

Referenced by buildFrom(), vpPtu46::computeMGD(), vpBiclops::computeMGD(), vpBiclops::get_fMc(), vpMbTracker::savePose(), and vpPoseVector().

vpPoseVector vpPoseVector::buildFrom ( const vpTranslationVector tv,
const vpThetaUVector tu 
)

Build a 6 dimension pose vector $ [\bf t, \Theta \bf u]^\top$ from a translation vector $ \bf t $ and a $\Theta \bf u$ vector.

Parameters
tv: Translation vector $ \bf t $.
tu: $\Theta \bf u$ rotation vector.
Returns
The build pose vector.

Definition at line 200 of file vpPoseVector.cpp.

vpPoseVector vpPoseVector::buildFrom ( const vpTranslationVector tv,
const vpRotationMatrix R 
)

Build a 6 dimension pose vector $ [\bf t, \Theta \bf u]^\top$ from a translation vector $ \bf t $ and a rotation matrix $ \bf R $.

Parameters
tv: Translation vector $ \bf t $.
R: Rotation matrix $ \bf R $ from which $\Theta \bf u$ vector is extracted to initialise the pose vector.
Returns
The build pose vector.

Definition at line 225 of file vpPoseVector.cpp.

References buildFrom(), and vpThetaUVector::buildFrom().

vpColVector vpMatrix::column ( const unsigned int  j)
inherited
Deprecated:
This method is deprecated. You should use getCol().

Return the j-th columns of the matrix.

Warning
notice column(1) is the 0-th column.
Parameters
j: Index of the column to extract.

Definition at line 2362 of file vpMatrix.cpp.

References vpMatrix::getRows().

vpMatrix vpMatrix::computeCovarianceMatrix ( const vpMatrix A,
const vpColVector x,
const vpColVector b 
)
staticinherited

Compute the covariance matrix of the parameters x from a least squares minimisation defined as: Ax = b

Parameters
A: Matrix A from Ax = b.
x: Vector x from Ax = b corresponding to the parameters to estimate.
b: Vector b from Ax = b.

Definition at line 61 of file vpMatrix_covariance.cpp.

References vpException::divideByZeroError, vpMatrix::getCols(), vpMatrix::getRows(), vpMatrix::pseudoInverse(), and vpMatrix::t().

Referenced by vpMbTracker::computeCovarianceMatrix(), vpPose::poseVirtualVS(), and vpPose::poseVirtualVSrobust().

vpMatrix vpMatrix::computeCovarianceMatrix ( const vpMatrix A,
const vpColVector x,
const vpColVector b,
const vpMatrix W 
)
staticinherited

Compute the covariance matrix of the parameters x from a least squares minimisation defined as: WAx = Wb

Parameters
A: Matrix A from WAx = Wb.
x: Vector x from WAx = Wb corresponding to the parameters to estimate.
b: Vector b from WAx = Wb.
W: Diagonal weigths matrix from WAx = Wb.

Definition at line 89 of file vpMatrix_covariance.cpp.

References vpException::divideByZeroError, vpMatrix::getCols(), and vpMatrix::t().

double vpMatrix::cond ( )
inherited
Returns
The condition number, the ratio of the largest singular value of the matrix to the smallest.

Definition at line 4295 of file vpMatrix.cpp.

References vpMatrix::getCols(), and vpMatrix::svd().

std::ostream & vpMatrix::cppPrint ( std::ostream &  os,
const char *  matrixName = NULL,
bool  octet = false 
) const
inherited

Print to be used as part of a C++ code later.

Print under the following form: vpMatrix A(6,4); A[0][0] = 1.4; A[0][1] = 0.6; ...

Parameters
osthe stream to be printed in.
matrixNamename of the matrix, "A" by default, to be used for the line vpMatrix A(6,7) (see example).
octetif false, print using double, if true, print byte per byte each bytes of the double array.

Definition at line 3120 of file vpMatrix.cpp.

References vpMatrix::getRows().

void vpMatrix::createDiagonalMatrix ( const vpColVector A,
vpMatrix DA 
)
staticinherited

Create a diagonal matrix with the element of a vector $ DA_{ii} = A_i $.

Parameters
A: Vector which element will be put in the diagonal.
DA: Diagonal matrix DA[i][i] = A[i]
See also
diag()

Definition at line 2869 of file vpMatrix.cpp.

References vpMatrix::getRows(), vpMatrix::resize(), vpCERROR, and vpERROR_TRACE.

static vpColVector vpColVector::cross ( const vpColVector a,
const vpColVector b 
)
inlinestaticinherited
vpColVector vpColVector::crossProd ( const vpColVector a,
const vpColVector b 
)
staticinherited

Compute the cross product of two vectors C = a x b.

Parameters
a: vpColVector
b: vpColVector

Definition at line 747 of file vpColVector.cpp.

References vpMatrix::getRows(), vpMatrixException::incorrectMatrixSizeError, vpColVector::skew(), and vpERROR_TRACE.

Referenced by vpMbTracker::addPolygon(), vpPose::coplanar(), and vpImageSimulator::setCameraPosition().

std::ostream & vpMatrix::csvPrint ( std::ostream &  os) const
inherited

Print matrix in csv format.

Print as comma separated values so that this output can be imported into any program which has a csv data import option: 0.939846, 0.0300754, 0.340272 0.0300788, 0.984961, -0.170136 -0.340272, 0.170136, 0.924807

Definition at line 3087 of file vpMatrix.cpp.

References vpMatrix::getCols(), and vpMatrix::getRows().

double vpMatrix::det ( vpDetMethod  method = LU_DECOMPOSITION) const
inherited

Compute the determinant of a n-by-n matrix.

Parameters
method: Method used to compute the determinant. Default LU decomposition methos is faster than the method based on Gaussian elimination.
Returns
Determinant of the matrix.
#include <iostream>
#include <visp/vpMatrix.h>
int main()
{
vpMatrix A(3,3);
A[0][0] = 1/1.; A[0][1] = 1/2.; A[0][2] = 1/3.;
A[1][0] = 1/3.; A[1][1] = 1/4.; A[1][2] = 1/5.;
A[2][0] = 1/6.; A[2][1] = 1/7.; A[2][2] = 1/8.;
std::cout << "Initial matrix: \n" << A << std::endl;
// Compute the determinant
std:: cout << "Determinant by default method : " <<
A.det() << std::endl;
std:: cout << "Determinant by LU decomposition: " <<
A.det(vpMatrix::LU_DECOMPOSITION ) << std::endl;
}
Examples:
testMatrixInverse.cpp.

Definition at line 3765 of file vpMatrix.cpp.

References vpMatrix::LU_DECOMPOSITION.

Referenced by vpTemplateTrackerTriangle::init().

void vpMatrix::diag ( const vpColVector A)
inherited

Create a diagonal matrix with the element of a vector.

Parameters
A: Vector which element will be put in the diagonal.
See also
createDiagonalMatrix()
#include <iostream>
#include <visp/vpColVector.h>
#include <visp/vpMatrix.h>
int main()
{
v[0] = 1;
v[1] = 2;
v[2] = 3;
A.diag(v);
std::cout << "A:\n" << A << std::endl;
// A is now equal to:
// 1 0 0
// 0 2 0
// 0 0 3
}

Definition at line 2841 of file vpMatrix.cpp.

References vpMatrix::getRows(), vpMatrix::resize(), vpCERROR, and vpERROR_TRACE.

Referenced by vpMbEdgeKltTracker::computeVVS(), vpMbKltTracker::computeVVS(), and vpMbEdgeTracker::computeVVS().

double dotProd ( const vpColVector a,
const vpColVector b 
)
staticinherited
vpColVector vpMatrix::eigenValues ( )
inherited

Compute the eigenvalues of a n-by-n real symmetric matrix.

Returns
The eigenvalues of a n-by-n real symmetric matrix.
Warning
This method is only available if the Gnu Scientific Library (GSL) is detected as a third party library.
Exceptions
vpMatrixException::matrixErrorIf the matrix is not square or if the matrix is not symmetric.
vpMatrixException::notImplementedErrorIf the GSL library is not detected

Here an example:

#include <iostream>
#include <visp/vpColVector.h>
#include <visp/vpMatrix.h>
int main()
{
vpMatrix A(3,3); // A is a symmetric matrix
A[0][0] = 1/1.; A[0][1] = 1/2.; A[0][2] = 1/3.;
A[1][0] = 1/2.; A[1][1] = 1/3.; A[1][2] = 1/4.;
A[2][0] = 1/3.; A[2][1] = 1/4.; A[2][2] = 1/5.;
std::cout << "Initial symmetric matrix: \n" << A << std::endl;
// Compute the eigen values
vpColVector evalue; // Eigenvalues
evalue = A.eigenValues();
std::cout << "Eigen values: \n" << evalue << std::endl;
}
See also
eigenValues(vpColVector &, vpMatrix &)

Definition at line 3348 of file vpMatrix.cpp.

References vpMatrix::colNum, vpMatrixException::matrixError, vpMatrixException::notImplementedError, vpMatrix::rowNum, vpMatrix::t(), and vpERROR_TRACE.

void vpMatrix::eigenValues ( vpColVector evalue,
vpMatrix evector 
)
inherited

Compute the eigenvalues of a n-by-n real symmetric matrix.

Returns
The eigenvalues of a n-by-n real symmetric matrix.
Warning
This method is only available if the Gnu Scientific Library (GSL) is detected as a third party library.
Parameters
evalue: Eigenvalues of the matrix.
evector: Eigenvector of the matrix.
Exceptions
vpMatrixException::matrixErrorIf the matrix is not square or if the matrix is not symmetric.
vpMatrixException::notImplementedErrorIf the GSL library is not detected

Here an example:

#include <iostream>
#include <visp/vpColVector.h>
#include <visp/vpMatrix.h>
int main()
{
vpMatrix A(4,4); // A is a symmetric matrix
A[0][0] = 1/1.; A[0][1] = 1/2.; A[0][2] = 1/3.; A[0][3] = 1/4.;
A[1][0] = 1/2.; A[1][1] = 1/3.; A[1][2] = 1/4.; A[1][3] = 1/5.;
A[2][0] = 1/3.; A[2][1] = 1/4.; A[2][2] = 1/5.; A[2][3] = 1/6.;
A[3][0] = 1/4.; A[3][1] = 1/5.; A[3][2] = 1/6.; A[3][3] = 1/7.;
std::cout << "Initial symmetric matrix: \n" << A << std::endl;
vpColVector d; // Eigenvalues
vpMatrix V; // Eigenvectors
// Compute the eigenvalues and eigenvectors
A.eigenValues(d, V);
std::cout << "Eigen values: \n" << d << std::endl;
std::cout << "Eigen vectors: \n" << V << std::endl;
D.diag(d); // Eigenvalues are on the diagonal
std::cout << "D: " << D << std::endl;
// Verification: A * V = V * D
std::cout << "AV-VD = 0 ? \n" << (A*V) - (V*D) << std::endl;
}
See also
eigenValues()

Definition at line 3467 of file vpMatrix.cpp.

References vpMatrix::colNum, vpMatrix::data, vpMatrixException::matrixError, vpMatrixException::notImplementedError, vpColVector::resize(), vpMatrix::resize(), vpMatrix::rowNum, vpMatrix::t(), and vpERROR_TRACE.

double vpMatrix::euclideanNorm ( ) const
inherited

Compute and return the Euclidean norm $ ||x|| = \sqrt{ \sum{x_{ij}^2}} $.

Returns
The Euclidean norm if the matrix is initialized, 0 otherwise.
See also
infinityNorm()

Definition at line 3168 of file vpMatrix.cpp.

References vpMatrix::data, and vpMatrix::dsize.

Referenced by vpSimulatorAfma6::setPosition().

vpMatrix vpMatrix::expm ( )
inherited

Compute the exponential matrix of a square matrix.

Returns
Return the exponential matrix.

Definition at line 4137 of file vpMatrix.cpp.

References vpMatrix::colNum, vpMatrix::data, vpMatrixException::incorrectMatrixSizeError, vpMatrix::inverseByLU(), vpMatrix::rowNum, vpMatrix::setIdentity(), vpMatrix::sum(), and vpTRACE.

Referenced by vpTemplateTrackerWarpHomographySL3::computeCoeff().

void vpMatrix::eye ( unsigned int  n)
inherited

Set an n-by-n matrix to identity.

eye(n) is an n-by-n matrix with ones on the diagonal and zeros else where.

Examples:
testMatrix.cpp.

Definition at line 1252 of file vpMatrix.cpp.

References vpCERROR, and vpERROR_TRACE.

Referenced by vpMbEdgeTracker::computeVVS(), and vpServo::setServo().

void vpMatrix::eye ( unsigned int  m,
unsigned int  n 
)
inherited

Set an m-by-n matrix to identity.

eye(m,n) is an m-by-n matrix with ones on the diagonal and zeros else where.

Definition at line 1272 of file vpMatrix.cpp.

References vpMatrix::colNum, vpMatrix::resize(), vpMatrix::rowNum, vpCERROR, and vpERROR_TRACE.

vpColVector vpMatrix::getCol ( const unsigned int  j) const
inherited

Extract a column vector from a matrix.

Warning
All the indexes start from 0 in this function.
Parameters
j: Index of the column to extract. If j=0, the first column is extracted.
Returns
The extracted column vector.

The following example shows how to use this function:

#include <visp/vpColVector.h>
#include <visp/vpMatrix.h>
int main()
{
vpMatrix A(4,4);
for(unsigned int i=0; i < A.getRows(); i++)
for(unsigned int j=0; j < A.getCols(); j++)
A[i][j] = i*A.getCols()+j;
A.print(std::cout, 4);
vpColVector cv = A.getCol(1);
std::cout << "Column vector: \n" << cv << std::endl;
}

It produces the following output:

[4,4]=
0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
column vector:
1
5
9
13

Definition at line 2463 of file vpMatrix.cpp.

References vpException::dimensionError, vpMatrix::getCols(), and vpMatrix::getRows().

Referenced by vpHomography::DLT(), vpPose::poseDementhonPlan(), and vpPose::poseFromRectangle().

vpColVector vpMatrix::getCol ( const unsigned int  j,
const unsigned int  i_begin,
const unsigned int  column_size 
) const
inherited

Extract a column vector from a matrix.

Warning
All the indexes start from 0 in this function.
Parameters
j: Index of the column to extract. If col=0, the first column is extracted.
i_begin: Index of the row that gives the location of the first element of the column vector to extract.
column_size: Size of the column vector to extract.
Returns
The extracted column vector.

The following example shows how to use this function:

#include <visp/vpColVector.h>
#include <visp/vpMatrix.h>
int main()
{
vpMatrix A(4,4);
for(unsigned int i=0; i < A.getRows(); i++)
for(unsigned int j=0; j < A.getCols(); j++)
A[i][j] = i*A.getCols()+j;
A.print(std::cout, 4);
vpColVector cv = A.getCol(1, 1, 3);
std::cout << "Column vector: \n" << cv << std::endl;
}

It produces the following output:

[4,4]=
0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
column vector:
5
9
13

Definition at line 2413 of file vpMatrix.cpp.

References vpException::dimensionError, vpMatrix::getCols(), and vpMatrix::getRows().

unsigned int vpMatrix::getCols ( ) const
inlineinherited

Return the number of columns of the matrix.

Examples:
servoViper850Point2DArtVelocity-jointAvoidance-basic.cpp, testMatrixInverse.cpp, and testSvd.cpp.

Definition at line 163 of file vpMatrix.h.

Referenced by vpMatrix::add2Matrices(), vpMatrix::add2WeightedMatrices(), vpSubRowVector::checkParentStatus(), vpSubMatrix::checkParentStatus(), vpServo::computeControlLaw(), vpMatrix::computeCovarianceMatrix(), vpMatrix::computeHLM(), vpServo::computeInteractionMatrix(), vpMbTracker::computeJTR(), vpMatrix::cond(), vpMatrix::csvPrint(), vpMatrix::getCol(), vpImageSimulator::getImage(), vpMatrix::getRow(), vpSubRowVector::init(), vpSubMatrix::init(), vpMatrix::init(), vpCameraParameters::initFromCalibrationMatrix(), vpMatrix::insert(), vpMatrix::inverseByCholeskyLapack(), vpMatrix::inverseByQRLapack(), vpMatrix::juxtaposeMatrices(), vpMatrix::kernel(), vpMatrix::kron(), vpMatrix::maplePrint(), vpRowVector::operator*(), vpRotationMatrix::operator*(), vpVelocityTwistMatrix::operator*(), vpForceTwistMatrix::operator*(), vpMatrix::operator*(), vpRowVector::operator+(), vpMatrix::operator+=(), vpRowVector::operator-(), vpMatrix::operator-=(), vpSubRowVector::operator=(), vpSubColVector::operator=(), vpSubMatrix::operator=(), vpRowVector::operator=(), vpColVector::operator=(), vpRotationMatrix::operator=(), vpHomography::operator=(), vpPose::poseDementhonPlan(), vpMatrix::print(), vpMatrix::pseudoInverse(), vpIoTools::readConfigVar(), vpRowVector::reshape(), vpColVector::reshape(), vpMatrix::row(), vpMatrix::saveMatrix(), vpMatrix::saveMatrixYAML(), vpServo::secondaryTask(), vpRowVector::size(), vpMatrix::stackMatrices(), vpMatrix::sub2Matrices(), and vpMatrix::svd().

double vpMatrix::getMaxValue ( ) const
inherited
Examples:
servoMomentImage.cpp.

Definition at line 4238 of file vpMatrix.cpp.

References vpMatrix::data, and vpMatrix::dsize.

double vpMatrix::getMinValue ( ) const
inherited
Examples:
servoMomentImage.cpp.

Definition at line 4224 of file vpMatrix.cpp.

References vpMatrix::data, and vpMatrix::dsize.

vpRowVector vpMatrix::getRow ( const unsigned int  i) const
inherited

Extract a row vector from a matrix.

Warning
All the indexes start from 0 in this function.
Parameters
i: Index of the row to extract. If i=0, the first row is extracted.
Returns
The extracted row vector.

The following example shows how to use this function:

#include <visp/vpMatrix.h>
#include <visp/vpRowVector.h>
int main()
{
vpMatrix A(4,4);
for(unsigned int i=0; i < A.getRows(); i++)
for(unsigned int j=0; j < A.getCols(); j++)
A[i][j] = i*A.getCols()+j;
A.print(std::cout, 4);
vpRowVector rv = A.getRow(1);
std::cout << "Row vector: \n" << rv << std::endl;
}

It produces the following output:

[4,4]=
0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
Row vector:
4 5 6 7

Definition at line 2510 of file vpMatrix.cpp.

References vpException::dimensionError, vpMatrix::getCols(), and vpMatrix::getRows().

Referenced by vpMatrix::kernel(), and vpMatrix::pseudoInverse().

vpRowVector vpMatrix::getRow ( const unsigned int  i,
const unsigned int  j_begin,
const unsigned int  row_size 
) const
inherited

Extract a row vector from a matrix.

Warning
All the indexes start from 0 in this function.
Parameters
i: Index of the row to extract. If i=0, the first row is extracted.
j_begin: Index of the column that gives the location of the first element of the row vector to extract.
row_size: Size of the row vector to extract.
Returns
The extracted row vector.

The following example shows how to use this function:

#include <visp/vpMatrix.h>
#include <visp/vpRowVector.h>
int main()
{
vpMatrix A(4,4);
for(unsigned int i=0; i < A.getRows(); i++)
for(unsigned int j=0; j < A.getCols(); j++)
A[i][j] = i*A.getCols()+j;
A.print(std::cout, 4);
vpRowVector rv = A.getRow(1, 1, 3);
std::cout << "Row vector: \n" << rv << std::endl;
}

It produces the following output:

[4,4]=
0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
Row vector:
5 6 7

Definition at line 2559 of file vpMatrix.cpp.

References vpException::dimensionError, vpMatrix::getCols(), and vpMatrix::getRows().

unsigned int vpMatrix::getRows ( ) const
inlineinherited

Return the number of rows of the matrix.

Examples:
testMatrixInverse.cpp, and testSvd.cpp.

Definition at line 161 of file vpMatrix.h.

Referenced by vpMatrix::add2Matrices(), vpMatrix::add2WeightedMatrices(), vpLine::changeFrame(), vpSubColVector::checkParentStatus(), vpSubMatrix::checkParentStatus(), vpMatrix::column(), vpServo::computeControlLaw(), vpMatrix::computeCovarianceMatrix(), vpMbTracker::computeCovarianceMatrix(), vpServo::computeError(), vpMatrix::computeHLM(), vpServo::computeInteractionMatrix(), vpMbTracker::computeJTR(), vpPtu46::computeMGD(), vpPose::computeResidual(), vpMbEdgeKltTracker::computeVVS(), vpMbKltTracker::computeVVS(), vpMbEdgeTracker::computeVVS(), vpMatrix::cppPrint(), vpMatrix::createDiagonalMatrix(), vpColVector::crossProd(), vpMatrix::csvPrint(), vpDot2::defineDots(), vpMatrix::diag(), vpProjectionDisplay::display(), vpColVector::dotProd(), vpGenericFeature::error(), vpImageFilter::filter(), vpPtu46::get_eJe(), vpBiclops::get_eJe(), vpPtu46::get_fJe(), vpBiclops::get_fJe(), vpBiclops::get_fMe(), vpGenericFeature::get_s(), vpMatrix::getCol(), vpBasicFeature::getDimension(), vpImageSimulator::getImage(), vpAfma6::getInverseKinematics(), vpViper::getInverseKinematicsWrist(), vpMatrix::getRow(), vpSubColVector::init(), vpSubMatrix::init(), vpMatrix::init(), vpCameraParameters::initFromCalibrationMatrix(), vpMatrix::insert(), vpFeatureLuminance::interaction(), vpGenericFeature::interaction(), vpMatrix::inverseByCholeskyLapack(), vpMatrix::inverseByLU(), vpMatrix::inverseByQRLapack(), vpColVector::invSort(), vpMatrix::juxtaposeMatrices(), vpMatrix::kernel(), vpScale::KernelDensity(), vpScale::KernelDensityGradient(), vpMatrix::kron(), vpMatrix::maplePrint(), vpMatrix::matlabPrint(), vpColVector::mean(), vpScale::MeanShift(), vpColVector::median(), vpRobust::MEstimator(), vpMatrix::multMatrixVector(), vpRowVector::operator*(), vpRotationMatrix::operator*(), vpVelocityTwistMatrix::operator*(), vpForceTwistMatrix::operator*(), vpMatrix::operator*(), vpColVector::operator+(), vpMatrix::operator+=(), vpColVector::operator-(), vpMatrix::operator-=(), vpSubColVector::operator=(), vpSubRowVector::operator=(), vpSubMatrix::operator=(), vpColVector::operator=(), vpRotationMatrix::operator=(), vpRGBa::operator=(), vpHomography::operator=(), vpPlot::plot(), vpPose::poseDementhonPlan(), vpPose::poseVirtualVSrobust(), vpKalmanFilter::prediction(), vpMatrix::print(), vpLine::projection(), vpMatrix::pseudoInverse(), vpIoTools::readConfigVar(), vpRowVector::reshape(), vpColVector::reshape(), vpMatrix::saveMatrix(), vpMatrix::saveMatrixYAML(), vpGenericFeature::set_s(), vpGenericFeature::setError(), vpMbTracker::setEstimatedDoF(), vpGenericFeature::setInteractionMatrix(), vpSimulatorAfma6::setJointLimit(), vpSimulatorViper850::setJointLimit(), vpRobotBiclopsController::setPosition(), vpRobotAfma4::setPosition(), vpRobotBiclopsController::setVelocity(), vpRobotPtu46::setVelocity(), vpRobotBiclops::setVelocity(), vpSimulatorAfma6::setVelocity(), vpSimulatorViper850::setVelocity(), vpRobotAfma4::setVelocity(), vpLine::setWorldCoordinates(), vpRobust::simultMEstimator(), vpColVector::size(), vpColVector::skew(), vpColVector::sort(), vpColVector::stack(), vpMatrix::stackMatrices(), vpMatrix::sub2Matrices(), vpMatrix::svd(), and vpColVector::vpColVector().

double vpMatrix::infinityNorm ( ) const
inherited

Compute and return the infinity norm $ {||x||}_{\infty} = max\left(\sum_{j=0}^{n}{\mid x_{ij} \mid}\right) $ with $i \in \{0, ..., m\}$ where $(m,n)$ is the matrix size.

Returns
The infinity norm if the matrix is initialized, 0 otherwise.
See also
euclideanNorm()

Definition at line 3192 of file vpMatrix.cpp.

References vpMatrix::colNum, vpMatrix::rowNum, and vpMatrix::rowPtrs.

void vpMatrix::init ( const vpMatrix M,
unsigned int  r,
unsigned int  c,
unsigned int  nrows,
unsigned int  ncols 
)
inherited

Initialize the matrix from a part of an input matrix M.

Parameters
M: Input matrix used for initialization.
r: row index in matrix M.
c: column index in matrix M.
nrows: Number of rows of the matrix that should be initialized.
ncols: Number of columns of the matrix that should be initialized.

The sub-matrix starting from M[r][c] element and ending on M[r+nrows-1][c+ncols-1] element is used to initialize the matrix.

The following code shows how to use this function:

#include <visp/vpMatrix.h>
int main()
{
vpMatrix M(4,5);
int val = 0;
for(size_t i=0; i<M.getRows(); i++) {
for(size_t j=0; j<M.getCols(); j++) {
M[i][j] = val++;
}
}
M.print (std::cout, 4, "M ");
N.init(M, 0, 1, 2, 3);
N.print (std::cout, 4, "N ");
}

It produces the following output:

M [4,5]=
0 1 2 3 4
5 6 7 8 9
10 11 12 13 14
15 16 17 18 19
N [2,3]=
1 2 3
6 7 8

Definition at line 331 of file vpMatrix.cpp.

References vpException::dimensionError, vpMatrix::getCols(), vpMatrix::getRows(), vpMatrix::resize(), and vpMatrix::rowPtrs.

void vpColVector::insert ( unsigned int  i,
const vpColVector v 
)
inherited

Insert a column vector.

Parameters
i: Index of the first element to introduce. This index starts from 0.
v: Column vector to insert.

The following example shows how to use this function:

#include <visp/vpColVector.h>
int main()
{
for (unsigned int i=0; i < v.size(); i++)
v[i] = i;
std::cout << "v:\n" << v << std::endl;
for (unsigned int i=0; i < w.size(); i++)
w[i] = i+10;
std::cout << "w:\n" << w << std::endl;
v.insert(1, w);
std::cout << "v:\n" << v << std::endl;
}

It produces the following output:

v:
0
1
2
3
w:
10
11
v:
0
10
11
3

Definition at line 857 of file vpColVector.cpp.

References vpException::dimensionError, and vpColVector::size().

void vpMatrix::insert ( const vpMatrix A,
const unsigned int  r,
const unsigned int  c 
)
inherited

Insert matrix A at the given position in the current matrix.

Warning
Throw vpMatrixException::incorrectMatrixSizeError if the dimensions of the matrices do not allow the operation.
Parameters
A: The matrix to insert.
r: The index of the row to begin to insert data.
c: The index of the column to begin to insert data.

Definition at line 3291 of file vpMatrix.cpp.

References vpMatrix::colNum, vpMatrix::getCols(), vpMatrix::getRows(), vpMatrixException::incorrectMatrixSizeError, and vpMatrix::rowNum.

Referenced by vpNurbs::curveKnotIns(), vpMatrix::insert(), vpPioneerPan::set_mMp(), and vpPioneerPan::set_pMe().

vpMatrix vpMatrix::insert ( const vpMatrix A,
const vpMatrix B,
const unsigned int  r,
const unsigned int  c 
)
staticinherited

Insert matrix B in matrix A at the given position.

Parameters
A: Main matrix.
B: Matrix to insert.
r: Index of the row where to add the matrix.
c: Index of the column where to add the matrix.
Returns
Matrix with B insert in A.
Warning
Throw exception if the sizes of the matrices do not allow the insertion.

Definition at line 2666 of file vpMatrix.cpp.

References vpMatrix::insert(), and vpCERROR.

void insert ( const vpMatrix A,
const vpMatrix B,
vpMatrix C,
const unsigned int  r,
const unsigned int  c 
)
staticinherited

Insert matrix B in matrix A at the given position.

Parameters
A: Main matrix.
B: Matrix to insert.
C: Result matrix.
r: Index of the row where to insert matrix B.
c: Index of the column where to insert matrix B.
Warning
Throw exception if the sizes of the matrices do not allow the insertion.

Definition at line 2697 of file vpMatrix.cpp.

References vpMatrix::getCols(), vpMatrix::getRows(), vpMatrixException::incorrectMatrixSizeError, vpMatrix::resize(), vpCERROR, and vpERROR_TRACE.

vpMatrix vpMatrix::inverseByCholesky ( ) const
inherited

Compute the inverse of a n-by-n matrix using the Cholesky decomposition. The matrix must be real and symmetric. Only available if lapack is installed.

Returns
The inverse matrix.

Here an example:

#include <visp/vpMatrix.h>
int main()
{
vpMatrix A(4,4);
// Symmetric matrix
A[0][0] = 1/1.; A[0][1] = 1/5.; A[0][2] = 1/6.; A[0][3] = 1/7.;
A[1][0] = 1/5.; A[1][1] = 1/3.; A[1][2] = 1/3.; A[1][3] = 1/5.;
A[2][0] = 1/6.; A[2][1] = 1/3.; A[2][2] = 1/2.; A[2][3] = 1/6.;
A[3][0] = 1/7.; A[3][1] = 1/5.; A[3][2] = 1/6.; A[3][3] = 1/7.;
// Compute the inverse
vpMatrix A_1; // A^-1
A_1 = A.inverseByCholesky();
std::cout << "Inverse by Cholesky: \n" << A_1 << std::endl;
std::cout << "A*A^-1: \n" << A * A_1 << std::endl;
}
See also
pseudoInverse()

Definition at line 122 of file vpMatrix_cholesky.cpp.

References vpMatrix::colNum, vpMatrix::inverseByCholeskyLapack(), vpMatrixException::matrixError, vpMatrix::rowNum, and vpERROR_TRACE.

vpMatrix vpMatrix::inverseByCholeskyLapack ( ) const
inherited
vpMatrix vpMatrix::inverseByLU ( ) const
inherited

Compute the inverse of a n-by-n matrix using the LU decomposition.

Returns
The inverse matrix.

Here an example:

#include <visp/vpMatrix.h>
int main()
{
vpMatrix A(4,4);
A[0][0] = 1/1.; A[0][1] = 1/2.; A[0][2] = 1/3.; A[0][3] = 1/4.;
A[1][0] = 1/5.; A[1][1] = 1/3.; A[1][2] = 1/3.; A[1][3] = 1/5.;
A[2][0] = 1/6.; A[2][1] = 1/4.; A[2][2] = 1/2.; A[2][3] = 1/6.;
A[3][0] = 1/7.; A[3][1] = 1/5.; A[3][2] = 1/6.; A[3][3] = 1/7.;
// Compute the inverse
vpMatrix A_1; // A^-1
A_1 = A.inverseByLU();
std::cout << "Inverse by LU: \n" << A_1 << std::endl;
std::cout << "A*A^-1: \n" << A * A_1 << std::endl;
}
See also
pseudoInverse()
Examples:
photometricVisualServoing.cpp.

Definition at line 236 of file vpMatrix_lu.cpp.

References vpMatrix::colNum, vpMatrix::getRows(), vpMatrixException::matrixError, vpMatrix::rowNum, and vpERROR_TRACE.

Referenced by vpMatrix::expm(), vpKalmanFilter::filtering(), vpTemplateTrackerWarpHomographySL3::findWarp(), vpTemplateTrackerWarpAffine::getParamInverse(), vpTemplateTrackerTriangle::init(), vpTemplateTrackerSSDInverseCompositional::initCompInverse(), vpTemplateTrackerZNCCForwardAdditional::initHessienDesired(), vpTemplateTrackerZNCCInverseCompositional::initHessienDesired(), vpTemplateTracker::setHDes(), vpTemplateTrackerSSDForwardCompositional::trackNoPyr(), and vpTemplateTrackerSSDForwardAdditional::trackNoPyr().

vpMatrix vpMatrix::inverseByQR ( ) const
inherited

Compute the inverse of a n-by-n matrix using the QR decomposition. Only available if lapack is installed.

Returns
The inverse matrix.

Here an example:

#include <visp/vpMatrix.h>
int main()
{
vpMatrix A(4,4);
A[0][0] = 1/1.; A[0][1] = 1/2.; A[0][2] = 1/3.; A[0][3] = 1/4.;
A[1][0] = 1/5.; A[1][1] = 1/3.; A[1][2] = 1/3.; A[1][3] = 1/5.;
A[2][0] = 1/6.; A[2][1] = 1/4.; A[2][2] = 1/2.; A[2][3] = 1/6.;
A[3][0] = 1/7.; A[3][1] = 1/5.; A[3][2] = 1/6.; A[3][3] = 1/7.;
// Compute the inverse
vpMatrix A_1; // A^-1
A_1 = A.inverseByQR();
std::cout << "Inverse by QR: \n" << A_1 << std::endl;
std::cout << "A*A^-1: \n" << A * A_1 << std::endl;
}
See also
pseudoInverse()

Definition at line 228 of file vpMatrix_qr.cpp.

References vpMatrix::colNum, vpMatrix::inverseByQRLapack(), vpMatrixException::matrixError, vpMatrix::rowNum, and vpERROR_TRACE.

vpMatrix vpMatrix::inverseByQRLapack ( ) const
inherited
vpColVector vpColVector::invSort ( const vpColVector v)
staticinherited

reverse sorting of the elements of vector v

Definition at line 446 of file vpColVector.cpp.

References vpMatrix::data, vpMatrix::getRows(), vpMatrixException::notInitializedError, and vpERROR_TRACE.

vpMatrix vpMatrix::juxtaposeMatrices ( const vpMatrix A,
const vpMatrix B 
)
staticinherited

Juxtapose to matrices C = [ A B ].

$ C = \left( \begin{array}{cc} A & B \end{array}\right) $

Parameters
A: Left matrix.
B: Right matrix.
Returns
Juxtaposed matrix C = [ A B ]
Warning
A and B must have the same number of column

Definition at line 2740 of file vpMatrix.cpp.

References vpCERROR.

void juxtaposeMatrices ( const vpMatrix A,
const vpMatrix B,
vpMatrix C 
)
staticinherited

Juxtapose to matrices C = [ A B ].

$ C = \left( \begin{array}{cc} A & B \end{array}\right) $

Parameters
A: Left matrix.
B: Right matrix.
C: Juxtaposed matrix C = [ A B ]
Warning
A and B must have the same number of column

Definition at line 2769 of file vpMatrix.cpp.

References vpMatrix::getCols(), vpMatrix::getRows(), vpMatrixException::incorrectMatrixSizeError, vpMatrix::resize(), vpCERROR, and vpERROR_TRACE.

unsigned int vpMatrix::kernel ( vpMatrix kerA,
double  svThreshold = 1e-6 
)
inherited

Function to compute the null space (the kernel) of the interaction matrix A which is not full rank. The null space ( the kernel ) of a matrix A is defined as Null(A) = Ker(M) ={KerA : A*KerA =0}.

Parameters
kerA: The matrix to contain the null space (kernel) of A (A*KerA.t()=0)
svThreshold: Specify the used threshold in the svd(...) function (a function to compute the singular value decomposition)
Returns
the rank of the matrix.
Examples:
servoViper850Point2DArtVelocity-jointAvoidance-basic.cpp.

Definition at line 3569 of file vpMatrix.cpp.

References vpMatrix::getCols(), vpMatrix::getRow(), vpMatrix::getRows(), vpMatrix::resize(), vpMatrix::sumSquare(), and vpMatrix::svd().

void vpMatrix::kill ( )
inherited

Destruction of the matrix (Memory de-allocation)

Definition at line 355 of file vpMatrix.cpp.

References vpMatrix::data, and vpMatrix::rowPtrs.

Referenced by vpMatrix::~vpMatrix().

void vpMatrix::kron ( const vpMatrix m1,
const vpMatrix m2,
vpMatrix out 
)
staticinherited

Compute Kronecker product matrix.

Parameters
m1: vpMatrix;
m2: vpMatrix;
out: The kronecker product : $ m1 \otimes m2 $

Definition at line 1563 of file vpMatrix.cpp.

References vpMatrix::colNum, vpMatrix::getCols(), vpMatrix::getRows(), vpMatrixException::incorrectMatrixSizeError, vpMatrix::rowNum, and vpERROR_TRACE.

Referenced by vpMatrix::kron().

vpMatrix vpMatrix::kron ( const vpMatrix m1,
const vpMatrix m2 
)
staticinherited

Compute Kronecker product matrix.

Parameters
m1: vpMatrix;
m2: vpMatrix;
Returns
The kronecker product : $ m1 \otimes m2 $

Definition at line 1607 of file vpMatrix.cpp.

References vpMatrix::getCols(), and vpMatrix::getRows().

void vpMatrix::kron ( const vpMatrix m,
vpMatrix out 
)
inherited

Compute Kronecker product matrix.

Parameters
m: vpMatrix.
out: If m1.kron(m2) out contains the kronecker product's result : $ m1 \otimes m2 $.

Definition at line 1597 of file vpMatrix.cpp.

References vpMatrix::kron().

vpMatrix vpMatrix::kron ( const vpMatrix m)
inherited

Compute Kronecker product matrix.

Parameters
m: vpMatrix;
Returns
m1.kron(m2) The kronecker product : $ m1 \otimes m2 $

Definition at line 1638 of file vpMatrix.cpp.

References vpMatrix::kron().

void vpPoseVector::load ( std::ifstream &  f)

Read a pose vector from an input file stream.

Parameters
f: The input file stream..Should be open before entering in this method.
Exceptions
vpException::ioError: If the input file stream is not open.
See also
save()

Definition at line 302 of file vpPoseVector.cpp.

References vpException::ioError, and vpERROR_TRACE.

static bool vpMatrix::loadMatrix ( std::string  filename,
vpMatrix M,
const bool  binary = false,
char *  Header = NULL 
)
inlinestaticinherited

Load a matrix from a file.

Parameters
filename: absolute file name
M: matrix to be loaded
binary:If true the matrix is loaded from a binary file, else from a text file.
Header: Header of the file is loaded in this parameter
Returns
Returns true if no problem appends.

Definition at line 264 of file vpMatrix.h.

Referenced by vpDot2::defineDots().

bool vpMatrix::loadMatrix ( const char *  filename,
vpMatrix M,
const bool  binary = false,
char *  header = NULL 
)
staticinherited

Load a matrix from a file.

Parameters
filename: Absolute file name.
M: Matrix to be loaded.
binary: If true the matrix is loaded from a binary file, else from a text file.
header: header of the file loaded in this parameter.
Returns
Returns true if no problem happened.

Definition at line 3963 of file vpMatrix.cpp.

References vpException::badValue, and vpMatrix::resize().

static bool vpMatrix::loadMatrixYAML ( std::string  filename,
vpMatrix M,
char *  header = NULL 
)
inlinestaticinherited

Load a matrix from a YAML-formatted file.

Parameters
filename: absolute file name.
M: matrix to be loaded from the file.
header: Header of the file is loaded in this parameter.
Returns
Returns true if no problem appends.

Definition at line 317 of file vpMatrix.h.

bool vpMatrix::loadMatrixYAML ( const char *  filename,
vpMatrix M,
char *  header = NULL 
)
staticinherited

Load a matrix from a YAML-formatted file.

Parameters
filename: absolute file name.
M: matrix to be loaded from the file.
header: header of the file is loaded in this parameter.
Returns
Returns true on success.
See also
saveMatrixYAML()

Definition at line 4060 of file vpMatrix.cpp.

References vpMatrix::resize().

std::ostream & vpMatrix::maplePrint ( std::ostream &  os) const
inherited

Print using MAPLE matrix input format.

Print using the following way so that this output can be directly copied into MAPLE: ([ [0.939846, 0.0300754, 0.340272, ], [0.0300788, 0.984961, -0.170136, ], [-0.340272, 0.170136, 0.924807, ], ])

Definition at line 3061 of file vpMatrix.cpp.

References vpMatrix::getCols(), and vpMatrix::getRows().

std::ostream & vpMatrix::matlabPrint ( std::ostream &  os) const
inherited

Print using matlab syntax, to be put in matlab later.

Print using the following form: [ a,b,c; d,e,f; g,h,i]

Definition at line 3032 of file vpMatrix.cpp.

References vpMatrix::getRows().

double vpColVector::mean ( const vpColVector v)
staticinherited

compute the mean

Compute the mean value of all the element of the vector.

Definition at line 626 of file vpColVector.cpp.

References vpMatrix::data, vpMatrix::getRows(), vpMatrixException::notInitializedError, and vpERROR_TRACE.

double vpColVector::median ( const vpColVector v)
staticinherited

compute the median

Compute the median value of all the element of the vector

Definition at line 653 of file vpColVector.cpp.

References vpMatrix::data, vpMatrix::getRows(), vpMatrixException::notInitializedError, and vpERROR_TRACE.

void vpMatrix::mult2Matrices ( const vpMatrix A,
const vpMatrix B,
vpMatrix C 
)
staticinherited

Operation C = A * B.

The result is placed in the third parameter C and not returned. A new matrix won't be allocated for every use of the function (Speed gain if used many times with the same result matrix size).

See also
operator*()

Definition at line 480 of file vpMatrix.cpp.

References vpMatrix::colNum, vpMatrixException::incorrectMatrixSizeError, vpMatrix::resize(), vpMatrix::rowNum, vpMatrix::rowPtrs, and vpERROR_TRACE.

Referenced by vpMatrix::operator*().

void vpMatrix::multMatrixVector ( const vpMatrix A,
const vpColVector b,
vpColVector c 
)
staticinherited

Operation c = A * b (c and b are vectors).

The result is placed in the second parameter C and not returned. A new matrix won't be allocated for every use of the function (Speed gain if used many times with the same result matrix size).

See also
operator*(const vpColVector &b) const

Definition at line 931 of file vpMatrix.cpp.

References vpMatrix::colNum, vpMatrix::getRows(), vpMatrixException::incorrectMatrixSizeError, vpColVector::resize(), vpMatrix::rowNum, vpMatrix::rowPtrs, and vpERROR_TRACE.

Referenced by vpRotationMatrix::operator*(), and vpMatrix::operator*().

void vpMatrix::negateMatrix ( const vpMatrix A,
vpMatrix C 
)
staticinherited

Operation C = -A.

The result is placed in the second parameter C and not returned. A new matrix won't be allocated for every use of the function (Speed gain if used many times with the same result matrix size).

See also
operator-(void)

Definition at line 818 of file vpMatrix.cpp.

References vpMatrix::colNum, vpMatrix::resize(), vpMatrix::rowNum, vpMatrix::rowPtrs, and vpERROR_TRACE.

Referenced by vpMatrix::operator-().

vpColVector & normalize ( )
inherited

Normalise the vector.

normalise the vector

\[ {\bf x}_i = \frac{{\bf x}_i}{\sqrt{\sum_{i=1}^{n}x^2_i}} \]

normalise the vector

\[ {\bf x}_i = \frac{{\bf x}_i}{\sqrt{\sum_{i=1}^{n}x^2_i}} \]

Definition at line 430 of file vpColVector.cpp.

References vpMatrix::sumSquare().

Referenced by vpCameraParameters::computeFov(), vpMbtDistanceKltPoints::init(), vpMbtPolygon::isVisible(), vpPose::poseDementhonNonPlan(), and vpMbKltTracker::setPose().

double vpColVector::operator* ( const vpColVector x) const
inherited

Dot product.

operator dot product

Definition at line 81 of file vpColVector.cpp.

References vpMatrix::rowNum.

vpMatrix vpColVector::operator* ( const vpRowVector x) const
inherited

Dot product.

operator dot product

Definition at line 91 of file vpColVector.cpp.

References vpMatrix::vpMatrix().

vpColVector vpColVector::operator* ( const double  x) const
inherited

Multiplication by a scalar V = A * x.

operator multiplication by a scalar V = A * x

Definition at line 152 of file vpColVector.cpp.

References vpMatrix::data, vpColVector::resize(), vpMatrix::rowNum, and vpERROR_TRACE.

vpMatrix vpMatrix::operator* ( const vpMatrix B) const
inherited

Operation C = A * B (A is unchanged).

See also
mult2Matrices() to avoid matrix allocation for each use.

Definition at line 523 of file vpMatrix.cpp.

References vpMatrix::mult2Matrices().

vpMatrix vpMatrix::operator* ( const vpHomography H) const
inherited

Allows to multiply a matrix by an homography. Operation M = K * H (H is unchanged).

Definition at line 536 of file vpMatrix.cpp.

References vpMatrix::colNum, vpException::dimensionError, and vpMatrix::rowNum.

vpTranslationVector vpMatrix::operator* ( const vpTranslationVector b) const
inherited

Operation c = A * b (A is unchanged, c and b are translation vectors).

Definition at line 975 of file vpMatrix.cpp.

References vpMatrix::colNum, vpMatrixException::incorrectMatrixSizeError, vpMatrix::rowNum, vpMatrix::rowPtrs, and vpERROR_TRACE.

vpMatrix & vpMatrix::operator*= ( const double  x)
inherited

Multiply all the element of the matrix by x : Aij = Aij * x.

Definition at line 1178 of file vpMatrix.cpp.

References vpMatrix::colNum, vpMatrix::rowNum, and vpMatrix::rowPtrs.

vpColVector vpColVector::operator+ ( const vpColVector v) const
inherited

Addition of two vectors V = A+v.

operator addition of two vectors

Definition at line 65 of file vpColVector.cpp.

References vpException::dimensionError, vpMatrix::getRows(), and vpMatrix::rowNum.

vpMatrix vpMatrix::operator+ ( const vpMatrix B) const
inherited

Operation C = A + B (A is unchanged).

See also
add2Matrices() to avoid matrix allocation for each use.

Definition at line 653 of file vpMatrix.cpp.

References vpMatrix::add2Matrices().

vpMatrix & vpMatrix::operator+= ( const vpMatrix B)
inherited
vpMatrix & vpMatrix::operator+= ( const double  x)
inherited

Add x to all the element of the matrix : Aij = Aij + x.

Definition at line 1130 of file vpMatrix.cpp.

References vpMatrix::colNum, vpMatrix::rowNum, and vpMatrix::rowPtrs.

vpColVector vpColVector::operator- ( const vpColVector v) const
inherited

Substraction of two vectors V = A-v.

operator substraction of two vectors V = A-v

Definition at line 98 of file vpColVector.cpp.

References vpException::dimensionError, vpMatrix::getRows(), and vpMatrix::rowNum.

vpColVector vpColVector::operator- ( void  ) const
inherited

Operator A = -A.

Definition at line 131 of file vpColVector.cpp.

References vpMatrix::data, vpColVector::resize(), vpMatrix::rowNum, and vpERROR_TRACE.

vpMatrix vpMatrix::operator- ( const vpMatrix B) const
inherited

Operation C = A - B (A is unchanged).

See also
sub2Matrices() to avoid matrix allocation for each use.

Definition at line 724 of file vpMatrix.cpp.

References vpMatrix::sub2Matrices().

vpMatrix & vpMatrix::operator-= ( const vpMatrix B)
inherited
vpMatrix & vpMatrix::operator-= ( const double  x)
inherited

Substract x to all the element of the matrix : Aij = Aij - x.

Definition at line 1154 of file vpMatrix.cpp.

References vpMatrix::colNum, vpMatrix::rowNum, and vpMatrix::rowPtrs.

vpMatrix vpMatrix::operator/ ( const double  x) const
inherited

Cij = Aij / x (A is unchanged)

Definition at line 1085 of file vpMatrix.cpp.

References vpMatrix::colNum, vpException::divideByZeroError, vpMatrix::resize(), vpMatrix::rowNum, vpMatrix::rowPtrs, vpCERROR, and vpERROR_TRACE.

vpMatrix & vpMatrix::operator/= ( double  x)
inherited

Divide all the element of the matrix by x : Aij = Aij / x.

Definition at line 1193 of file vpMatrix.cpp.

References vpMatrix::colNum, vpException::divideByZeroError, vpMatrix::rowNum, and vpMatrix::rowPtrs.

vpColVector & vpColVector::operator<< ( const vpColVector v)
inherited

Copy operator. Allows operation such as A << v

#include <visp/vpColVector.h>
int main()
{
vpColVector A, B(5);
for (unsigned int i=0; i<B.size(); i++)
B[i] = i;
A << B;
std::cout << "A: \n" << A << std::endl;
}

In column vector A we get:

A:
0
1
2
3
4

Definition at line 265 of file vpColVector.cpp.

vpColVector & vpColVector::operator<< ( double *  x)
inherited

Assigment operator. Allow operation such as A = *v

The following example shows how to use this operator.

#include <visp/vpColVector.h>
int main()
{
size_t n = 5;
double *B = new double [n];
for (unsigned int i = 0; i < n; i++)
B[i] = i;
A << B;
std::cout << "A: \n" << A << std::endl;
delete [] B;
}

It produces the following output:

A:
0
1
2
3
4

Definition at line 300 of file vpColVector.cpp.

References vpMatrix::colNum, vpMatrix::rowNum, and vpMatrix::rowPtrs.

double& vpPoseVector::operator[] ( unsigned int  i)
inline

Set the value of an element of the pose vector: r[i] = x.

Parameters
i: Pose vector element index
// Create a pose vector with translation and rotation set to zero
// Initialize the pose vector
r[0] = 1;
r[1] = 2;
r[2] = 3;
r[3] = M_PI;
r[4] = -M_PI;
r[5] = 0;

This code produces the same effect:

vpPoseVector r(1, 2, 3, M_PI, -M_PI, 0);

Definition at line 149 of file vpPoseVector.h.

const double& vpPoseVector::operator[] ( unsigned int  i) const
inline

Get the value of an element of the pose vector: x = r[i].

Parameters
i: Pose vector element index
vpPoseVector r(1, 2, 3, M_PI, -M_PI, 0);
double tx,ty,tz; // Translation
double tux, tuy,tuz; // Theta u rotation
tx = r[0];
ty = r[1];
tz = r[2];
tux = r[3];
tuy = r[4];
tuz = r[5];

Definition at line 168 of file vpPoseVector.h.

void vpPoseVector::print ( )

Prints to the standart stream the pose vector.

Warning
Values concerning the $ \Theta \bf u$ rotation are converted in degrees.

The following code

// Create a pose vector
vpPoseVector r(1, 2, 3, M_PI, -M_PI, 0);
r.print();

produces the output:

1 2 3 180 -180 0

Definition at line 257 of file vpPoseVector.cpp.

References vpMath::deg().

int vpMatrix::print ( std::ostream &  s,
unsigned int  length,
char const *  intro = 0 
)
inherited

Pretty print a matrix. The data are tabulated. The common widths before and after the decimal point are set with respect to the parameter maxlen.

Parameters
sStream used for the printing.
lengthThe suggested width of each matrix element. The actual width grows in order to accomodate the whole integral part, and shrinks if the whole extent is not needed for all the numbers.
introThe introduction which is printed before the matrix. Can be set to zero (or omitted), in which case the introduction is not printed.
Returns
Returns the common total width for all matrix elements
See also
std::ostream &operator <<(ostream &s,const vpMatrix &m)
Examples:
servoSimu3D_cdMc_CamVelocity.cpp, servoSimu3D_cMcd_CamVelocity.cpp, testMatrix.cpp, and testTwistMatrix.cpp.

Definition at line 2937 of file vpMatrix.cpp.

References vpMatrix::getCols(), vpMatrix::getRows(), and vpMath::maximum().

void vpMatrix::printSize ( )
inlineinherited

Definition at line 190 of file vpMatrix.h.

vpMatrix vpMatrix::pseudoInverse ( double  svThreshold = 1e-6) const
inherited

Compute the pseudo inverse of the matrix using the SVD.

Compute and return the pseudo inverse of a n-by-m matrix : $ A^+ $.

Parameters
svThreshold: Threshold used to test the singular values.
Returns
Pseudo inverse of the matrix.

Here an example to compute the inverse of a n-by-n matrix. If the matrix is n-by-n it is also possible to use inverseByLU().

#include <visp/vpMatrix.h>
int main()
{
vpMatrix A(4,4);
A[0][0] = 1/1.; A[0][1] = 1/2.; A[0][2] = 1/3.; A[0][3] = 1/4.;
A[1][0] = 1/5.; A[1][1] = 1/3.; A[1][2] = 1/3.; A[1][3] = 1/5.;
A[2][0] = 1/6.; A[2][1] = 1/4.; A[2][2] = 1/2.; A[2][3] = 1/6.;
A[3][0] = 1/7.; A[3][1] = 1/5.; A[3][2] = 1/6.; A[3][3] = 1/7.;
// Compute the inverse
vpMatrix A_1; // A^-1
A_1 = A.pseudoInverse();
std::cout << "Inverse by pseudo inverse: \n" << A_1 << std::endl;
std::cout << "A*A^-1: \n" << A * A_1 << std::endl;
}
See also
inverseByLU()

Definition at line 1932 of file vpMatrix.cpp.

Referenced by vpCalibration::calibrationTsai(), vpSimulatorAfma6::computeArticularVelocity(), vpSimulatorViper850::computeArticularVelocity(), vpServo::computeControlLaw(), vpMatrix::computeCovarianceMatrix(), vpMbEdgeKltTracker::computeVVS(), vpMbKltTracker::computeVVS(), vpMbEdgeTracker::computeVVS(), vpNurbs::globalCurveApprox(), vpNurbs::globalCurveInterp(), vpMeEllipse::initTracking(), vpHomography::inverse(), vpMeLine::leastSquare(), vpPose::poseDementhonNonPlan(), vpPose::poseFromRectangle(), vpPose::poseVirtualVS(), vpMatrix::pseudoInverse(), vpHomography::robust(), and vpMatrix::solveBySVD().

unsigned int vpMatrix::pseudoInverse ( vpMatrix Ap,
double  svThreshold = 1e-6 
) const
inherited

Compute the pseudo inverse of the matrix $Ap = A^+$.

Compute the pseudo inverse of the matrix using the SVD. return the rank

Parameters
Ap: The pseudo inverse $ A^+ $.
svThreshold: Threshold used to test the singular values.
Returns
Return the rank of the matrix A

Definition at line 1892 of file vpMatrix.cpp.

References vpMatrix::pseudoInverse().

unsigned int vpMatrix::pseudoInverse ( vpMatrix Ap,
vpColVector sv,
double  svThreshold = 1e-6 
) const
inherited

Compute the pseudo inverse of the matrix $Ap = A^+$.

Compute the pseudo inverse of the matrix using the SVD. return the rank and the singular value

Parameters
Ap: The pseudo inverse $ A^+ $.
sv: Singular values.
svThreshold: Threshold used to test the singular values.
Returns
Return the rank of the matrix A

Definition at line 1948 of file vpMatrix.cpp.

References vpMatrix::pseudoInverse().

unsigned int vpMatrix::pseudoInverse ( vpMatrix Ap,
vpColVector sv,
double  svThreshold,
vpMatrix imA,
vpMatrix imAt 
) const
inherited

Compute the pseudo inverse of the matrix $Ap = A^+$ along with Ker A, Ker $A^T$, Im A and Im $A^T$.

Compute the pseudo inverse of the matrix using the SVD. return the rank and the singular value, image

Pseudo inverse, kernel and image are computed using the SVD decomposition.

A is an m x n matrix, if m >=n the svd works on A other wise it works on $A^T$.

Therefore if m>=n we have

\[ {\bf A}_{m\times n} = {\bf U}_{m\times m} {\bf S}_{m\times n} {\bf V^\top}_{n\times n} \]

\[ {\bf A}_{m\times n} = \left[\begin{array}{ccc}\mbox{Im} {\bf A} & | & \mbox{Ker} {\bf A^\top} \end{array} \right] {\bf S} \left[ \begin{array}{c} (\mbox{Im} {\bf A^\top})^\top \\ (\mbox{Ker}{\bf A})^\top \end{array}\right] \]

where Im(A) is an m x r matrix (r is the rank of A) and Im(A^T) is an r x n matrix

Parameters
Ap: The pseudo inverse $ A^+ $.
sv: Singular values.
svThreshold: Threshold used to test the singular values.
imAt: Image A^T
imAImage A
Returns
Return the rank of the matrix A

Definition at line 1987 of file vpMatrix.cpp.

References vpMatrix::getCols(), vpMatrix::getRows(), vpColVector::resize(), vpMatrix::resize(), vpMatrix::svd(), and vpMatrix::t().

unsigned int vpMatrix::pseudoInverse ( vpMatrix Ap,
vpColVector sv,
double  svThreshold,
vpMatrix imA,
vpMatrix imAt,
vpMatrix kerA 
) const
inherited

Compute the pseudo inverse of the matrix $Ap = A^+$ along with Ker A, Ker $A^T$, Im A and Im $A^T$.

Compute the pseudo inverse of the matrix using the SVD. return the rank and the singular value, image, kernel.

Pseudo inverse, kernel and image are computed using the SVD decomposition.

A is an m x n matrix, if m >=n the svd works on A other wise it works on $A^T$.

Therefore if m>=n we have

\[ {\bf A}_{m\times n} = {\bf U}_{m\times m} {\bf S}_{m\times n} {\bf V^\top}_{n\times n} \]

\[ {\bf A}_{m\times n} = \left[\begin{array}{ccc}\mbox{Im} {\bf A} & | & \mbox{Ker} {\bf A^\top} \end{array} \right] {\bf S} \left[ \begin{array}{c} (\mbox{Im} {\bf A^\top})^\top \\ (\mbox{Ker}{\bf A})^\top \end{array}\right] \]

where Im(A) is an m x r matrix (r is the rank of A) and Im(A^T) is an r x n matrix

Parameters
Ap: The pseudo inverse $ A^+ $.
sv: Singular values.
svThreshold: Threshold used to test the singular values.
imAImage A
imAt: Image A^T
kerA: null space of A
Returns
Return the rank of the matrix A

Definition at line 2165 of file vpMatrix.cpp.

References vpMatrix::getCols(), vpMatrix::getRow(), vpMatrix::getRows(), vpColVector::resize(), vpMatrix::resize(), vpMatrix::sumSquare(), vpMatrix::svd(), and vpMatrix::t().

void vpColVector::rad2deg ( )
inlineinherited

Convert a column vector containing angles in radians into degrees.

Definition at line 182 of file vpColVector.h.

References vpMatrix::rowNum.

Referenced by vpRobotViper650::setPosition(), vpRobotViper850::setPosition(), vpRobotViper650::setVelocity(), and vpRobotViper850::setVelocity().

void vpColVector::reshape ( vpMatrix m,
const unsigned int &  nrows,
const unsigned int &  ncols 
)
inherited

Reshape methods.

reshape the colvector in a matrix

Parameters
m: the reshaped Matrix
nrows: number of rows of the matrix
ncols: number of columns of the matrix

Definition at line 790 of file vpColVector.cpp.

References vpMatrix::data, vpMatrix::dsize, vpMatrix::getCols(), vpMatrix::getRows(), vpMatrixException::incorrectMatrixSizeError, vpMatrix::resize(), and vpERROR_TRACE.

Referenced by vpColVector::reshape().

vpMatrix vpColVector::reshape ( const unsigned int &  nrows,
const unsigned int &  ncols 
)
inherited

reshape the colvector in a matrix

Parameters
nrows: number of rows of the matrix
ncols: number of columns of the matrix
Returns
a vpMatrix

Definition at line 778 of file vpColVector.cpp.

References vpColVector::reshape().

void vpColVector::resize ( const unsigned int  i,
const bool  flagNullify = true 
)
inlineinherited

Set the size of the column vector.

Parameters
i: Column vector size.
flagNullify: If true, set the data to zero.
Examples:
servoAfma4Point2DCamVelocityKalman.cpp, servoViper850Point2DCamVelocityKalman.cpp, and testSvd.cpp.

Definition at line 98 of file vpColVector.h.

References vpMatrix::resize().

Referenced by vpPoint::changeFrame(), vpLine::changeFrame(), vpRobotAfma6::checkJointLimits(), vpServo::computeError(), vpPose::computeResidual(), vpPose::computeTransformation(), vpMbEdgeKltTracker::computeVVS(), vpMbKltTracker::computeVVS(), vpMbEdgeTracker::computeVVS(), vpFeatureMoment::duplicate(), vpMatrix::eigenValues(), vpFeatureLuminance::error(), vpThetaUVector::extract(), vpRobotPtu46::getDisplacement(), vpRobotBiclops::getDisplacement(), vpSimulatorAfma6::getDisplacement(), vpRobotAfma4::getDisplacement(), vpSimulatorViper850::getDisplacement(), vpRobotAfma6::getDisplacement(), vpRobotViper850::getDisplacement(), vpRobotViper650::getDisplacement(), vpRobotViper650::getForceTorque(), vpRobotViper850::getForceTorque(), vpAfma6::getInverseKinematics(), vpViper::getInverseKinematicsWrist(), vpPlane::getNormal(), vpRobotPtu46::getPosition(), vpRobotCamera::getPosition(), vpSimulatorCamera::getPosition(), vpSimulatorPioneer::getPosition(), vpSimulatorPioneerPan::getPosition(), vpRobotBiclops::getPosition(), vpSimulatorAfma6::getPosition(), vpSimulatorViper850::getPosition(), vpRobotAfma4::getPosition(), vpRobotAfma6::getPosition(), vpRobotViper650::getPosition(), vpRobotViper850::getPosition(), vpRobotPioneer::getVelocity(), vpRobotPtu46::getVelocity(), vpRobotBiclops::getVelocity(), vpSimulatorAfma6::getVelocity(), vpSimulatorViper850::getVelocity(), vpRobotAfma4::getVelocity(), vpRobotAfma6::getVelocity(), vpRobotViper850::getVelocity(), vpRobotViper650::getVelocity(), vpCircle::init(), vpSphere::init(), vpFeatureEllipse::init(), vpFeatureVanishingPoint::init(), vpMeTracker::init(), vpFeatureLuminance::init(), vpLine::init(), vpRobotBiclops::init(), vpKalmanFilter::init(), vpFeatureSegment::init(), vpPoint::init(), vpTemplateTrackerTriangle::init(), vpFeatureDepth::init(), vpCylinder::init(), vpFeatureMoment::init(), vpFeaturePoint::init(), vpFeatureLine::init(), vpImageSimulator::init(), vpFeaturePoint3D::init(), vpFeatureThetaU::init(), vpRobotAfma4::init(), vpSimulatorAfma6::init(), vpFeaturePointPolar::init(), vpSimulatorViper850::init(), vpRobotAfma6::init(), vpFeatureTranslation::init(), vpRobotViper650::init(), vpRobotViper850::init(), vpTemplateTrackerZNCCInverseCompositional::initHessienDesired(), vpMbtDistanceLine::initInteractionMatrixError(), vpMbtDistanceCircle::initInteractionMatrixError(), vpMbtDistanceCylinder::initInteractionMatrixError(), vpMatrix::multMatrixVector(), vpColVector::operator*(), vpColVector::operator-(), vpColVector::operator=(), vpTranslationVector::operator=(), vpPose::poseDementhonNonPlan(), vpPose::poseVirtualVSrobust(), vpPoint::projection(), vpLine::projection(), vpMatrix::pseudoInverse(), vpPose::ransac(), vpSimulatorAfma6::readPosFile(), vpSimulatorViper850::readPosFile(), vpRobotAfma4::readPosFile(), vpRobotAfma6::readPosFile(), vpRobotViper650::readPosFile(), vpRobotViper850::readPosFile(), vpRobotPtu46::readPositionFile(), vpRobotBiclops::readPositionFile(), vpRobust::resize(), vpColVector::stack(), vpMatrix::stackColumns(), vpMatrix::svd(), vpMbEdgeKltTracker::trackFirstLoop(), vpFeatureMoment::update(), vpColVector::vpColVector(), vpGenericFeature::vpGenericFeature(), vpImageSimulator::vpImageSimulator(), vpRobotWireFrameSimulator::vpRobotWireFrameSimulator(), vpRobust::vpRobust(), vpTemplateTracker::vpTemplateTracker(), vpTemplateTrackerSSD::vpTemplateTrackerSSD(), vpTemplateTrackerSSDESM::vpTemplateTrackerSSDESM(), vpTemplateTrackerZNCC::vpTemplateTrackerZNCC(), and vpViper::vpViper().

void vpMatrix::resize ( const unsigned int  nrows,
const unsigned int  ncols,
const bool  flagNullify = true 
)
inherited

Set the size of the matrix and initialize all the values to zero.

Parameters
nrows: number of rows
ncols: number of column
flagNullify: if true, then the matrix is re-initialized to 0 after resize. If false, the initial values from the common part of the matrix (common part between old and new version of the matrix) are kept. Default value is true.
Returns
OK or MEMORY_FAULT if memory cannot be allocated
Examples:
testMatrix.cpp, testMatrixInverse.cpp, and testSvd.cpp.

Definition at line 199 of file vpMatrix.cpp.

References vpMatrix::colNum, vpMatrix::data, vpMatrix::dsize, vpException::memoryAllocationError, vpMatrix::rowNum, vpMatrix::rowPtrs, vpMatrix::trsize, vpCDEBUG, vpDEBUG_TRACE, and vpERROR_TRACE.

Referenced by vpMatrix::AAt(), vpMatrix::add2Matrices(), vpMatrix::add2WeightedMatrices(), vpMatrix::AtA(), vpServo::computeControlLaw(), vpMatrix::computeHLM(), vpMbTracker::computeJTR(), vpMbEdgeKltTracker::computeVVS(), vpMbKltTracker::computeVVS(), vpMatrix::createDiagonalMatrix(), vpMatrix::diag(), vpProjectionDisplay::display(), vpHomography::DLT(), vpMatrix::eigenValues(), vpMatrix::eye(), vpPtu46::get_eJe(), vpAfma4::get_eJe(), vpAfma6::get_eJe(), vpBiclops::get_eJe(), vpPtu46::get_fJe(), vpAfma4::get_fJe(), vpAfma6::get_fJe(), vpBiclops::get_fJe(), vpAfma4::get_fJe_inverse(), vpViper::get_fJw(), vpCameraParameters::get_K(), vpCameraParameters::get_K_inverse(), vpRotationMatrix::init(), vpProjectionDisplay::init(), vpVelocityTwistMatrix::init(), vpForceTwistMatrix::init(), vpKalmanFilter::init(), vpHomogeneousMatrix::init(), vpMatrix::init(), vpTemplateTrackerSSDInverseCompositional::initCompInverse(), vpMbtDistanceCircle::initInteractionMatrixError(), vpMbtDistanceCylinder::initInteractionMatrixError(), vpTemplateTracker::initTracking(), vpMatrix::insert(), vpFeatureEllipse::interaction(), vpFeatureVanishingPoint::interaction(), vpFeatureLuminance::interaction(), vpFeatureSegment::interaction(), vpGenericFeature::interaction(), vpFeatureDepth::interaction(), vpFeaturePoint::interaction(), vpFeatureLine::interaction(), vpFeaturePoint3D::interaction(), vpFeaturePointPolar::interaction(), vpFeatureThetaU::interaction(), vpFeatureTranslation::interaction(), vpMatrix::juxtaposeMatrices(), vpMatrix::kernel(), vpMatrix::loadMatrix(), vpMatrix::loadMatrixYAML(), vpMatrix::mult2Matrices(), vpMatrix::negateMatrix(), vpMatrix::operator*(), vpMatrix::operator/(), vpMatrix::operator=(), vpPose::poseDementhonPlan(), vpPose::poseVirtualVSrobust(), vpMatrix::pseudoInverse(), vpIoTools::readConfigVar(), vpRowVector::reshape(), vpColVector::reshape(), vpColVector::resize(), vpRowVector::resize(), vpServo::secondaryTask(), vpTemplateTrackerWarp::setNbParam(), vpColVector::skew(), vpMatrix::skew(), vpMatrix::stackMatrices(), vpMatrix::sub2Matrices(), vpMatrix::svd(), vpMatrix::t(), vpMatrix::transpose(), vpMatrix::vpMatrix(), vpTemplateTrackerSSD::vpTemplateTrackerSSD(), vpTemplateTrackerSSDESM::vpTemplateTrackerSSDESM(), vpTemplateTrackerSSDInverseCompositional::vpTemplateTrackerSSDInverseCompositional(), vpTemplateTrackerWarpAffine::vpTemplateTrackerWarpAffine(), vpTemplateTrackerWarpHomography::vpTemplateTrackerWarpHomography(), vpTemplateTrackerWarpHomographySL3::vpTemplateTrackerWarpHomographySL3(), vpTemplateTrackerWarpSRT::vpTemplateTrackerWarpSRT(), vpTemplateTrackerWarpTranslation::vpTemplateTrackerWarpTranslation(), and vpTemplateTrackerZNCC::vpTemplateTrackerZNCC().

vpRowVector vpMatrix::row ( const unsigned int  i)
inherited
Deprecated:
This method is deprecated. You should use getRow().

Return the i-th row of the matrix.

Warning
notice row(1) is the 0th row.

Definition at line 2346 of file vpMatrix.cpp.

References vpMatrix::getCols().

vpColVector vpColVector::rows ( unsigned int  first_row,
unsigned int  last_row 
)
inlineinherited

Definition at line 131 of file vpColVector.h.

void vpPoseVector::save ( std::ofstream &  f) const

Save the pose vector in the output file stream.

Parameters
f: Output file stream. Should be open before entering in this method.
Exceptions
vpException::ioError: If the output stream is not open.
See also
load()

Definition at line 277 of file vpPoseVector.cpp.

References vpException::ioError, and vpERROR_TRACE.

static bool vpMatrix::saveMatrix ( std::string  filename,
const vpMatrix M,
const bool  binary = false,
const char *  Header = "" 
)
inlinestaticinherited

Save a matrix to a file.

Parameters
filename: absolute file name
M: matrix to be saved
binary:If true the matrix is save in a binary file, else a text file.
Header: optional line that will be saved at the beginning of the file
Returns
Returns true if no problem appends.

Warning : If you save the matrix as in a text file the precision is less than if you save it in a binary file.

Definition at line 285 of file vpMatrix.h.

Referenced by vpDot2::defineDots().

bool vpMatrix::saveMatrix ( const char *  filename,
const vpMatrix M,
const bool  binary = false,
const char *  header = "" 
)
staticinherited

Save a matrix to a file.

Parameters
filename: Absolute file name.
M: Matrix to be saved.
binary: If true the matrix is saved in a binary file, else a text file.
header: Optional line that will be saved at the beginning of the file.
Returns
Returns true if no problem happened.

Warning : If you save the matrix as in a text file the precision is less than if you save it in a binary file.

Definition at line 3792 of file vpMatrix.cpp.

References vpMatrix::getCols(), and vpMatrix::getRows().

static bool vpMatrix::saveMatrixYAML ( std::string  filename,
const vpMatrix M,
const char *  header = "" 
)
inlinestaticinherited

Save a matrix in a YAML-formatted file.

Parameters
filename: absolute file name.
M: matrix to be saved in the file.
header: optional lines that will be saved at the beginning of the file. Should be YAML-formatted and will adapt to the indentation if any.
Returns
Returns true if success.

Definition at line 303 of file vpMatrix.h.

bool vpMatrix::saveMatrixYAML ( const char *  filename,
const vpMatrix M,
const char *  header = "" 
)
staticinherited

Save a matrix in a YAML-formatted file.

Parameters
filename: absolute file name.
M: matrix to be saved in the file.
header: optional lines that will be saved at the beginning of the file. Should be YAML-formatted and will adapt to the indentation if any.
Returns
Returns true if success.

Here is an example of outputs.

vpMatrix M(3,4);
vpMatrix::saveMatrixYAML("matrix.yml", M, "example: a YAML-formatted header");
vpMatrix::saveMatrixYAML("matrixIndent.yml", M, "example:\n - a YAML-formatted header\n - with inner indentation");

Content of matrix.yml:

example: a YAML-formatted header
rows: 3
cols: 4
- [0, 0, 0, 0]
- [0, 0, 0, 0]
- [0, 0, 0, 0]

Content of matrixIndent.yml:

example:
- a YAML-formatted header
- with inner indentation
rows: 3
cols: 4
- [0, 0, 0, 0]
- [0, 0, 0, 0]
- [0, 0, 0, 0]
See also
loadMatrixYAML()

Definition at line 3892 of file vpMatrix.cpp.

References vpMatrix::getCols(), and vpMatrix::getRows().

vpMatrix vpColVector::skew ( const vpColVector v)
staticinherited

Compute the skew symmetric matrix $[{\bf v}]_\times$ of vector v.

\[ \mbox{if} \quad {\bf V} = \left( \begin{array}{c} x \\ y \\ z \end{array}\right), \quad \mbox{then} \qquad [{\bf v}]_\times = \left( \begin{array}{ccc} 0 & -z & y \\ z & 0 & -x \\ -y & x & 0 \end{array}\right) \]

Parameters
v: Input vector used to compute the skew symmetric matrix.
Examples:
servoSimu3D_cMcd_CamVelocityWithoutVpServo.cpp.

Definition at line 718 of file vpColVector.cpp.

References vpMatrix::getRows(), vpMatrixException::incorrectMatrixSizeError, vpMatrix::resize(), and vpERROR_TRACE.

Referenced by vpCalibration::calibrationTsai(), vpMbTracker::computeCovarianceMatrix(), vpColVector::crossProd(), and vpFeatureThetaU::interaction().

void vpMatrix::solveBySVD ( const vpColVector b,
vpColVector x 
) const
inherited

Solve a linear system $ A X = B $ using Singular Value Decomposition (SVD).

Non destructive wrt. A and B.

Parameters
b: Vector $ B $.
x: Vector $ X $.

Here an example:

#include <visp/vpColVector.h>
#include <visp/vpMatrix.h>
int main()
{
vpMatrix A(3,3);
A[0][0] = 4.64;
A[0][1] = 0.288;
A[0][2] = -0.384;
A[1][0] = 0.288;
A[1][1] = 7.3296;
A[1][2] = 2.2272;
A[2][0] = -0.384;
A[2][1] = 2.2272;
A[2][2] = 6.0304;
vpColVector X(3), B(3);
B[0] = 1;
B[1] = 2;
B[2] = 3;
A.solveBySVD(B, X);
// Obtained values of X
// X[0] = 0.2468;
// X[1] = 0.120782;
// X[2] = 0.468587;
std::cout << "X:\n" << X << std::endl;
}
See also
solveBySVD(const vpColVector &)

Definition at line 1693 of file vpMatrix.cpp.

References vpMatrix::pseudoInverse().

Referenced by vpMatrix::solveBySVD().

vpColVector vpMatrix::solveBySVD ( const vpColVector B) const
inherited

Solve a linear system $ A X = B $ using Singular Value Decomposition (SVD).

Non destructive wrt. A and B.

Parameters
B: Vector $ B $.
Returns
Vector $ X $.

Here an example:

#include <visp/vpColVector.h>
#include <visp/vpMatrix.h>
int main()
{
vpMatrix A(3,3);
A[0][0] = 4.64;
A[0][1] = 0.288;
A[0][2] = -0.384;
A[1][0] = 0.288;
A[1][1] = 7.3296;
A[1][2] = 2.2272;
A[2][0] = -0.384;
A[2][1] = 2.2272;
A[2][2] = 6.0304;
vpColVector X(3), B(3);
B[0] = 1;
B[1] = 2;
B[2] = 3;
X = A.solveBySVD(B);
// Obtained values of X
// X[0] = 0.2468;
// X[1] = 0.120782;
// X[2] = 0.468587;
std::cout << "X:\n" << X << std::endl;
}
See also
solveBySVD(const vpColVector &, vpColVector &)

Definition at line 1748 of file vpMatrix.cpp.

References vpMatrix::colNum, and vpMatrix::solveBySVD().

vpColVector vpColVector::sort ( const vpColVector v)
staticinherited

sort the elements of vector v

Examples:
testSvd.cpp.

Definition at line 477 of file vpColVector.cpp.

References vpMatrix::data, vpMatrix::getRows(), vpMatrixException::notInitializedError, and vpERROR_TRACE.

void vpColVector::stack ( const double &  b)
inherited

Stack column vector with new element.

Parameters
b: Element to stack to the existing one.
double b = 3;
A.stack(b); // A = [A b]T
// A is now an 4 dimension column vector
See also
stack(const vpColVector &, const vpColVector &)
stack(const vpColVector &, const vpColVector &, vpColVector &)
Examples:
servoPioneerPoint2DDepthWithoutVpServo.cpp.

Definition at line 522 of file vpColVector.cpp.

References vpColVector::resize(), and vpMatrix::rowNum.

Referenced by vpColVector::stack().

void vpColVector::stack ( const vpColVector B)
inherited

Stack column vectors.

Parameters
B: Vector to stack to the existing one.
A.stack(B); // A = [A B]T
// A is now an 8 dimension column vector
See also
stack(const vpColVector &, const double &)
stack(const vpColVector &, const vpColVector &)
stack(const vpColVector &, const vpColVector &, vpColVector &)

Definition at line 545 of file vpColVector.cpp.

References vpColVector::stack().

vpColVector vpColVector::stack ( const vpColVector A,
const vpColVector B 
)
staticinherited

Stack column vectors.

Parameters
A: Initial vector.
B: Vector to stack at the end of A.
Returns
Stacked vector $[A B]^T$.
C = vpColVector::stack(A, B); // C = [A B]T
// C is now an 8 dimension column vector
See also
stack(const vpColVector &)
stack(const vpColVector &, const vpColVector &, vpColVector &)

Definition at line 568 of file vpColVector.cpp.

References vpColVector::stack().

void vpColVector::stack ( const vpColVector A,
const vpColVector B,
vpColVector C 
)
staticinherited

Stack column vectors.

Parameters
A: Initial vector.
B: Vector to stack at the end of A.
C: Resulting stacked vector $C = [A B]^T$.
vpColVector::stack(A, B, C); // C = [A B]T
// C is now an 8 dimension column vector
See also
stack(const vpColVector &)
stack(const vpColVector &, const vpColVector &)

Definition at line 593 of file vpColVector.cpp.

References vpMatrix::getRows(), and vpColVector::resize().

void vpMatrix::stackColumns ( vpColVector out)
inherited

Stacks columns of a matrix in a vector.

Parameters
out: a vpColVector.

Definition at line 1493 of file vpMatrix.cpp.

References vpMatrix::colNum, vpMatrix::data, vpColVector::resize(), vpMatrix::rowNum, vpMatrix::rowPtrs, vpCERROR, and vpERROR_TRACE.

vpColVector vpMatrix::stackColumns ( )
inherited

Stacks columns of a matrix in a vector.

Returns
a vpColVector.

Definition at line 1517 of file vpMatrix.cpp.

References vpMatrix::colNum, and vpMatrix::rowNum.

vpMatrix vpMatrix::stackMatrices ( const vpMatrix A,
const vpMatrix B 
)
staticinherited

Stack two Matrices C = [ A B ]^T.

Stack matrices. "Stack" two matrices C = [ A B ]^T.

$ C = \left( \begin{array}{c} A \\ B \end{array}\right) $

Parameters
A: Upper matrix.
B: Lower matrix.
Returns
Stacked matrix C = [ A B ]^T
Warning
A and B must have the same number of column.

Definition at line 2581 of file vpMatrix.cpp.

References vpMatrix::stackMatrices(), and vpCERROR.

void stackMatrices ( const vpMatrix A,
const vpMatrix B,
vpMatrix C 
)
staticinherited

Stack two Matrices C = [ A B ]^T.

stackMatrices. "stack" two matrices C = [ A B ]^T

$ C = \left( \begin{array}{c} A \\ B \end{array}\right) $

Parameters
A: Upper matrix.
B: Lower matrix.
C: Stacked matrix C = [ A B ]^T
Warning
A and B must have the same number of column

Definition at line 2610 of file vpMatrix.cpp.

References vpMatrix::getCols(), vpMatrix::getRows(), vpMatrixException::incorrectMatrixSizeError, vpMatrix::resize(), vpCERROR, and vpERROR_TRACE.

void vpMatrix::stackRows ( vpRowVector out)
inherited

Stacks rows of a matrix in a vector

Parameters
out: a vpRowVector.

Definition at line 1528 of file vpMatrix.cpp.

References vpMatrix::colNum, vpMatrix::data, vpMatrix::dsize, vpRowVector::resize(), vpMatrix::rowNum, vpCERROR, and vpERROR_TRACE.

vpRowVector vpMatrix::stackRows ( )
inherited

Stacks rows of a matrix in a vector.

Returns
a vpRowVector.

Definition at line 1550 of file vpMatrix.cpp.

References vpMatrix::colNum, and vpMatrix::rowNum.

void vpMatrix::sub2Matrices ( const vpMatrix A,
const vpMatrix B,
vpMatrix C 
)
staticinherited

Operation C = A - B.

The result is placed in the third parameter C and not returned. A new matrix won't be allocated for every use of the function (Speed gain if used many times with the same result matrix size).

See also
operator-()

Definition at line 671 of file vpMatrix.cpp.

References vpMatrix::colNum, vpMatrix::getCols(), vpMatrix::getRows(), vpMatrixException::incorrectMatrixSizeError, vpMatrix::resize(), vpMatrix::rowNum, vpMatrix::rowPtrs, and vpERROR_TRACE.

Referenced by vpMatrix::operator-().

double vpMatrix::sum ( ) const
inherited

Return the sum of all the $a_{ij}$ elements of the matrix.

Returns
$\sum a_{ij}$

Definition at line 903 of file vpMatrix.cpp.

References vpMatrix::colNum, vpMatrix::rowNum, and vpMatrix::rowPtrs.

Referenced by vpMatrix::expm().

void vpMatrix::svd ( vpColVector w,
vpMatrix v 
)
inherited

Singular value decomposition (SVD).

\[ M = U \Sigma V^{\top} \]

Warning
Destructive method wrt. to the matrix $ M $ to decompose. You should make a COPY of that matrix if needed not to CHANGE.
Parameters
w: Vector of singular values. $ \Sigma = diag(w) $.
v: Matrix $ V $.
Returns
Matrix $ U $.
Warning
If the GNU Scientific Library (GSL) third party library is used to compute the SVD decomposition, the singular values $ \Sigma_{i,i} $ are ordered in decreasing fashion in w. This is not the case, if the GSL is not detected by ViSP.

Here an example of SVD decomposition of a non square Matrix M.

#include <visp/vpColVector.h>
#include <visp/vpMatrix.h>
int main()
{
vpMatrix M(3,2);
M[0][0] = 1;
M[1][0] = 2;
M[2][0] = 0.5;
M[0][1] = 6;
M[1][1] = 8 ;
M[2][1] = 9 ;
vpMatrix Mrec;
vpMatrix Sigma;
M.svd(w, v);
// Here M is modified and is now equal to U
// Construct the diagonal matrix from the singular values
Sigma.diag(w);
// Reconstruct the initial matrix M using the decomposition
Mrec = M * Sigma * v.t();
// Here, Mrec is obtained equal to the initial value of M
// Mrec[0][0] = 1;
// Mrec[1][0] = 2;
// Mrec[2][0] = 0.5;
// Mrec[0][1] = 6;
// Mrec[1][1] = 8 ;
// Mrec[2][1] = 9 ;
std::cout << "Reconstructed M matrix: \n" << Mrec << std::endl;
}
Examples:
servoMomentImage.cpp.

Definition at line 1822 of file vpMatrix.cpp.

References vpMatrix::getCols(), vpMatrix::getRows(), vpColVector::resize(), and vpMatrix::resize().

Referenced by vpHomography::computeDisplacement(), vpMatrix::cond(), vpHomography::DLT(), vpMatrix::kernel(), vpPose::poseDementhonPlan(), and vpMatrix::pseudoInverse().

vpMatrix vpMatrix::transpose ( ) const
inherited

Compute and return the transpose of the matrix.

See also
t()

Definition at line 1326 of file vpMatrix.cpp.

Referenced by vpTemplateTrackerWarpSRT::getParamInverse().

void vpMatrix::transpose ( vpMatrix At) const
inherited

Compute At the transpose of the matrix.

Parameters
At: Resulting transpose matrix.
See also
t()

Definition at line 1338 of file vpMatrix.cpp.

References vpMatrix::colNum, vpMatrix::resize(), vpMatrix::rowNum, vpMatrix::rowPtrs, vpCERROR, and vpERROR_TRACE.

Friends And Related Function Documentation

vpColVector operator* ( const double &  x,
const vpColVector B 
)
related

multiplication by a scalar Ci = x*Bi

Definition at line 363 of file vpColVector.cpp.

vpMatrix operator* ( const double &  x,
const vpMatrix B 
)
related

Multiplication by a scalar Cij = x*Bij.

Definition at line 1006 of file vpMatrix.cpp.

References vpMatrix::getCols(), vpMatrix::getRows(), vpMatrix::resize(), and vpERROR_TRACE.

void skew ( const vpTranslationVector t,
vpMatrix M 
)
related

Compute the skew symmetric matrix $M$ of translation vector $t$ (matrice de pre-produit vectoriel).

\[ \mbox{if} \quad {\bf t} = \left( \begin{array}{c} t_x \\ t_y \\ t_z \end{array}\right), \quad \mbox{then} \qquad M = \left( \begin{array}{ccc} 0 & -t_z & t_y \\ t_z & 0 & -t_x \\ -t_y & t_x & 0 \end{array}\right) \]

Parameters
t: Translation vector in input used to compute the skew symmetric matrix M.
M: Skew symmetric matrix of translation vector $t$.
Examples:
servoSimuSphere.cpp.

Definition at line 296 of file vpTranslationVector.cpp.

References vpMatrix::resize().

void vpGEMM ( const vpMatrix A,
const vpMatrix B,
const double &  alpha,
const vpMatrix C,
const double &  beta,
vpMatrix D,
const unsigned int &  ops = 0 
)
related

This function performs generalized matrix multiplication: D = alpha*op(A)*op(B) + beta*op(C), where op(X) is X or X^T. Operation on A, B and C matrices is described by enumeration vpGEMMmethod.

For example, to compute alpha*A^T*B^T+beta*C we need to call :

vpGEMM(A,B,alpha,C,beta, VP_GEMM_A_T + VP_GEMM_B_T);

If C is not used, vpGEMM must be called using an empty matrix null :

vpGEMM(A,B,alpha,C, null,0);
Exceptions
vpMatrixException::incorrectMatrixSizeErrorif the sizes of the matrices do not allow the operations.
Parameters
A: a Matrix
B: a Matrix
alpha: a scalar
C: a Matrix
beta: a scalar
D: a Matrix
ops: a scalar describing operation applied on the matrices
Examples:
testMatrix.cpp.

Definition at line 331 of file vpGEMM.h.

References vpMatrixException::incorrectMatrixSizeError, and vpERROR_TRACE.

enum vpGEMMmethod
related

Enumeration of the operations applied on matrices in vpGEMM function.

Operations are :

  • VP_GEMM_A_T to use the transpose matrix of A instead of the matrix A
  • VP_GEMM_B_T to use the transpose matrix of B instead of the matrix B
  • VP_GEMM_C_T to use the transpose matrix of C instead of the matrix C

Definition at line 63 of file vpGEMM.h.

Member Data Documentation

double* vpMatrix::data
inherited

address of the first element of the data array

Definition at line 118 of file vpMatrix.h.

Referenced by vpMatrix::AtA(), vpHomogeneousMatrix::buildFrom(), vpSubColVector::checkParentStatus(), vpSubRowVector::checkParentStatus(), vpSubMatrix::checkParentStatus(), vpPose::computeResidual(), vpPose::computeTransformation(), vpHomogeneousMatrix::convert(), vpColVector::dotProd(), vpMatrix::eigenValues(), vpMatrix::euclideanNorm(), vpMatrix::expm(), vpRobotViper650::getForceTorque(), vpRobotViper850::getForceTorque(), vpMatrix::getMaxValue(), vpMatrix::getMinValue(), vpRobotViper650::getPosition(), vpRobotViper850::getPosition(), vpRobotViper850::getVelocity(), vpRobotViper650::getVelocity(), vpSubColVector::init(), vpSubRowVector::init(), vpSubMatrix::init(), vpMatrix::init(), vpRobotViper650::init(), vpRobotViper850::init(), vpMatrix::inverseByCholeskyLapack(), vpMatrix::inverseByQRLapack(), vpColVector::invSort(), vpMatrix::kill(), vpColVector::mean(), vpColVector::median(), vpRowVector::operator*(), vpTranslationVector::operator*(), vpColVector::operator*(), vpTranslationVector::operator-(), vpColVector::operator-(), vpRowVector::operator-(), vpSubColVector::operator=(), vpSubRowVector::operator=(), vpRowVector::operator=(), vpColVector::operator=(), vpTranslationVector::operator=(), vpMatrix::operator=(), vpRowVector::operator[](), vpColVector::operator[](), vpPose::ransac(), vpRowVector::reshape(), vpColVector::reshape(), vpMatrix::resize(), vpRobotAfma4::setPosition(), vpRobotViper650::setPosition(), vpRobotViper850::setPosition(), vpRobotAfma4::setVelocity(), vpRobotAfma6::setVelocity(), vpRobotViper650::setVelocity(), vpRobotViper850::setVelocity(), vpColVector::sort(), vpMatrix::stackColumns(), vpMatrix::stackRows(), vpRowVector::t(), vpColVector::t(), vpColVector::vpColVector(), vpMatrix::vpMatrix(), vpSubColVector::~vpSubColVector(), vpSubMatrix::~vpSubMatrix(), and vpSubRowVector::~vpSubRowVector().

unsigned int vpMatrix::trsize
protectedinherited

Total row space.

Definition at line 126 of file vpMatrix.h.

Referenced by vpSubColVector::init(), vpSubRowVector::init(), vpSubMatrix::init(), vpMatrix::init(), and vpMatrix::resize().