39#include <visp3/core/vpArray2D.h>
40#include <visp3/core/vpConfig.h>
41#include <visp3/core/vpException.h>
42#include <visp3/core/vpForceTwistMatrix.h>
43#include <visp3/core/vpHomogeneousMatrix.h>
44#include <visp3/core/vpRotationMatrix.h>
45#include <visp3/core/vpTime.h>
46#include <visp3/core/vpVelocityTwistMatrix.h>
187 vpMatrix(
const vpMatrix &M,
unsigned int r,
unsigned int c,
unsigned int nrows,
unsigned int ncols);
205#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
207 explicit vpMatrix(
const std::initializer_list<double> &list);
208 explicit vpMatrix(
unsigned int nrows,
unsigned int ncols,
const std::initializer_list<double> &list);
209 explicit vpMatrix(
const std::initializer_list<std::initializer_list<double> > &lists);
226 if (rowPtrs != NULL) {
230 rowNum = colNum = dsize = 0;
247 return m_lapack_min_size;
263 m_lapack_min_size = min_size;
272 void diag(
const double &val = 1.0);
276 void eye(
unsigned int n);
278 void eye(
unsigned int m,
unsigned int n);
290#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
295 vpMatrix&
operator=(
const std::initializer_list<std::initializer_list<double> > &lists);
329 void insert(
const vpMatrix &A,
unsigned int r,
unsigned int c);
337 vpMatrix extract(
unsigned int r,
unsigned int c,
unsigned int nrows,
unsigned int ncols)
const;
339 vpColVector getCol(
unsigned int j,
unsigned int i_begin,
unsigned int size)
const;
341 vpRowVector getRow(
unsigned int i,
unsigned int j_begin,
unsigned int size)
const;
343 void init(
const vpMatrix &M,
unsigned int r,
unsigned int c,
unsigned int nrows,
unsigned int ncols);
352 double det(vpDetMethod method = LU_DECOMPOSITION)
const;
353 double detByLU()
const;
354#ifdef VISP_HAVE_EIGEN3
355 double detByLUEigen3()
const;
357#if defined(VISP_HAVE_LAPACK)
358 double detByLULapack()
const;
360#if (VISP_HAVE_OPENCV_VERSION >= 0x020101)
361 double detByLUOpenCV()
const;
404 double sumSquare()
const;
451#if defined(VISP_HAVE_EIGEN3)
454#if defined(VISP_HAVE_LAPACK)
457#if (VISP_HAVE_OPENCV_VERSION >= 0x020101)
465#if defined(VISP_HAVE_LAPACK)
466 vpMatrix inverseByCholeskyLapack()
const;
468#if (VISP_HAVE_OPENCV_VERSION >= 0x020101)
469 vpMatrix inverseByCholeskyOpenCV()
const;
474#if defined(VISP_HAVE_LAPACK)
479 vpMatrix inverseTriangular(
bool upper =
true)
const;
481 vpMatrix pseudoInverse(
double svThreshold = 1e-6)
const;
482 unsigned int pseudoInverse(
vpMatrix &Ap,
double svThreshold = 1e-6)
const;
483 unsigned int pseudoInverse(
vpMatrix &Ap,
vpColVector &sv,
double svThreshold = 1e-6)
const;
486 vpMatrix pseudoInverse(
int rank_in)
const;
487 int pseudoInverse(
vpMatrix &Ap,
int rank_in)
const;
492#if defined(VISP_HAVE_LAPACK)
502#if defined(VISP_HAVE_EIGEN3)
512#if (VISP_HAVE_OPENCV_VERSION >= 0x020101)
530 double cond(
double svThreshold = 1e-6)
const;
531 unsigned int kernel(
vpMatrix &kerAt,
double svThreshold = 1e-6)
const;
532 unsigned int nullSpace(
vpMatrix &kerA,
double svThreshold = 1e-6)
const;
533 unsigned int nullSpace(
vpMatrix &kerA,
int dim)
const;
542#ifdef VISP_HAVE_EIGEN3
545#if defined(VISP_HAVE_LAPACK)
548#if (VISP_HAVE_OPENCV_VERSION >= 0x020101)
559 unsigned int qr(
vpMatrix &Q,
vpMatrix &R,
bool full =
false,
bool squareR =
false,
double tol = 1e-6)
const;
560 unsigned int qrPivot(
vpMatrix &Q,
vpMatrix &R,
vpMatrix &P,
bool full =
false,
bool squareR =
false,
double tol = 1e-6)
const;
581 double euclideanNorm()
const;
582 double frobeniusNorm()
const;
583 double inducedL2Norm()
const;
584 double infinityNorm()
const;
592 std::ostream &cppPrint(std::ostream &os,
const std::string &matrixName =
"A",
bool octet =
false)
const;
593 std::ostream &csvPrint(std::ostream &os)
const;
594 std::ostream &maplePrint(std::ostream &os)
const;
595 std::ostream &matlabPrint(std::ostream &os)
const;
596 int print(std::ostream &s,
unsigned int length,
const std::string &intro =
"")
const;
651 static void add2WeightedMatrices(
const vpMatrix &A,
const double &wA,
const vpMatrix &B,
const double &wB,
653 static void computeHLM(
const vpMatrix &H,
const double &alpha,
vpMatrix &HLM);
749 const char *header =
"")
772#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
821 vp_deprecated
void setIdentity(
const double &val = 1.0);
827#ifndef DOXYGEN_SHOULD_SKIP_THIS
831 vp_deprecated
double detByLUGsl()
const {
832#if defined(VISP_HAVE_LAPACK)
833 return detByLULapack();
836 "Undefined detByLULapack(). Install Lapack 3rd party"));
843 vp_deprecated
vpMatrix inverseByLUGsl()
const {
844#if defined(VISP_HAVE_LAPACK)
845 return inverseByLULapack();
848 "Undefined inverseByLULapack(). Install Lapack 3rd party"));
855 vpMatrix inverseByCholeskyGsl()
const {
856#if defined(VISP_HAVE_LAPACK)
857 return inverseByCholeskyLapack();
860 "Undefined inverseByCholeskyLapack(). Install Lapack 3rd party"));
868#if defined(VISP_HAVE_LAPACK)
869 return inverseByQRLapack();
872 "Undefined inverseByQRLapack(). Install Lapack 3rd party"));
879 vpMatrix pseudoInverseGsl(
double svThreshold = 1e-6)
const {
880#if defined(VISP_HAVE_LAPACK)
881 return pseudoInverseLapack(svThreshold);
885 "Undefined pseudoInverseLapack(). Install Lapack 3rd party"));
892 unsigned int pseudoInverseGsl(
vpMatrix &Ap,
double svThreshold = 1e-6)
const {
893#if defined(VISP_HAVE_LAPACK)
894 return pseudoInverseLapack(Ap, svThreshold);
899 "Undefined pseudoInverseLapack(). Install Lapack 3rd party"));
906 unsigned int pseudoInverseGsl(
vpMatrix &Ap,
vpColVector &sv,
double svThreshold = 1e-6)
const {
907#if defined(VISP_HAVE_LAPACK)
908 return pseudoInverseLapack(Ap, sv, svThreshold);
914 "Undefined pseudoInverseLapack(). Install Lapack 3rd party"));
923#if defined(VISP_HAVE_LAPACK)
924 return pseudoInverseLapack(Ap, sv, svThreshold, imA, imAt, kerAt);
933 "Undefined pseudoInverseLapack(). Install Lapack 3rd party"));
941#if defined(VISP_HAVE_LAPACK)
947 "Undefined svdLapack(). Install Lapack 3rd party"));
956 static unsigned int m_lapack_min_size;
957 static const unsigned int m_lapack_min_size_default;
959#if defined(VISP_HAVE_LAPACK)
960 static void blas_dgemm(
char trans_a,
char trans_b,
unsigned int M_,
unsigned int N_,
unsigned int K_,
double alpha,
961 double *a_data,
unsigned int lda_,
double *b_data,
unsigned int ldb_,
double beta,
double *c_data,
963 static void blas_dgemv(
char trans,
unsigned int M_,
unsigned int N_,
double alpha,
double *a_data,
unsigned int lda_,
964 double *x_data,
int incx_,
double beta,
double *y_data,
int incy_);
965 static void blas_dsyev(
char jobz,
char uplo,
unsigned int n_,
double *a_data,
unsigned int lda_,
966 double *w_data,
double *work_data,
int lwork_,
int &info_);
974#if defined(VISP_USE_MSVC) && defined(visp_EXPORTS)
975const __declspec(selectany)
unsigned int vpMatrix::m_lapack_min_size_default = 0;
976__declspec(selectany)
unsigned int vpMatrix::m_lapack_min_size = vpMatrix::m_lapack_min_size_default;
979#ifndef DOXYGEN_SHOULD_SKIP_THIS
Implementation of a generic 2D array used as base class for matrices and vectors.
static bool load(const std::string &filename, vpArray2D< Type > &A, bool binary=false, char *header=NULL)
unsigned int getCols() const
vpArray2D< Type > & operator=(Type x)
Set all the elements of the array to x.
static bool saveYAML(const std::string &filename, const vpArray2D< Type > &A, const char *header="")
friend std::ostream & operator<<(std::ostream &s, const vpArray2D< Type > &A)
static bool loadYAML(const std::string &filename, vpArray2D< Type > &A, char *header=NULL)
unsigned int getRows() const
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.
error that can be emited by ViSP classes.
Implementation of an homogeneous matrix and operations on such kind of matrices.
VISP_EXPORT vpImagePoint operator*(const vpImagePoint &ip1, double scale)
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 bool loadMatrixYAML(const std::string &filename, vpArray2D< double > &M, char *header=NULL)
static bool loadMatrix(const std::string &filename, vpArray2D< double > &M, bool binary=false, char *header=NULL)
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
int pseudoInverseLapack(vpMatrix &Ap, vpColVector &sv, int rank_in) const
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
vp_deprecated void stackMatrices(const vpMatrix &A)
unsigned int pseudoInverseEigen3(vpMatrix &Ap, vpColVector &sv, double svThreshold=1e-6) const
int pseudoInverseEigen3(vpMatrix &Ap, vpColVector &sv, int rank_in) const
vpMatrix(const vpArray2D< double > &A)
unsigned int pseudoInverseEigen3(vpMatrix &Ap, double svThreshold=1e-6) const
static vp_deprecated vpMatrix stackMatrices(const vpMatrix &A, const vpMatrix &B)
unsigned int pseudoInverseLapack(vpMatrix &Ap, vpColVector &sv, double svThreshold=1e-6) const
vpMatrix pseudoInverseLapack(int rank_in) const
virtual ~vpMatrix()
Destructor (Memory de-allocation)
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)
vp_deprecated void init()
int pseudoInverseEigen3(vpMatrix &Ap, int rank_in) const
static bool saveMatrixYAML(const std::string &filename, const vpArray2D< double > &M, const char *header="")
static vp_deprecated void stackMatrices(const vpMatrix &A, const vpMatrix &B, vpMatrix &C)
unsigned int pseudoInverseOpenCV(vpMatrix &Ap, vpColVector &sv, double svThreshold=1e-6) const
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.
vpColVector operator*(const double &x, const vpColVector &v)