Visual Servoing Platform  version 3.2.1 under development (2019-09-22) under development (2019-09-22)
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, Diag 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  vpColVector getDiag() const;
392  void init(const vpMatrix &M, unsigned int r, unsigned int c, unsigned int nrows, unsigned int ncols);
394 
395  //---------------------------------
396  // Matrix operations.
397  //---------------------------------
400  // return the determinant of the matrix.
401  double det(vpDetMethod method = LU_DECOMPOSITION) const;
402  double detByLU() const;
403 #ifdef VISP_HAVE_EIGEN3
404  double detByLUEigen3() const;
405 #endif
406 #ifdef VISP_HAVE_GSL
407  double detByLUGsl() const;
408 #endif
409 #if defined(VISP_HAVE_LAPACK)
410  double detByLULapack() const;
411 #endif
412 #if (VISP_HAVE_OPENCV_VERSION >= 0x020101)
413  double detByLUOpenCV() const;
414 #endif
415 
416  // Compute the exponential matrix of a square matrix
417  vpMatrix expm() const;
418 
419  // operation A = A + B
420  vpMatrix &operator+=(const vpMatrix &B);
421  // operation A = A - B
422  vpMatrix &operator-=(const vpMatrix &B);
423  vpMatrix operator*(const vpMatrix &B) const;
424  vpMatrix operator*(const vpRotationMatrix &R) const;
425  vpMatrix operator*(const vpVelocityTwistMatrix &V) const;
426  vpMatrix operator*(const vpForceTwistMatrix &V) const;
427  // operation t_out = A * t (A is unchanged, t and t_out are translation
428  // vectors)
429  vpTranslationVector operator*(const vpTranslationVector &tv) const;
430  vpColVector operator*(const vpColVector &v) const;
431  vpMatrix operator+(const vpMatrix &B) const;
432  vpMatrix operator-(const vpMatrix &B) const;
433  vpMatrix operator-() const;
434 
436  vpMatrix &operator+=(const double x);
438  vpMatrix &operator-=(const double x);
440  vpMatrix &operator*=(const double x);
442  vpMatrix &operator/=(double x);
443 
444  // Cij = Aij * x (A is unchanged)
445  vpMatrix operator*(const double x) const;
446  // Cij = Aij / x (A is unchanged)
447  vpMatrix operator/(const double x) const;
448 
454  double sum() const;
455  double sumSquare() const;
456 
457  //-------------------------------------------------
458  // Hadamard product
459  //-------------------------------------------------
461  vpMatrix hadamard(const vpMatrix &m) const;
462 
463  //-------------------------------------------------
464  // Kronecker product
465  //-------------------------------------------------
468  // Compute Kronecker product matrix
469  void kron(const vpMatrix &m1, vpMatrix &out) const;
470 
471  // Compute Kronecker product matrix
472  vpMatrix kron(const vpMatrix &m1) const;
474 
475  //-------------------------------------------------
476  // Transpose
477  //-------------------------------------------------
480  // Compute the transpose C = A^T
481  vpMatrix t() const;
482 
483  // Compute the transpose C = A^T
484  vpMatrix transpose() const;
485  void transpose(vpMatrix &C) const;
486 
487  vpMatrix AAt() const;
488  void AAt(vpMatrix &B) const;
489 
490  vpMatrix AtA() const;
491  void AtA(vpMatrix &B) const;
493 
494  //-------------------------------------------------
495  // Matrix inversion
496  //-------------------------------------------------
499  // inverse matrix A using the LU decomposition
500  vpMatrix inverseByLU() const;
501 
502 #if defined(VISP_HAVE_EIGEN3)
503  vpMatrix inverseByLUEigen3() const;
504 #endif
505 #if defined(VISP_HAVE_GSL)
506  vpMatrix inverseByLUGsl() const;
507 #endif
508 #if defined(VISP_HAVE_LAPACK)
509  vpMatrix inverseByLULapack() const;
510 #endif
511 #if (VISP_HAVE_OPENCV_VERSION >= 0x020101)
512  vpMatrix inverseByLUOpenCV() const;
513 #endif
514 
515  // inverse matrix A using the Cholesky decomposition (only for real
516  // symmetric matrices)
517  vpMatrix inverseByCholesky() const;
518 
519 #if defined(VISP_HAVE_LAPACK)
520  vpMatrix inverseByCholeskyLapack() const;
521 #endif
522 #if (VISP_HAVE_OPENCV_VERSION >= 0x020101)
523  vpMatrix inverseByCholeskyOpenCV() const;
524 #endif
525 
526  // inverse matrix A using the QR decomposition
527  vpMatrix inverseByQR() const;
528 #if defined(VISP_HAVE_LAPACK)
529  vpMatrix inverseByQRLapack() const;
530 #endif
531 
532  // inverse triangular matrix
533  vpMatrix inverseTriangular(bool upper = true) const;
534 
535 
536  vpMatrix pseudoInverse(double svThreshold = 1e-6) const;
537  unsigned int pseudoInverse(vpMatrix &Ap, double svThreshold = 1e-6) const;
538  unsigned int pseudoInverse(vpMatrix &Ap, vpColVector &sv, double svThreshold = 1e-6) const;
539  unsigned int pseudoInverse(vpMatrix &Ap, vpColVector &sv, double svThreshold, vpMatrix &imA, vpMatrix &imAt) const;
540  unsigned int pseudoInverse(vpMatrix &Ap, vpColVector &sv, double svThreshold, vpMatrix &imA, vpMatrix &imAt,
541  vpMatrix &kerAt) const;
542 
543 #if defined(VISP_HAVE_LAPACK)
544  vpMatrix pseudoInverseLapack(double svThreshold = 1e-6) const;
545  unsigned int pseudoInverseLapack(vpMatrix &Ap, double svThreshold = 1e-6) const;
546  unsigned int pseudoInverseLapack(vpMatrix &Ap, vpColVector &sv, double svThreshold = 1e-6) const;
547  unsigned int pseudoInverseLapack(vpMatrix &Ap, vpColVector &sv, double svThreshold, vpMatrix &imA, vpMatrix &imAt,
548  vpMatrix &kerAt) const;
549 #endif
550 #if defined(VISP_HAVE_EIGEN3)
551  vpMatrix pseudoInverseEigen3(double svThreshold = 1e-6) const;
552  unsigned int pseudoInverseEigen3(vpMatrix &Ap, double svThreshold = 1e-6) const;
553  unsigned int pseudoInverseEigen3(vpMatrix &Ap, vpColVector &sv, double svThreshold = 1e-6) const;
554  unsigned int pseudoInverseEigen3(vpMatrix &Ap, vpColVector &sv, double svThreshold, vpMatrix &imA, vpMatrix &imAt,
555  vpMatrix &kerAt) const;
556 #endif
557 #if (VISP_HAVE_OPENCV_VERSION >= 0x020101)
558  vpMatrix pseudoInverseOpenCV(double svThreshold = 1e-6) const;
559  unsigned int pseudoInverseOpenCV(vpMatrix &Ap, double svThreshold = 1e-6) const;
560  unsigned int pseudoInverseOpenCV(vpMatrix &Ap, vpColVector &sv, double svThreshold = 1e-6) const;
561  unsigned int pseudoInverseOpenCV(vpMatrix &Ap, vpColVector &sv, double svThreshold, vpMatrix &imA, vpMatrix &imAt,
562  vpMatrix &kerAt) const;
563 #endif
564 #if defined(VISP_HAVE_GSL)
565  vpMatrix pseudoInverseGsl(double svThreshold = 1e-6) const;
566  unsigned int pseudoInverseGsl(vpMatrix &Ap, double svThreshold = 1e-6) const;
567  unsigned int pseudoInverseGsl(vpMatrix &Ap, vpColVector &sv, double svThreshold = 1e-6) const;
568  unsigned int pseudoInverseGsl(vpMatrix &Ap, vpColVector &sv, double svThreshold, vpMatrix &imA, vpMatrix &imAt,
569  vpMatrix &kerAt) const;
570 #endif
571 
573 
574  //-------------------------------------------------
575  // SVD decomposition
576  //-------------------------------------------------
577 
580  double cond(double svThreshold = 1e-6) const;
581  unsigned int kernel(vpMatrix &kerAt, double svThreshold = 1e-6) const;
582 
583  // solve Ax=B using the SVD decomposition (usage A = solveBySVD(B,x) )
584  void solveBySVD(const vpColVector &B, vpColVector &x) const;
585  // solve Ax=B using the SVD decomposition (usage x=A.solveBySVD(B))
586  vpColVector solveBySVD(const vpColVector &B) const;
587 
588  // singular value decomposition SVD
589  void svd(vpColVector &w, vpMatrix &V);
590 #ifdef VISP_HAVE_EIGEN3
591  void svdEigen3(vpColVector &w, vpMatrix &V);
592 #endif
593 #ifdef VISP_HAVE_GSL
594  void svdGsl(vpColVector &w, vpMatrix &V);
595 #endif
596 #if defined(VISP_HAVE_LAPACK)
597  void svdLapack(vpColVector &w, vpMatrix &V);
598 #endif
599 #if (VISP_HAVE_OPENCV_VERSION >= 0x020101) // Require opencv >= 2.1.1
600  void svdOpenCV(vpColVector &w, vpMatrix &V);
601 #endif
602 
603 
604  //-------------------------------------------------
605  // QR decomposition
606  //-------------------------------------------------
607 
610  unsigned int qr(vpMatrix &Q, vpMatrix &R, bool full = false, bool squareR = false, double tol = 1e-6) const;
611  unsigned int qrPivot(vpMatrix &Q, vpMatrix &R, vpMatrix &P, bool full = false, bool squareR = false, double tol = 1e-6) const;
612  void solveByQR(const vpColVector &b, vpColVector &x) const;
613  vpColVector solveByQR(const vpColVector &b) const;
615 
616  //-------------------------------------------------
617  // Eigen values and vectors
618  //-------------------------------------------------
622  // compute the eigen values using the Gnu Scientific library
623  vpColVector eigenValues() const;
624  void eigenValues(vpColVector &evalue, vpMatrix &evector) const;
626 
627  //-------------------------------------------------
628  // Norms
629  //-------------------------------------------------
632  double euclideanNorm() const;
633  double frobeniusNorm() const;
634  double inducedL2Norm() const;
635  double infinityNorm() const;
637 
638  //---------------------------------
639  // Printing
640  //---------------------------------
643  std::ostream &cppPrint(std::ostream &os, const std::string &matrixName = "A", bool octet = false) const;
644  std::ostream &csvPrint(std::ostream &os) const;
645  std::ostream &maplePrint(std::ostream &os) const;
646  std::ostream &matlabPrint(std::ostream &os) const;
647  int print(std::ostream &s, unsigned int length, const std::string &intro = "") const;
648  void printSize() const { std::cout << getRows() << " x " << getCols() << " "; }
650 
651  //------------------------------------------------------------------
652  // Static functionalities
653  //------------------------------------------------------------------
654 
655  //---------------------------------
656  // Setting a diagonal matrix with Static Public Member Functions
657  //---------------------------------
660  // Create a diagonal matrix with the element of a vector DAii = Ai
661  static void createDiagonalMatrix(const vpColVector &A, vpMatrix &DA);
663 
664  //---------------------------------
665  // Matrix insertion with Static Public Member Functions
666  //---------------------------------
669  // Insert matrix B in matrix A at the given position (r, c).
670  static vpMatrix insert(const vpMatrix &A, const vpMatrix &B, const unsigned int r, const unsigned int c);
671  // Insert matrix B in matrix A (not modified) at the given position (r, c),
672  // the result is given in matrix C.
673  static void insert(const vpMatrix &A, const vpMatrix &B, vpMatrix &C, const unsigned int r, const unsigned int c);
674 
675  //---------------------------------
676  // Stacking with Static Public Member Functions
677  //---------------------------------
680  // Juxtapose to matrices C = [ A B ]
681  static vpMatrix juxtaposeMatrices(const vpMatrix &A, const vpMatrix &B);
682  // Juxtapose to matrices C = [ A B ]
683  static void juxtaposeMatrices(const vpMatrix &A, const vpMatrix &B, vpMatrix &C);
684  // Stack two matrices C = [ A B ]^T
685  static vpMatrix stack(const vpMatrix &A, const vpMatrix &B);
686  static vpMatrix stack(const vpMatrix &A, const vpRowVector &r);
687  static vpMatrix stack(const vpMatrix &A, const vpColVector &c);
688 
689  // Stack two matrices C = [ A B ]^T
690  static void stack(const vpMatrix &A, const vpMatrix &B, vpMatrix &C);
691  static void stack(const vpMatrix &A, const vpRowVector &r, vpMatrix &C);
692  static void stack(const vpMatrix &A, const vpColVector &c, vpMatrix &C);
694 
695  //---------------------------------
696  // Matrix operations Static Public Member Functions
697  //---------------------------------
700  static void add2Matrices(const vpMatrix &A, const vpMatrix &B, vpMatrix &C);
701  static void add2Matrices(const vpColVector &A, const vpColVector &B, vpColVector &C);
702  static void add2WeightedMatrices(const vpMatrix &A, const double &wA, const vpMatrix &B, const double &wB,
703  vpMatrix &C);
704  static void computeHLM(const vpMatrix &H, const double &alpha, vpMatrix &HLM);
705  static void mult2Matrices(const vpMatrix &A, const vpMatrix &B, vpMatrix &C);
706  static void mult2Matrices(const vpMatrix &A, const vpMatrix &B, vpRotationMatrix &C);
707  static void mult2Matrices(const vpMatrix &A, const vpMatrix &B, vpHomogeneousMatrix &C);
708  static void mult2Matrices(const vpMatrix &A, const vpColVector &B, vpColVector &C);
709  static void multMatrixVector(const vpMatrix &A, const vpColVector &v, vpColVector &w);
710  static void negateMatrix(const vpMatrix &A, vpMatrix &C);
711  static void sub2Matrices(const vpMatrix &A, const vpMatrix &B, vpMatrix &C);
712  static void sub2Matrices(const vpColVector &A, const vpColVector &B, vpColVector &C);
714 
715  //---------------------------------
716  // Kronecker product Static Public Member Functions
717  //---------------------------------
720  // Compute Kronecker product matrix
721  static void kron(const vpMatrix &m1, const vpMatrix &m2, vpMatrix &out);
722 
723  // Compute Kronecker product matrix
724  static vpMatrix kron(const vpMatrix &m1, const vpMatrix &m2);
726 
727  //-------------------------------------------------
728  // 2D Convolution Static Public Member Functions
729  //-------------------------------------------------
731  static vpMatrix conv2(const vpMatrix &M, const vpMatrix &kernel, const std::string &mode="full");
732  static void conv2(const vpMatrix &M, const vpMatrix &kernel, vpMatrix &res, const std::string &mode="full");
733 
734  //---------------------------------
735  // Covariance computation Static Public Member Functions
736  //---------------------------------
739  static vpMatrix computeCovarianceMatrix(const vpMatrix &A, const vpColVector &x, const vpColVector &b);
740  static vpMatrix computeCovarianceMatrix(const vpMatrix &A, const vpColVector &x, const vpColVector &b,
741  const vpMatrix &w);
742  static vpMatrix computeCovarianceMatrixVVS(const vpHomogeneousMatrix &cMo, const vpColVector &deltaS,
743  const vpMatrix &Ls, const vpMatrix &W);
744  static vpMatrix computeCovarianceMatrixVVS(const vpHomogeneousMatrix &cMo, const vpColVector &deltaS,
745  const vpMatrix &Ls);
747 
748  //---------------------------------
749  // Matrix I/O Static Public Member Functions
750  //---------------------------------
764  static inline bool loadMatrix(const std::string &filename, vpArray2D<double> &M, const bool binary = false,
765  char *header = NULL)
766  {
767  return vpArray2D<double>::load(filename, M, binary, header);
768  }
769 
780  static inline bool loadMatrixYAML(const std::string &filename, vpArray2D<double> &M, char *header = NULL)
781  {
782  return vpArray2D<double>::loadYAML(filename, M, header);
783  }
784 
799  static inline bool saveMatrix(const std::string &filename, const vpArray2D<double> &M, const bool binary = false,
800  const char *header = "")
801  {
802  return vpArray2D<double>::save(filename, M, binary, header);
803  }
804 
817  static inline bool saveMatrixYAML(const std::string &filename, const vpArray2D<double> &M, const char *header = "")
818  {
819  return vpArray2D<double>::saveYAML(filename, M, header);
820  }
822 
823 #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
824 
832  vp_deprecated void init() {}
833 
837  vp_deprecated void stackMatrices(const vpMatrix &A) { stack(A); }
842  vp_deprecated static vpMatrix stackMatrices(const vpMatrix &A, const vpMatrix &B) { return stack(A, B); }
847  vp_deprecated static void stackMatrices(const vpMatrix &A, const vpMatrix &B, vpMatrix &C) { stack(A, B, C); }
852  vp_deprecated static vpMatrix stackMatrices(const vpMatrix &A, const vpRowVector &B);
857  vp_deprecated static void stackMatrices(const vpMatrix &A, const vpRowVector &B, vpMatrix &C);
862  vp_deprecated static vpMatrix stackMatrices(const vpColVector &A, const vpColVector &B);
867  vp_deprecated static void stackMatrices(const vpColVector &A, const vpColVector &B, vpColVector &C);
868 
872  vp_deprecated void setIdentity(const double &val = 1.0);
873 
874  vp_deprecated vpRowVector row(const unsigned int i);
875  vp_deprecated vpColVector column(const unsigned int j);
876 
878 #endif
879 
880 private:
881 #if defined(VISP_HAVE_LAPACK) && !defined(VISP_HAVE_LAPACK_BUILT_IN)
882  static void blas_dgemm(char trans_a, char trans_b, const int M, const int N, const int K, double alpha,
883  double *a_data, const int lda, double *b_data, const int ldb, double beta, double *c_data,
884  const int ldc);
885  static void blas_dgemv(char trans, const int M, const int N, double alpha, double *a_data, const int lda,
886  double *x_data, const int incx, double beta, double *y_data, const int incy);
887 #endif
888 
889  static void computeCovarianceMatrixVVS(const vpHomogeneousMatrix &cMo, const vpColVector &deltaS, const vpMatrix &Ls,
890  vpMatrix &Js, vpColVector &deltaP);
891 };
892 
894 
895 #ifndef DOXYGEN_SHOULD_SKIP_THIS
896 VISP_EXPORT
897 #endif
898 vpMatrix operator*(const double &x, const vpMatrix &A);
899 
900 #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:764
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
unsigned int getRows() const
Definition: vpArray2D.h:289
vp_deprecated void stackMatrices(const vpMatrix &A)
Definition: vpMatrix.h:837
Implementation of a generic 2D array used as base class for matrices and vectors. ...
Definition: vpArray2D.h:131
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.
unsigned int getCols() const
Definition: vpArray2D.h:279
vpColVector operator*(const double &x, const vpColVector &v)
static vp_deprecated void stackMatrices(const vpMatrix &A, const vpMatrix &B, vpMatrix &C)
Definition: vpMatrix.h:847
vpMatrix(const vpMatrix &A)
Definition: vpMatrix.h:214
vp_deprecated void init()
Definition: vpMatrix.h:832
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
vpArray2D< Type > hadamard(const vpArray2D< Type > &m) const
Definition: vpArray2D.h:925
friend std::ostream & operator<<(std::ostream &s, const vpArray2D< Type > &A)
Definition: vpArray2D.h:486
static vp_deprecated vpMatrix stackMatrices(const vpMatrix &A, const vpMatrix &B)
Definition: vpMatrix.h:842
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
void printSize() const
Definition: vpMatrix.h:648
static bool saveMatrixYAML(const std::string &filename, const vpArray2D< double > &M, const char *header="")
Definition: vpMatrix.h:817
static bool saveMatrix(const std::string &filename, const vpArray2D< double > &M, const bool binary=false, const char *header="")
Definition: vpMatrix.h:799
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:780