Visual Servoing Platform  version 3.6.1 under development (2024-05-26)
vpRowVector.cpp
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2023 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * See the file LICENSE.txt at the root directory of this source
11  * distribution for additional information about the GNU GPL.
12  *
13  * For using ViSP with software that can not be combined with the GNU
14  * GPL, please contact Inria about acquiring a ViSP Professional
15  * Edition License.
16  *
17  * See https://visp.inria.fr for more information.
18  *
19  * This software was developed at:
20  * Inria Rennes - Bretagne Atlantique
21  * Campus Universitaire de Beaulieu
22  * 35042 Rennes Cedex
23  * France
24  *
25  * If you have questions regarding the use of this file, please contact
26  * Inria at visp@inria.fr
27  *
28  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30  *
31  * Description:
32  * Operation on row vectors.
33  *
34 *****************************************************************************/
35 
41 #include <assert.h>
42 #include <cmath>
43 #include <sstream>
44 #include <stdlib.h>
45 #include <string.h>
46 
47 #include <visp3/core/vpArray2D.h>
48 #include <visp3/core/vpColVector.h>
49 #include <visp3/core/vpDebug.h>
50 #include <visp3/core/vpException.h>
51 #include <visp3/core/vpMatrix.h>
52 #include <visp3/core/vpRowVector.h>
53 
56 {
57  unsigned int k = v.colNum;
58  if (colNum != k) {
59  try {
60  resize(k);
61  }
62  catch (...) {
63  throw;
64  }
65  }
66 
67  memcpy(data, v.data, colNum * sizeof(double));
68 
69  return *this;
70 }
71 
80 {
81  if (M.getRows() != 1) {
82  throw(vpException(vpException::dimensionError, "Cannot initialize a (1x%d) row vector from a (%dx%d) matrix",
83  M.getCols(), M.getRows(), M.getCols()));
84  }
85 
86  if (M.getCols() != colNum) {
87  resize(M.getCols());
88  }
89 
90  memcpy(data, M.data, colNum * sizeof(double));
91  return *this;
92 }
93 
97 vpRowVector &vpRowVector::operator=(const std::vector<double> &v)
98 {
99  unsigned int v_size = v.size();
100  resize(v_size);
101  for (unsigned int i = 0; i < v_size; ++i) {
102  (*this)[i] = v[i];
103  }
104  return *this;
105 }
109 vpRowVector &vpRowVector::operator=(const std::vector<float> &v)
110 {
111  unsigned int v_size = v.size();
112  resize(v_size);
113  for (unsigned int i = 0; i < v_size; ++i) {
114  (*this)[i] = static_cast<float>(v[i]);
115  }
116  return *this;
117 }
118 
121 {
122  for (unsigned int i = 0; i < rowNum; ++i) {
123  for (unsigned int j = 0; j < colNum; ++j) {
124  rowPtrs[i][j] = x;
125  }
126  }
127  return *this;
128 }
129 
130 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
132 {
133  if (this != &other) {
134  free(data);
135  free(rowPtrs);
136 
137  rowNum = other.rowNum;
138  colNum = other.colNum;
139  rowPtrs = other.rowPtrs;
140  dsize = other.dsize;
141  data = other.data;
142 
143  other.rowNum = 0;
144  other.colNum = 0;
145  other.rowPtrs = nullptr;
146  other.dsize = 0;
147  other.data = nullptr;
148  }
149 
150  return *this;
151 }
152 
171 vpRowVector &vpRowVector::operator=(const std::initializer_list<double> &list)
172 {
173  resize(1, static_cast<unsigned int>(list.size()), false);
174  std::copy(list.begin(), list.end(), data);
175  return *this;
176 }
177 #endif
178 
180 {
181  if ((colNum != v.colNum) || (rowNum != v.rowNum) /* should not happen */) {
182  return false;
183  }
184 
185  for (unsigned int i = 0; i < colNum; ++i) {
186  if (!vpMath::equal(data[i], v.data[i], std::numeric_limits<double>::epsilon())) {
187  return false;
188  }
189  }
190 
191  return true;
192 }
193 
194 bool vpRowVector::operator!=(const vpRowVector &v) const { return !(*this == v); }
195 
210 double vpRowVector::operator*(const vpColVector &x) const
211 {
212  unsigned int nelements = x.getRows();
213  if (getCols() != nelements) {
214  throw(vpException(vpException::dimensionError, "Cannot multiply (1x%d) row vector by (%dx1) column vector", colNum,
215  x.getRows()));
216  }
217 
218  double scalar = 0.0;
219 
220  for (unsigned int i = 0; i < nelements; ++i) {
221  scalar += (*this)[i] * x[i];
222  }
223  return scalar;
224 }
241 {
242  vpRowVector c(M.getCols());
243 
244  if (colNum != M.getRows()) {
245  throw(vpException(vpException::dimensionError, "Cannot multiply (1x%d) row vector by (%dx%d) matrix", colNum,
246  M.getRows(), M.getCols()));
247  }
248 
249  c = 0.0;
250 
251  for (unsigned int i = 0; i < colNum; ++i) {
252  double bi = data[i]; // optimization em 5/12/2006
253  unsigned int m_cols = M.getCols();
254  for (unsigned int j = 0; j < m_cols; ++j) {
255  c[j] += bi * M[i][j];
256  }
257  }
258 
259  return c;
260 }
261 
282 {
283  vpRowVector v(colNum);
284 
285  double *vd = v.data;
286  double *d = data;
287 
288  for (unsigned int i = 0; i < colNum; ++i) {
289  *(vd++) = (*d++) * x;
290  }
291  return v;
292 }
293 
312 {
313  for (unsigned int i = 0; i < colNum; ++i) {
314  (*this)[i] *= x;
315  }
316  return (*this);
317 }
318 
339 {
340  vpRowVector v(colNum);
341 
342  double *vd = v.data;
343  double *d = data;
344 
345  for (unsigned int i = 0; i < colNum; ++i) {
346  *(vd++) = (*d++) / x;
347  }
348  return v;
349 }
350 
370 {
371  for (unsigned int i = 0; i < colNum; ++i) {
372  (*this)[i] /= x;
373  }
374  return (*this);
375 }
376 
388 {
389  vpRowVector A(colNum);
390 
391  double *vd = A.data;
392  double *d = data;
393 
394  for (unsigned int i = 0; i < colNum; ++i) {
395  *(vd++) = -(*d++);
396  }
397 
398  return A;
399 }
400 
406 {
407  if (getCols() != m.getCols()) {
408  throw(vpException(vpException::dimensionError, "Cannot subtract (1x%d) row vector to (1x%d) row vector", getCols(),
409  m.getCols()));
410  }
411 
412  vpRowVector v(colNum);
413 
414  for (unsigned int i = 0; i < colNum; ++i) {
415  v[i] = (*this)[i] - m[i];
416  }
417  return v;
418 }
419 
425 {
426  if (getCols() != v.getCols()) {
427  throw(vpException(vpException::dimensionError, "Cannot add (1x%d) row vector to (1x%d) row vector", getCols(),
428  v.getCols()));
429  }
430 
431  vpRowVector r(colNum);
432 
433  for (unsigned int i = 0; i < colNum; ++i) {
434  r[i] = (*this)[i] + v[i];
435  }
436  return r;
437 }
438 
445 {
446  if (getCols() != v.getCols()) {
447  throw(vpException(vpException::dimensionError, "Cannot add (1x%d) row vector to (1x%d) row vector", getCols(),
448  v.getCols()));
449  }
450 
451  for (unsigned int i = 0; i < colNum; ++i) {
452  (*this)[i] += v[i];
453  }
454  return (*this);
455 }
456 
463 {
464  if (getCols() != v.getCols()) {
465  throw(vpException(vpException::dimensionError, "Cannot subtract (1x%d) row vector to (1x%d) row vector", getCols(),
466  v.getCols()));
467  }
468 
469  for (unsigned int i = 0; i < colNum; ++i) {
470  (*this)[i] -= v[i];
471  }
472  return (*this);
473 }
474 
497 {
498  *this = v;
499  return *this;
500 }
501 
503 {
504  resize(1, false);
505  data[0] = val;
506  return *this;
507 }
508 
510 {
511  resize(colNum + 1, false);
512  data[colNum - 1] = val;
513  return *this;
514 }
515 
520 {
521  vpColVector v(colNum);
522  memcpy(v.data, data, colNum * sizeof(double));
523  return v;
524 }
525 
530 vpColVector vpRowVector::transpose() const { return t(); }
535 void vpRowVector::transpose(vpColVector &v) const { v = t(); }
536 
541 vpRowVector::vpRowVector(const vpMatrix &M, unsigned int i) : vpArray2D<double>(1, M.getCols())
542 {
543  unsigned int m_cols = M.getCols();
544  for (unsigned int j = 0; j < m_cols; ++j) {
545  (*this)[j] = M[i][j];
546  }
547 }
554 vpRowVector::vpRowVector(const vpMatrix &M) : vpArray2D<double>(1, M.getCols())
555 {
556  if (M.getRows() != 1) {
557  throw(vpException(vpException::dimensionError, "Cannot construct a (1x%d) row vector from a (%dx%d) matrix",
558  M.getCols(), M.getRows(), M.getCols()));
559  }
560  unsigned int m_cols = M.getCols();
561  for (unsigned int j = 0; j < m_cols; ++j) {
562  (*this)[j] = M[0][j];
563  }
564 }
565 
569 vpRowVector::vpRowVector(const std::vector<double> &v) : vpArray2D<double>(1, static_cast<unsigned int>(v.size()))
570 {
571  unsigned int v_size = v.size();
572  for (unsigned int j = 0; j < v_size; ++j) {
573  (*this)[j] = v[j];
574  }
575 }
579 vpRowVector::vpRowVector(const std::vector<float> &v) : vpArray2D<double>(1, static_cast<unsigned int>(v.size()))
580 {
581  unsigned int v_size = v.size();
582  for (unsigned int j = 0; j < v_size; ++j) {
583  (*this)[j] = static_cast<double>(v[j]);
584  }
585 }
586 
600 vpRowVector::vpRowVector(const vpRowVector &v, unsigned int c, unsigned int ncols) : vpArray2D<double>(1, ncols)
601 {
602  init(v, c, ncols);
603 }
604 
605 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
607 {
608  rowNum = v.rowNum;
609  colNum = v.colNum;
610  rowPtrs = v.rowPtrs;
611  dsize = v.dsize;
612  data = v.data;
613 
614  v.rowNum = 0;
615  v.colNum = 0;
616  v.rowPtrs = nullptr;
617  v.dsize = 0;
618  v.data = nullptr;
619 }
620 #endif
621 
632 {
633  x = x / sqrt(x.sumSquare());
634 
635  return x;
636 }
637 
647 {
648  double sum_square = sumSquare();
649  if (std::fabs(sum_square) > std::numeric_limits<double>::epsilon()) {
650  *this /= sqrt(sum_square);
651  }
652 
653  // If sum = 0, we have a nul vector. So we return just.
654  return *this;
655 }
656 
668 vpMatrix vpRowVector::reshape(unsigned int nrows, unsigned int ncols)
669 {
670  vpMatrix M(nrows, ncols);
671  reshape(M, nrows, ncols);
672  return M;
673 }
674 
718 void vpRowVector::reshape(vpMatrix &M, const unsigned int &nrows, const unsigned int &ncols)
719 {
720  if (dsize != (nrows * ncols)) {
721  throw(vpException(vpException::dimensionError, "Cannot reshape (1x%d) row vector in (%dx%d) matrix", colNum,
722  M.getRows(), M.getCols()));
723  }
724  try {
725  if ((M.getRows() != nrows) || (M.getCols() != ncols)) {
726  M.resize(nrows, ncols);
727  }
728  }
729  catch (...) {
730  throw;
731  }
732  for (unsigned int i = 0; i < nrows; ++i) {
733  for (unsigned int j = 0; j < ncols; ++j) {
734  M[i][j] = data[(i * ncols) + j];
735  }
736  }
737 }
738 
770 void vpRowVector::insert(unsigned int i, const vpRowVector &v)
771 {
772  if ( (i + v.size()) > this->size()) {
774  "Unable to insert (1x%d) row vector in (1x%d) row "
775  "vector at position (%d)",
776  v.getCols(), colNum, i));
777  }
778  unsigned int v_size = v.size();
779  for (unsigned int j = 0; j < v_size; ++j) {
780  (*this)[i + j] = v[j];
781  }
782 }
783 
788 std::vector<double> vpRowVector::toStdVector() const
789 {
790  std::vector<double> v(this->size());
791 
792  unsigned int this_size = this->size();
793  for (unsigned int i = 0; i < this_size; ++i) {
794  v[i] = data[i];
795  }
796  return v;
797 }
798 
815 void vpRowVector::stack(double d)
816 {
817  this->resize(colNum + 1, false);
818  (*this)[colNum - 1] = d;
819 }
820 
840 void vpRowVector::stack(const vpRowVector &v) { *this = vpRowVector::stack(*this, v); }
841 
863 {
864  vpRowVector C;
865  vpRowVector::stack(A, B, C);
866  return C;
867 }
868 
890 {
891  unsigned int nrA = A.getCols();
892  unsigned int nrB = B.getCols();
893 
894  if ((nrA == 0) && (nrB == 0)) {
895  C.resize(0);
896  return;
897  }
898 
899  if (nrB == 0) {
900  C = A;
901  return;
902  }
903 
904  if (nrA == 0) {
905  C = B;
906  return;
907  }
908 
909  // General case
910  C.resize(nrA + nrB);
911 
912  for (unsigned int i = 0; i < nrA; ++i) {
913  C[i] = A[i];
914  }
915 
916  for (unsigned int i = 0; i < nrB; ++i) {
917  C[nrA + i] = B[i];
918  }
919 }
920 
925 {
926  if ((v.data == nullptr) || (v.size() == 0)) {
927  throw(vpException(vpException::dimensionError, "Cannot compute mean value of an empty row vector"));
928  }
929 
930  double mean = 0;
931  double *vd = v.data;
932  unsigned int v_col = v.getCols();
933  for (unsigned int i = 0; i < v_col; ++i) {
934  mean += *(vd++);
935  }
936 
937  return mean / v.getCols();
938 }
939 
944 {
945  if ((v.data == nullptr) || (v.size() == 0)) {
946  throw(vpException(vpException::dimensionError, "Cannot compute mean value of an empty row vector"));
947  }
948 
949  std::vector<double> vectorOfDoubles(v.data, v.data + v.colNum);
950 
951  return vpMath::getMedian(vectorOfDoubles);
952 }
953 
957 double vpRowVector::stdev(const vpRowVector &v, bool useBesselCorrection)
958 {
959  if ((v.data == nullptr) || (v.size() == 0)) {
960  throw(vpException(vpException::dimensionError, "Cannot compute mean value of an empty row vector"));
961  }
962 
963  double mean_value = mean(v);
964  double sum_squared_diff = 0.0;
965  unsigned int v_size = v.size();
966  for (unsigned int i = 0; i < v_size; ++i) {
967  sum_squared_diff += (v[i] - mean_value) * (v[i] - mean_value);
968  }
969 
970  double divisor = static_cast<double>(v.size());
971  if (useBesselCorrection && (v.size() > 1)) {
972  divisor = divisor - 1;
973  }
974 
975  return std::sqrt(sum_squared_diff / divisor);
976 }
977 
997 int vpRowVector::print(std::ostream &s, unsigned int length, char const *intro) const
998 {
999  typedef std::string::size_type size_type;
1000 
1001  unsigned int m = 1;
1002  unsigned int n = getCols();
1003 
1004  std::vector<std::string> values(m * n);
1005  std::ostringstream oss;
1006  std::ostringstream ossFixed;
1007  std::ios_base::fmtflags original_flags = oss.flags();
1008 
1009  // ossFixed <<std::fixed
1010  ossFixed.setf(std::ios::fixed, std::ios::floatfield);
1011 
1012  size_type maxBefore = 0; // the length of the integral part
1013  size_type maxAfter = 0; // number of decimals plus
1014  // one place for the decimal point
1015  for (unsigned int j = 0; j < n; ++j) {
1016  oss.str("");
1017  oss << (*this)[j];
1018  if (oss.str().find("e") != std::string::npos) {
1019  ossFixed.str("");
1020  ossFixed << (*this)[j];
1021  oss.str(ossFixed.str());
1022  }
1023 
1024  values[j] = oss.str();
1025  size_type thislen = values[j].size();
1026  size_type p = values[j].find('.');
1027 
1028  if (p == std::string::npos) {
1029  maxBefore = vpMath::maximum(maxBefore, thislen);
1030  // maxAfter remains the same
1031  }
1032  else {
1033  maxBefore = vpMath::maximum(maxBefore, p);
1034  maxAfter = vpMath::maximum(maxAfter, thislen - p - 1);
1035  }
1036  }
1037 
1038  size_type totalLength = length;
1039  // increase totalLength according to maxBefore
1040  totalLength = vpMath::maximum(totalLength, maxBefore);
1041  // decrease maxAfter according to totalLength
1042  maxAfter = std::min<size_type>(maxAfter, totalLength - maxBefore);
1043  if (maxAfter == 1) {
1044  maxAfter = 0;
1045  }
1046 
1047  // the following line is useful for debugging
1048  // std::cerr <<totalLength <<" " <<maxBefore <<" " <<maxAfter <<"\n";
1049 
1050  if (intro) {
1051  s << intro;
1052  }
1053  s << "[" << m << "," << n << "]=\n";
1054 
1055  s << " ";
1056  for (unsigned int j = 0; j < n; ++j) {
1057  size_type p = values[j].find('.');
1058  s.setf(std::ios::right, std::ios::adjustfield);
1059  s.width(static_cast<std::streamsize>(maxBefore));
1060  s << values[j].substr(0, p).c_str();
1061 
1062  if (maxAfter > 0) {
1063  s.setf(std::ios::left, std::ios::adjustfield);
1064  if (p != std::string::npos) {
1065  s.width(static_cast<std::streamsize>(maxAfter));
1066  s << values[j].substr(p, maxAfter).c_str();
1067  }
1068  else {
1069  assert(maxAfter > 1);
1070  s.width( static_cast<std::streamsize> (maxAfter));
1071  s << ".0";
1072  }
1073  }
1074 
1075  s << ' ';
1076  }
1077  s << std::endl;
1078 
1079  s.flags(original_flags); // restore s to standard state
1080 
1081  return static_cast<int>(maxBefore + maxAfter);
1082 }
1083 
1087 vpRowVector operator*(const double &x, const vpRowVector &v)
1088 {
1089  vpRowVector vout;
1090  vout = v * x;
1091  return vout;
1092 }
1093 
1099 double vpRowVector::sum() const
1100 {
1101  double sum = 0.0;
1102 
1103  for (unsigned int j = 0; j < colNum; ++j) {
1104  sum += rowPtrs[0][j];
1105  }
1106 
1107  return sum;
1108 }
1109 
1117 {
1118  double sum_square = 0.0;
1119 
1120  for (unsigned int j = 0; j < colNum; ++j) {
1121  double x = rowPtrs[0][j];
1122  sum_square += x * x;
1123  }
1124 
1125  return sum_square;
1126 }
1127 
1134 {
1135  double norm = sumSquare();
1136 
1137  return sqrt(norm);
1138 }
1139 
1140 #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
1150 double vpRowVector::euclideanNorm() const { return frobeniusNorm(); }
1151 #endif
1152 
1188 void vpRowVector::init(const vpRowVector &v, unsigned int c, unsigned int ncols)
1189 {
1190  unsigned int cncols = c + ncols;
1191 
1192  if (cncols > v.getCols()) {
1193  throw(vpException(vpException::dimensionError, "Bad column dimension (%d > %d) used to initialize vpRowVector",
1194  cncols, v.getCols()));
1195  }
1196  resize(ncols);
1197  if (this->rowPtrs == nullptr) { // Fix coverity scan: explicit null dereferenced
1198  return; // Noting to do
1199  }
1200  for (unsigned int i = 0; i < ncols; ++i) {
1201  (*this)[i] = v[i + c];
1202  }
1203 }
1204 
1235 std::ostream &vpRowVector::cppPrint(std::ostream &os, const std::string &matrixName, bool octet) const
1236 {
1237  os << "vpRowVector " << matrixName << " (" << this->getCols() << "); " << std::endl;
1238 
1239  unsigned int this_cols = this->getCols();
1240  for (unsigned int j = 0; j < this_cols; ++j) {
1241  if (!octet) {
1242  os << matrixName << "[" << j << "] = " << (*this)[j] << "; " << std::endl;
1243  }
1244  else {
1245  for (unsigned int k = 0; k < sizeof(double); ++k) {
1246  os << "((unsigned char*)&(" << matrixName << "[" << j << "]) )[" << k << "] = 0x" << std::hex
1247  << static_cast<unsigned int>(((unsigned char *)&((*this)[j]))[k]) << "; " << std::endl;
1248  }
1249  }
1250  }
1251  std::cout << std::endl;
1252  return os;
1253 }
1254 
1279 std::ostream &vpRowVector::csvPrint(std::ostream &os) const
1280 {
1281  unsigned int this_cols = this->getCols();
1282  for (unsigned int j = 0; j < this_cols; ++j) {
1283  os << (*this)[j];
1284  if (!(j == (this->getCols() - 1))) {
1285  os << ", ";
1286  }
1287  }
1288  os << std::endl;
1289  return os;
1290 }
1291 
1315 std::ostream &vpRowVector::maplePrint(std::ostream &os) const
1316 {
1317  os << "([ " << std::endl;
1318  os << "[";
1319  unsigned int this_cols = this->getCols();
1320  for (unsigned int j = 0; j < this_cols; ++j) {
1321  os << (*this)[j] << ", ";
1322  }
1323  os << "]," << std::endl;
1324  os << "])" << std::endl;
1325  return os;
1326 }
1327 
1358 std::ostream &vpRowVector::matlabPrint(std::ostream &os) const
1359 {
1360  os << "[ ";
1361 
1362  unsigned int this_cols = this->getCols();
1363  for (unsigned int j = 0; j < this_cols; ++j) {
1364  os << (*this)[j] << ", ";
1365  }
1366  os << "]" << std::endl;
1367  return os;
1368 }
Implementation of a generic 2D array used as base class for matrices and vectors.
Definition: vpArray2D.h:126
unsigned int getCols() const
Definition: vpArray2D.h:329
double * data
Address of the first element of the data array.
Definition: vpArray2D.h:139
double ** rowPtrs
Address of the first element of each rows.
Definition: vpArray2D.h:133
void resize(unsigned int nrows, unsigned int ncols, bool flagNullify=true, bool recopy_=true)
Definition: vpArray2D.h:354
unsigned int rowNum
Number of rows in the array.
Definition: vpArray2D.h:129
unsigned int dsize
Current array size (rowNum * colNum)
Definition: vpArray2D.h:135
unsigned int size() const
Return the number of elements of the 2D array.
Definition: vpArray2D.h:341
unsigned int getRows() const
Definition: vpArray2D.h:339
unsigned int colNum
Number of columns in the array.
Definition: vpArray2D.h:131
Implementation of column vector and the associated operations.
Definition: vpColVector.h:163
vpColVector operator*(const double &x, const vpColVector &v)
error that can be emitted by ViSP classes.
Definition: vpException.h:59
@ dimensionError
Bad dimension.
Definition: vpException.h:70
static double getMedian(const std::vector< double > &v)
Definition: vpMath.cpp:323
static Type maximum(const Type &a, const Type &b)
Definition: vpMath.h:252
static bool equal(double x, double y, double threshold=0.001)
Definition: vpMath.h:454
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:146
Implementation of row vector and the associated operations.
Definition: vpRowVector.h:107
bool operator==(const vpRowVector &v) const
Comparison operator.
vpRowVector & operator/=(double x)
double frobeniusNorm() const
vpColVector t() const
vp_deprecated double euclideanNorm() const
void resize(unsigned int i, bool flagNullify=true)
Definition: vpRowVector.h:261
vpRowVector & operator+=(vpRowVector v)
bool operator!=(const vpRowVector &v) const
vpRowVector operator-() const
static double mean(const vpRowVector &v)
void insert(unsigned int i, const vpRowVector &v)
vpRowVector & operator,(double val)
vpRowVector()
Basic constructor that creates an empty 0-size row vector.
Definition: vpRowVector.h:110
vpColVector transpose() const
void stack(double d)
vpRowVector operator+(const vpRowVector &v) const
vpRowVector & operator=(const vpRowVector &v)
Copy operator. Allow operation such as A = v.
Definition: vpRowVector.cpp:55
vp_deprecated void init()
Definition: vpRowVector.h:309
std::ostream & maplePrint(std::ostream &os) const
double sum() const
double operator*(const vpColVector &x) const
std::ostream & cppPrint(std::ostream &os, const std::string &matrixName="A", bool octet=false) const
vpRowVector & operator*=(double x)
double sumSquare() const
vpRowVector & normalize()
std::ostream & csvPrint(std::ostream &os) const
vpRowVector operator/(double x) const
void reshape(vpMatrix &M, const unsigned int &nrows, const unsigned int &ncols)
static double median(const vpRowVector &v)
std::vector< double > toStdVector() const
vpRowVector & operator<<(const vpRowVector &v)
static double stdev(const vpRowVector &v, bool useBesselCorrection=false)
vpRowVector & operator-=(vpRowVector v)
int print(std::ostream &s, unsigned int length, char const *intro=0) const
std::ostream & matlabPrint(std::ostream &os) const