Visual Servoing Platform  version 3.2.1 under development (2019-05-26)
vpMatrix.h
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2019 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 http://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  * Matrix manipulation.
33  *
34  * Authors:
35  * Eric Marchand
36  *
37  *****************************************************************************/
38 
39 #ifndef vpMatrix_H
40 #define vpMatrix_H
41 
42 #include <visp3/core/vpArray2D.h>
43 #include <visp3/core/vpConfig.h>
44 #include <visp3/core/vpException.h>
45 #include <visp3/core/vpForceTwistMatrix.h>
46 #include <visp3/core/vpHomogeneousMatrix.h>
47 #include <visp3/core/vpRotationMatrix.h>
48 #include <visp3/core/vpTime.h>
49 #include <visp3/core/vpVelocityTwistMatrix.h>
50 
51 #ifdef VISP_HAVE_GSL
52 #include <gsl/gsl_eigen.h>
53 #include <gsl/gsl_math.h>
54 #endif
55 
56 #include <iostream>
57 #include <math.h>
58 
59 class vpRowVector;
60 class vpColVector;
64 class vpForceTwistMatrix;
65 
164 class VISP_EXPORT vpMatrix : public vpArray2D<double>
165 {
166 public:
171  typedef enum {
172  LU_DECOMPOSITION
173  } vpDetMethod;
174 
175 public:
180  vpMatrix() : vpArray2D<double>(0, 0) {}
181 
188  vpMatrix(unsigned int r, unsigned int c) : vpArray2D<double>(r, c) {}
189 
197  vpMatrix(unsigned int r, unsigned int c, double val) : vpArray2D<double>(r, c, val) {}
198  vpMatrix(const vpMatrix &M, unsigned int r, unsigned int c, unsigned int nrows, unsigned int ncols);
199 
212  vpMatrix(const vpArray2D<double> &A) : vpArray2D<double>(A) {}
213 
214  vpMatrix(const vpMatrix &A) : vpArray2D<double>(A) {}
215 
216 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
217  vpMatrix(vpMatrix &&A);
218 
242  explicit vpMatrix(const std::initializer_list<double> &list) : vpArray2D<double>(list) { }
243 
267  explicit vpMatrix(unsigned int nrows, unsigned int ncols, const std::initializer_list<double> &list)
268  : vpArray2D<double>(nrows, ncols, list) {}
269 
292  explicit vpMatrix(const std::initializer_list<std::initializer_list<double> > &lists) : vpArray2D<double>(lists) { }
293 #endif
294 
296  virtual ~vpMatrix() {}
297 
302  void clear()
303  {
304  if (data != NULL) {
305  free(data);
306  data = NULL;
307  }
308 
309  if (rowPtrs != NULL) {
310  free(rowPtrs);
311  rowPtrs = NULL;
312  }
313  rowNum = colNum = dsize = 0;
314  }
315 
316  //-------------------------------------------------
317  // Setting a diagonal matrix
318  //-------------------------------------------------
321  void diag(const double &val = 1.0);
322  void diag(const vpColVector &A);
323  // Initialize an identity matrix n-by-n
324  void eye();
325  void eye(unsigned int n);
326  // Initialize an identity matrix m-by-n
327  void eye(unsigned int m, unsigned int n);
329 
330  //---------------------------------
331  // Assignment
332  //---------------------------------
335  vpMatrix &operator<<(double *);
336  vpMatrix& operator<<(double val);
337  vpMatrix& operator,(double val);
339 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
340  vpMatrix &operator=(const vpMatrix &A);
342 
343  vpMatrix& operator=(const std::initializer_list<double> &list);
344  vpMatrix& operator=(const std::initializer_list<std::initializer_list<double> > &lists);
345 #endif
346  vpMatrix &operator=(const double x);
348 
349  //-------------------------------------------------
350  // Stacking
351  //-------------------------------------------------
354  // Stack the matrix A below the current one, copy if not initialized this =
355  // [ this A ]^T
356  void stack(const vpMatrix &A);
357  void stack(const vpRowVector &r);
358  void stack(const vpColVector &c);
359  // Stacks columns of a matrix in a vector
360  void stackColumns(vpColVector &out);
361 
362  // Stacks columns of a matrix in a vector
363  vpColVector stackColumns();
364 
365  // Stacks columns of a matrix in a vector
366  void stackRows(vpRowVector &out);
367 
368  // Stacks columns of a matrix in a vector
369  vpRowVector stackRows();
371 
372  //---------------------------------
373  // Matrix insertion
374  //---------------------------------
377  // Insert matrix A in the current matrix at the given position (r, c).
378  void insert(const vpMatrix &A, const unsigned int r, const unsigned int c);
380 
381  //-------------------------------------------------
382  // Columns, Rows extraction, SubMatrix
383  //-------------------------------------------------
386  vpMatrix extract(unsigned int r, unsigned int c, unsigned int nrows, unsigned int ncols) const;
387  vpColVector getCol(const unsigned int j) const;
388  vpColVector getCol(const unsigned int j, const unsigned int i_begin, const unsigned int size) const;
389  vpRowVector getRow(const unsigned int i) const;
390  vpRowVector getRow(const unsigned int i, const unsigned int j_begin, const unsigned int size) const;
391  void init(const vpMatrix &M, unsigned int r, unsigned int c, unsigned int nrows, unsigned int ncols);
393 
394  //---------------------------------
395  // Matrix operations.
396  //---------------------------------
399  // return the determinant of the matrix.
400  double det(vpDetMethod method = LU_DECOMPOSITION) const;
401  double detByLU() const;
402 #ifdef VISP_HAVE_EIGEN3
403  double detByLUEigen3() const;
404 #endif
405 #ifdef VISP_HAVE_GSL
406  double detByLUGsl() const;
407 #endif
408 #if defined(VISP_HAVE_LAPACK)
409  double detByLULapack() const;
410 #endif
411 #if (VISP_HAVE_OPENCV_VERSION >= 0x020101)
412  double detByLUOpenCV() const;
413 #endif
414 
415  // Compute the exponential matrix of a square matrix
416  vpMatrix expm() const;
417 
418  // operation A = A + B
419  vpMatrix &operator+=(const vpMatrix &B);
420  // operation A = A - B
421  vpMatrix &operator-=(const vpMatrix &B);
422  vpMatrix operator*(const vpMatrix &B) const;
423  vpMatrix operator*(const vpRotationMatrix &R) const;
424  vpMatrix operator*(const vpVelocityTwistMatrix &V) const;
425  vpMatrix operator*(const vpForceTwistMatrix &V) const;
426  // operation t_out = A * t (A is unchanged, t and t_out are translation
427  // vectors)
428  vpTranslationVector operator*(const vpTranslationVector &tv) const;
429  vpColVector operator*(const vpColVector &v) const;
430  vpMatrix operator+(const vpMatrix &B) const;
431  vpMatrix operator-(const vpMatrix &B) const;
432  vpMatrix operator-() const;
433 
435  vpMatrix &operator+=(const double x);
437  vpMatrix &operator-=(const double x);
439  vpMatrix &operator*=(const double x);
441  vpMatrix &operator/=(double x);
442 
443  // Cij = Aij * x (A is unchanged)
444  vpMatrix operator*(const double x) const;
445  // Cij = Aij / x (A is unchanged)
446  vpMatrix operator/(const double x) const;
447 
453  double sum() const;
454  double sumSquare() const;
455 
456  //-------------------------------------------------
457  // Hadamard product
458  //-------------------------------------------------
460  vpMatrix hadamard(const vpMatrix &m) const;
461 
462  //-------------------------------------------------
463  // Kronecker product
464  //-------------------------------------------------
467  // Compute Kronecker product matrix
468  void kron(const vpMatrix &m1, vpMatrix &out) const;
469 
470  // Compute Kronecker product matrix
471  vpMatrix kron(const vpMatrix &m1) const;
473 
474  //-------------------------------------------------
475  // Transpose
476  //-------------------------------------------------
479  // Compute the transpose C = A^T
480  vpMatrix t() const;
481 
482  // Compute the transpose C = A^T
483  vpMatrix transpose() const;
484  void transpose(vpMatrix &C) const;
485 
486  vpMatrix AAt() const;
487  void AAt(vpMatrix &B) const;
488 
489  vpMatrix AtA() const;
490  void AtA(vpMatrix &B) const;
492 
493  //-------------------------------------------------
494  // Matrix inversion
495  //-------------------------------------------------
498  // inverse matrix A using the LU decomposition
499  vpMatrix inverseByLU() const;
500 
501 #if defined(VISP_HAVE_EIGEN3)
502  vpMatrix inverseByLUEigen3() const;
503 #endif
504 #if defined(VISP_HAVE_GSL)
505  vpMatrix inverseByLUGsl() const;
506 #endif
507 #if defined(VISP_HAVE_LAPACK)
508  vpMatrix inverseByLULapack() const;
509 #endif
510 #if (VISP_HAVE_OPENCV_VERSION >= 0x020101)
511  vpMatrix inverseByLUOpenCV() const;
512 #endif
513 
514  // inverse matrix A using the Cholesky decomposition (only for real
515  // symmetric matrices)
516  vpMatrix inverseByCholesky() const;
517 
518 #if defined(VISP_HAVE_LAPACK)
519  vpMatrix inverseByCholeskyLapack() const;
520 #endif
521 #if (VISP_HAVE_OPENCV_VERSION >= 0x020101)
522  vpMatrix inverseByCholeskyOpenCV() const;
523 #endif
524 
525  // inverse matrix A using the QR decomposition
526  vpMatrix inverseByQR() const;
527 #if defined(VISP_HAVE_LAPACK)
528  vpMatrix inverseByQRLapack() const;
529 #endif
530 
531  // inverse triangular matrix
532  vpMatrix inverseTriangular(bool upper = true) const;
533 
534 
535  vpMatrix pseudoInverse(double svThreshold = 1e-6) const;
536  unsigned int pseudoInverse(vpMatrix &Ap, double svThreshold = 1e-6) const;
537  unsigned int pseudoInverse(vpMatrix &Ap, vpColVector &sv, double svThreshold = 1e-6) const;
538  unsigned int pseudoInverse(vpMatrix &Ap, vpColVector &sv, double svThreshold, vpMatrix &imA, vpMatrix &imAt) const;
539  unsigned int pseudoInverse(vpMatrix &Ap, vpColVector &sv, double svThreshold, vpMatrix &imA, vpMatrix &imAt,
540  vpMatrix &kerAt) const;
541 
542 #if defined(VISP_HAVE_LAPACK)
543  vpMatrix pseudoInverseLapack(double svThreshold = 1e-6) const;
544  unsigned int pseudoInverseLapack(vpMatrix &Ap, double svThreshold = 1e-6) const;
545  unsigned int pseudoInverseLapack(vpMatrix &Ap, vpColVector &sv, double svThreshold = 1e-6) const;
546  unsigned int pseudoInverseLapack(vpMatrix &Ap, vpColVector &sv, double svThreshold, vpMatrix &imA, vpMatrix &imAt,
547  vpMatrix &kerAt) const;
548 #endif
549 #if defined(VISP_HAVE_EIGEN3)
550  vpMatrix pseudoInverseEigen3(double svThreshold = 1e-6) const;
551  unsigned int pseudoInverseEigen3(vpMatrix &Ap, double svThreshold = 1e-6) const;
552  unsigned int pseudoInverseEigen3(vpMatrix &Ap, vpColVector &sv, double svThreshold = 1e-6) const;
553  unsigned int pseudoInverseEigen3(vpMatrix &Ap, vpColVector &sv, double svThreshold, vpMatrix &imA, vpMatrix &imAt,
554  vpMatrix &kerAt) const;
555 #endif
556 #if (VISP_HAVE_OPENCV_VERSION >= 0x020101)
557  vpMatrix pseudoInverseOpenCV(double svThreshold = 1e-6) const;
558  unsigned int pseudoInverseOpenCV(vpMatrix &Ap, double svThreshold = 1e-6) const;
559  unsigned int pseudoInverseOpenCV(vpMatrix &Ap, vpColVector &sv, double svThreshold = 1e-6) const;
560  unsigned int pseudoInverseOpenCV(vpMatrix &Ap, vpColVector &sv, double svThreshold, vpMatrix &imA, vpMatrix &imAt,
561  vpMatrix &kerAt) const;
562 #endif
563 #if defined(VISP_HAVE_GSL)
564  vpMatrix pseudoInverseGsl(double svThreshold = 1e-6) const;
565  unsigned int pseudoInverseGsl(vpMatrix &Ap, double svThreshold = 1e-6) const;
566  unsigned int pseudoInverseGsl(vpMatrix &Ap, vpColVector &sv, double svThreshold = 1e-6) const;
567  unsigned int pseudoInverseGsl(vpMatrix &Ap, vpColVector &sv, double svThreshold, vpMatrix &imA, vpMatrix &imAt,
568  vpMatrix &kerAt) const;
569 #endif
570 
572 
573  //-------------------------------------------------
574  // SVD decomposition
575  //-------------------------------------------------
576 
579  double cond(double svThreshold = 1e-6) const;
580  unsigned int kernel(vpMatrix &kerAt, double svThreshold = 1e-6) const;
581 
582  // solve Ax=B using the SVD decomposition (usage A = solveBySVD(B,x) )
583  void solveBySVD(const vpColVector &B, vpColVector &x) const;
584  // solve Ax=B using the SVD decomposition (usage x=A.solveBySVD(B))
585  vpColVector solveBySVD(const vpColVector &B) const;
586 
587  // singular value decomposition SVD
588  void svd(vpColVector &w, vpMatrix &V);
589 #ifdef VISP_HAVE_EIGEN3
590  void svdEigen3(vpColVector &w, vpMatrix &V);
591 #endif
592 #ifdef VISP_HAVE_GSL
593  void svdGsl(vpColVector &w, vpMatrix &V);
594 #endif
595 #if defined(VISP_HAVE_LAPACK)
596  void svdLapack(vpColVector &w, vpMatrix &V);
597 #endif
598 #if (VISP_HAVE_OPENCV_VERSION >= 0x020101) // Require opencv >= 2.1.1
599  void svdOpenCV(vpColVector &w, vpMatrix &V);
600 #endif
601 
602 
603  //-------------------------------------------------
604  // QR decomposition
605  //-------------------------------------------------
606 
609  unsigned int qr(vpMatrix &Q, vpMatrix &R, bool full = false, bool squareR = false, double tol = 1e-6) const;
610  unsigned int qrPivot(vpMatrix &Q, vpMatrix &R, vpMatrix &P, bool full = false, bool squareR = false, double tol = 1e-6) const;
611  void solveByQR(const vpColVector &b, vpColVector &x) const;
612  vpColVector solveByQR(const vpColVector &b) const;
614 
615  //-------------------------------------------------
616  // Eigen values and vectors
617  //-------------------------------------------------
621  // compute the eigen values using the Gnu Scientific library
622  vpColVector eigenValues() const;
623  void eigenValues(vpColVector &evalue, vpMatrix &evector) const;
625 
626  //-------------------------------------------------
627  // Norms
628  //-------------------------------------------------
631  double euclideanNorm() const;
632  double frobeniusNorm() const;
633  double inducedL2Norm() const;
634  double infinityNorm() const;
636 
637  //---------------------------------
638  // Printing
639  //---------------------------------
642  std::ostream &cppPrint(std::ostream &os, const std::string &matrixName = "A", bool octet = false) const;
643  std::ostream &csvPrint(std::ostream &os) const;
644  std::ostream &maplePrint(std::ostream &os) const;
645  std::ostream &matlabPrint(std::ostream &os) const;
646  int print(std::ostream &s, unsigned int length, const std::string &intro = "") const;
647  void printSize() const { std::cout << getRows() << " x " << getCols() << " "; }
649 
650  //------------------------------------------------------------------
651  // Static functionalities
652  //------------------------------------------------------------------
653 
654  //---------------------------------
655  // Setting a diagonal matrix with Static Public Member Functions
656  //---------------------------------
659  // Create a diagonal matrix with the element of a vector DAii = Ai
660  static void createDiagonalMatrix(const vpColVector &A, vpMatrix &DA);
662 
663  //---------------------------------
664  // Matrix insertion with Static Public Member Functions
665  //---------------------------------
668  // Insert matrix B in matrix A at the given position (r, c).
669  static vpMatrix insert(const vpMatrix &A, const vpMatrix &B, const unsigned int r, const unsigned int c);
670  // Insert matrix B in matrix A (not modified) at the given position (r, c),
671  // the result is given in matrix C.
672  static void insert(const vpMatrix &A, const vpMatrix &B, vpMatrix &C, const unsigned int r, const unsigned int c);
673 
674  //---------------------------------
675  // Stacking with Static Public Member Functions
676  //---------------------------------
679  // Juxtapose to matrices C = [ A B ]
680  static vpMatrix juxtaposeMatrices(const vpMatrix &A, const vpMatrix &B);
681  // Juxtapose to matrices C = [ A B ]
682  static void juxtaposeMatrices(const vpMatrix &A, const vpMatrix &B, vpMatrix &C);
683  // Stack two matrices C = [ A B ]^T
684  static vpMatrix stack(const vpMatrix &A, const vpMatrix &B);
685  static vpMatrix stack(const vpMatrix &A, const vpRowVector &r);
686  static vpMatrix stack(const vpMatrix &A, const vpColVector &c);
687 
688  // Stack two matrices C = [ A B ]^T
689  static void stack(const vpMatrix &A, const vpMatrix &B, vpMatrix &C);
690  static void stack(const vpMatrix &A, const vpRowVector &r, vpMatrix &C);
691  static void stack(const vpMatrix &A, const vpColVector &c, vpMatrix &C);
693 
694  //---------------------------------
695  // Matrix operations Static Public Member Functions
696  //---------------------------------
699  static void add2Matrices(const vpMatrix &A, const vpMatrix &B, vpMatrix &C);
700  static void add2Matrices(const vpColVector &A, const vpColVector &B, vpColVector &C);
701  static void add2WeightedMatrices(const vpMatrix &A, const double &wA, const vpMatrix &B, const double &wB,
702  vpMatrix &C);
703  static void computeHLM(const vpMatrix &H, const double &alpha, vpMatrix &HLM);
704  static void mult2Matrices(const vpMatrix &A, const vpMatrix &B, vpMatrix &C);
705  static void mult2Matrices(const vpMatrix &A, const vpMatrix &B, vpRotationMatrix &C);
706  static void mult2Matrices(const vpMatrix &A, const vpMatrix &B, vpHomogeneousMatrix &C);
707  static void mult2Matrices(const vpMatrix &A, const vpColVector &B, vpColVector &C);
708  static void multMatrixVector(const vpMatrix &A, const vpColVector &v, vpColVector &w);
709  static void negateMatrix(const vpMatrix &A, vpMatrix &C);
710  static void sub2Matrices(const vpMatrix &A, const vpMatrix &B, vpMatrix &C);
711  static void sub2Matrices(const vpColVector &A, const vpColVector &B, vpColVector &C);
713 
714  //---------------------------------
715  // Kronecker product Static Public Member Functions
716  //---------------------------------
719  // Compute Kronecker product matrix
720  static void kron(const vpMatrix &m1, const vpMatrix &m2, vpMatrix &out);
721 
722  // Compute Kronecker product matrix
723  static vpMatrix kron(const vpMatrix &m1, const vpMatrix &m2);
725 
726  //-------------------------------------------------
727  // 2D Convolution Static Public Member Functions
728  //-------------------------------------------------
730  static vpMatrix conv2(const vpMatrix &M, const vpMatrix &kernel, const std::string &mode="full");
731  static void conv2(const vpMatrix &M, const vpMatrix &kernel, vpMatrix &res, const std::string &mode="full");
732 
733  //---------------------------------
734  // Covariance computation Static Public Member Functions
735  //---------------------------------
738  static vpMatrix computeCovarianceMatrix(const vpMatrix &A, const vpColVector &x, const vpColVector &b);
739  static vpMatrix computeCovarianceMatrix(const vpMatrix &A, const vpColVector &x, const vpColVector &b,
740  const vpMatrix &w);
741  static vpMatrix computeCovarianceMatrixVVS(const vpHomogeneousMatrix &cMo, const vpColVector &deltaS,
742  const vpMatrix &Ls, const vpMatrix &W);
743  static vpMatrix computeCovarianceMatrixVVS(const vpHomogeneousMatrix &cMo, const vpColVector &deltaS,
744  const vpMatrix &Ls);
746 
747  //---------------------------------
748  // Matrix I/O Static Public Member Functions
749  //---------------------------------
763  static inline bool loadMatrix(const std::string &filename, vpArray2D<double> &M, const bool binary = false,
764  char *header = NULL)
765  {
766  return vpArray2D<double>::load(filename, M, binary, header);
767  }
768 
779  static inline bool loadMatrixYAML(const std::string &filename, vpArray2D<double> &M, char *header = NULL)
780  {
781  return vpArray2D<double>::loadYAML(filename, M, header);
782  }
783 
798  static inline bool saveMatrix(const std::string &filename, const vpArray2D<double> &M, const bool binary = false,
799  const char *header = "")
800  {
801  return vpArray2D<double>::save(filename, M, binary, header);
802  }
803 
816  static inline bool saveMatrixYAML(const std::string &filename, const vpArray2D<double> &M, const char *header = "")
817  {
818  return vpArray2D<double>::saveYAML(filename, M, header);
819  }
821 
822 #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
823 
831  vp_deprecated void init() {}
832 
836  vp_deprecated void stackMatrices(const vpMatrix &A) { stack(A); }
841  vp_deprecated static vpMatrix stackMatrices(const vpMatrix &A, const vpMatrix &B) { return stack(A, B); }
846  vp_deprecated static void stackMatrices(const vpMatrix &A, const vpMatrix &B, vpMatrix &C) { stack(A, B, C); }
851  vp_deprecated static vpMatrix stackMatrices(const vpMatrix &A, const vpRowVector &B);
856  vp_deprecated static void stackMatrices(const vpMatrix &A, const vpRowVector &B, vpMatrix &C);
861  vp_deprecated static vpMatrix stackMatrices(const vpColVector &A, const vpColVector &B);
866  vp_deprecated static void stackMatrices(const vpColVector &A, const vpColVector &B, vpColVector &C);
867 
871  vp_deprecated void setIdentity(const double &val = 1.0);
872 
873  vp_deprecated vpRowVector row(const unsigned int i);
874  vp_deprecated vpColVector column(const unsigned int j);
875 
877 #endif
878 
879 private:
880 #if defined(VISP_HAVE_LAPACK) && !defined(VISP_HAVE_LAPACK_BUILT_IN)
881  static void blas_dgemm(char trans_a, char trans_b, const int M, const int N, const int K, double alpha,
882  double *a_data, const int lda, double *b_data, const int ldb, double beta, double *c_data,
883  const int ldc);
884  static void blas_dgemv(char trans, const int M, const int N, double alpha, double *a_data, const int lda,
885  double *x_data, const int incx, double beta, double *y_data, const int incy);
886 #endif
887 
888  static void computeCovarianceMatrixVVS(const vpHomogeneousMatrix &cMo, const vpColVector &deltaS, const vpMatrix &Ls,
889  vpMatrix &Js, vpColVector &deltaP);
890 };
891 
893 
894 #ifndef DOXYGEN_SHOULD_SKIP_THIS
895 VISP_EXPORT
896 #endif
897 vpMatrix operator*(const double &x, const vpMatrix &A);
898 
899 #endif
vpMatrix(const std::initializer_list< std::initializer_list< double > > &lists)
Definition: vpMatrix.h:292
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:164
static bool save(const std::string &filename, const vpArray2D< Type > &A, const bool binary=false, const char *header="")
Definition: vpArray2D.h:730
static bool saveYAML(const std::string &filename, const vpArray2D< Type > &A, const char *header="")
Definition: vpArray2D.h:823
static bool loadMatrix(const std::string &filename, vpArray2D< double > &M, const bool binary=false, char *header=NULL)
Definition: vpMatrix.h:763
vpArray2D< Type > & operator=(Type x)
Set all the elements of the array to x.
Definition: vpArray2D.h:406
static bool loadYAML(const std::string &filename, vpArray2D< Type > &A, char *header=NULL)
Definition: vpArray2D.h:645
vpMatrix(unsigned int nrows, unsigned int ncols, const std::initializer_list< double > &list)
Definition: vpMatrix.h:267
Implementation of an homogeneous matrix and operations on such kind of matrices.
Implementation of row vector and the associated operations.
Definition: vpRowVector.h:115
vp_deprecated void stackMatrices(const vpMatrix &A)
Definition: vpMatrix.h:836
Implementation of a generic 2D array used as base class for matrices and vectors. ...
Definition: vpArray2D.h:131
unsigned int getCols() const
Definition: vpArray2D.h:279
void printSize() const
Definition: vpMatrix.h:647
vpMatrix(unsigned int r, unsigned int c, double val)
Definition: vpMatrix.h:197
vpMatrix()
Definition: vpMatrix.h:180
Implementation of a rotation matrix and operations on such kind of matrices.
vpColVector operator*(const double &x, const vpColVector &v)
static vp_deprecated void stackMatrices(const vpMatrix &A, const vpMatrix &B, vpMatrix &C)
Definition: vpMatrix.h:846
vpMatrix(const vpMatrix &A)
Definition: vpMatrix.h:214
vp_deprecated void init()
Definition: vpMatrix.h:831
static bool load(const std::string &filename, vpArray2D< Type > &A, const bool binary=false, char *header=NULL)
Definition: vpArray2D.h:533
void clear()
Definition: vpMatrix.h:302
friend std::ostream & operator<<(std::ostream &s, const vpArray2D< Type > &A)
Definition: vpArray2D.h:486
unsigned int getRows() const
Definition: vpArray2D.h:289
vpArray2D< Type > hadamard(const vpArray2D< Type > &m) const
Definition: vpArray2D.h:925
static vp_deprecated vpMatrix stackMatrices(const vpMatrix &A, const vpMatrix &B)
Definition: vpMatrix.h:841
vpMatrix(unsigned int r, unsigned int c)
Definition: vpMatrix.h:188
vpMatrix(const std::initializer_list< double > &list)
Definition: vpMatrix.h:242
Implementation of column vector and the associated operations.
Definition: vpColVector.h:130
virtual ~vpMatrix()
Destructor (Memory de-allocation)
Definition: vpMatrix.h:296
static bool saveMatrixYAML(const std::string &filename, const vpArray2D< double > &M, const char *header="")
Definition: vpMatrix.h:816
static bool saveMatrix(const std::string &filename, const vpArray2D< double > &M, const bool binary=false, const char *header="")
Definition: vpMatrix.h:798
vpMatrix(const vpArray2D< double > &A)
Definition: vpMatrix.h:212
Class that consider the case of a translation vector.
static bool loadMatrixYAML(const std::string &filename, vpArray2D< double > &M, char *header=NULL)
Definition: vpMatrix.h:779