51#include <visp3/core/vpCPUFeatures.h>
52#include <visp3/core/vpColVector.h>
53#include <visp3/core/vpDebug.h>
54#include <visp3/core/vpException.h>
55#include <visp3/core/vpMath.h>
56#include <visp3/core/vpRotationVector.h>
58#include <Simd/SimdLib.hpp>
69 for (
unsigned int i = 0; i <
rowNum; i++)
70 r[i] = (*
this)[i] + v[i];
102 for (
unsigned int i = 0; i < 3; i++)
103 s[i] = (*
this)[i] +
t[i];
116 for (
unsigned int i = 0; i <
rowNum; i++)
128 for (
unsigned int i = 0; i <
rowNum; i++)
144 "Cannot compute the dot product between column vectors "
145 "with different dimensions (%d) and (%d)",
150 for (
unsigned int i = 0; i <
rowNum; i++)
151 r += (*
this)[i] * v[i];
167 for (
unsigned int i = 0; i <
rowNum; i++) {
168 for (
unsigned int j = 0; j < v.
getCols(); j++) {
169 M[i][j] = (*this)[i] * v[j];
180 "Bad size during vpColVector (%dx1) and vpColVector "
181 "(%dx1) subtraction",
186 for (
unsigned int i = 0; i <
rowNum; i++)
187 v[i] = (*
this)[i] - m[i];
248 unsigned int rnrows = r + nrows;
257 for (
unsigned int i = r; i < rnrows; i++)
258 (*
this)[i - r] = v[i];
263 for (
unsigned int i = 0; i < v.
size(); i++)
269 for (
unsigned int i = 0; i < p.
size(); i++)
275 for (
unsigned int i = 0; i < v.
size(); i++)
282 for (
unsigned int i = 0; i < M.
getCols(); i++)
283 (*
this)[i] = M[i][j];
299 for (
unsigned int i = 0; i < M.
getRows(); i++)
300 (*
this)[i] = M[i][0];
308 for (
unsigned int i = 0; i < v.size(); i++)
316 for (
unsigned int i = 0; i < v.size(); i++)
317 (*
this)[i] = (double)(v[i]);
320#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
358 for (
unsigned int i = 0; i <
rowNum; i++)
391 for (
unsigned int i = 0; i <
rowNum; i++)
392 *(vd++) = (*d++) * x;
416 for (
unsigned int i = 0; i <
rowNum; i++)
440 for (
unsigned int i = 0; i <
rowNum; i++)
471 for (
unsigned int i = 0; i <
rowNum; i++)
472 *(vd++) = (*d++) / x;
499 resize((
unsigned int)v.size(),
false);
500 for (
unsigned int i = 0; i < v.size(); i++)
509 resize((
unsigned int)v.size(),
false);
510 for (
unsigned int i = 0; i < v.size(); i++)
511 (*
this)[i] = (float)v[i];
517 unsigned int k = v.
rowNum;
618 for (
unsigned int i = 0; i <
rowNum; i++) {
619 for (
unsigned int j = 0; j <
colNum; j++) {
681 for (
unsigned int i = 0; i <
rowNum; i++)
692 std::vector<double> v(this->
size());
694 for (
unsigned int i = 0; i < this->
size(); i++)
699#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
705 if (
this != &other) {
717 other.rowPtrs = NULL;
750 resize(
static_cast<unsigned int>(list.size()),
false);
751 std::copy(list.begin(), list.end(),
data);
767 for (
unsigned int i = 0; i <
rowNum; i++) {
783 for (
unsigned int i = 0; i <
rowNum; i++) {
848 if (a.
data == NULL) {
851 if (b.
data == NULL) {
856 "Cannot compute the dot product between column vectors "
857 "with different dimensions (%d) and (%d)",
865 for (
unsigned int i = 0; i < a.
getRows(); i++)
866 c += *(ad++) * *(bd++);
906 if (std::fabs(sum_square) > std::numeric_limits<double>::epsilon())
907 *
this /= sqrt(sum_square);
943 if (v.
data == NULL) {
948 unsigned int nb_permutation = 1;
950 while (nb_permutation != 0) {
952 for (
unsigned int j = v.
getRows() - 1; j >= i + 1; j--) {
953 if ((tab[j] > tab[j - 1])) {
995 if (v.
data == NULL) {
1000 unsigned int nb_permutation = 1;
1002 while (nb_permutation != 0) {
1004 for (
unsigned int j = v.
getRows() - 1; j >= i + 1; j--) {
1005 if ((tab[j] < tab[j - 1])) {
1006 double tmp = tab[j];
1007 tab[j] = tab[j - 1];
1106 unsigned int nrA = A.
getRows();
1107 unsigned int nrB = B.
getRows();
1109 if (nrA == 0 && nrB == 0) {
1125 C.
resize(nrA + nrB,
false);
1127 for (
unsigned int i = 0; i < nrA; i++)
1130 for (
unsigned int i = 0; i < nrB; i++)
1139 if (v.
data == NULL || v.
size() == 0) {
1159 if (v.
data == NULL || v.
size() == 0) {
1173 if (v.
data == NULL || v.
size() == 0) {
1177 return SimdVectorStdev(v.
data, v.
rowNum, useBesselCorrection);
1202 M.
resize(3, 3,
false,
false);
1229 "Cannot compute the cross product between column "
1230 "vector with dimension %d and %d",
1309 if (
dsize != nrows * ncols) {
1314 M.
resize(nrows, ncols,
false,
false);
1316 for (
unsigned int j = 0; j < ncols; j++)
1317 for (
unsigned int i = 0; i < nrows; i++)
1318 M[i][j] =
data[j * nrows + i];
1355 if (i + v.
size() > this->size())
1364 if (i + v.
size() > this->size())
1393 typedef std::string::size_type size_type;
1398 std::vector<std::string> values(m * n);
1399 std::ostringstream oss;
1400 std::ostringstream ossFixed;
1401 std::ios_base::fmtflags original_flags = oss.flags();
1404 ossFixed.setf(std::ios::fixed, std::ios::floatfield);
1406 size_type maxBefore = 0;
1407 size_type maxAfter = 0;
1409 for (
unsigned int i = 0; i < m; ++i) {
1412 if (oss.str().find(
"e") != std::string::npos) {
1414 ossFixed << (*this)[i];
1415 oss.str(ossFixed.str());
1418 values[i] = oss.str();
1419 size_type thislen = values[i].size();
1420 size_type p = values[i].find(
'.');
1422 if (p == std::string::npos) {
1432 size_type totalLength = length;
1436 maxAfter = (std::min)(maxAfter, totalLength - maxBefore);
1445 s <<
"[" << m <<
"," << n <<
"]=\n";
1447 for (
unsigned int i = 0; i < m; i++) {
1449 size_type p = values[i].find(
'.');
1450 s.setf(std::ios::right, std::ios::adjustfield);
1451 s.width((std::streamsize)maxBefore);
1452 s << values[i].substr(0, p).c_str();
1455 s.setf(std::ios::left, std::ios::adjustfield);
1456 if (p != std::string::npos) {
1457 s.width((std::streamsize)maxAfter);
1458 s << values[i].substr(p, maxAfter).c_str();
1461 assert(maxAfter > 1);
1462 s.width((std::streamsize)maxAfter);
1472 s.flags(original_flags);
1474 return (
int)(maxBefore + maxAfter);
1543 for (
unsigned int i = 0; i <
rowNum; i++) {
1544 double x = fabs((*
this)[i]);
1582 os <<
"vpColVector " << matrixName <<
" (" << this->
getRows() <<
"); " << std::endl;
1584 for (
unsigned int i = 0; i < this->
getRows(); ++i) {
1587 os << matrixName <<
"[" << i <<
"] = " << (*this)[i] <<
"; " << std::endl;
1590 for (
unsigned int k = 0; k <
sizeof(double); ++k) {
1591 os <<
"((unsigned char*)&(" << matrixName <<
"[" << i <<
"]) )[" << k <<
"] = 0x" << std::hex
1592 << (
unsigned int)((
unsigned char *)&((*this)[i]))[k] <<
"; " << std::endl;
1596 std::cout << std::endl;
1628 for (
unsigned int i = 0; i < this->
getRows(); ++i) {
1663 os <<
"([ " << std::endl;
1664 for (
unsigned int i = 0; i < this->
getRows(); ++i) {
1666 os << (*this)[i] <<
", ";
1667 os <<
"]," << std::endl;
1669 os <<
"])" << std::endl;
1712 for (
unsigned int i = 0; i < this->
getRows(); ++i) {
1713 os << (*this)[i] <<
", ";
1714 if (this->
getRows() != i + 1) {
1715 os <<
";" << std::endl;
1718 os <<
"]" << std::endl;
1724#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
Implementation of a generic 2D array used as base class for matrices and vectors.
unsigned int getCols() const
double * data
Address of the first element of the data array.
double ** rowPtrs
Address of the first element of each rows.
void resize(unsigned int nrows, unsigned int ncols, bool flagNullify=true, bool recopy_=true)
unsigned int rowNum
Number of rows in the array.
friend std::ostream & operator<<(std::ostream &s, const vpArray2D< double > &A)
unsigned int dsize
Current array size (rowNum * colNum)
unsigned int size() const
Return the number of elements of the 2D array.
unsigned int getRows() const
unsigned int colNum
Number of columns in the array.
Implementation of column vector and the associated operations.
void reshape(vpMatrix &M, const unsigned int &nrows, const unsigned int &ncols)
static double dotProd(const vpColVector &a, const vpColVector &b)
vpColVector operator-() const
vpColVector & operator*=(double x)
std::ostream & matlabPrint(std::ostream &os) const
vp_deprecated double euclideanNorm() const
vpColVector & operator=(const vpColVector &v)
Copy operator. Allow operation such as A = v.
vpColVector operator/(double x) const
vpColVector & normalize()
static double median(const vpColVector &v)
vpColVector hadamard(const vpColVector &v) const
std::ostream & csvPrint(std::ostream &os) const
std::ostream & maplePrint(std::ostream &os) const
vpColVector & operator,(double val)
int print(std::ostream &s, unsigned int length, char const *intro=0) const
bool operator==(const vpColVector &v) const
Comparison operator.
vpColVector & operator/=(double x)
static vpColVector invSort(const vpColVector &v)
bool operator!=(const vpColVector &v) const
static vpMatrix skew(const vpColVector &v)
vp_deprecated void init()
double operator*(const vpColVector &x) const
vpColVector()
Basic constructor that creates an empty 0-size column vector.
vpColVector operator+(const vpColVector &v) const
Operator that allows to add two column vectors.
std::vector< double > toStdVector() const
static double mean(const vpColVector &v)
vpColVector operator*(const double &x, const vpColVector &v)
vpColVector & operator+=(vpColVector v)
Operator that allows to add two column vectors.
static vpColVector crossProd(const vpColVector &a, const vpColVector &b)
double infinityNorm() const
vpRowVector transpose() const
static double stdev(const vpColVector &v, bool useBesselCorrection=false)
std::ostream & cppPrint(std::ostream &os, const std::string &matrixName="A", bool octet=false) const
double frobeniusNorm() const
vpColVector & operator-=(vpColVector v)
Operator that allows to subtract two column vectors.
static vpColVector sort(const vpColVector &v)
void insert(unsigned int i, const vpColVector &v)
void resize(unsigned int i, bool flagNullify=true)
error that can be emitted by ViSP classes.
@ dimensionError
Bad dimension.
static double getMedian(const std::vector< double > &v)
static Type maximum(const Type &a, const Type &b)
static bool equal(double x, double y, double threshold=0.001)
Implementation of a matrix and operations on matrices.
Implementation of a pose vector and operations on poses.
Implementation of a generic rotation vector.
Implementation of row vector and the associated operations.
Class that consider the case of a translation vector.