34#include <visp3/core/vpConfig.h>
35#include <visp3/core/vpMatrix.h>
37#if defined(VISP_HAVE_SIMDLIB)
38#include <Simd/SimdLib.h>
41#ifdef VISP_HAVE_LAPACK
43#include <gsl/gsl_eigen.h>
44#include <gsl/gsl_linalg.h>
45#include <gsl/gsl_math.h>
46#elif defined(VISP_HAVE_MKL)
53#ifndef DOXYGEN_SHOULD_SKIP_THIS
56 unsigned int ncols,
double svThreshold,
vpMatrix &Ap,
int &rank_out,
int *rank_in,
60 unsigned int ncols,
double svThreshold,
vpMatrix &Ap,
int &rank_out,
int *rank_in,
63 Ap.
resize(ncols, nrows,
true,
false);
70 unsigned int sv_size = sv.
size();
71 for (
unsigned int i = 0;
i < sv_size; ++
i) {
72 if (sv[i] >(maxsv * svThreshold)) {
77 unsigned int rank =
static_cast<unsigned int>(rank_out);
79 rank =
static_cast<unsigned int>(*rank_in);
82 for (
unsigned int i = 0;
i < ncols; ++
i) {
83 for (
unsigned int j = 0;
j < nrows; ++
j) {
84 for (
unsigned int k = 0; k < rank; ++k) {
85 Ap[
i][
j] += (V[
i][k] * U[
j][k]) / sv[k];
94 for (
unsigned int i = 0;
i < nrows; ++
i) {
95 for (
unsigned int j = 0;
j < rank; ++
j) {
96 (*imA)[
i][
j] = U[
i][
j];
103 imAt->
resize(ncols, rank);
104 for (
unsigned int i = 0;
i < ncols; ++
i) {
105 for (
unsigned int j = 0;
j < rank; ++
j) {
106 (*imAt)[
i][
j] = V[
i][
j];
113 kerAt->
resize(ncols - rank, ncols);
115 unsigned int v_rows = V.
getRows();
116 for (
unsigned int k = 0; k < (ncols - rank); ++k) {
117 unsigned j = k + rank;
118 for (
unsigned int i = 0;
i < v_rows; ++
i) {
119 (*kerAt)[k][
i] = V[
i][
j];
188#if defined(VISP_HAVE_LAPACK)
190#elif defined(VISP_HAVE_EIGEN3)
192#elif defined(VISP_HAVE_OPENCV)
198 "Install Lapack, Eigen3 or OpenCV 3rd party"));
268#if defined(VISP_HAVE_LAPACK)
270#elif defined(VISP_HAVE_EIGEN3)
272#elif defined(VISP_HAVE_OPENCV)
278 "Install Lapack, Eigen3 or OpenCV 3rd party"));
338#if defined(VISP_HAVE_LAPACK)
340#elif defined(VISP_HAVE_EIGEN3)
342#elif defined(VISP_HAVE_OPENCV)
347 "Install Lapack, Eigen3 or OpenCV 3rd party"));
407#if defined(VISP_HAVE_LAPACK)
409#elif defined(VISP_HAVE_EIGEN3)
411#elif defined(VISP_HAVE_OPENCV)
416 "Install Lapack, Eigen3 or OpenCV 3rd party"));
487#if defined(VISP_HAVE_LAPACK)
489#elif defined(VISP_HAVE_EIGEN3)
491#elif defined(VISP_HAVE_OPENCV)
498 "Install Lapack, Eigen3 or OpenCV 3rd party"));
574#if defined(VISP_HAVE_LAPACK)
576#elif defined(VISP_HAVE_EIGEN3)
578#elif defined(VISP_HAVE_OPENCV)
585 "Install Lapack, Eigen3 or OpenCV 3rd party"));
868#if defined(VISP_HAVE_LAPACK)
870#elif defined(VISP_HAVE_EIGEN3)
872#elif defined(VISP_HAVE_OPENCV)
882 "Install Lapack, Eigen3 or OpenCV 3rd party"));
999#if defined(VISP_HAVE_LAPACK)
1001#elif defined(VISP_HAVE_EIGEN3)
1003#elif defined(VISP_HAVE_OPENCV)
1013 "Install Lapack, Eigen3 or OpenCV 3rd party"));
1034 double maxSingularValue = w.getMaxValue();
1037 double lambda = ratioOfMaxSvd * maxSingularValue;
void resize(unsigned int nrows, unsigned int ncols, bool flagNullify=true, bool recopy_=true)
unsigned int size() const
Return the number of elements of the 2D array.
unsigned int getRows() const
Implementation of column vector and the associated operations.
error that can be emitted by ViSP classes.
Implementation of a matrix and operations on matrices.
vpMatrix pseudoInverseOpenCV(double svThreshold=1e-6) const
vpMatrix pseudoInverseEigen3(double svThreshold=1e-6) const
vpMatrix dampedInverse(const double &ratioOfMaxSvd=1e-4) const
vpMatrix inverseByLU() const
void svd(vpColVector &w, vpMatrix &V)
vpMatrix pseudoInverseLapack(double svThreshold=1e-6) const
vpMatrix pseudoInverse(double svThreshold=1e-6) const
vpMatrix transpose() const