54 #include <visp3/core/vpCPUFeatures.h> 55 #include <visp3/core/vpColVector.h> 56 #include <visp3/core/vpDebug.h> 57 #include <visp3/core/vpException.h> 58 #include <visp3/core/vpMath.h> 59 #include <visp3/core/vpRotationVector.h> 61 #include <Simd/SimdLib.hpp> 72 for (
unsigned int i = 0; i <
rowNum; i++)
73 r[i] = (*
this)[i] + v[i];
105 for (
unsigned int i = 0; i < 3; i++)
106 s[i] = (*
this)[i] + t[i];
119 for (
unsigned int i = 0; i <
rowNum; i++)
131 for (
unsigned int i = 0; i <
rowNum; i++)
147 "Cannot compute the dot product between column vectors " 148 "with different dimensions (%d) and (%d)",
153 for (
unsigned int i = 0; i <
rowNum; i++)
154 r += (*
this)[i] * v[i];
170 for (
unsigned int i = 0; i <
rowNum; i++) {
171 for (
unsigned int j = 0; j < v.
getCols(); j++) {
172 M[i][j] = (*this)[i] * v[j];
183 "Bad size during vpColVector (%dx1) and vpColVector " 184 "(%dx1) subtraction",
189 for (
unsigned int i = 0; i <
rowNum; i++)
190 v[i] = (*
this)[i] - m[i];
251 unsigned int rnrows = r + nrows;
260 for (
unsigned int i = r; i < rnrows; i++)
261 (*
this)[i - r] = v[i];
266 for (
unsigned int i = 0; i < v.
size(); i++)
272 for (
unsigned int i = 0; i < p.
size(); i++)
278 for (
unsigned int i = 0; i < v.
size(); i++)
285 for (
unsigned int i = 0; i < M.
getCols(); i++)
286 (*
this)[i] = M[i][j];
302 for (
unsigned int i = 0; i < M.
getRows(); i++)
303 (*
this)[i] = M[i][0];
311 for (
unsigned int i = 0; i < v.size(); i++)
319 for (
unsigned int i = 0; i < v.size(); i++)
320 (*
this)[i] = (double)(v[i]);
323 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) 361 for (
unsigned int i = 0; i <
rowNum; i++)
394 for (
unsigned int i = 0; i <
rowNum; i++)
395 *(vd++) = (*d++) * x;
419 for (
unsigned int i = 0; i <
rowNum; i++)
443 for (
unsigned int i = 0; i <
rowNum; i++)
474 for (
unsigned int i = 0; i <
rowNum; i++)
475 *(vd++) = (*d++) / x;
502 resize((
unsigned int)v.size(),
false);
503 for (
unsigned int i = 0; i < v.size(); i++)
512 resize((
unsigned int)v.size(),
false);
513 for (
unsigned int i = 0; i < v.size(); i++)
514 (*
this)[i] = (float)v[i];
520 unsigned int k = v.
rowNum;
621 for (
unsigned int i = 0; i <
rowNum; i++) {
622 for (
unsigned int j = 0; j <
colNum; j++) {
684 for (
unsigned int i = 0; i <
rowNum; i++)
695 std::vector<double> v(this->
size());
697 for (
unsigned int i = 0; i < this->
size(); i++)
702 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) 708 if (
this != &other) {
720 other.rowPtrs = NULL;
753 resize(static_cast<unsigned int>(list.size()),
false);
754 std::copy(list.begin(), list.end(),
data);
764 for (
unsigned int i = 0; i <
rowNum; i++) {
773 return !(*
this == v);
818 if (a.
data == NULL) {
821 if (b.
data == NULL) {
826 "Cannot compute the dot product between column vectors " 827 "with different dimensions (%d) and (%d)",
835 for (
unsigned int i = 0; i < a.
getRows(); i++)
836 c += *(ad++) * *(bd++);
869 if (std::fabs(sum_square) > std::numeric_limits<double>::epsilon())
870 *
this /= sqrt(sum_square);
906 if (v.
data == NULL) {
911 unsigned int nb_permutation = 1;
913 while (nb_permutation != 0) {
915 for (
unsigned int j = v.
getRows() - 1; j >= i + 1; j--) {
916 if ((tab[j] > tab[j - 1])) {
958 if (v.
data == NULL) {
963 unsigned int nb_permutation = 1;
965 while (nb_permutation != 0) {
967 for (
unsigned int j = v.
getRows() - 1; j >= i + 1; j--) {
968 if ((tab[j] < tab[j - 1])) {
1069 unsigned int nrA = A.
getRows();
1070 unsigned int nrB = B.
getRows();
1072 if (nrA == 0 && nrB == 0) {
1088 C.
resize(nrA + nrB,
false);
1090 for (
unsigned int i = 0; i < nrA; i++)
1093 for (
unsigned int i = 0; i < nrB; i++)
1102 if (v.
data == NULL || v.
size() == 0) {
1122 if (v.
data == NULL || v.
size() == 0) {
1136 if (v.
data == NULL || v.
size() == 0) {
1140 return SimdVectorStdev(v.
data, v.
rowNum, useBesselCorrection);
1165 M.
resize(3, 3,
false,
false);
1193 "Cannot compute the cross product between column " 1194 "vector with dimension %d and %d",
1273 if (
dsize != nrows * ncols) {
1278 M.
resize(nrows, ncols,
false,
false);
1280 for (
unsigned int j = 0; j < ncols; j++)
1281 for (
unsigned int i = 0; i < nrows; i++)
1282 M[i][j] =
data[j * nrows + i];
1348 typedef std::string::size_type size_type;
1353 std::vector<std::string> values(m * n);
1354 std::ostringstream oss;
1355 std::ostringstream ossFixed;
1356 std::ios_base::fmtflags original_flags = oss.flags();
1359 ossFixed.setf(std::ios::fixed, std::ios::floatfield);
1361 size_type maxBefore = 0;
1362 size_type maxAfter = 0;
1364 for (
unsigned int i = 0; i < m; ++i) {
1367 if (oss.str().find(
"e") != std::string::npos) {
1369 ossFixed << (*this)[i];
1370 oss.str(ossFixed.str());
1373 values[i] = oss.str();
1374 size_type thislen = values[i].size();
1375 size_type p = values[i].find(
'.');
1377 if (p == std::string::npos) {
1386 size_type totalLength = length;
1390 maxAfter = (std::min)(maxAfter, totalLength - maxBefore);
1399 s <<
"[" << m <<
"," << n <<
"]=\n";
1401 for (
unsigned int i = 0; i < m; i++) {
1403 size_type p = values[i].find(
'.');
1404 s.setf(std::ios::right, std::ios::adjustfield);
1405 s.width((std::streamsize)maxBefore);
1406 s << values[i].substr(0, p).c_str();
1409 s.setf(std::ios::left, std::ios::adjustfield);
1410 if (p != std::string::npos) {
1411 s.width((std::streamsize)maxAfter);
1412 s << values[i].substr(p, maxAfter).c_str();
1414 assert(maxAfter > 1);
1415 s.width((std::streamsize)maxAfter);
1425 s.flags(original_flags);
1427 return (
int)(maxBefore + maxAfter);
1515 for (
unsigned int i = 0; i <
rowNum; i++) {
1516 double x = fabs((*
this)[i]);
1554 os <<
"vpColVector " << matrixName <<
" (" << this->
getRows() <<
"); " << std::endl;
1556 for (
unsigned int i = 0; i < this->
getRows(); ++i) {
1559 os << matrixName <<
"[" << i <<
"] = " << (*this)[i] <<
"; " << std::endl;
1561 for (
unsigned int k = 0; k <
sizeof(double); ++k) {
1562 os <<
"((unsigned char*)&(" << matrixName <<
"[" << i <<
"]) )[" << k <<
"] = 0x" << std::hex
1563 << (
unsigned int)((
unsigned char *)&((*this)[i]))[k] <<
"; " << std::endl;
1567 std::cout << std::endl;
1599 for (
unsigned int i = 0; i < this->
getRows(); ++i) {
1634 os <<
"([ " << std::endl;
1635 for (
unsigned int i = 0; i < this->
getRows(); ++i) {
1637 os << (*this)[i] <<
", ";
1638 os <<
"]," << std::endl;
1640 os <<
"])" << std::endl;
1683 for (
unsigned int i = 0; i < this->
getRows(); ++i) {
1684 os << (*this)[i] <<
", ";
1685 if (this->
getRows() != i + 1) {
1686 os <<
";" << std::endl;
1688 os <<
"]" << std::endl;
1694 #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) 1714 #endif // defined(VISP_BUILD_DEPRECATED_FUNCTIONS) vp_deprecated double euclideanNorm() const
Implementation of a matrix and operations on matrices.
Implementation of a generic rotation vector.
bool operator==(const vpColVector &v) const
Comparison operator.
void resize(unsigned int nrows, unsigned int ncols, bool flagNullify=true, bool recopy_=true)
double frobeniusNorm() const
double operator*(const vpColVector &x) const
vp_deprecated void init()
static vpColVector invSort(const vpColVector &v)
static vpColVector sort(const vpColVector &v)
Implementation of row vector and the associated operations.
static double getMedian(const std::vector< double > &v)
vpColVector operator*(const double &x, const vpColVector &v)
static bool equal(double x, double y, double s=0.001)
vpColVector & operator,(double val)
vpColVector operator/(double x) const
error that can be emited by ViSP classes.
unsigned int getRows() const
double * data
Address of the first element of the data array.
Implementation of a generic 2D array used as base class for matrices and vectors. ...
vpColVector & operator*=(double x)
unsigned int size() const
Return the number of elements of the 2D array.
std::vector< double > toStdVector() const
static double median(const vpColVector &v)
static Type maximum(const Type &a, const Type &b)
unsigned int getCols() const
vpColVector & operator/=(double x)
vpColVector hadamard(const vpColVector &v) const
unsigned int rowNum
Number of rows in the array.
vpRowVector transpose() const
vpColVector & normalize()
std::ostream & csvPrint(std::ostream &os) const
double infinityNorm() const
std::ostream & matlabPrint(std::ostream &os) const
vpColVector & operator<<(const vpColVector &v)
static double mean(const vpColVector &v)
vpColVector & operator-=(vpColVector v)
Operator that allows to subtract two column vectors.
unsigned int colNum
Number of columns in the array.
void insert(unsigned int i, const vpColVector &v)
void resize(unsigned int i, bool flagNullify=true)
vpColVector & operator=(const vpColVector &v)
Copy operator. Allow operation such as A = v.
int print(std::ostream &s, unsigned int length, char const *intro=0) const
vpColVector & operator+=(vpColVector v)
Operator that allows to add two column vectors.
Implementation of column vector and the associated operations.
static double dotProd(const vpColVector &a, const vpColVector &b)
vpColVector operator-() const
Implementation of a pose vector and operations on poses.
vpColVector()
Basic constructor that creates an empty 0-size column vector.
std::ostream & maplePrint(std::ostream &os) const
vpColVector operator+(const vpColVector &v) const
Operator that allows to add two column vectors.
static vpMatrix skew(const vpColVector &v)
unsigned int dsize
Current array size (rowNum * colNum)
void reshape(vpMatrix &M, const unsigned int &nrows, const unsigned int &ncols)
static double stdev(const vpColVector &v, bool useBesselCorrection=false)
static vpColVector crossProd(const vpColVector &a, const vpColVector &b)
std::ostream & cppPrint(std::ostream &os, const std::string &matrixName="A", bool octet=false) const
Class that consider the case of a translation vector.
double ** rowPtrs
Address of the first element of each rows.
bool operator!=(const vpColVector &v) const