This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // method for calculating the pseudo-Inverse as recommended by Eigen developers | |
| template<typename _Matrix_Type_> | |
| _Matrix_Type_ pseudoInverse(const _Matrix_Type_ &a, double epsilon = std::numeric_limits<double>::epsilon()) | |
| { | |
| Eigen::JacobiSVD< _Matrix_Type_ > svd(a ,Eigen::ComputeFullU | Eigen::ComputeFullV); | |
| // For a non-square matrix | |
| // Eigen::JacobiSVD< _Matrix_Type_ > svd(a ,Eigen::ComputeThinU | Eigen::ComputeThinV); | |
| double tolerance = epsilon * std::max(a.cols(), a.rows()) *svd.singularValues().array().abs()(0); | |
| return svd.matrixV() * (svd.singularValues().array().abs() > tolerance).select(svd.singularValues().array().inverse(), 0).matrix().asDiagonal() * svd.matrixU().adjoint(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cmake_minimum_required(VERSION 2.8.11) | |
| project(qtosg) | |
| set(CMAKE_INCLUDE_CURRENT_DIR ON) | |
| set(CMAKE_AUTOMOC ON) | |
| find_package(Qt5 REQUIRED COMPONENTS Core Gui OpenGL) | |
| find_package(OpenSceneGraph REQUIRED COMPONENTS osgDB osgGA osgUtil osgViewer) | |
| include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cmake_minimum_required(VERSION 3.5) | |
| project(DBusTest) | |
| find_package(Qt5 CONFIG REQUIRED Core DBus) | |
| set(prog_SRCS my.test.Calculator.xml) | |
| qt5_generate_dbus_interface(Calc.hh | |
| my.test.Calculator.xml | |
| OPTIONS -A | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <Eigen/Dense> | |
| template <class MatT> | |
| Eigen::Matrix<typename MatT::Scalar, MatT::ColsAtCompileTime, MatT::RowsAtCompileTime> | |
| pseudoinverse(const MatT &mat, typename MatT::Scalar tolerance = typename MatT::Scalar{1e-4}) // choose appropriately | |
| { | |
| typedef typename MatT::Scalar Scalar; | |
| auto svd = mat.jacobiSvd(Eigen::ComputeFullU | Eigen::ComputeFullV); | |
| const auto &singularValues = svd.singularValues(); | |
| Eigen::Matrix<Scalar, MatT::ColsAtCompileTime, MatT::RowsAtCompileTime> singularValuesInv(mat.cols(), mat.rows()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Compute the (Moore-Penrose) pseudo-inverse of a libgsl matrix in plain C. | |
| * | |
| * Compile uding: | |
| * | |
| * gcc moore_penrose_pseudoinverse.c -lgsl -lblas | |
| * | |
| * Dependencies: | |
| * - libgsl (GNU Scientific Library) | |
| * - libblas (Basic Linear Algebra Subprograms) |