SVD.h
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package ArmarX::Core
17 * @author Simon Ottenhaus ( simon dot ottenhaus at kit dot edu )
18 * @date 2015
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 
23 #pragma once
24 
25 #include <math.h>
26 #include <Eigen/Eigen>
27 
28 namespace armarx::math
29 {
30  class SVD
31  {
32  private:
33  Eigen::JacobiSVD<Eigen::MatrixXf> svd;
34  public:
35  Eigen::MatrixXf matrixU;
36  Eigen::MatrixXf matrixV;
37  Eigen::VectorXf singularValues;
38  SVD(Eigen::MatrixXf matrix)
39  : svd(matrix, Eigen::ComputeThinU | Eigen::ComputeThinV)
40  {
41  matrixU = svd.matrixU();
42  matrixV = svd.matrixV();
43  singularValues = svd.singularValues();
44  }
45 
46  Eigen::Vector3f getLeftSingularVector3D(int nr)
47  {
48  return matrixU.block<3, 1>(0, nr);
49  }
50  float getLeftSingularValue(int nr)
51  {
52  return singularValues(nr);
53  }
54 
55  };
56 }
57 
58 
Eigen
Definition: Elements.h:36
armarx::math::SVD::getLeftSingularVector3D
Eigen::Vector3f getLeftSingularVector3D(int nr)
Definition: SVD.h:46
armarx::math::SVD
Definition: SVD.h:30
armarx::math::SVD::matrixU
Eigen::MatrixXf matrixU
Definition: SVD.h:35
armarx::math::SVD::singularValues
Eigen::VectorXf singularValues
Definition: SVD.h:37
armarx::math::SVD::matrixV
Eigen::MatrixXf matrixV
Definition: SVD.h:36
armarx::math
Definition: LinearizeAngularTrajectory.cpp:27
armarx::math::SVD::getLeftSingularValue
float getLeftSingularValue(int nr)
Definition: SVD.h:50
armarx::math::SVD::SVD
SVD(Eigen::MatrixXf matrix)
Definition: SVD.h:38