Visual Servoing Platform  version 3.0.0
vpColVector Class Reference

#include <visp3/core/vpColVector.h>

+ Inheritance diagram for vpColVector:

Public Member Functions

 vpColVector ()
 
 vpColVector (unsigned int n)
 
 vpColVector (unsigned int n, double val)
 
 vpColVector (const vpColVector &v)
 
 vpColVector (const vpColVector &v, unsigned int r, unsigned int nrows)
 
 vpColVector (const vpRotationVector &v)
 
 vpColVector (const vpPoseVector &p)
 
 vpColVector (const vpTranslationVector &t)
 
 vpColVector (const vpMatrix &M)
 
 vpColVector (const vpMatrix &M, unsigned int j)
 
 vpColVector (const std::vector< double > &v)
 
 vpColVector (const std::vector< float > &v)
 
virtual ~vpColVector ()
 
void clear ()
 
void deg2rad ()
 
double euclideanNorm () const
 
vpColVector extract (unsigned int r, unsigned int colsize) const
 
double infinityNorm () const
 
void init (const vpColVector &v, unsigned int r, unsigned int nrows)
 
void insert (unsigned int i, const vpColVector &v)
 
vpColVectornormalize ()
 
vpColVectornormalize (vpColVector &x) const
 
double & operator[] (unsigned int n)
 
const double & operator[] (unsigned int n) const
 
vpColVectoroperator= (const vpColVector &v)
 
vpColVectoroperator= (const vpPoseVector &p)
 
vpColVectoroperator= (const vpRotationVector &rv)
 
vpColVectoroperator= (const vpTranslationVector &tv)
 
vpColVectoroperator= (const vpMatrix &M)
 
vpColVectoroperator= (const std::vector< double > &v)
 
vpColVectoroperator= (const std::vector< float > &v)
 
vpColVectoroperator= (double x)
 
double operator* (const vpColVector &x) const
 
vpMatrix operator* (const vpRowVector &v) const
 
vpColVector operator* (const double x) const
 
vpColVectoroperator*= (double x)
 
vpColVector operator/ (const double x) const
 
vpColVectoroperator/= (double x)
 
vpColVector operator+ (const vpColVector &v) const
 
vpColVectoroperator+= (vpColVector v)
 
vpColVector operator- (const vpColVector &v) const
 
vpColVectoroperator-= (vpColVector v)
 
vpColVector operator- () const
 
vpColVectoroperator<< (const vpColVector &v)
 
vpColVectoroperator<< (double *)
 
int print (std::ostream &s, unsigned int length, char const *intro=0) const
 
void rad2deg ()
 
void reshape (vpMatrix &M, const unsigned int &nrows, const unsigned int &ncols)
 
vpMatrix reshape (const unsigned int &nrows, const unsigned int &ncols)
 
void resize (const unsigned int i, const bool flagNullify=true)
 
void resize (const unsigned int nrows, const unsigned int ncols, const bool flagNullify)
 
void stack (const double &d)
 
void stack (const vpColVector &v)
 
double sumSquare () const
 
vpRowVector t () const
 
vpRowVector transpose () const
 
void transpose (vpRowVector &v) const
 
Inherited functionalities from vpArray2D
double getMinValue () const
 
double getMaxValue () const
 
unsigned int getRows () const
 
unsigned int getCols () const
 
unsigned int size () const
 

Static Public Member Functions

static vpColVector cross (const vpColVector &a, const vpColVector &b)
 
static vpColVector crossProd (const vpColVector &a, const vpColVector &b)
 
static double dotProd (const vpColVector &a, const vpColVector &b)
 
static vpColVector invSort (const vpColVector &v)
 
static double median (const vpColVector &v)
 
static double mean (const vpColVector &v)
 
static vpMatrix skew (const vpColVector &v)
 
static vpColVector sort (const vpColVector &v)
 
static vpColVector stack (const vpColVector &A, const vpColVector &B)
 
static void stack (const vpColVector &A, const vpColVector &B, vpColVector &C)
 
static double stdev (const vpColVector &v, const bool useBesselCorrection=false)
 
Inherited I/O from vpArray2D with Static Public Member Functions
static bool load (const std::string &filename, vpArray2D< double > &A, const bool binary=false, char *header=NULL)
 
static bool loadYAML (const std::string &filename, vpArray2D< double > &A, char *header=NULL)
 
static bool save (const std::string &filename, const vpArray2D< double > &A, const bool binary=false, const char *header="")
 
static bool saveYAML (const std::string &filename, const vpArray2D< double > &A, const char *header="")
 

Public Attributes

double * data
 

Protected Attributes

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

Friends

class vpMatrix
 

Related Functions

(Note that these are not member functions.)

vpColVector operator* (const double &x, const vpColVector &v)
 
enum  vpGEMMmethod
 

Deprecated functions

vp_deprecated void init ()
 
vp_deprecated vpColVector rows (unsigned int first_row, unsigned int last_row) const
 
vp_deprecated void setIdentity (const double &val=1.0)
 
vp_deprecated void stackMatrices (const vpColVector &r)
 
static vp_deprecated vpColVector stackMatrices (const vpColVector &A, const vpColVector &B)
 
static vp_deprecated void stackMatrices (const vpColVector &A, const vpColVector &B, vpColVector &C)
 

Detailed Description

Implementation of column vector and the associated operations.

This class provides a data structure for a column vector that contains values of double. It contains also some functions to achieve a set of operations on these vectors.

The vpColVector class is derived from vpArray2D<double>.

Examples:
calibrateTsai.cpp, exponentialMap.cpp, homographyHartleyDLT2DObject.cpp, homographyHLM2DObject.cpp, homographyHLM3DObject.cpp, homographyRansac2DObject.cpp, manServo4PointsDisplay.cpp, manServoMomentsSimple.cpp, manSimu4Dots.cpp, manSimu4Points.cpp, moveAfma4.cpp, moveBiclops.cpp, movePioneer.cpp, movePtu46.cpp, photometricVisualServoing.cpp, servoAfma4Point2DArtVelocity.cpp, servoAfma4Point2DCamVelocity.cpp, servoAfma4Point2DCamVelocityKalman.cpp, servoAfma62DhalfCamVelocity.cpp, servoAfma6Cylinder2DCamVelocity.cpp, servoAfma6Cylinder2DCamVelocitySecondaryTask.cpp, servoAfma6Ellipse2DCamVelocity.cpp, servoAfma6FourPoints2DArtVelocity.cpp, servoAfma6FourPoints2DCamVelocityInteractionCurrent.cpp, servoAfma6FourPoints2DCamVelocityInteractionDesired.cpp, servoAfma6Line2DCamVelocity.cpp, servoAfma6Point2DArtVelocity.cpp, servoAfma6Point2DCamVelocity.cpp, servoAfma6Points2DCamVelocityEyeToHand.cpp, servoAfma6Segment2DCamVelocity.cpp, servoAfma6SquareLines2DCamVelocity.cpp, servoAfma6TwoLines2DCamVelocity.cpp, servoBiclopsPoint2DArtVelocity.cpp, servoMomentImage.cpp, servoMomentPoints.cpp, servoMomentPolygon.cpp, servoPioneerPanSegment3D.cpp, servoPioneerPoint2DDepth.cpp, servoPioneerPoint2DDepthWithoutVpServo.cpp, servoPtu46Point2DArtVelocity.cpp, servoSimu3D_cdMc_CamVelocity.cpp, servoSimu3D_cdMc_CamVelocityWithoutVpServo.cpp, servoSimu3D_cMcd_CamVelocity.cpp, servoSimu3D_cMcd_CamVelocityWithoutVpServo.cpp, servoSimu4Points.cpp, servoSimuAfma6FourPoints2DCamVelocity.cpp, servoSimuCircle2DCamVelocity.cpp, servoSimuCircle2DCamVelocityDisplay.cpp, servoSimuCylinder.cpp, servoSimuCylinder2DCamVelocityDisplay.cpp, servoSimuCylinder2DCamVelocityDisplaySecondaryTask.cpp, servoSimuFourPoints2DCamVelocity.cpp, servoSimuFourPoints2DCamVelocityDisplay.cpp, servoSimuFourPoints2DPolarCamVelocityDisplay.cpp, servoSimuLine2DCamVelocityDisplay.cpp, servoSimuPoint2DCamVelocity1.cpp, servoSimuPoint2DCamVelocity2.cpp, servoSimuPoint2DCamVelocity3.cpp, servoSimuPoint2DhalfCamVelocity1.cpp, servoSimuPoint2DhalfCamVelocity2.cpp, servoSimuPoint2DhalfCamVelocity3.cpp, servoSimuPoint3DCamVelocity.cpp, servoSimuSphere.cpp, servoSimuSphere2DCamVelocity.cpp, servoSimuSphere2DCamVelocitySecondaryTask.cpp, servoSimuSquareLine2DCamVelocityDisplay.cpp, servoSimuThetaUCamVelocity.cpp, servoSimuViper850FourPoints2DCamVelocity.cpp, servoViper650FourPoints2DArtVelocityInteractionCurrent.cpp, servoViper650FourPoints2DCamVelocityInteractionCurrent.cpp, servoViper650Point2DCamVelocity.cpp, servoViper850FourPoints2DArtVelocityInteractionCurrent.cpp, servoViper850FourPoints2DArtVelocityInteractionDesired.cpp, servoViper850FourPoints2DCamVelocityInteractionCurrent.cpp, servoViper850FourPointsKinect.cpp, servoViper850Point2DArtVelocity-jointAvoidance-basic.cpp, servoViper850Point2DArtVelocity-jointAvoidance-gpa.cpp, servoViper850Point2DArtVelocity-jointAvoidance-large.cpp, servoViper850Point2DArtVelocity.cpp, servoViper850Point2DCamVelocity.cpp, servoViper850Point2DCamVelocityKalman.cpp, simulateCircle2DCamVelocity.cpp, simulateFourPoints2DCartesianCamVelocity.cpp, simulateFourPoints2DPolarCamVelocity.cpp, sonarPioneerReader.cpp, templateTracker.cpp, testColVector.cpp, testDisplacement.cpp, testFeatureSegment.cpp, testKalmanAcceleration.cpp, testKalmanVelocity.cpp, testMatrix.cpp, testRobotAfma6Pose.cpp, testRobotViper850.cpp, testRobotViper850Pose.cpp, testSvd.cpp, testTwistMatrix.cpp, testViper850.cpp, tutorial-homography-from-points.cpp, tutorial-ibvs-4pts-display.cpp, tutorial-ibvs-4pts-image-tracking.cpp, tutorial-ibvs-4pts-ogre-tracking.cpp, tutorial-ibvs-4pts-ogre.cpp, tutorial-ibvs-4pts-plotter-continuous-gain-adaptive.cpp, tutorial-ibvs-4pts-plotter-gain-adaptive.cpp, tutorial-ibvs-4pts-plotter.cpp, tutorial-ibvs-4pts-wireframe-camera.cpp, tutorial-ibvs-4pts-wireframe-robot-afma6.cpp, tutorial-ibvs-4pts-wireframe-robot-viper.cpp, tutorial-ibvs-4pts.cpp, tutorial-image-simulator.cpp, tutorial-pioneer-robot.cpp, tutorial-simu-pioneer-continuous-gain-adaptive.cpp, tutorial-simu-pioneer-continuous-gain-constant.cpp, tutorial-simu-pioneer-pan.cpp, tutorial-simu-pioneer.cpp, and tutorial-template-tracker.cpp.

Definition at line 72 of file vpColVector.h.

Constructor & Destructor Documentation

vpColVector::vpColVector ( )
inline

Basic constructor that creates an empty 0-size column vector.

Definition at line 78 of file vpColVector.h.

vpColVector::vpColVector ( unsigned int  n)
inline

Construct a column vector of size n. All the elements are initialized to zero.

Definition at line 80 of file vpColVector.h.

vpColVector::vpColVector ( unsigned int  n,
double  val 
)
inline

Construct a column vector of size n. Each element is set to val.

Definition at line 82 of file vpColVector.h.

vpColVector::vpColVector ( const vpColVector v)
inline

Copy constructor that allows to construct a column vector from an other one.

Definition at line 84 of file vpColVector.h.

vpColVector::vpColVector ( const vpColVector v,
unsigned int  r,
unsigned int  nrows 
)

Construct a column vector from a part of an input column vector v.

Parameters
v: Input column vector used for initialization.
r: row index in v that corresponds to the first element of the column vector to contruct.
nrows: Number of rows of the constructed column vector.

The sub-vector starting from v[r] element and ending on v[r+nrows-1] element is used to initialize the contructed column vector.

See also
init()

Definition at line 177 of file vpColVector.cpp.

References init().

vpColVector::vpColVector ( const vpRotationVector v)

Constructor that initialize a column vector from a 3-dim (Euler or $\theta {\bf u}$) or 4-dim (quaternion) rotation vector.

Definition at line 235 of file vpColVector.cpp.

References vpArray2D< Type >::size().

vpColVector::vpColVector ( const vpPoseVector p)

Constructor that initialize a column vector from a 6-dim pose vector.

Definition at line 242 of file vpColVector.cpp.

References vpArray2D< Type >::size().

vpColVector::vpColVector ( const vpTranslationVector t)

Constructor that initialize a column vector from a 3-dim translation vector.

Definition at line 249 of file vpColVector.cpp.

References vpArray2D< Type >::size().

vpColVector::vpColVector ( const vpMatrix M)

Constructor that creates a column vector from a m-by-1 matrix M.

Exceptions
vpException::dimensionErrorIf the matrix is not a m-by-1 matrix.

Definition at line 269 of file vpColVector.cpp.

References vpException::dimensionError, vpArray2D< Type >::getCols(), and vpArray2D< Type >::getRows().

vpColVector::vpColVector ( const vpMatrix M,
unsigned int  j 
)

Constructor that take column j of matrix M.

Definition at line 257 of file vpColVector.cpp.

References vpArray2D< Type >::getCols().

vpColVector::vpColVector ( const std::vector< double > &  v)

Constructor that creates a column vector from a std vector of double.

Definition at line 285 of file vpColVector.cpp.

vpColVector::vpColVector ( const std::vector< float > &  v)

Constructor that creates a column vector from a std vector of float.

Definition at line 294 of file vpColVector.cpp.

virtual vpColVector::~vpColVector ( )
inlinevirtual

Destructor.

Definition at line 100 of file vpColVector.h.

Member Function Documentation

void vpColVector::clear ( )
inline

Removes all elements from the vector (which are destroyed), leaving the container with a size of 0.

Examples:
testColVector.cpp.

Definition at line 106 of file vpColVector.h.

References vpArray2D< double >::colNum, vpArray2D< double >::data, vpArray2D< double >::dsize, vpArray2D< double >::rowNum, and vpArray2D< double >::rowPtrs.

Referenced by vpMbTracker::createCylinderBBox().

static vpColVector vpColVector::cross ( const vpColVector a,
const vpColVector b 
)
inlinestatic

Compute and return the cross product of two 3-dimension vectors: $a \times b$.

Parameters
a: 3-dimension column vector.
b: 3-dimension column vector.
Returns
The cross product $a \times b$.
Exceptions
vpException::dimensionErrorIf the vectors dimension is not equal to 3.

Definition at line 257 of file vpColVector.h.

Referenced by vpMbtDistanceLine::buildFrom(), vpPlane::init(), and vpPose::poseDementhonNonPlan().

vpColVector vpColVector::crossProd ( const vpColVector a,
const vpColVector b 
)
static

Compute and return the cross product of two vectors $a \times b$.

Parameters
a: 3-dimension column vector.
b: 3-dimension column vector.
Returns
The cross product $a \times b$.
Exceptions
vpException::dimensionErrorIf the vectors dimension is not equal to 3.

Definition at line 1027 of file vpColVector.cpp.

References vpException::dimensionError, vpArray2D< Type >::getRows(), and skew().

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

double vpColVector::dotProd ( const vpColVector a,
const vpColVector b 
)
static

Compute end return the dot product of two column vectors:

\[ a \cdot b = \sum_{i=0}^n a_i * b_i\]

where n is the dimension of both vectors.

Exceptions
vpException::dimensionErrorIf the vector dimension differ.

Definition at line 677 of file vpColVector.cpp.

References vpArray2D< Type >::data, vpException::dimensionError, vpException::fatalError, vpArray2D< Type >::getRows(), and vpArray2D< Type >::size().

Referenced by vpPose::calculArbreDementhon(), vpMbtPolygon::isVisible(), vpPose::poseDementhonPlan(), and vpImageSimulator::setCameraPosition().

double vpColVector::euclideanNorm ( ) const

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

Returns
The Euclidean norm if the vector is initialized, 0 otherwise.

Definition at line 1242 of file vpColVector.cpp.

References vpArray2D< double >::data, and vpArray2D< double >::dsize.

Referenced by vpServo::computeProjectionOperators(), vpMbTracker::createCylinderBBox(), and vpSimulatorAfma6::setPosition().

vpColVector vpColVector::extract ( unsigned int  r,
unsigned int  colsize 
) const
inline

Extract a sub-column vector from a column vector.

Parameters
r: Index of the row corresponding to the first element of the vector to extract.
colsize: Size of the vector to extract.
Exceptions
vpException::fatalErrorIf the vector to extract is not contained in the original one.
for (unsigned int i=0; i<4; i++)
v1.stack(i);
// v1 is equal to [0 1 2 3]^T
vpColVector v2 = v1.extract(1, 3);
// v2 is equal to [1 2 3]^T
Examples:
testColVector.cpp.

Definition at line 146 of file vpColVector.h.

References vpException::fatalError, and vpArray2D< double >::rowNum.

double vpArray2D< double >::getMaxValue ( ) const
inherited

Return the array max value.

Examples:
servoMomentImage.cpp.
double vpArray2D< double >::getMinValue ( ) const
inherited

Return the array min value.

Examples:
servoMomentImage.cpp.
double vpColVector::infinityNorm ( ) const

Compute and return the infinity norm $ {||x||}_{\infty} = max\left({\mid x_{i} \mid}\right) $ with $i \in \{0, ..., m-1\}$ where m is the vector size and $x_i$ an element of the vector.

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

Definition at line 1263 of file vpColVector.cpp.

References vpArray2D< double >::rowNum.

void vpColVector::init ( const vpColVector v,
unsigned int  r,
unsigned int  nrows 
)

Initialize the column vector from a part of an input column vector v.

Parameters
v: Input column vector used for initialization.
r: row index in v that corresponds to the first element of the column vector to contruct.
nrows: Number of rows of the constructed column vector.

The sub-vector starting from v[r] element and ending on v[r+nrows-1] element is used to initialize the contructed column vector.

The following code shows how to use this function:

#include <visp3/core/vpColVector.h>
int main()
{
int val = 0;
for(size_t i=0; i<v.getRows(); i++) {
v[i] = val++;
}
std::cout << "v: " << v.t() << std::endl;
w.init(v, 0, 2);
std::cout << "w: " << w.t() << std::endl;
}

It produces the following output:

v: 0 1 2 3
w: 1 2
Examples:
testColVector.cpp.

Definition at line 219 of file vpColVector.cpp.

References vpException::dimensionError, vpArray2D< Type >::getRows(), resize(), and vpArray2D< double >::rowPtrs.

vp_deprecated void vpColVector::init ( )
inline
Deprecated:
Provided only for compat with previous releases. This function does nothing.

Definition at line 286 of file vpColVector.h.

Referenced by vpColVector(), and vpSubColVector::vpSubColVector().

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

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 <visp3/core/vpColVector.h>
int main()
{
for (unsigned int i=0; i < v.size(); i++)
v[i] = i;
std::cout << "v: " << v.t() << std::endl;
for (unsigned int i=0; i < w.size(); i++)
w[i] = i+10;
std::cout << "w: " << w.t() << std::endl;
v.insert(1, w);
std::cout << "v: " << v.t() << std::endl;
}

It produces the following output:

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

Definition at line 1107 of file vpColVector.cpp.

References vpException::dimensionError, vpArray2D< Type >::size(), and vpArray2D< double >::size().

vpColVector vpColVector::invSort ( const vpColVector v)
static

Return a column vector with elements of v that are reverse sorted.

See also
sort()

Definition at line 743 of file vpColVector.cpp.

References vpArray2D< Type >::data, vpException::fatalError, and vpArray2D< Type >::getRows().

static bool vpArray2D< double >::load ( const std::string &  filename,
vpArray2D< double > &  A,
const bool  binary = false,
char *  header = NULL 
)
inlinestaticinherited

Load a matrix from a file.

Parameters
filename: Absolute file name.
A: Array 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 success.
See also
save()

Definition at line 308 of file vpArray2D.h.

References vpException::badValue, and vpArray2D< Type >::resize().

static bool vpArray2D< double >::loadYAML ( const std::string &  filename,
vpArray2D< double > &  A,
char *  header = NULL 
)
inlinestaticinherited

Load an array from a YAML-formatted file.

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

Definition at line 392 of file vpArray2D.h.

References vpArray2D< Type >::resize().

double vpColVector::mean ( const vpColVector v)
static

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

Examples:
testColVector.cpp.

Definition at line 928 of file vpColVector.cpp.

References vpArray2D< Type >::data, vpException::fatalError, and vpArray2D< Type >::getRows().

Referenced by stdev().

double vpColVector::median ( const vpColVector v)
static

Compute the median value of all the elements of the vector.

Examples:
testColVector.cpp.

Definition at line 946 of file vpColVector.cpp.

References vpArray2D< Type >::data, vpException::fatalError, vpMath::getMedian(), and vpArray2D< Type >::size().

vpColVector & vpColVector::normalize ( vpColVector x) const

Normalise the vector:

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

Definition at line 710 of file vpColVector.cpp.

References sumSquare().

double vpColVector::operator* ( const vpColVector v) const

Operator that performs the dot product between two column vectors.

Exceptions
vpException::dimensionErrorIf the vector dimension differ.
See also
dotProd()

Definition at line 116 of file vpColVector.cpp.

References vpException::dimensionError, vpArray2D< double >::rowNum, vpArray2D< double >::size(), and vpArray2D< Type >::size().

vpMatrix vpColVector::operator* ( const vpRowVector v) const

Multiply a column vector by a row vector.

Parameters
v: Row vector.
Returns
The resulting matrix.

Definition at line 139 of file vpColVector.cpp.

References vpArray2D< Type >::getCols(), and vpArray2D< double >::rowNum.

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

Operator that allows to multiply each element of a column vector by a scalar.

Parameters
x: The scalar.
Returns
The column vector multiplied by the scalar. The current column vector (*this) is unchanged.
v[0] = 1;
v[1] = 2;
v[2] = 3;
vpColVector w = v * 3;
// v is unchanged
// w is now equal to : [3, 6, 9]

Definition at line 350 of file vpColVector.cpp.

References vpArray2D< Type >::data, vpArray2D< double >::data, and vpArray2D< double >::rowNum.

vpColVector & vpColVector::operator*= ( double  x)

Operator that allows to multiply each element of a column vector by a scalar.

Parameters
x: The scalar.
Returns
The column vector multiplied by the scalar.
v[0] = 1;
v[1] = 2;
v[2] = 3;
v *= 3;
// v is now equal to : [3, 6, 9]

Definition at line 378 of file vpColVector.cpp.

References vpArray2D< double >::rowNum.

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

Operator that allows to add two column vectors.

Definition at line 64 of file vpColVector.cpp.

References vpException::dimensionError, vpArray2D< Type >::getRows(), vpArray2D< double >::getRows(), and vpArray2D< double >::rowNum.

vpColVector & vpColVector::operator+= ( vpColVector  v)

Operator that allows to add two column vectors.

Definition at line 80 of file vpColVector.cpp.

References vpException::dimensionError, vpArray2D< Type >::getRows(), vpArray2D< double >::getRows(), and vpArray2D< double >::rowNum.

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

operator substraction of two vectors V = A-v

Definition at line 151 of file vpColVector.cpp.

References vpException::dimensionError, vpArray2D< Type >::getRows(), vpArray2D< double >::getRows(), and vpArray2D< double >::rowNum.

vpColVector vpColVector::operator- ( ) const

Operator that allows to negate all the column vector elements.

vpColVector r(3, 1);
// r contains [1 1 1]^T
vpColVector v = -r;
// v contains [-1 -1 -1]^T

Definition at line 311 of file vpColVector.cpp.

References vpArray2D< Type >::data, vpArray2D< double >::data, resize(), vpArray2D< double >::rowNum, and vpERROR_TRACE.

vpColVector & vpColVector::operator-= ( vpColVector  v)

Operator that allows to substract two column vectors.

Definition at line 94 of file vpColVector.cpp.

References vpException::dimensionError, vpArray2D< Type >::getRows(), vpArray2D< double >::getRows(), and vpArray2D< double >::rowNum.

vpColVector vpColVector::operator/ ( const double  x) const

Operator that allows to divide each element of a column vector by a scalar.

Parameters
x: The scalar.
Returns
The column vector divided by the scalar. The current column vector (*this) is unchanged.
v[0] = 8;
v[1] = 4;
v[2] = 2;
vpColVector w = v / 2;
// v is unchanged
// w is now equal to : [4, 2, 1]

Definition at line 428 of file vpColVector.cpp.

References vpArray2D< Type >::data, vpArray2D< double >::data, and vpArray2D< double >::rowNum.

vpColVector & vpColVector::operator/= ( double  x)

Operator that allows to divide each element of a column vector by a scalar.

Parameters
x: The scalar.
Returns
The column vector divided by the scalar.
v[0] = 8;
v[1] = 4;
v[2] = 2;
v /= 2;
// v is now equal to : [4, 2, 1]

Definition at line 402 of file vpColVector.cpp.

References vpArray2D< double >::rowNum.

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

Copy operator. Allows operation such as A << v

#include <visp3/core/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: " << A.t() << std::endl;
}

In column vector A we get:

A: 0 1 2 3 4

Definition at line 580 of file vpColVector.cpp.

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

Assigment operator. Allow operation such as A = *v

The following example shows how to use this operator.

#include <visp3/core/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: " << A.t() << std::endl;
delete [] B;
}

It produces the following output:

A: 0 1 2 3 4

Definition at line 610 of file vpColVector.cpp.

References vpArray2D< double >::colNum, vpArray2D< double >::rowNum, and vpArray2D< double >::rowPtrs.

vpColVector & vpColVector::operator= ( const vpColVector v)

Copy operator. Allow operation such as A = v.

Definition at line 485 of file vpColVector.cpp.

References vpArray2D< double >::data, vpArray2D< Type >::data, resize(), vpArray2D< Type >::rowNum, and vpArray2D< double >::rowNum.

vpColVector & vpColVector::operator= ( const vpPoseVector p)

Operator that allows to convert a pose vector into a column vector.

Definition at line 543 of file vpColVector.cpp.

References vpArray2D< double >::data, vpArray2D< Type >::data, vpArray2D< Type >::getRows(), resize(), and vpArray2D< double >::rowNum.

vpColVector & vpColVector::operator= ( const vpRotationVector rv)

Operator that allows to convert a rotation vector into a column vector.

Definition at line 524 of file vpColVector.cpp.

References vpArray2D< double >::data, vpArray2D< Type >::data, vpArray2D< Type >::getRows(), resize(), and vpArray2D< double >::rowNum.

vpColVector & vpColVector::operator= ( const vpTranslationVector tv)

Operator that allows to convert a translation vector into a column vector.

Definition at line 505 of file vpColVector.cpp.

References vpArray2D< double >::data, vpArray2D< Type >::data, vpArray2D< Type >::getRows(), resize(), and vpArray2D< double >::rowNum.

vpColVector & vpColVector::operator= ( const vpMatrix M)

Transform a m-by-1 matrix into a column vector.

Warning
Handled with care; M should be a 1 column matrix.
Exceptions
vpException::dimensionErrorIf the matrix has more than 1 column.

Definition at line 444 of file vpColVector.cpp.

References vpArray2D< double >::data, vpArray2D< Type >::data, vpException::dimensionError, vpArray2D< Type >::getCols(), vpArray2D< Type >::getRows(), resize(), and vpArray2D< double >::rowNum.

vpColVector & vpColVector::operator= ( const std::vector< double > &  v)

Initialize a row vector from a standard vector of double.

Definition at line 467 of file vpColVector.cpp.

References resize().

vpColVector & vpColVector::operator= ( const std::vector< float > &  v)

Initialize a row vector from a standard vector of double.

Definition at line 477 of file vpColVector.cpp.

References resize().

vpColVector & vpColVector::operator= ( double  x)

Set each element of the column vector to x.

Definition at line 621 of file vpColVector.cpp.

References vpArray2D< double >::data, and vpArray2D< double >::rowNum.

double& vpColVector::operator[] ( unsigned int  n)
inline

Operator that allows to set a value of an element $v_i$: v[i] = x.

Definition at line 165 of file vpColVector.h.

References vpArray2D< double >::data.

const double& vpColVector::operator[] ( unsigned int  n) const
inline

Operator that allows to get the value of an element $v_i$: x = v[i].

Definition at line 167 of file vpColVector.h.

References vpArray2D< double >::data.

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

Pretty print a column vector. 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 vector 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 vector. Can be set to zero (or omitted), in which case the introduction is not printed.
Returns
Returns the common total width for all vector elements.
See also
std::ostream &operator<<(std::ostream &s, const vpArray2D<Type> &A)
Examples:
servoSimu3D_cdMc_CamVelocity.cpp, servoSimu3D_cMcd_CamVelocity.cpp, testColVector.cpp, and testTwistMatrix.cpp.

Definition at line 1135 of file vpColVector.cpp.

References vpArray2D< double >::getRows(), and vpMath::maximum().

void vpColVector::rad2deg ( )
inline

Convert a column vector containing angles in radians into degrees.

See also
deg2rad()

Definition at line 202 of file vpColVector.h.

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

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

Reshape the column vector 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 1057 of file vpColVector.cpp.

References vpArray2D< double >::data, vpException::dimensionError, vpArray2D< double >::dsize, vpArray2D< Type >::getCols(), vpArray2D< Type >::getRows(), vpArray2D< Type >::resize(), and vpArray2D< double >::rowNum.

Referenced by reshape().

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

Reshape the column vector in a matrix.

Parameters
nrows: number of rows of the matrix
ncols: number of columns of the matrix
Returns
The reshaped matrix.

Definition at line 1045 of file vpColVector.cpp.

References reshape().

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

Modify the size of the column vector.

Parameters
i: Size of the vector. This value corresponds to the vector number of rows.
flagNullify: If true, set the data to zero.
Exceptions
vpException::fatalErrorWhen ncols is not equal to 1.
Examples:
servoAfma4Point2DCamVelocityKalman.cpp, servoViper850Point2DCamVelocityKalman.cpp, testColVector.cpp, and testSvd.cpp.

Definition at line 217 of file vpColVector.h.

References vpArray2D< Type >::resize().

Referenced by vpMatrix::add2Matrices(), vpPoint::changeFrame(), vpLine::changeFrame(), vpRobotAfma6::checkJointLimits(), vpServo::computeError(), vpMbTracker::computeJTR(), vpMbEdgeKltTracker::computeVVS(), vpMbKltTracker::computeVVS(), vpMbEdgeTracker::computeVVS(), vpFeatureMoment::duplicate(), 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(), vpSimulatorCamera::getPosition(), vpRobotCamera::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(), vpPoint::getWorldCoordinates(), vpCircle::init(), vpSphere::init(), vpFeatureEllipse::init(), vpFeatureVanishingPoint::init(), vpMeTracker::init(), vpFeatureLuminance::init(), vpPoint::init(), vpLine::init(), vpKalmanFilter::init(), vpRobotBiclops::init(), vpFeatureSegment::init(), init(), vpTemplateTrackerTriangle::init(), vpFeatureDepth::init(), vpCylinder::init(), vpFeaturePoint::init(), vpFeatureMoment::init(), vpFeatureLine::init(), vpImageSimulator::init(), vpFeaturePoint3D::init(), vpFeatureThetaU::init(), vpRobotAfma4::init(), vpSimulatorAfma6::init(), vpFeaturePointPolar::init(), vpSimulatorViper850::init(), vpFeatureTranslation::init(), vpRobotAfma6::init(), vpRobotViper650::init(), vpRobotViper850::init(), vpTemplateTrackerMIESM::initCompInverse(), vpTemplateTrackerZNCCInverseCompositional::initHessienDesired(), vpMbtDistanceCircle::initInteractionMatrixError(), vpMbtDistanceLine::initInteractionMatrixError(), vpMbtDistanceCylinder::initInteractionMatrixError(), vpMatrix::multMatrixVector(), operator-(), vpSubColVector::operator=(), operator=(), vpPose::poseDementhonNonPlan(), vpPose::poseVirtualVSrobust(), vpPoint::projection(), vpLine::projection(), vpMatrix::pseudoInverse(), vpSimulatorAfma6::readPosFile(), vpSimulatorViper850::readPosFile(), vpRobotAfma4::readPosFile(), vpRobotAfma6::readPosFile(), vpRobotViper850::readPosFile(), vpRobotViper650::readPosFile(), vpRobotPtu46::readPositionFile(), vpRobotBiclops::readPositionFile(), vpRobust::resize(), stack(), vpMatrix::stackColumns(), vpMatrix::sub2Matrices(), vpMatrix::svd(), vpMbEdgeKltTracker::trackFirstLoop(), vpFeatureMoment::update(), vpGenericFeature::vpGenericFeature(), vpImageSimulator::vpImageSimulator(), vpRobotWireFrameSimulator::vpRobotWireFrameSimulator(), vpRobust::vpRobust(), vpSickLDMRS::vpSickLDMRS(), vpTemplateTracker::vpTemplateTracker(), vpTemplateTrackerMI::vpTemplateTrackerMI(), vpTemplateTrackerSSD::vpTemplateTrackerSSD(), vpTemplateTrackerSSDESM::vpTemplateTrackerSSDESM(), vpTemplateTrackerZNCC::vpTemplateTrackerZNCC(), and vpViper::vpViper().

void vpColVector::resize ( const unsigned int  nrows,
const unsigned int  ncols,
const bool  flagNullify 
)
inline

Resize the column vector to a nrows-dimension vector. This function can only be used with ncols = 1.

Parameters
nrows: Vector number of rows. This value corresponds to the size of the vector.
ncols: Vector number of columns. This value should be set to 1.
flagNullify: If true, set the data to zero.
Exceptions
vpException::fatalErrorWhen ncols is not equal to 1.

Definition at line 231 of file vpColVector.h.

References vpException::fatalError, and vpArray2D< Type >::resize().

vp_deprecated vpColVector vpColVector::rows ( unsigned int  first_row,
unsigned int  last_row 
) const
inline
Deprecated:
You should rather use extract().

Definition at line 290 of file vpColVector.h.

static bool vpArray2D< double >::save ( const std::string &  filename,
const vpArray2D< double > &  A,
const bool  binary = false,
const char *  header = "" 
)
inlinestaticinherited

Save a matrix to a file.

Parameters
filename: Absolute file name.
A: Array 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 success.

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

See also
load()

Definition at line 468 of file vpArray2D.h.

References vpArray2D< Type >::getCols(), and vpArray2D< Type >::getRows().

static bool vpArray2D< double >::saveYAML ( const std::string &  filename,
const vpArray2D< double > &  A,
const char *  header = "" 
)
inlinestaticinherited

Save an array in a YAML-formatted file.

Parameters
filename: absolute file name.
A: array 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.

vpArray2D::saveYAML("matrix.yml", M, "example: a YAML-formatted header");
vpArray2D::saveYAML("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
loadYAML()

Definition at line 560 of file vpArray2D.h.

References vpArray2D< Type >::getCols(), and vpArray2D< Type >::getRows().

vp_deprecated void vpColVector::setIdentity ( const double &  val = 1.0)
Deprecated:
You should rather use eye()
unsigned int vpArray2D< double >::size ( ) const
inlineinherited
vpMatrix vpColVector::skew ( const vpColVector v)
static

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 1001 of file vpColVector.cpp.

References vpException::dimensionError, vpArray2D< Type >::getRows(), and vpArray2D< Type >::resize().

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

vpColVector vpColVector::sort ( const vpColVector v)
static

Return a column vector with elements of v that are sorted.

See also
invSort()
Examples:
testSvd.cpp.

Definition at line 777 of file vpColVector.cpp.

References vpArray2D< Type >::data, vpException::fatalError, and vpArray2D< Type >::getRows().

void vpColVector::stack ( const vpColVector v)

Stack column vectors.

Parameters
v: Vector to stack to the existing one.
vpColVector v1(3, 1);
// v1 is equal to [1 1 1]^T
vpColVector v2(2, 3);
// v2 is equal to [3 3]^T
v1.stack(v2);
// v1 is equal to [1 1 1 3 3]^T
See also
stack(const vpColVector &, const double &)
stack(const vpColVector &, const vpColVector &)
stack(const vpColVector &, const vpColVector &, vpColVector &)

Definition at line 847 of file vpColVector.cpp.

References stack().

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

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 870 of file vpColVector.cpp.

References stack().

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

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 895 of file vpColVector.cpp.

References vpArray2D< Type >::getRows(), and resize().

vp_deprecated void vpColVector::stackMatrices ( const vpColVector r)
inline
Deprecated:
You should rather use stack(const vpColVector &)

Definition at line 301 of file vpColVector.h.

References vpMatrix::stack().

static vp_deprecated vpColVector vpColVector::stackMatrices ( const vpColVector A,
const vpColVector B 
)
inlinestatic
Deprecated:
You should rather use stack(const vpColVector &A, const vpColVector &B)

Definition at line 305 of file vpColVector.h.

References vpMatrix::stack().

static vp_deprecated void vpColVector::stackMatrices ( const vpColVector A,
const vpColVector B,
vpColVector C 
)
inlinestatic
double vpColVector::stdev ( const vpColVector v,
const bool  useBesselCorrection = false 
)
static

Compute the standard deviation value of all the elements of the vector.

Examples:
testColVector.cpp.

Definition at line 965 of file vpColVector.cpp.

References vpArray2D< Type >::data, vpException::fatalError, mean(), and vpArray2D< Type >::size().

vpRowVector vpColVector::transpose ( ) const

Transpose the column vector. The resulting vector becomes a row vector.

See also
t()

Definition at line 644 of file vpColVector.cpp.

References t().

void vpColVector::transpose ( vpRowVector v) const

Transpose the column vector. The resulting vector v becomes a row vector.

See also
t()

Definition at line 653 of file vpColVector.cpp.

References t().

Friends And Related Function Documentation

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

Allows to multiply a scalar by a column vector.

Definition at line 663 of file vpColVector.cpp.

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 57 of file vpGEMM.h.

friend class vpMatrix
friend

Definition at line 74 of file vpColVector.h.

Member Data Documentation

double * vpArray2D< double >::data
inherited

Address of the first element of the data array.

Examples:
testDisplacement.cpp, testMatrix.cpp, testPoseVector.cpp, and testTranslationVector.cpp.

Definition at line 84 of file vpArray2D.h.

Referenced by vpMatrix::AtA(), vpHomogeneousMatrix::buildFrom(), vpRzyxVector::buildFrom(), vpRzyzVector::buildFrom(), vpRxyzVector::buildFrom(), vpThetaUVector::buildFrom(), vpSubColVector::checkParentStatus(), vpSubRowVector::checkParentStatus(), vpSubMatrix::checkParentStatus(), clear(), vpHomogeneousMatrix::convert(), vpTranslationVector::euclideanNorm(), vpRowVector::euclideanNorm(), euclideanNorm(), vpMatrix::euclideanNorm(), vpMatrix::expm(), vpThetaUVector::extract(), vpSubColVector::init(), vpSubRowVector::init(), vpSubMatrix::init(), vpTranslationVector::operator*(), vpRowVector::operator*(), operator*(), vpHomography::operator*(), vpTranslationVector::operator-(), vpRowVector::operator-(), operator-(), vpTranslationVector::operator/(), vpRowVector::operator/(), operator/(), vpHomography::operator/(), vpHomography::operator/=(), vpSubColVector::operator=(), vpSubRowVector::operator=(), vpTranslationVector::operator=(), vpRowVector::operator=(), operator=(), vpRzyxVector::operator=(), vpRzyzVector::operator=(), vpRxyzVector::operator=(), vpMatrix::operator=(), vpThetaUVector::operator=(), operator[](), vpRowVector::reshape(), reshape(), vpQuaternionVector::set(), vpMatrix::stackRows(), vpRotationVector::t(), vpTranslationVector::t(), vpPoseVector::t(), vpRowVector::t(), t(), vpQuaternionVector::w(), vpQuaternionVector::x(), vpQuaternionVector::y(), vpQuaternionVector::z(), vpSubColVector::~vpSubColVector(), vpSubMatrix::~vpSubMatrix(), and vpSubRowVector::~vpSubRowVector().