44 #include <visp3/core/vpConfig.h>
55 #include <visp3/core/vpArray2D.h>
56 #include <visp3/core/vpException.h>
57 #include <visp3/core/vpForceTwistMatrix.h>
58 #include <visp3/core/vpHomogeneousMatrix.h>
59 #include <visp3/core/vpRotationMatrix.h>
60 #include <visp3/core/vpTime.h>
61 #include <visp3/core/vpVelocityTwistMatrix.h>
203 vpMatrix(
const vpMatrix &M,
unsigned int r,
unsigned int c,
unsigned int nrows,
unsigned int ncols);
227 static vpMatrix view(
double *data,
unsigned int rows,
unsigned int cols);
229 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
231 VP_EXPLICIT
vpMatrix(
const std::initializer_list<double> &list);
232 VP_EXPLICIT
vpMatrix(
unsigned int nrows,
unsigned int ncols,
const std::initializer_list<double> &list);
233 VP_EXPLICIT
vpMatrix(
const std::initializer_list<std::initializer_list<double> > &lists);
242 if (data !=
nullptr) {
247 if (rowPtrs !=
nullptr) {
291 void diag(
const double &val = 1.0);
295 void eye(
unsigned int n);
297 void eye(
unsigned int m,
unsigned int n);
318 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
322 vpMatrix &
operator=(
const std::initializer_list<std::initializer_list<double> > &lists);
364 vpMatrix extract(
unsigned int r,
unsigned int c,
unsigned int nrows,
unsigned int ncols)
const;
366 vpColVector getCol(
unsigned int j,
unsigned int i_begin,
unsigned int size)
const;
368 vpRowVector getRow(
unsigned int i,
unsigned int j_begin,
unsigned int size)
const;
370 void init(
const vpMatrix &M,
unsigned int r,
unsigned int c,
unsigned int nrows,
unsigned int ncols);
406 double det(vpDetMethod method = LU_DECOMPOSITION)
const;
407 double detByLU()
const;
408 #if defined(VISP_HAVE_EIGEN3)
409 double detByLUEigen3()
const;
411 #if defined(VISP_HAVE_LAPACK)
412 double detByLULapack()
const;
414 #if defined(VISP_HAVE_OPENCV)
415 double detByLUOpenCV()
const;
418 #if defined(VISP_HAVE_EIGEN3)
421 #if defined(VISP_HAVE_LAPACK)
424 #if defined(VISP_HAVE_OPENCV)
468 double sumSquare()
const;
515 #if defined(VISP_HAVE_EIGEN3)
518 #if defined(VISP_HAVE_LAPACK)
521 #if defined(VISP_HAVE_OPENCV)
529 #if defined(VISP_HAVE_LAPACK)
530 vpMatrix inverseByCholeskyLapack()
const;
532 #if defined(VISP_HAVE_OPENCV)
533 vpMatrix inverseByCholeskyOpenCV()
const;
538 #if defined(VISP_HAVE_LAPACK)
543 vpMatrix inverseTriangular(
bool upper =
true)
const;
545 vpMatrix pseudoInverse(
double svThreshold = 1e-6)
const;
546 unsigned int pseudoInverse(
vpMatrix &Ap,
double svThreshold = 1e-6)
const;
547 unsigned int pseudoInverse(
vpMatrix &Ap,
vpColVector &sv,
double svThreshold = 1e-6)
const;
550 vpMatrix pseudoInverse(
int rank_in)
const;
551 int pseudoInverse(
vpMatrix &Ap,
int rank_in)
const;
556 #if defined(VISP_HAVE_LAPACK)
566 #if defined(VISP_HAVE_EIGEN3)
576 #if defined(VISP_HAVE_OPENCV)
587 vpMatrix dampedInverse(
const double &ratioOfMaxSvd = 1e-4)
const;
596 double cond(
double svThreshold = 1e-6)
const;
597 unsigned int kernel(
vpMatrix &kerAt,
double svThreshold = 1e-6)
const;
598 unsigned int nullSpace(
vpMatrix &kerA,
double svThreshold = 1e-6)
const;
599 unsigned int nullSpace(
vpMatrix &kerA,
int dim)
const;
608 #ifdef VISP_HAVE_EIGEN3
611 #if defined(VISP_HAVE_LAPACK)
614 #if defined(VISP_HAVE_OPENCV)
625 unsigned int qr(
vpMatrix &Q,
vpMatrix &R,
bool full =
false,
bool squareR =
false,
double tol = 1e-6)
const;
627 double tol = 1e-6)
const;
648 double frobeniusNorm()
const;
649 double inducedL2Norm()
const;
650 double infinityNorm()
const;
658 std::ostream &cppPrint(std::ostream &os,
const std::string &matrixName =
"A",
bool octet =
false)
const;
659 std::ostream &csvPrint(std::ostream &os)
const;
660 std::ostream &maplePrint(std::ostream &os)
const;
661 std::ostream &matlabPrint(std::ostream &os)
const;
662 int print(std::ostream &s,
unsigned int length,
const std::string &intro =
"")
const;
717 static void add2WeightedMatrices(
const vpMatrix &A,
const double &wA,
const vpMatrix &B,
const double &wB,
719 static void computeHLM(
const vpMatrix &H,
const double &alpha,
vpMatrix &HLM);
832 char *header =
nullptr)
988 const char *header =
"")
1073 #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
1074 VP_DEPRECATED
double euclideanNorm()
const;
1084 VP_DEPRECATED
void init() { }
1089 VP_DEPRECATED
void stackMatrices(
const vpMatrix &A) { stack(A); }
1124 VP_DEPRECATED
void setIdentity(
const double &val = 1.0);
1130 #ifndef DOXYGEN_SHOULD_SKIP_THIS
1134 VP_DEPRECATED
double detByLUGsl()
const
1136 #if defined(VISP_HAVE_LAPACK)
1137 return detByLULapack();
1146 VP_DEPRECATED
vpMatrix inverseByLUGsl()
const
1148 #if defined(VISP_HAVE_LAPACK)
1149 return inverseByLULapack();
1158 VP_DEPRECATED
vpMatrix inverseByCholeskyGsl()
const
1160 #if defined(VISP_HAVE_LAPACK)
1161 return inverseByCholeskyLapack();
1170 VP_DEPRECATED
vpMatrix inverseByQRGsl()
const
1172 #if defined(VISP_HAVE_LAPACK)
1173 return inverseByQRLapack();
1182 VP_DEPRECATED
vpMatrix pseudoInverseGsl(
double svThreshold = 1e-6)
const
1184 #if defined(VISP_HAVE_LAPACK)
1185 return pseudoInverseLapack(svThreshold);
1195 VP_DEPRECATED
unsigned int pseudoInverseGsl(
vpMatrix &Ap,
double svThreshold = 1e-6)
const
1197 #if defined(VISP_HAVE_LAPACK)
1198 return pseudoInverseLapack(Ap, svThreshold);
1209 VP_DEPRECATED
unsigned int pseudoInverseGsl(
vpMatrix &Ap,
vpColVector &sv,
double svThreshold = 1e-6)
const
1211 #if defined(VISP_HAVE_LAPACK)
1212 return pseudoInverseLapack(Ap, sv, svThreshold);
1227 #if defined(VISP_HAVE_LAPACK)
1228 return pseudoInverseLapack(Ap, sv, svThreshold, imA, imAt, kerAt);
1245 #if defined(VISP_HAVE_LAPACK)
1259 static unsigned int m_lapack_min_size;
1260 static const unsigned int m_lapack_min_size_default;
1262 #if defined(VISP_HAVE_LAPACK)
1263 static void blas_dgemm(
char trans_a,
char trans_b,
unsigned int M_,
unsigned int N_,
unsigned int K_,
double alpha,
1264 double *a_data,
unsigned int lda_,
double *b_data,
unsigned int ldb_,
double beta,
1265 double *c_data,
unsigned int ldc_);
1266 static void blas_dgemv(
char trans,
unsigned int M_,
unsigned int N_,
double alpha,
double *a_data,
unsigned int lda_,
1267 double *x_data,
int incx_,
double beta,
double *y_data,
int incy_);
1268 static void blas_dsyev(
char jobz,
char uplo,
unsigned int n_,
double *a_data,
unsigned int lda_,
double *w_data,
1269 double *work_data,
int lwork_,
int &info_);
1274 #ifdef VISP_HAVE_GSL
1285 #if defined(VISP_USE_MSVC) && defined(visp_EXPORTS)
1286 const __declspec(selectany)
unsigned int vpMatrix::m_lapack_min_size_default = 0;
1287 __declspec(selectany)
unsigned int vpMatrix::m_lapack_min_size = vpMatrix::m_lapack_min_size_default;
1290 #ifndef DOXYGEN_SHOULD_SKIP_THIS
Implementation of a generic 2D array used as base class for matrices and vectors.
unsigned int getCols() const
static bool loadYAML(const std::string &filename, vpArray2D< Type > &A, char *header=nullptr)
void insert(const vpArray2D< Type > &A, unsigned int r, unsigned int c)
static bool saveYAML(const std::string &filename, const vpArray2D< Type > &A, const char *header="")
static vpArray2D< Type > view(const vpArray2D< Type > &A)
Creates a view of the Matrix A. A view shares the same underlying memory as the original array....
static vpArray2D< Type > conv2(const vpArray2D< Type > &M, const vpArray2D< Type > &kernel, const std::string &mode)
friend std::ostream & operator<<(std::ostream &s, const vpArray2D< Type > &A)
static bool load(const std::string &filename, vpArray2D< Type > &A, bool binary=false, char *header=nullptr)
vpArray2D< Type > t() const
Compute the transpose of the array.
unsigned int getRows() const
vpArray2D< Type > & operator=(Type x)
Set all the elements of the array to x.
vpArray2D< Type > hadamard(const vpArray2D< Type > &m) const
static bool save(const std::string &filename, const vpArray2D< Type > &A, bool binary=false, const char *header="")
Implementation of column vector and the associated operations.
vpColVector operator*(const double &x, const vpColVector &v)
error that can be emitted by ViSP classes.
Implementation of an homogeneous matrix and operations on such kind of matrices.
Implementation of a matrix and operations on matrices.
static void setLapackMatrixMinSize(unsigned int min_size)
int pseudoInverseOpenCV(vpMatrix &Ap, int rank_in) const
vpMatrix(unsigned int r, unsigned int c)
vpMatrix(unsigned int r, unsigned int c, double val)
vpMatrix pseudoInverseOpenCV(double svThreshold=1e-6) const
int pseudoInverseLapack(vpMatrix &Ap, int rank_in) const
unsigned int pseudoInverseLapack(vpMatrix &Ap, double svThreshold=1e-6) const
static unsigned int getLapackMatrixMinSize()
vpMatrix pseudoInverseEigen3(double svThreshold=1e-6) const
unsigned int pseudoInverseOpenCV(vpMatrix &Ap, double svThreshold=1e-6) const
unsigned int pseudoInverseEigen3(vpMatrix &Ap, vpColVector &sv, double svThreshold, vpMatrix &imA, vpMatrix &imAt, vpMatrix &kerAt) const
VP_EXPLICIT vpMatrix(const vpArray2D< double > &A)
int pseudoInverseLapack(vpMatrix &Ap, vpColVector &sv, int rank_in) const
static bool loadMatrix(const std::string &filename, vpArray2D< double > &M, bool binary=false, char *header=nullptr)
int pseudoInverseEigen3(vpMatrix &Ap, vpColVector &sv, int rank_in, vpMatrix &imA, vpMatrix &imAt, vpMatrix &kerAt) const
int pseudoInverseLapack(vpMatrix &Ap, vpColVector &sv, int rank_in, vpMatrix &imA, vpMatrix &imAt, vpMatrix &kerAt) const
vpMatrix pseudoInverseOpenCV(int rank_in) const
unsigned int pseudoInverseEigen3(vpMatrix &Ap, vpColVector &sv, double svThreshold=1e-6) const
int pseudoInverseEigen3(vpMatrix &Ap, vpColVector &sv, int rank_in) const
unsigned int pseudoInverseEigen3(vpMatrix &Ap, double svThreshold=1e-6) const
unsigned int pseudoInverseLapack(vpMatrix &Ap, vpColVector &sv, double svThreshold=1e-6) const
vpMatrix pseudoInverseLapack(int rank_in) const
unsigned int pseudoInverseLapack(vpMatrix &Ap, vpColVector &sv, double svThreshold, vpMatrix &imA, vpMatrix &imAt, vpMatrix &kerAt) const
vpMatrix pseudoInverseEigen3(int rank_in) const
int pseudoInverseOpenCV(vpMatrix &Ap, vpColVector &sv, int rank_in, vpMatrix &imA, vpMatrix &imAt, vpMatrix &kerAt) const
int pseudoInverseOpenCV(vpMatrix &Ap, vpColVector &sv, int rank_in) const
vpMatrix pseudoInverseLapack(double svThreshold=1e-6) const
vpMatrix(const vpMatrix &A)
int pseudoInverseEigen3(vpMatrix &Ap, int rank_in) const
static bool saveMatrixYAML(const std::string &filename, const vpArray2D< double > &M, const char *header="")
unsigned int pseudoInverseOpenCV(vpMatrix &Ap, vpColVector &sv, double svThreshold=1e-6) const
static bool loadMatrixYAML(const std::string &filename, vpArray2D< double > &M, char *header=nullptr)
static bool saveMatrix(const std::string &filename, const vpArray2D< double > &M, bool binary=false, const char *header="")
unsigned int pseudoInverseOpenCV(vpMatrix &Ap, vpColVector &sv, double svThreshold, vpMatrix &imA, vpMatrix &imAt, vpMatrix &kerAt) const
Implementation of a rotation matrix and operations on such kind of matrices.
Implementation of row vector and the associated operations.
Class that consider the case of a translation vector.
vpMatrix operator*(const double &x, const vpMatrix &A)