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>
209 vpMatrix(
const vpMatrix &M,
unsigned int r,
unsigned int c,
unsigned int nrows,
unsigned int ncols);
233 static vpMatrix view(
double *data,
unsigned int rows,
unsigned int cols);
234 static void view(
vpMatrix &v,
double *data,
unsigned int rows,
unsigned int cols);
236#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
238 VP_EXPLICIT
vpMatrix(
const std::initializer_list<double> &list);
239 VP_EXPLICIT
vpMatrix(
unsigned int nrows,
unsigned int ncols,
const std::initializer_list<double> &list);
240 VP_EXPLICIT
vpMatrix(
const std::initializer_list<std::initializer_list<double> > &lists);
249 if (
data !=
nullptr) {
298 void diag(
const double &val = 1.0);
302 void eye(
unsigned int n);
304 void eye(
unsigned int m,
unsigned int n);
325#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
329 vpMatrix &
operator=(
const std::initializer_list<std::initializer_list<double> > &lists);
371 vpMatrix extract(
unsigned int r,
unsigned int c,
unsigned int nrows,
unsigned int ncols)
const;
373 vpColVector getCol(
unsigned int j,
unsigned int i_begin,
unsigned int size)
const;
375 vpRowVector getRow(
unsigned int i,
unsigned int j_begin,
unsigned int size)
const;
377 void init(
const vpMatrix &M,
unsigned int r,
unsigned int c,
unsigned int nrows,
unsigned int ncols);
413 double det(vpDetMethod method = LU_DECOMPOSITION)
const;
414 double detByLU()
const;
415#if defined(VISP_HAVE_EIGEN3)
416 double detByLUEigen3()
const;
418#if defined(VISP_HAVE_LAPACK)
419 double detByLULapack()
const;
421#if defined(VISP_HAVE_OPENCV)
422 double detByLUOpenCV()
const;
425#if defined(VISP_HAVE_EIGEN3)
428#if defined(VISP_HAVE_LAPACK)
431#if defined(VISP_HAVE_OPENCV)
475 double sumSquare()
const;
522#if defined(VISP_HAVE_EIGEN3)
525#if defined(VISP_HAVE_LAPACK)
528#if defined(VISP_HAVE_OPENCV)
536#if defined(VISP_HAVE_LAPACK)
537 vpMatrix inverseByCholeskyLapack()
const;
539#if defined(VISP_HAVE_OPENCV)
540 vpMatrix inverseByCholeskyOpenCV()
const;
545#if defined(VISP_HAVE_LAPACK)
550 vpMatrix inverseTriangular(
bool upper =
true)
const;
552 vpMatrix pseudoInverse(
double svThreshold = 1e-6)
const;
553 unsigned int pseudoInverse(
vpMatrix &Ap,
double svThreshold = 1e-6)
const;
554 unsigned int pseudoInverse(
vpMatrix &Ap,
vpColVector &sv,
double svThreshold = 1e-6)
const;
557 vpMatrix pseudoInverse(
int rank_in)
const;
558 int pseudoInverse(
vpMatrix &Ap,
int rank_in)
const;
563#if defined(VISP_HAVE_LAPACK)
573#if defined(VISP_HAVE_EIGEN3)
583#if defined(VISP_HAVE_OPENCV)
603 double cond(
double svThreshold = 1e-6)
const;
604 unsigned int kernel(
vpMatrix &kerAt,
double svThreshold = 1e-6)
const;
615#ifdef VISP_HAVE_EIGEN3
618#if defined(VISP_HAVE_LAPACK)
621#if defined(VISP_HAVE_OPENCV)
632 unsigned int qr(
vpMatrix &Q,
vpMatrix &R,
bool full =
false,
bool squareR =
false,
double tol = 1e-6)
const;
634 double tol = 1e-6)
const;
665 std::ostream &
cppPrint(std::ostream &os,
const std::string &matrixName =
"A",
bool octet =
false)
const;
666 std::ostream &
csvPrint(std::ostream &os)
const;
667 std::ostream &
maplePrint(std::ostream &os)
const;
669 int print(std::ostream &s,
unsigned int length,
const std::string &intro =
"")
const;
724 static void add2WeightedMatrices(
const vpMatrix &A,
const double &wA,
const vpMatrix &B,
const double &wB,
726 static void computeHLM(
const vpMatrix &H,
const double &alpha,
vpMatrix &HLM);
842 char *header =
nullptr)
998 const char *header =
"")
1083#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
1084 VP_DEPRECATED
double euclideanNorm()
const;
1134 VP_DEPRECATED
void setIdentity(
const double &val = 1.0);
1140#ifndef DOXYGEN_SHOULD_SKIP_THIS
1144 VP_DEPRECATED
double detByLUGsl()
const
1146#if defined(VISP_HAVE_LAPACK)
1147 return detByLULapack();
1156 VP_DEPRECATED vpMatrix inverseByLUGsl()
const
1158#if defined(VISP_HAVE_LAPACK)
1159 return inverseByLULapack();
1168 VP_DEPRECATED vpMatrix inverseByCholeskyGsl()
const
1170#if defined(VISP_HAVE_LAPACK)
1171 return inverseByCholeskyLapack();
1180 VP_DEPRECATED vpMatrix inverseByQRGsl()
const
1182#if defined(VISP_HAVE_LAPACK)
1183 return inverseByQRLapack();
1192 VP_DEPRECATED vpMatrix pseudoInverseGsl(
double svThreshold = 1e-6)
const
1194#if defined(VISP_HAVE_LAPACK)
1195 return pseudoInverseLapack(svThreshold);
1205 VP_DEPRECATED
unsigned int pseudoInverseGsl(vpMatrix &Ap,
double svThreshold = 1e-6)
const
1207#if defined(VISP_HAVE_LAPACK)
1208 return pseudoInverseLapack(Ap, svThreshold);
1219 VP_DEPRECATED
unsigned int pseudoInverseGsl(vpMatrix &Ap, vpColVector &sv,
double svThreshold = 1e-6)
const
1221#if defined(VISP_HAVE_LAPACK)
1222 return pseudoInverseLapack(Ap, sv, svThreshold);
1234 VP_DEPRECATED
unsigned int pseudoInverseGsl(vpMatrix &Ap, vpColVector &sv,
double svThreshold, vpMatrix &imA, vpMatrix &imAt,
1235 vpMatrix &kerAt)
const
1237#if defined(VISP_HAVE_LAPACK)
1238 return pseudoInverseLapack(Ap, sv, svThreshold, imA, imAt, kerAt);
1253 VP_DEPRECATED
void svdGsl(vpColVector &w, vpMatrix &V)
1255#if defined(VISP_HAVE_LAPACK)
1269 static unsigned int m_lapack_min_size;
1270 static const unsigned int m_lapack_min_size_default;
1272#if defined(VISP_HAVE_LAPACK)
1273 static void blas_dgemm(
char trans_a,
char trans_b,
unsigned int M_,
unsigned int N_,
unsigned int K_,
double alpha,
1274 double *a_data,
unsigned int lda_,
double *b_data,
unsigned int ldb_,
double beta,
1275 double *c_data,
unsigned int ldc_);
1276 static void blas_dgemv(
char trans,
unsigned int M_,
unsigned int N_,
double alpha,
double *a_data,
unsigned int lda_,
1277 double *x_data,
int incx_,
double beta,
double *y_data,
int incy_);
1278 static void blas_dsyev(
char jobz,
char uplo,
unsigned int n_,
double *a_data,
unsigned int lda_,
double *w_data,
1279 double *work_data,
int lwork_,
int &info_);
1281 unsigned int qrPivotLapack(vpMatrix &Q, vpMatrix &R, vpMatrix &P,
bool full,
bool squareR,
1285 unsigned int qrPivotLapackGSL(vpMatrix &Q, vpMatrix &R, vpMatrix &P,
bool full,
bool squareR,
1290 static void computeCovarianceMatrixVVS(
const vpHomogeneousMatrix &cMo,
const vpColVector &deltaS,
const vpMatrix &Ls,
1291 vpMatrix &Js, vpColVector &deltaP);
1295#if defined(VISP_USE_MSVC) && defined(visp_EXPORTS)
1296const __declspec(selectany)
unsigned int vpMatrix::m_lapack_min_size_default = 0;
1297__declspec(selectany)
unsigned int vpMatrix::m_lapack_min_size = vpMatrix::m_lapack_min_size_default;
1300#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)
vpArray2D< Type > & operator=(Type x)
Set all the elements of the array to x.
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....
friend std::ostream & operator<<(std::ostream &s, const vpArray2D< Type > &A)
static vpArray2D< Type > conv2(const vpArray2D< Type > &M, const vpArray2D< Type > &kernel, const std::string &mode)
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 > 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 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
void svdLapack(vpColVector &w, vpMatrix &V)
vpMatrix(unsigned int r, unsigned int c)
vpColVector eigenValues() const
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
std::ostream & cppPrint(std::ostream &os, const std::string &matrixName="A", bool octet=false) const
double cond(double svThreshold=1e-6) const
static unsigned int getLapackMatrixMinSize()
VP_DEPRECATED void stackMatrices(const vpMatrix &A)
vpMatrix pseudoInverseEigen3(double svThreshold=1e-6) const
unsigned int qr(vpMatrix &Q, vpMatrix &R, bool full=false, bool squareR=false, double tol=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 print(std::ostream &s, unsigned int length, const std::string &intro="") const
int pseudoInverseLapack(vpMatrix &Ap, vpColVector &sv, int rank_in) const
std::ostream & maplePrint(std::ostream &os) const
unsigned int kernel(vpMatrix &kerAt, double svThreshold=1e-6) 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
vpMatrix dampedInverse(const double &ratioOfMaxSvd=1e-4) const
void stack(const vpMatrix &A)
unsigned int pseudoInverseEigen3(vpMatrix &Ap, vpColVector &sv, double svThreshold=1e-6) const
static VP_DEPRECATED vpMatrix stackMatrices(const vpMatrix &A, const vpMatrix &B)
static VP_DEPRECATED void stackMatrices(const vpMatrix &A, const vpMatrix &B, vpMatrix &C)
void solveBySVD(const vpColVector &B, vpColVector &x) const
int pseudoInverseEigen3(vpMatrix &Ap, vpColVector &sv, int rank_in) const
void svd(vpColVector &w, vpMatrix &V)
unsigned int pseudoInverseEigen3(vpMatrix &Ap, double svThreshold=1e-6) const
void svdOpenCV(vpColVector &w, vpMatrix &V)
unsigned int qrPivot(vpMatrix &Q, vpMatrix &R, vpMatrix &P, bool full=false, bool squareR=false, double tol=1e-6) const
unsigned int pseudoInverseLapack(vpMatrix &Ap, vpColVector &sv, double svThreshold=1e-6) const
vpMatrix pseudoInverseLapack(int rank_in) const
double inducedL2Norm() const
unsigned int pseudoInverseLapack(vpMatrix &Ap, vpColVector &sv, double svThreshold, vpMatrix &imA, vpMatrix &imAt, vpMatrix &kerAt) const
vpMatrix pseudoInverseEigen3(int rank_in) const
double infinityNorm() const
double frobeniusNorm() 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
void solveByQR(const vpColVector &b, vpColVector &x) const
vpMatrix pseudoInverseLapack(double svThreshold=1e-6) const
vpMatrix(const vpMatrix &A)
int pseudoInverseEigen3(vpMatrix &Ap, int rank_in) const
VP_DEPRECATED void init()
static bool saveMatrixYAML(const std::string &filename, const vpArray2D< double > &M, const char *header="")
void svdEigen3(vpColVector &w, vpMatrix &V)
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
std::ostream & csvPrint(std::ostream &os) const
unsigned int nullSpace(vpMatrix &kerA, double svThreshold=1e-6) const
std::ostream & matlabPrint(std::ostream &os) 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.