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 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
229 VP_EXPLICIT
vpMatrix(
const std::initializer_list<double> &list);
230 VP_EXPLICIT
vpMatrix(
unsigned int nrows,
unsigned int ncols,
const std::initializer_list<double> &list);
231 VP_EXPLICIT
vpMatrix(
const std::initializer_list<std::initializer_list<double> > &lists);
240 if (data !=
nullptr) {
245 if (rowPtrs !=
nullptr) {
289 void diag(
const double &val = 1.0);
293 void eye(
unsigned int n);
295 void eye(
unsigned int m,
unsigned int n);
316 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
320 vpMatrix &
operator=(
const std::initializer_list<std::initializer_list<double> > &lists);
362 vpMatrix extract(
unsigned int r,
unsigned int c,
unsigned int nrows,
unsigned int ncols)
const;
364 vpColVector getCol(
unsigned int j,
unsigned int i_begin,
unsigned int size)
const;
366 vpRowVector getRow(
unsigned int i,
unsigned int j_begin,
unsigned int size)
const;
368 void init(
const vpMatrix &M,
unsigned int r,
unsigned int c,
unsigned int nrows,
unsigned int ncols);
404 double det(vpDetMethod method = LU_DECOMPOSITION)
const;
405 double detByLU()
const;
406 #if defined(VISP_HAVE_EIGEN3)
407 double detByLUEigen3()
const;
409 #if defined(VISP_HAVE_LAPACK)
410 double detByLULapack()
const;
412 #if defined(VISP_HAVE_OPENCV)
413 double detByLUOpenCV()
const;
416 #if defined(VISP_HAVE_EIGEN3)
419 #if defined(VISP_HAVE_LAPACK)
422 #if defined(VISP_HAVE_OPENCV)
466 double sumSquare()
const;
513 #if defined(VISP_HAVE_EIGEN3)
516 #if defined(VISP_HAVE_LAPACK)
519 #if defined(VISP_HAVE_OPENCV)
527 #if defined(VISP_HAVE_LAPACK)
528 vpMatrix inverseByCholeskyLapack()
const;
530 #if defined(VISP_HAVE_OPENCV)
531 vpMatrix inverseByCholeskyOpenCV()
const;
536 #if defined(VISP_HAVE_LAPACK)
541 vpMatrix inverseTriangular(
bool upper =
true)
const;
543 vpMatrix pseudoInverse(
double svThreshold = 1e-6)
const;
544 unsigned int pseudoInverse(
vpMatrix &Ap,
double svThreshold = 1e-6)
const;
545 unsigned int pseudoInverse(
vpMatrix &Ap,
vpColVector &sv,
double svThreshold = 1e-6)
const;
548 vpMatrix pseudoInverse(
int rank_in)
const;
549 int pseudoInverse(
vpMatrix &Ap,
int rank_in)
const;
554 #if defined(VISP_HAVE_LAPACK)
564 #if defined(VISP_HAVE_EIGEN3)
574 #if defined(VISP_HAVE_OPENCV)
585 vpMatrix dampedInverse(
const double &ratioOfMaxSvd = 1e-4)
const;
594 double cond(
double svThreshold = 1e-6)
const;
595 unsigned int kernel(
vpMatrix &kerAt,
double svThreshold = 1e-6)
const;
596 unsigned int nullSpace(
vpMatrix &kerA,
double svThreshold = 1e-6)
const;
597 unsigned int nullSpace(
vpMatrix &kerA,
int dim)
const;
606 #ifdef VISP_HAVE_EIGEN3
609 #if defined(VISP_HAVE_LAPACK)
612 #if defined(VISP_HAVE_OPENCV)
623 unsigned int qr(
vpMatrix &Q,
vpMatrix &R,
bool full =
false,
bool squareR =
false,
double tol = 1e-6)
const;
625 double tol = 1e-6)
const;
646 double frobeniusNorm()
const;
647 double inducedL2Norm()
const;
648 double infinityNorm()
const;
656 std::ostream &cppPrint(std::ostream &os,
const std::string &matrixName =
"A",
bool octet =
false)
const;
657 std::ostream &csvPrint(std::ostream &os)
const;
658 std::ostream &maplePrint(std::ostream &os)
const;
659 std::ostream &matlabPrint(std::ostream &os)
const;
660 int print(std::ostream &s,
unsigned int length,
const std::string &intro =
"")
const;
715 static void add2WeightedMatrices(
const vpMatrix &A,
const double &wA,
const vpMatrix &B,
const double &wB,
717 static void computeHLM(
const vpMatrix &H,
const double &alpha,
vpMatrix &HLM);
830 char *header =
nullptr)
986 const char *header =
"")
1071 #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
1072 VP_DEPRECATED
double euclideanNorm()
const;
1082 VP_DEPRECATED
void init() { }
1087 VP_DEPRECATED
void stackMatrices(
const vpMatrix &A) { stack(A); }
1122 VP_DEPRECATED
void setIdentity(
const double &val = 1.0);
1128 #ifndef DOXYGEN_SHOULD_SKIP_THIS
1132 VP_DEPRECATED
double detByLUGsl()
const
1134 #if defined(VISP_HAVE_LAPACK)
1135 return detByLULapack();
1144 VP_DEPRECATED
vpMatrix inverseByLUGsl()
const
1146 #if defined(VISP_HAVE_LAPACK)
1147 return inverseByLULapack();
1156 VP_DEPRECATED
vpMatrix inverseByCholeskyGsl()
const
1158 #if defined(VISP_HAVE_LAPACK)
1159 return inverseByCholeskyLapack();
1168 VP_DEPRECATED
vpMatrix inverseByQRGsl()
const
1170 #if defined(VISP_HAVE_LAPACK)
1171 return inverseByQRLapack();
1180 VP_DEPRECATED
vpMatrix pseudoInverseGsl(
double svThreshold = 1e-6)
const
1182 #if defined(VISP_HAVE_LAPACK)
1183 return pseudoInverseLapack(svThreshold);
1193 VP_DEPRECATED
unsigned int pseudoInverseGsl(
vpMatrix &Ap,
double svThreshold = 1e-6)
const
1195 #if defined(VISP_HAVE_LAPACK)
1196 return pseudoInverseLapack(Ap, svThreshold);
1207 VP_DEPRECATED
unsigned int pseudoInverseGsl(
vpMatrix &Ap,
vpColVector &sv,
double svThreshold = 1e-6)
const
1209 #if defined(VISP_HAVE_LAPACK)
1210 return pseudoInverseLapack(Ap, sv, svThreshold);
1225 #if defined(VISP_HAVE_LAPACK)
1226 return pseudoInverseLapack(Ap, sv, svThreshold, imA, imAt, kerAt);
1243 #if defined(VISP_HAVE_LAPACK)
1257 static unsigned int m_lapack_min_size;
1258 static const unsigned int m_lapack_min_size_default;
1260 #if defined(VISP_HAVE_LAPACK)
1261 static void blas_dgemm(
char trans_a,
char trans_b,
unsigned int M_,
unsigned int N_,
unsigned int K_,
double alpha,
1262 double *a_data,
unsigned int lda_,
double *b_data,
unsigned int ldb_,
double beta,
1263 double *c_data,
unsigned int ldc_);
1264 static void blas_dgemv(
char trans,
unsigned int M_,
unsigned int N_,
double alpha,
double *a_data,
unsigned int lda_,
1265 double *x_data,
int incx_,
double beta,
double *y_data,
int incy_);
1266 static void blas_dsyev(
char jobz,
char uplo,
unsigned int n_,
double *a_data,
unsigned int lda_,
double *w_data,
1267 double *work_data,
int lwork_,
int &info_);
1272 #ifdef VISP_HAVE_GSL
1283 #if defined(VISP_USE_MSVC) && defined(visp_EXPORTS)
1284 const __declspec(selectany)
unsigned int vpMatrix::m_lapack_min_size_default = 0;
1285 __declspec(selectany)
unsigned int vpMatrix::m_lapack_min_size = vpMatrix::m_lapack_min_size_default;
1288 #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 > 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)