34 Eigen::JacobiSVD< Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic,Eigen::RowMajor> > svd(
toEigen(in), Eigen::ComputeThinU | Eigen::ComputeThinV);
36 U.
resize(svd.matrixU().rows(),svd.matrixU().cols());
39 S.
resize(svd.singularValues().size());
40 toEigen(S) = svd.singularValues();
42 V.
resize(svd.matrixV().rows(),svd.matrixV().cols());
48 int m = in.
rows(), n = in.
cols(), k = m<n?m:n;
55 for (
int c = 0; c < k; c++) {
57 Spinv(c, c) = 1 / Sdiag(c);
65 int m = in.
rows(), n = in.
cols(), k = m<n?m:n;
72 for (
int c = 0; c < k; c++) {
74 Spinv(c, c) = 1 / Sdiag(c);
82 int m = in.
rows(), n = in.
cols(), k = m<n?m:n;
84 if ((
int)sv.
size() != k) {
91 for (
int c = 0; c < k; c++) {
93 Spinv(c, c) = 1 / sv(c);
102 int m = in.
rows(), n = in.
cols(), k = m<n?m:n;
104 if ((
int)sv.
size() != k) {
111 for (
int c = 0; c < k; c++) {
113 Spinv(c, c) = 1 / sv(c);
145 int m = in.
rows(), n = in.
cols(), k = m<n?m:n;
147 if ((
int)sv.
size() != k) {
154 double damp2 = damp*damp;
155 for (
int c = 0; c < k; c++) {
156 Spinv(c, c) = sv(c) / (sv(c) * sv(c) + damp2);
173 int k = std::min(m, n);
179 for(
int c = 0; c < k; c++) {
180 if(Sdiag(c) <= tol) {
198 int k = std::min(m, n);
204 for (
int c = 0; c < k; c++) {
205 if (Sdiag(c) <= tol) {
void resize(size_t r, size_t c)
Resize the matrix, if matrix is not empty preserve old content.
Matrix transposed() const
Return the transposed of the matrix.
bool setRow(size_t row, const Vector &r)
Set a row of the matrix copying the values from a vector: the vector length must be equal to the numb...
size_t cols() const
Return number of columns.
size_t rows() const
Return number of rows.
void resize(size_t size) override
Resize the vector.
Eigen::Map< Eigen::VectorXd > toEigen(yarp::sig::Vector &yarpVector)
Convert a yarp::sig::Vector to a Eigen::Map<Eigen::VectorXd> object.
yarp::sig::Matrix eye(int r, int c)
Build an identity matrix (defined in Math.h).
yarp::sig::Matrix projectionMatrix(const yarp::sig::Matrix &A, double tol=0.0)
Compute the projection matrix of A, that is defined as A times its pseudoinverse: A*pinv(A) (defined ...
void SVD(const yarp::sig::Matrix &in, yarp::sig::Matrix &U, yarp::sig::Vector &S, yarp::sig::Matrix &V)
Factorize the M-by-N matrix 'in' into the singular value decomposition in = U S V^T (defined in SVD....
void SVDMod(const yarp::sig::Matrix &in, yarp::sig::Matrix &U, yarp::sig::Vector &S, yarp::sig::Matrix &V)
Perform SVD decomposition on a MxN matrix (for M >= N) (defined in SVD.h).
yarp::sig::Matrix pinv(const yarp::sig::Matrix &in, double tol=0.0)
Perform the moore-penrose pseudo-inverse of a matrix (defined in SVD.h).
yarp::sig::Matrix pinvDamped(const yarp::sig::Matrix &in, yarp::sig::Vector &sv, double damp)
Perform the damped pseudo-inverse of a matrix (defined in SVD.h).
yarp::sig::Vector zeros(int s)
Creates a vector of zeros (defined in Math.h).
yarp::sig::Matrix nullspaceProjection(const yarp::sig::Matrix &A, double tol=0.0)
Compute the nullspace projection matrix of A, that is defined as the difference between the identity ...
void SVDJacobi(const yarp::sig::Matrix &in, yarp::sig::Matrix &U, yarp::sig::Vector &S, yarp::sig::Matrix &V)
Perform SVD decomposition on a matrix using the Jacobi method (defined in SVD.h).