Visual Servoing Platform  version 3.6.1 under development (2024-11-15)
vpSubColVector Class Reference

#include <visp3/core/vpSubColVector.h>

+ Inheritance diagram for vpSubColVector:

Public Member Functions

 vpSubColVector ()
 
 vpSubColVector (vpColVector &v, const unsigned int &offset, const unsigned int &nrows)
 
virtual ~vpSubColVector () VP_OVERRIDE
 
void checkParentStatus () const
 
void init (vpColVector &v, const unsigned int &offset, const unsigned int &nrows)
 
vpSubColVectoroperator= (const vpSubColVector &B)
 
vpSubColVectoroperator= (const vpPoseVector &p)
 
vpSubColVectoroperator= (const vpRotationVector &rv)
 
vpSubColVectoroperator= (const vpTranslationVector &tv)
 
vpSubColVectoroperator= (const vpColVector &B)
 
vpSubColVectoroperator= (const vpMatrix &B)
 
vpSubColVectoroperator= (const double &x)
 
void clear ()
 
std::ostream & cppPrint (std::ostream &os, const std::string &matrixName="A", bool octet=false) const
 
std::ostream & csvPrint (std::ostream &os) const
 
vpColVectordeg2rad ()
 
vpColVector extract (unsigned int r, unsigned int colsize) const
 
double frobeniusNorm () const
 
vpColVector hadamard (const vpColVector &v) const
 
double infinityNorm () const
 
void init (const vpColVector &v, unsigned int r, unsigned int nrows)
 
void insert (unsigned int i, const vpColVector &v)
 
std::ostream & maplePrint (std::ostream &os) const
 
std::ostream & matlabPrint (std::ostream &os) const
 
vpColVectornormalize ()
 
vpColVectornormalize (vpColVector &x) const
 
double & operator[] (unsigned int n)
 
const double & operator[] (unsigned int n) const
 
bool operator== (const vpColVector &v) const
 
bool operator== (double v) const
 
bool operator!= (const vpColVector &v) const
 
bool operator!= (double v) const
 
double operator* (const vpColVector &v) const
 
vpMatrix operator* (const vpRowVector &v) const
 
vpMatrix operator* (const vpMatrix &M) const
 
vpColVector operator* (double x) const
 
vpColVectoroperator*= (double x)
 
vpColVector operator/ (double x) const
 
vpColVectoroperator/= (double x)
 
vpColVector operator+ (const vpColVector &v) const
 
vpTranslationVector operator+ (const vpTranslationVector &t) const
 
vpColVectoroperator+= (vpColVector v)
 
vpColVector operator- (const vpColVector &v) const
 
vpColVector operator- () const
 
vpColVectoroperator-= (vpColVector v)
 
vpColVectoroperator<< (const vpColVector &v)
 
vpColVectoroperator<< (double *x)
 
vpColVectoroperator<< (double val)
 
vpColVectoroperator, (double val)
 
int print (std::ostream &s, unsigned int length, char const *intro=0) const
 
vpColVectorrad2deg ()
 
void reshape (vpMatrix &M, const unsigned int &nrows, const unsigned int &ncols)
 
vpMatrix reshape (unsigned int nrows, unsigned int ncols)
 
void resize (unsigned int i, bool flagNullify=true)
 
void resize (unsigned int nrows, unsigned int ncols, bool flagNullify)
 
void stack (double d)
 
void stack (const vpColVector &v)
 
double sum () const
 
double sumSquare () const
 
vpRowVector t () const
 
std::vector< double > toStdVector () const
 
vpRowVector transpose () const
 
void transpose (vpRowVector &v) const
 
Inherited functionalities from vpArray2D
vpArray2D< double > hadamard (const vpArray2D< double > &m) const
 
void insert (const vpArray2D< double > &A, unsigned int r, unsigned int c)
 
bool operator== (const vpArray2D< double > &A) const
 
bool operator!= (const vpArray2D< double > &A) const
 
void resize (unsigned int nrows, unsigned int ncols, bool flagNullify=true, bool recopy_=true)
 
unsigned int getCols () const
 
double getMaxValue () const
 
double getMinValue () const
 
unsigned int getRows () const
 
unsigned int size () const
 

Static Public Member Functions

static vpColVector stack (const vpColVector &A, const vpColVector &B)
 
static void stack (const vpColVector &A, const vpColVector &B, vpColVector &C)
 
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 double stdev (const vpColVector &v, bool useBesselCorrection=false)
 

Public Attributes

double * data
 

Protected Attributes

unsigned int m_pRowNum
 
vpColVectorm_parent
 

Related Functions

(Note that these are not member functions.)

bool operator== (const vpArray2D< double > &A) const
 
bool operator== (const vpArray2D< float > &A) const
 
vpColVector operator* (const double &x, const vpColVector &v)
 
enum  vpGEMMmethod
 
void vpGEMM (const vpArray2D< double > &A, const vpArray2D< double > &B, const double &alpha, const vpArray2D< double > &C, const double &beta, vpArray2D< double > &D, const unsigned int &ops=0)
 

Inherited I/O from vpArray2D with Static Public Member Functions

unsigned int rowNum
 
unsigned int colNum
 
double ** rowPtrs
 
unsigned int dsize
 
vpArray2D< double > insert (const vpArray2D< double > &A, const vpArray2D< double > &B, unsigned int r, unsigned int c)
 
static void insert (const vpArray2D< double > &A, const vpArray2D< double > &B, vpArray2D< double > &C, unsigned int r, unsigned int c)
 
static bool load (const std::string &filename, vpArray2D< double > &A, bool binary=false, char *header=nullptr)
 
static bool loadYAML (const std::string &filename, vpArray2D< double > &A, char *header=nullptr)
 
static bool save (const std::string &filename, const vpArray2D< double > &A, bool binary=false, const char *header="")
 
static bool saveYAML (const std::string &filename, const vpArray2D< double > &A, const char *header="")
 
static vpArray2D< double > conv2 (const vpArray2D< double > &M, const vpArray2D< double > &kernel, const std::string &mode)
 
static void conv2 (const vpArray2D< double > &M, const vpArray2D< double > &kernel, vpArray2D< double > &res, const std::string &mode)
 

Detailed Description

This class provides a mask on a vpColVector. It has internally a pointer to the parent vpColVector. All properties of vpColVector are available with a vpSubColVector.

See also
vpMatrix vpColVector vpRowVector

Definition at line 57 of file vpSubColVector.h.

Constructor & Destructor Documentation

◆ vpSubColVector() [1/2]

BEGIN_VISP_NAMESPACE vpSubColVector::vpSubColVector ( )

Default constructor that creates an empty vector.

Definition at line 41 of file vpSubColVector.cpp.

◆ vpSubColVector() [2/2]

vpSubColVector::vpSubColVector ( vpColVector v,
const unsigned int &  offset,
const unsigned int &  nrows 
)

Construct a sub-column vector from a parent column vector.

Parameters
v: parent column vector.
offset: offset where the sub-column vector starts in the parent column vector.
nrows: size of the sub-column vector.

Definition at line 49 of file vpSubColVector.cpp.

References init().

◆ ~vpSubColVector()

vpSubColVector::~vpSubColVector ( )
virtual

Destructor that set the pointer to the parent column vector to nullptr.

Definition at line 98 of file vpSubColVector.cpp.

References vpArray2D< double >::data.

Member Function Documentation

◆ checkParentStatus()

void vpSubColVector::checkParentStatus ( ) const

This method can be used to detect if the parent column vector always exits or its size have not changed. If this not the case an exception is thrown.

Definition at line 105 of file vpSubColVector.cpp.

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

◆ clear()

void vpColVector::clear ( )
inlineinherited

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

Examples
testColVector.cpp.

Definition at line 290 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().

◆ conv2() [1/2]

vpArray2D< double > vpArray2D< double >::conv2 ( const vpArray2D< Type > &  M,
const vpArray2D< Type > &  kernel,
const std::string &  mode 
)
staticinherited

Perform a 2D convolution similar to Matlab conv2 function: $ M \star kernel $.

Parameters
M: First matrix.
kernel: Second matrix.
mode: Convolution mode: "full" (default), "same", "valid".
Convolution mode: full, same, valid (image credit: Theano doc).
Note
This is a very basic implementation that does not use FFT.

Definition at line 1053 of file vpArray2D.h.

◆ conv2() [2/2]

void vpArray2D< double >::conv2 ( const vpArray2D< Type > &  M,
const vpArray2D< Type > &  kernel,
vpArray2D< Type > &  res,
const std::string &  mode 
)
staticinherited

Perform a 2D convolution similar to Matlab conv2 function: $ M \star kernel $.

Parameters
M: First array.
kernel: Second array.
res: Result.
mode: Convolution mode: "full" (default), "same", "valid".
Convolution mode: full, same, valid (image credit: Theano doc).
Note
This is a very basic implementation that does not use FFT.

Definition at line 1067 of file vpArray2D.h.

◆ cppPrint()

std::ostream & vpColVector::cppPrint ( std::ostream &  os,
const std::string &  matrixName = "A",
bool  octet = false 
) const
inherited

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

Parameters
os: the stream to be printed in.
matrixName: name of the column vector, "A" by default.
octet: if false, print using double, if true, print byte per byte each bytes of the double array.

The following code shows how to use this function:

#include <visp3/core/vpColVector.h>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
int main()
{
for (unsigned int i=0; i<v.size(); ++i)
v[i] = i;
v.cppPrint(std::cout, "v");
}
Implementation of column vector and the associated operations.
Definition: vpColVector.h:191

It produces the following output that could be copy/paste in a C++ code:

v[0] = 0;
v[1] = 1;
v[2] = 2;
See also
print(), matlabPrint(), maplePrint()

Definition at line 953 of file vpColVector.cpp.

References vpArray2D< double >::getRows().

◆ cross()

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

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.
See also
crossProd(), dotProd(), operator*(const vpColVector &)

Definition at line 1259 of file vpColVector.h.

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

◆ crossProd()

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

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

Parameters
[in]a: 3-dimension column vector.
[in]b: 3-dimension column vector.
Returns
The cross product $a \times b$.
Exceptions
vpException::dimensionErrorIf the vectors dimension is not equal to 3.
See also
dotProd()

Definition at line 755 of file vpColVector.cpp.

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

Referenced by vpMbTracker::addPolygon(), vpMbTracker::addProjectionErrorPolygon(), vpPose::coplanar(), vpMbTracker::createCylinderBBox(), vpMath::lookAt(), vpThetaUVector::operator*(), vpPose::poseLagrangePlan(), and vpImageSimulator::setCameraPosition().

◆ csvPrint()

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

Print/save a column vector in csv format.

The following code

#include <visp3/core/vpColVector.h>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
int main()
{
std::ofstream ofs("log.csv", std::ofstream::out);
for (unsigned int i=0; i<v.size(); ++i)
v[i] = i;
v.csvPrint(ofs);
ofs.close();
}

produces log.csv file that contains:

0
1
2

Definition at line 974 of file vpColVector.cpp.

References vpArray2D< double >::getRows().

◆ deg2rad()

vpColVector& vpColVector::deg2rad ( )
inlineinherited

Converts a column vector containing angles in degrees into radians and returns a reference to the vector.

Returns
A reference to the vector with values expressed in [rad].
See also
rad2deg()

Definition at line 380 of file vpColVector.h.

Referenced by vpRobotViper650::getPosition(), vpRobotViper850::getPosition(), vpRobotViper650::getVelocity(), vpRobotViper850::getVelocity(), vpRobotViper650::init(), vpRobotViper850::init(), vpRobotViper650::readPosFile(), vpRobotViper850::readPosFile(), vpRobotBiclops::readPositionFile(), vpRobotPtu46::readPositionFile(), vpRobotViper650::setPosition(), and vpRobotViper850::setPosition().

◆ dotProd()

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

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.
See also
cross(), crossProd()

Definition at line 538 of file vpColVector.cpp.

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

Referenced by vpMbtFaceDepthNormal::computeNormalVisibility(), vpMbtPolygon::isVisible(), vpThetaUVector::operator*(), and vpImageSimulator::setCameraPosition().

◆ extract()

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

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
vpColVector extract(unsigned int r, unsigned int colsize) const
Definition: vpColVector.h:405
void stack(double d)
Examples
catchLuminanceMapping.cpp, catchRotation.cpp, testColVector.cpp, testForceTorqueAti.cpp, testForceTorqueAtiNetFTSensor.cpp, and testForceTorqueIitSensor.cpp.

Definition at line 405 of file vpColVector.h.

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

Referenced by vpLinProg::colReduction(), vpRobotUniversalRobots::setPosition(), vpLinProg::simplex(), vpLinProg::solveLP(), and vpQuadProg::solveQPi().

◆ frobeniusNorm()

double vpColVector::frobeniusNorm ( ) const
inherited

Compute and return the Frobenius norm $ ||v|| = \sqrt{ \sum_{v_{i}^2}} $ of all the elements $v_{i}$ of the column vector $ \bf v $ that is of dimension $ m $.

Returns
The Frobenius norm if the vector is initialized, 0 otherwise.
See also
infinityNorm()
Examples
testSvd.cpp, tutorial-pf.cpp, ukf-linear-example.cpp, ukf-nonlinear-complex-example.cpp, and ukf-nonlinear-example.cpp.

Definition at line 916 of file vpColVector.cpp.

References vpColVector::sumSquare().

Referenced by vpServo::computeProjectionOperators(), vpMbTracker::createCylinderBBox(), and vpMbtFaceDepthNormal::planeIsInvalid().

◆ getCols()

◆ getMaxValue()

double vpArray2D< double >::getMaxValue
inherited

Return the array max value.

Examples
servoMomentImage.cpp.

Definition at line 339 of file vpArray2D.h.

◆ getMinValue()

double vpArray2D< double >::getMinValue
inherited

Return the array min value.

Examples
servoMomentImage.cpp.

Definition at line 341 of file vpArray2D.h.

◆ getRows()

◆ hadamard() [1/2]

vpArray2D< double > vpArray2D< double >::hadamard ( const vpArray2D< Type > &  m) const
inherited

Compute the Hadamard product (element wise matrix multiplication).

Parameters
m: Second matrix;
Returns
m1.hadamard(m2) The Hadamard product : $ m1 \circ m2 = (m1 \circ m2)_{i,j} = (m1)_{i,j} (m2)_{i,j} $

Definition at line 641 of file vpArray2D.h.

◆ hadamard() [2/2]

vpColVector vpColVector::hadamard ( const vpColVector v) const
inherited

◆ infinityNorm()

double vpColVector::infinityNorm ( ) const
inherited

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

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

Definition at line 941 of file vpColVector.cpp.

References vpArray2D< double >::rowNum.

Referenced by vpLinProg::colReduction(), vpAdaptiveGain::operator()(), and vpLinProg::rowReduction().

◆ init() [1/2]

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

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 construct.
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 constructed column vector.

The following code shows how to use this function:

#include <visp3/core/vpColVector.h>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
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;
}
void init(const vpColVector &v, unsigned int r, unsigned int nrows)
vpRowVector t() const

It produces the following output:

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

Definition at line 182 of file vpColVector.cpp.

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

Referenced by vpColVector::vpColVector().

◆ init() [2/2]

void vpSubColVector::init ( vpColVector v,
const unsigned int &  offset,
const unsigned int &  nrows 
)

Initialize a sub-column vector from a parent column vector.

Parameters
v: parent column vector.
offset: offset where the sub-column vector starts in the parent column vector.
nrows: size of the sub-column vector.

Definition at line 61 of file vpSubColVector.cpp.

References vpArray2D< double >::colNum, vpArray2D< double >::data, vpArray2D< Type >::data, vpException::dimensionError, vpArray2D< double >::dsize, vpException::fatalError, vpArray2D< Type >::getRows(), m_parent, m_pRowNum, vpArray2D< double >::rowNum, and vpArray2D< double >::rowPtrs.

Referenced by vpSubColVector().

◆ insert() [1/3]

vpArray2D< double > vpArray2D< double >::insert ( const vpArray2D< Type > &  A,
const vpArray2D< Type > &  B,
unsigned int  r,
unsigned int  c 
)
inherited

Insert array B in array A at the given position.

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

Definition at line 1081 of file vpArray2D.h.

◆ insert() [2/3]

void vpArray2D< double >::insert ( const vpArray2D< Type > &  A,
unsigned int  r,
unsigned int  c 
)
inlineinherited

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

Warning
Throw vpException::dimensionError if the dimensions of the matrices do not allow the operation.
Parameters
A: The array 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 497 of file vpArray2D.h.

◆ insert() [3/3]

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 <visp3/core/vpColVector.h>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
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
Examples
testColVector.cpp, and testVirtuoseAfma6.cpp.

Definition at line 791 of file vpColVector.cpp.

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

Referenced by vpMbDepthDenseTracker::computeVVSInteractionMatrixAndResidu(), vpMbDepthNormalTracker::computeVVSInteractionMatrixAndResidu(), vpMbGenericTracker::computeVVSInteractionMatrixAndResidu(), vpMbEdgeTracker::computeVVSWeights(), and vpMbGenericTracker::computeVVSWeights().

◆ invSort()

vpColVector vpColVector::invSort ( const vpColVector v)
staticinherited

Return a column vector with elements of v that are reverse sorted with values going from greatest to lowest.

Example:

#include <visp3/core/vpColVector.h>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
int main()
{
vpColVector v(10);
v[0] = 5; v[1] = 7; v[2] = 4; v[3] = 2; v[4] = 8;
v[5] = 6; v[6] = 1; v[7] = 9; v[8] = 0; v[9] = 3;
std::cout << "v: " << v.t() << std::endl;
std::cout << "s: " << s.t() << std::endl;
}
static vpColVector invSort(const vpColVector &v)

Output:

v: 5 7 4 2 8 6 1 9 0 3
s: 9 8 7 6 5 4 3 2 1 0
See also
sort()

Definition at line 586 of file vpColVector.cpp.

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

◆ load()

static bool vpArray2D< double >::load ( const std::string &  filename,
vpArray2D< Type > &  A,
bool  binary = false,
char *  header = nullptr 
)
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 669 of file vpArray2D.h.

◆ loadYAML()

static bool vpArray2D< double >::loadYAML ( const std::string &  filename,
vpArray2D< Type > &  A,
char *  header = nullptr 
)
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()
Examples
servoFlirPtuIBVS.cpp, servoFrankaIBVS.cpp, servoFrankaPBVS.cpp, servoUniversalRobotsIBVS.cpp, servoUniversalRobotsPBVS.cpp, tutorial-flir-ptu-ibvs.cpp, tutorial-hsv-segmentation-pcl-viewer.cpp, tutorial-hsv-segmentation-pcl.cpp, and tutorial-hsv-segmentation.cpp.

Definition at line 783 of file vpArray2D.h.

◆ maplePrint()

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

Print using Maple syntax, to copy/paste in Maple later.

The following code

#include <visp3/core/vpColVector.h>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
int main()
{
for (unsigned int i=0; i<v.size(); ++i)
v[i] = i;
std::cout << "v = "; v.maplePrint(std::cout);
}

produces this output:

v = ([
[0, ],
[1, ],
[2, ],
])

that could be copy/paste in Maple.

See also
print() matlabPrint(), cppPrint()

Definition at line 985 of file vpColVector.cpp.

References vpArray2D< double >::getRows().

◆ matlabPrint()

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

Print using Matlab syntax, to copy/paste in Matlab later.

The following code

#include <visp3/core/vpColVector.h>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
int main()
{
for (unsigned int i=0; i<v.size(); ++i)
v[i] = i;
std::cout << "v = "; v.matlabPrint(std::cout);
}

produces this output:

v = [ 0, ;
1, ;
2, ]

that could be copy/paste in Matlab:

>> v = [ 0, ;
1, ;
2, ]
v =
0
1
2
>>
See also
print(), cppPrint(), maplePrint()

Definition at line 998 of file vpColVector.cpp.

References vpArray2D< double >::getRows().

◆ mean()

double vpColVector::mean ( const vpColVector v)
staticinherited

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

Examples
testColVector.cpp.

Definition at line 683 of file vpColVector.cpp.

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

◆ median()

double vpColVector::median ( const vpColVector v)
staticinherited

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

Examples
testColVector.cpp.

Definition at line 695 of file vpColVector.cpp.

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

◆ normalize() [1/2]

vpColVector & vpColVector::normalize ( )
inherited

Normalize the column vector.

Considering the n-dim column vector $ {\bf x} = (x_0, x_1, \ldots, n_{n-1})$ normalize each vector element $ i $:

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

Returns
A reference to the normalized vector.
Examples
catchQuaternion.cpp, testColVector.cpp, and testVirtuoseHapticBox.cpp.

Definition at line 574 of file vpColVector.cpp.

References vpColVector::sumSquare().

Referenced by vpCameraParameters::computeFov(), vpMbtFaceDepthNormal::computeNormalVisibility(), vpMbTracker::createCylinderBBox(), vpMbtPolygon::isVisible(), and vpMath::lookAt().

◆ normalize() [2/2]

vpColVector & vpColVector::normalize ( vpColVector x) const
inherited

Normalize a column vector.

Considering the n-dim column vector $ {\bf x} = (x_0, x_1, \ldots, n_{n-1})$ normalize each vector element $ i $:

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

Parameters
[in,out]x: As input, the vector to normalize, as output the normalized vector.
Returns
A reference to the normalized vector.

Definition at line 567 of file vpColVector.cpp.

References vpColVector::sumSquare().

◆ operator!=() [1/3]

bool operator!= ( const vpArray2D< Type > &  A) const
inherited

Not equal to comparison operator of a 2D array.

Definition at line 523 of file vpArray2D.h.

◆ operator!=() [2/3]

bool vpColVector::operator!= ( const vpColVector v) const
inherited

Compare two column vectors.

Parameters
v: Vector to compare with.
Returns
true when their respective size or their values differ, false when their size and values are the same.

Definition at line 523 of file vpColVector.cpp.

◆ operator!=() [3/3]

bool vpColVector::operator!= ( double  v) const
inherited

Compare a column vector to a floating point value.

Parameters
v: Floating point value to compare with.
Returns
true when at least one value of the vector differ from the floating point value v. false when all the vector values are equal to v.

Definition at line 525 of file vpColVector.cpp.

◆ operator*() [1/4]

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

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< Type >::size(), and vpArray2D< double >::size().

◆ operator*() [2/4]

vpMatrix vpColVector::operator* ( const vpMatrix M) const
inherited

Multiply a column vector by a matrix.

Parameters
M: Matrix.
Returns
The resulting matrix.

Definition at line 144 of file vpColVector.cpp.

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

◆ operator*() [3/4]

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

Multiply a column vector by a row vector.

Parameters
v: Row vector.
Returns
The resulting matrix.

Definition at line 132 of file vpColVector.cpp.

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

◆ operator*() [4/4]

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

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

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

◆ operator*=()

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

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

References vpArray2D< double >::rowNum.

◆ operator+() [1/2]

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

Operator that allows to add two column vectors.

Definition at line 60 of file vpColVector.cpp.

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

◆ operator+() [2/2]

vpTranslationVector vpColVector::operator+ ( const vpTranslationVector t) const
inherited

Operator that allows to add a column vector to a translation vector.

Parameters
t: 3-dimension translation vector to add.
Returns
The sum of the current column vector (*this) and the translation vector to add.
v[0] = 4;
v[1] = 5;
v[2] = 6;
t2 = v + t1;
// t1 and v leave unchanged
// t2 is now equal to : 5, 7, 9
Class that consider the case of a translation vector.

Definition at line 74 of file vpColVector.cpp.

References vpException::dimensionError, vpArray2D< double >::getRows(), and vpColVector::t().

◆ operator+=()

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

Operator that allows to add two column vectors.

Definition at line 90 of file vpColVector.cpp.

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

◆ operator,()

vpColVector & vpColVector::operator, ( double  val)
inherited

This operator could be used to set column vector elements:

#include <visp3/code/vpColVector.h
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
int main()
{
vpColVector v;
v << -1, -2.1, -3;
std::cout << "v:" << v << std::endl;
}

It produces the following printings:

v: -1 -2.1 -3
See also
operator<<()

Definition at line 438 of file vpColVector.cpp.

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

◆ operator-() [1/2]

vpColVector vpColVector::operator- ( void  ) const
inherited

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

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

◆ operator-() [2/2]

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

Operator subtraction of two vectors this = this - v

Definition at line 161 of file vpColVector.cpp.

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

◆ operator-=()

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

Operator that allows to subtract two column vectors.

Definition at line 103 of file vpColVector.cpp.

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

◆ operator/()

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

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

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

◆ operator/=()

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

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

References vpArray2D< double >::rowNum.

◆ operator<<() [1/3]

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

Copy operator. Allows operation such as A << v

#include <visp3/core/vpColVector.h>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
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 415 of file vpColVector.cpp.

◆ operator<<() [2/3]

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

Assignment operator. Allow operation such as A = *v

The following example shows how to use this operator.

#include <visp3/core/vpColVector.h>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
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 421 of file vpColVector.cpp.

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

◆ operator<<() [3/3]

vpColVector & vpColVector::operator<< ( double  val)
inherited

This operator could be used to set column vector elements:

#include <visp3/code/vpColVector.h
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
int main()
{
vpColVector v;
v << -1, -2.1, -3;
std::cout << "v:" << v << std::endl;
}

It produces the following printings:

v: -1 -2.1 -3
See also
operator,()

Definition at line 431 of file vpColVector.cpp.

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

◆ operator=() [1/7]

vpSubColVector & vpSubColVector::operator= ( const double &  x)

Set all the elements of the sub-column vector to x.

Parameters
x: a scalar value.

Definition at line 182 of file vpSubColVector.cpp.

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

◆ operator=() [2/7]

vpSubColVector & vpSubColVector::operator= ( const vpColVector B)

Allow to initialize a sub-column vector from a column vector using operation A = B. Notice that the sub-column vector is not resized to the dimension of B.

Parameters
B: a column vector.

Definition at line 142 of file vpSubColVector.cpp.

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

◆ operator=() [3/7]

vpSubColVector & vpSubColVector::operator= ( const vpMatrix B)

Allow to initialize a sub-column vector from a m-by-1 matrix using operation A = B. Notice that the sub-column vector is not resized to the dimension of B.

Parameters
B: a matrix of size m-by-1.

Definition at line 164 of file vpSubColVector.cpp.

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

◆ operator=() [4/7]

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

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

Definition at line 231 of file vpSubColVector.cpp.

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

◆ operator=() [5/7]

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

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

Definition at line 212 of file vpSubColVector.cpp.

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

◆ operator=() [6/7]

vpSubColVector & vpSubColVector::operator= ( const vpSubColVector B)

Allow to initialize a sub-column vector from an other one using operation A = B. Notice that the sub-column vector is not resized to the dimension of B.

Parameters
B: a sub-column vector.

Definition at line 121 of file vpSubColVector.cpp.

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

◆ operator=() [7/7]

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

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

Definition at line 193 of file vpSubColVector.cpp.

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

◆ operator==() [1/3]

bool vpArray2D< double >::operator== ( const vpArray2D< Type > &  A) const
inherited

Equal to comparison operator of a 2D array.

Definition at line 519 of file vpArray2D.h.

◆ operator==() [2/3]

bool vpColVector::operator== ( const vpColVector v) const
inherited

Compare two column vectors.

Parameters
v: Vector to compare with.
Returns
true when their respective size and their respective values are the same, false when their size or values differ.

Definition at line 497 of file vpColVector.cpp.

References vpArray2D< Type >::colNum, vpArray2D< double >::colNum, vpArray2D< Type >::data, vpArray2D< double >::data, vpMath::equal(), vpArray2D< Type >::rowNum, and vpArray2D< double >::rowNum.

◆ operator==() [3/3]

bool vpColVector::operator== ( double  v) const
inherited

Compare a column vector to a floating point value.

Parameters
v: Floating point value to compare with.
Returns
true when all the values of the vector are equal to the floating point value v, false otherwise.

Definition at line 512 of file vpColVector.cpp.

References vpArray2D< double >::data, vpMath::equal(), and vpArray2D< double >::rowNum.

◆ operator[]() [1/2]

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

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

Definition at line 635 of file vpColVector.h.

References vpArray2D< double >::data.

◆ operator[]() [2/2]

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

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

Definition at line 640 of file vpColVector.h.

References vpArray2D< double >::data.

◆ print()

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

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 accommodate 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
testColVector.cpp, and testTwistMatrix.cpp.

Definition at line 802 of file vpColVector.cpp.

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

◆ rad2deg()

vpColVector& vpColVector::rad2deg ( )
inlineinherited

Converts a column vector containing angles in radians into degrees and returns a reference to the vector.

Returns
A reference to the vector with values expressed in [deg].
See also
deg2rad()
Examples
testUniversalRobotsGetData.cpp.

Definition at line 1053 of file vpColVector.h.

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

◆ reshape() [1/2]

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

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.
See also
reshape(vpMatrix &, const unsigned int &, const unsigned int &)

Definition at line 767 of file vpColVector.cpp.

References vpColVector::reshape().

◆ reshape() [2/2]

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

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.
Exceptions
vpException::dimensionErrorIf the matrix and the column vector have not the same size.

The following example shows how to use this method.

#include <visp3/core/vpColVector.h>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
int main()
{
int var=0;
vpMatrix mat(3, 4);
for (int i = 0; i < 3; ++i)
for (int j = 0; j < 4; ++j)
mat[i][j] = ++var;
std::cout << "mat: \n" << mat << std::endl;
vpColVector col = mat.stackColumns();
std::cout << "column vector: \n" << col << std::endl;
vpMatrix remat = col.reshape(3, 4);
std::cout << "remat: \n" << remat << std::endl;
}
void reshape(vpMatrix &M, const unsigned int &nrows, const unsigned int &ncols)
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:169

If you run the previous example, you get:

mat:
1 2 3 4
5 6 7 8
9 10 11 12
column vector:
1
5
9
2
6
10
3
7
11
4
8
12
remat:
1 2 3 4
5 6 7 8
9 10 11 12
Examples
testMatrixInitialization.cpp.

Definition at line 774 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 vpColVector::reshape().

◆ resize() [1/3]

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

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
ClassUsingPclViewer.cpp, catchJsonArrayConversion.cpp, perfMatrixMultiplication.cpp, servoAfma4Point2DCamVelocityKalman.cpp, servoViper850Point2DCamVelocityKalman.cpp, testColVector.cpp, and testRealSense2_T265_images_odometry_async.cpp.

Definition at line 1143 of file vpColVector.h.

References vpArray2D< Type >::resize().

Referenced by vpMatrix::add2Matrices(), vpCylinder::changeFrame(), vpLine::changeFrame(), vpPoint::changeFrame(), vpSphere::changeFrame(), vpCircle::changeFrame(), vpRobotAfma6::checkJointLimits(), vpLinProg::colReduction(), vpMbtFaceDepthNormal::computeDesiredFeaturesPCL(), vpMbtFaceDepthNormal::computeDesiredFeaturesSVD(), vpServo::computeError(), vpMbtFaceDepthNormal::computeInteractionMatrix(), vpMbtFaceDepthDense::computeInteractionMatrixAndResidu(), vpMbTracker::computeJTR(), vpMbtFaceDepthNormal::computeNormalVisibility(), vpPose::computeResidual(), vpMbDepthDenseTracker::computeVVSInit(), vpMbDepthNormalTracker::computeVVSInit(), vpMbEdgeTracker::computeVVSInit(), vpMbGenericTracker::computeVVSInit(), vpMatrix::cond(), vpFeatureMoment::duplicate(), VISP_NAMESPACE_NAME::eigen2visp(), vpMatrix::eigenValues(), vpFeatureLuminance::error(), vpFeatureLuminanceMapping::error(), vpMbtFaceDepthNormal::estimateFeatures(), vpMbtFaceDepthNormal::estimatePlaneEquationSVD(), vpThetaUVector::extract(), vpRobotFranka::getCoriolis(), vpQbSoftHand::getCurrent(), vpRobotAfma4::getDisplacement(), vpRobotAfma6::getDisplacement(), vpRobotViper650::getDisplacement(), vpRobotViper850::getDisplacement(), vpRobotFranka::getForceTorque(), vpRobotViper650::getForceTorque(), vpRobotViper850::getForceTorque(), vpRobotFranka::getGravity(), vpOccipitalStructure::getIMUAcceleration(), vpOccipitalStructure::getIMUData(), vpOccipitalStructure::getIMUVelocity(), vpAfma6::getInverseKinematics(), vpViper::getInverseKinematicsWrist(), vpRobotFlirPtu::getJointPosition(), vpRobotKinova::getJointPosition(), vpPlane::getNormal(), vpTemplateTrackerWarpHomography::getParam(), vpRobotFranka::getPosition(), vpRobotKinova::getPosition(), vpRobotUniversalRobots::getPosition(), vpRobotAfma4::getPosition(), vpRobotAfma6::getPosition(), vpRobotViper650::getPosition(), vpRobotViper850::getPosition(), vpRobotBiclops::getPosition(), vpRobotPololuPtu::getPosition(), vpRobotPtu46::getPosition(), vpSimulatorCamera::getPosition(), vpSimulatorPioneer::getPosition(), vpSimulatorPioneerPan::getPosition(), vpQbSoftHand::getPosition(), vpLuminanceDCT::vpMatrixZigZagIndex::getValues(), vpRobotFranka::getVelocity(), vpRobotBiclops::getVelocity(), vpRobotPtu46::getVelocity(), vpRobotPioneer::getVelocity(), vpRobotAfma4::getVelocity(), vpRobotAfma6::getVelocity(), vpRobotViper650::getVelocity(), vpRobotViper850::getVelocity(), vpPoint::getWorldCoordinates(), vpColVector::hadamard(), vpLuminanceMapping::imageAsVector(), vpMeTracker::init(), vpCircle::init(), vpCylinder::init(), vpLine::init(), vpPoint::init(), vpSphere::init(), vpRobotBiclops::init(), vpFeatureDepth::init(), vpFeatureEllipse::init(), vpFeatureLine::init(), vpFeaturePoint::init(), vpFeaturePoint3D::init(), vpFeaturePointPolar::init(), vpFeatureSegment::init(), vpFeatureThetaU::init(), vpFeatureTranslation::init(), vpFeatureVanishingPoint::init(), vpFeatureLuminanceMapping::init(), vpColVector::init(), vpImageSimulator::init(), vpTemplateTrackerTriangle::init(), vpFeatureLuminance::init(), vpKalmanFilter::init(), vpRobotAfma4::init(), vpRobotAfma6::init(), vpRobotViper650::init(), vpRobotViper850::init(), vpFeatureMoment::init(), vpTemplateTrackerMIESM::initCompInverse(), vpTemplateTrackerZNCCInverseCompositional::initHessienDesired(), vpMbtDistanceCircle::initInteractionMatrixError(), vpMbtDistanceCylinder::initInteractionMatrixError(), vpMbtDistanceLine::initInteractionMatrixError(), vpMatrix::kernel(), vpRobust::MEstimator(), vpMatrix::multMatrixVector(), vpMatrix::nullSpace(), vpColVector::operator,(), vpColVector::operator-(), vpColVector::operator<<(), vpFeatureLuminance::operator=(), vpColVector::operator=(), operator=(), vpPose::poseVirtualVSrobust(), vpPoint::projection(), vpCircle::projection(), vpCylinder::projection(), vpLine::projection(), vpSphere::projection(), vpRobotAfma4::readPosFile(), vpRobotAfma6::readPosFile(), vpRobotFranka::readPosFile(), vpRobotUniversalRobots::readPosFile(), vpRobotViper650::readPosFile(), vpRobotViper850::readPosFile(), vpRobotBiclops::readPositionFile(), vpRobotPtu46::readPositionFile(), vpLinProg::rowReduction(), vpLinProg::simplex(), vpLinProg::solveLP(), vpQuadProg::solveQPi(), vpColVector::stack(), vpMatrix::stackColumns(), vpMatrix::sub2Matrices(), vpMatrix::svdEigen3(), vpMatrix::svdLapack(), vpMatrix::svdOpenCV(), vpFeatureMoment::update(), vpGenericFeature::vpGenericFeature(), vpImageSimulator::vpImageSimulator(), vpMeEllipse::vpMeEllipse(), vpTemplateTracker::vpTemplateTracker(), vpTemplateTrackerMI::vpTemplateTrackerMI(), vpTemplateTrackerSSD::vpTemplateTrackerSSD(), vpTemplateTrackerSSDESM::vpTemplateTrackerSSDESM(), vpTemplateTrackerZNCC::vpTemplateTrackerZNCC(), and vpViper::vpViper().

◆ resize() [2/3]

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

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 1159 of file vpColVector.h.

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

◆ resize() [3/3]

void vpArray2D< double >::resize ( unsigned int  nrows,
unsigned int  ncols,
bool  flagNullify = true,
bool  recopy_ = true 
)
inlineinherited

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

Parameters
nrows: number of rows.
ncols: number of column.
flagNullify: if true, then the array is re-initialized to 0 after resize. If false, the initial values from the common part of the array (common part between old and new version of the array) are kept. Default value is true.
recopy_: if true, will perform an explicit recopy of the old data.
Examples
catchArray2D.cpp, catchJsonArrayConversion.cpp, catchParticleFilter.cpp, perfMatrixMultiplication.cpp, perfMatrixTranspose.cpp, testMatrix.cpp, testMatrixDeterminant.cpp, testMatrixInverse.cpp, testMatrixPseudoInverse.cpp, and testSvd.cpp.

Definition at line 362 of file vpArray2D.h.

◆ save()

static bool vpArray2D< double >::save ( const std::string &  filename,
const vpArray2D< Type > &  A,
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 874 of file vpArray2D.h.

◆ saveYAML()

static bool vpArray2D< double >::saveYAML ( const std::string &  filename,
const vpArray2D< Type > &  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");
static bool saveYAML(const std::string &filename, const vpArray2D< Type > &A, const char *header="")
Definition: vpArray2D.h:972

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]
double * data
Address of the first element of the data array.
Definition: vpArray2D.h:148

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 972 of file vpArray2D.h.

◆ size()

◆ skew()

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, and testVirtuoseHapticBox.cpp.

Definition at line 729 of file vpColVector.cpp.

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

Referenced by vpColVector::crossProd(), and vpFeatureThetaU::interaction().

◆ sort()

vpColVector vpColVector::sort ( const vpColVector v)
staticinherited

Return a column vector with elements of v that are sorted with values going from lowest to greatest.

Example:

#include <visp3/core/vpColVector.h>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
int main()
{
vpColVector v(10);
v[0] = 5; v[1] = 7; v[2] = 4; v[3] = 2; v[4] = 8;
v[5] = 6; v[6] = 1; v[7] = 9; v[8] = 0; v[9] = 3;
std::cout << "v: " << v.t() << std::endl;
std::cout << "s: " << s.t() << std::endl;
}
static vpColVector sort(const vpColVector &v)

Output:

v: 5 7 4 2 8 6 1 9 0 3
s: 0 1 2 3 4 5 6 7 8 9
See also
invSort()

Definition at line 611 of file vpColVector.cpp.

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

◆ stack() [1/4]

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

References vpColVector::stack().

◆ stack() [2/4]

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

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

◆ stack() [3/4]

void vpColVector::stack ( const vpColVector v)
inherited

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

References vpColVector::stack().

◆ stack() [4/4]

◆ stdev()

double vpColVector::stdev ( const vpColVector v,
bool  useBesselCorrection = false 
)
staticinherited

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

Examples
perfColVectorOperations.cpp, and testColVector.cpp.

Definition at line 706 of file vpColVector.cpp.

References vpArray2D< Type >::data, vpException::dimensionError, vpArray2D< Type >::rowNum, vpArray2D< Type >::size(), and vpColVector::sum().

◆ sum()

double vpColVector::sum ( ) const
inherited

Return the sum of all the elements $v_{i}$ of the column vector $ \bf v $ that is of dimension $ m $.

Returns
The value

\[ \sum_{i=0}^{m-1} v_i \]

.
Examples
catchLuminanceMapping.cpp, perfColVectorOperations.cpp, photometricMappingVisualServoing.cpp, tutorial-pf-curve-fitting-all.cpp, and tutorial-pf-curve-fitting-pf.cpp.

Definition at line 890 of file vpColVector.cpp.

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

Referenced by vpLuminancePCA::learn(), vpColVector::mean(), and vpColVector::stdev().

◆ sumSquare()

◆ t()

vpRowVector vpColVector::t ( ) const
inherited

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

Examples
catchEigenConversion.cpp, movePtu46.cpp, servoAfma6Cylinder2DCamVelocity.cpp, servoAfma6Cylinder2DCamVelocitySecondaryTask.cpp, servoAfma6Ellipse2DCamVelocity.cpp, servoBebop2.cpp, servoBiclopsPoint2DArtVelocity.cpp, servoPtu46Point2DArtVelocity.cpp, servoSimu3D_cMcd_CamVelocity.cpp, servoSimu3D_cMcd_CamVelocityWithoutVpServo.cpp, servoSimu3D_cdMc_CamVelocity.cpp, servoSimuFourPoints2DPolarCamVelocityDisplay.cpp, servoSimuSphere2DCamVelocityDisplaySecondaryTask.cpp, testColVector.cpp, testComedi.cpp, testDisplacement.cpp, testForceTorqueAti.cpp, testForceTorqueAtiNetFTSensor.cpp, testForceTorqueIitSensor.cpp, testFrankaCartForceTorque-2.cpp, testFrankaCartForceTorque.cpp, testFrankaCartVelocity-2.cpp, testFrankaCartVelocity-3.cpp, testFrankaCartVelocity.cpp, testFrankaGetPose.cpp, testFrankaJointPosition.cpp, testFrankaJointTorque.cpp, testFrankaJointVelocity-2.cpp, testFrankaJointVelocity-3.cpp, testFrankaJointVelocity.cpp, testFrankaJointVelocityLimits.cpp, testKalmanAcceleration.cpp, testKalmanVelocity.cpp, testMatrix.cpp, testMatrixInitialization.cpp, testPoint.cpp, testRobotViper650-frames.cpp, testRobotViper850-frames.cpp, testRobotViper850.cpp, testUniversalRobotsCartPosition.cpp, testUniversalRobotsCartVelocity.cpp, testUniversalRobotsGetData.cpp, testUniversalRobotsJointPosition.cpp, testUniversalRobotsJointVelocity.cpp, testVirtuose.cpp, testVirtuoseAfma6.cpp, testVirtuosePeriodicFunction.cpp, tutorial-homography-from-points.cpp, tutorial-hsv-segmentation-pcl-viewer.cpp, tutorial-hsv-segmentation-pcl.cpp, tutorial-hsv-segmentation.cpp, and tutorial-pioneer-robot.cpp.

Definition at line 527 of file vpColVector.cpp.

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

Referenced by vpMbtFaceDepthDense::computeInteractionMatrixAndResidu(), vpServo::computeProjectionOperators(), vpRobotBiclops::getPosition(), vpRobotBiclops::getVelocity(), vpTemplateTrackerZNCCInverseCompositional::initHessienDesired(), vpColVector::operator+(), vpForwardProjection::print(), vpServo::print(), vpMeEllipse::printParameters(), vpPose::printPoint(), vpServoData::save(), vpRobotKinova::setPosition(), vpRobotBiclops::setVelocity(), vpRobotPololuPtu::setVelocity(), vpLinProg::simplex(), vpTemplateTrackerSSDForwardAdditional::trackNoPyr(), vpTemplateTrackerMIForwardAdditional::trackNoPyr(), vpTemplateTrackerMIInverseCompositional::trackNoPyr(), and vpColVector::transpose().

◆ toStdVector()

std::vector< double > vpColVector::toStdVector ( ) const
inherited

Converts the vpColVector to a std::vector.

Returns
The corresponding std::vector<double>.
Examples
perfColVectorOperations.cpp, and testColVector.cpp.

Definition at line 455 of file vpColVector.cpp.

References vpArray2D< double >::data, and vpArray2D< double >::size().

Referenced by vpRobotUniversalRobots::get_fMe(), vpRobotUniversalRobots::setPosition(), and vpRobotUniversalRobots::setVelocity().

◆ transpose() [1/2]

vpRowVector vpColVector::transpose ( ) const
inherited

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

See also
t()
Examples
tutorial-pf-curve-fitting-all.cpp, and tutorial-pf-curve-fitting-pf.cpp.

Definition at line 534 of file vpColVector.cpp.

References vpColVector::t().

◆ transpose() [2/2]

void vpColVector::transpose ( vpRowVector v) const
inherited

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

See also
t()

Definition at line 536 of file vpColVector.cpp.

References vpColVector::t().

Friends And Related Function Documentation

◆ insert()

void vpArray2D< double >::insert ( const vpArray2D< Type > &  A,
const vpArray2D< Type > &  B,
vpArray2D< Type > &  C,
unsigned int  r,
unsigned int  c 
)
related

Insert array B in array A at the given position.

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

Definition at line 1096 of file vpArray2D.h.

◆ operator*()

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

Allows to multiply a scalar by a column vector.

Definition at line 1030 of file vpColVector.cpp.

◆ operator==() [1/2]

bool operator== ( const vpArray2D< double > &  A) const
related

Definition at line 1313 of file vpArray2D.h.

◆ operator==() [2/2]

bool operator== ( const vpArray2D< float > &  A) const
related

Definition at line 1332 of file vpArray2D.h.

◆ vpGEMM()

void vpGEMM ( const vpArray2D< double > &  A,
const vpArray2D< double > &  B,
const double &  alpha,
const vpArray2D< double > &  C,
const double &  beta,
vpArray2D< double > &  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 D = alpha*A^T*B^T+beta*C we need to call :

vpGEMM(A, B, alpha, C, beta, D, VP_GEMM_A_T + VP_GEMM_B_T);
void vpGEMM(const vpArray2D< double > &A, const vpArray2D< double > &B, const double &alpha, const vpArray2D< double > &C, const double &beta, vpArray2D< double > &D, const unsigned int &ops=0)
Definition: vpGEMM.h:414

If C is not used, vpGEMM must be called using an empty array null. Thus to compute D = alpha*A^T*B, we have to call:

vpGEMM(A, B, alpha, null, 0, D, VP_GEMM_B_T);
Exceptions
vpException::incorrectMatrixSizeErrorif the sizes of the matrices do not allow the operations.
Parameters
A: An array that could be a vpMatrix.
B: An array that could be a vpMatrix.
alpha: A scalar.
C: An array that could be a vpMatrix.
beta: A scalar.
D: The resulting array that could be a vpMatrix.
ops: A scalar describing operation applied on the matrices. Possible values are the one defined in vpGEMMmethod(): VP_GEMM_A_T, VP_GEMM_B_T, VP_GEMM_C_T.

Definition at line 414 of file vpGEMM.h.

◆ vpGEMMmethod

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

Member Data Documentation

◆ colNum

unsigned int vpArray2D< double >::colNum
protectedinherited

Number of columns in the array.

Definition at line 1103 of file vpArray2D.h.

◆ data

◆ dsize

unsigned int vpArray2D< double >::dsize
protectedinherited

Current array size (rowNum * colNum)

Definition at line 1107 of file vpArray2D.h.

◆ m_parent

vpColVector* vpSubColVector::m_parent
protected

Parent vpColVector.

Definition at line 82 of file vpSubColVector.h.

Referenced by checkParentStatus(), and init().

◆ m_pRowNum

unsigned int vpSubColVector::m_pRowNum
protected

Number of row of parent vpColVector at initialization.

Definition at line 80 of file vpSubColVector.h.

Referenced by checkParentStatus(), init(), and operator=().

◆ rowNum

unsigned int vpArray2D< double >::rowNum
protectedinherited

Number of rows in the array.

Definition at line 1101 of file vpArray2D.h.

◆ rowPtrs

double ** vpArray2D< double >::rowPtrs
protectedinherited

Address of the first element of each rows.

Definition at line 1105 of file vpArray2D.h.