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;
268 void diag(
const double &val = 1.0);
272 void eye(
unsigned int n);
274 void eye(
unsigned int m,
unsigned int n);
286 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
291 vpMatrix &
operator=(
const std::initializer_list<std::initializer_list<double> > &lists);
325 void insert(
const vpMatrix &A,
unsigned int r,
unsigned int c);
333 vpMatrix extract(
unsigned int r,
unsigned int c,
unsigned int nrows,
unsigned int ncols)
const;
335 vpColVector getCol(
unsigned int j,
unsigned int i_begin,
unsigned int size)
const;
337 vpRowVector getRow(
unsigned int i,
unsigned int j_begin,
unsigned int size)
const;
339 void init(
const vpMatrix &M,
unsigned int r,
unsigned int c,
unsigned int nrows,
unsigned int ncols);
348 double det(vpDetMethod method = LU_DECOMPOSITION)
const;
349 double detByLU()
const;
350 #ifdef VISP_HAVE_EIGEN3
351 double detByLUEigen3()
const;
353 #if defined(VISP_HAVE_LAPACK)
354 double detByLULapack()
const;
356 #if (VISP_HAVE_OPENCV_VERSION >= 0x020101)
357 double detByLUOpenCV()
const;
400 double sumSquare()
const;
447 #if defined(VISP_HAVE_EIGEN3)
450 #if defined(VISP_HAVE_LAPACK)
453 #if (VISP_HAVE_OPENCV_VERSION >= 0x020101)
461 #if defined(VISP_HAVE_LAPACK)
462 vpMatrix inverseByCholeskyLapack()
const;
464 #if (VISP_HAVE_OPENCV_VERSION >= 0x020101)
465 vpMatrix inverseByCholeskyOpenCV()
const;
470 #if defined(VISP_HAVE_LAPACK)
475 vpMatrix inverseTriangular(
bool upper =
true)
const;
477 vpMatrix pseudoInverse(
double svThreshold = 1e-6)
const;
478 unsigned int pseudoInverse(
vpMatrix &Ap,
double svThreshold = 1e-6)
const;
479 unsigned int pseudoInverse(
vpMatrix &Ap,
vpColVector &sv,
double svThreshold = 1e-6)
const;
483 vpMatrix pseudoInverse(
int rank_in)
const;
484 int pseudoInverse(
vpMatrix &Ap,
int rank_in)
const;
489 #if defined(VISP_HAVE_LAPACK)
501 #if defined(VISP_HAVE_EIGEN3)
513 #if (VISP_HAVE_OPENCV_VERSION >= 0x020101)
533 double cond(
double svThreshold = 1e-6)
const;
534 unsigned int kernel(
vpMatrix &kerAt,
double svThreshold = 1e-6)
const;
535 unsigned int nullSpace(
vpMatrix &kerA,
double svThreshold = 1e-6)
const;
536 unsigned int nullSpace(
vpMatrix &kerA,
int dim)
const;
545 #ifdef VISP_HAVE_EIGEN3
548 #if defined(VISP_HAVE_LAPACK)
551 #if (VISP_HAVE_OPENCV_VERSION >= 0x020101)
562 unsigned int qr(
vpMatrix &Q,
vpMatrix &R,
bool full =
false,
bool squareR =
false,
double tol = 1e-6)
const;
564 double tol = 1e-6)
const;
585 double euclideanNorm()
const;
586 double frobeniusNorm()
const;
587 double inducedL2Norm()
const;
588 double infinityNorm()
const;
596 std::ostream &cppPrint(std::ostream &os,
const std::string &matrixName =
"A",
bool octet =
false)
const;
597 std::ostream &csvPrint(std::ostream &os)
const;
598 std::ostream &maplePrint(std::ostream &os)
const;
599 std::ostream &matlabPrint(std::ostream &os)
const;
600 int print(std::ostream &s,
unsigned int length,
const std::string &intro =
"")
const;
655 static void add2WeightedMatrices(
const vpMatrix &A,
const double &wA,
const vpMatrix &B,
const double &wB,
657 static void computeHLM(
const vpMatrix &H,
const double &alpha,
vpMatrix &HLM);
921 const char *header =
"")
1002 #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
1051 vp_deprecated
void setIdentity(
const double &val = 1.0);
1057 #ifndef DOXYGEN_SHOULD_SKIP_THIS
1061 vp_deprecated
double detByLUGsl()
const
1063 #if defined(VISP_HAVE_LAPACK)
1064 return detByLULapack();
1073 vp_deprecated
vpMatrix inverseByLUGsl()
const
1075 #if defined(VISP_HAVE_LAPACK)
1076 return inverseByLULapack();
1085 vpMatrix inverseByCholeskyGsl()
const
1087 #if defined(VISP_HAVE_LAPACK)
1088 return inverseByCholeskyLapack();
1099 #if defined(VISP_HAVE_LAPACK)
1100 return inverseByQRLapack();
1109 vpMatrix pseudoInverseGsl(
double svThreshold = 1e-6)
const
1111 #if defined(VISP_HAVE_LAPACK)
1112 return pseudoInverseLapack(svThreshold);
1122 unsigned int pseudoInverseGsl(
vpMatrix &Ap,
double svThreshold = 1e-6)
const
1124 #if defined(VISP_HAVE_LAPACK)
1125 return pseudoInverseLapack(Ap, svThreshold);
1136 unsigned int pseudoInverseGsl(
vpMatrix &Ap,
vpColVector &sv,
double svThreshold = 1e-6)
const
1138 #if defined(VISP_HAVE_LAPACK)
1139 return pseudoInverseLapack(Ap, sv, svThreshold);
1154 #if defined(VISP_HAVE_LAPACK)
1155 return pseudoInverseLapack(Ap, sv, svThreshold, imA, imAt, kerAt);
1172 #if defined(VISP_HAVE_LAPACK)
1186 static unsigned int m_lapack_min_size;
1187 static const unsigned int m_lapack_min_size_default;
1189 #if defined(VISP_HAVE_LAPACK)
1190 static void blas_dgemm(
char trans_a,
char trans_b,
unsigned int M_,
unsigned int N_,
unsigned int K_,
double alpha,
1191 double *a_data,
unsigned int lda_,
double *b_data,
unsigned int ldb_,
double beta,
1192 double *c_data,
unsigned int ldc_);
1193 static void blas_dgemv(
char trans,
unsigned int M_,
unsigned int N_,
double alpha,
double *a_data,
unsigned int lda_,
1194 double *x_data,
int incx_,
double beta,
double *y_data,
int incy_);
1195 static void blas_dsyev(
char jobz,
char uplo,
unsigned int n_,
double *a_data,
unsigned int lda_,
double *w_data,
1196 double *work_data,
int lwork_,
int &info_);
1204 #if defined(VISP_USE_MSVC) && defined(visp_EXPORTS)
1205 const __declspec(selectany)
unsigned int vpMatrix::m_lapack_min_size_default = 0;
1206 __declspec(selectany)
unsigned int vpMatrix::m_lapack_min_size = vpMatrix::m_lapack_min_size_default;
1209 #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
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 > & 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.
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)