eigen

How to set SparseMatrix.valuePtr(), SparseMatrix.outerIndexPtr() and SparseMatrix.innerIndexPtr() for CSR Format?

坚强是说给别人听的谎言 提交于 2019-12-13 06:59:45
问题 I already have my sparse matrix data in CSR format, ie: I already have data for non zero values ( in the form of double[] ), the row and the column index ( both in the form of int[] ) of the non zero values. My problem is, how can I assign them directly to Sparse Matrix in eigen library? I know that the relevant fields in Sparse Matrix are valuePtr , outerIndexPtr and innerIndexPtr , but I can't set the pointer directly as per below: //the relevant SpMat fields (valuePtr,outerIndexPtr

Permuting sparse matrices in Eigen

假装没事ソ 提交于 2019-12-13 04:52:28
问题 I want to permute the rows and columns of a sparse matrix in Eigen. Here's the code I have but it's not working. #include <iostream> #include <Eigen/Core> #include <Eigen/SparseCore> typedef Eigen::SparseMatrix<double> SpMat; using namespace Eigen; using namespace std; int myrandom (int i) { return std::rand()%i;} int main() { PermutationMatrix<Dynamic,Dynamic> perm(5); MatrixXd x = MatrixXd::Random(5,5); SpMat y = x.sparseView(); int dim=5; perm.setIdentity(); for (int i=dim-1; i>0; --i) {

Eigen instance containing another instance holding a fixed-size eigen object

笑着哭i 提交于 2019-12-13 02:57:58
问题 I 've just read the Structures having static members eigen page. The latter states the following: If you define a structure having members of fixed-size vectorizable Eigen types, you must overload its "operator new" so that it generates 16-bytes-aligned pointers. Fortunately, Eigen provides you with a macro EIGEN_MAKE_ALIGNED_OPERATOR_NEW that does that for you. However it's not clear to me whether we should also use the EIGEN_MAKE_ALIGNED_OPERATOR_NEW macro for class instances that hold

Compiling with Cmake and using a header only library

白昼怎懂夜的黑 提交于 2019-12-13 02:19:13
问题 The question is a continuation/repeated one to a previous question, which didn't resolve the issue i'm running into. Using Eigen with Cmake Compiling Eigen with make file is one step task. But in Cmake, how do you add a header only library (basically i am using only the Eigen folder from the extracted archive folder in the Eigen website, and disregarding the rest.) Note: Eigen folder has its own CMakeLists.txt 回答1: You can use the FindEigen3.cmake. Put it into cmake/Modules folder and add the

Eigen's AutoDiffJacobian, need some help getting a learning example to work

随声附和 提交于 2019-12-12 22:51:57
问题 I have been using Eigen's AutoDiffScalar with much success and would now like to go over to the AutoDiffJacobian instead of doing this over by myself. Hence I created a learning example after have studied the AutoDiffJacobian.h, but something is wrong. Functor: template <typename Scalar> struct adFunctor { typedef Eigen::Matrix<Scalar, 3, 1> InputType; typedef Eigen::Matrix<Scalar, 2, 1> ValueType; typedef Eigen::Matrix<Scalar, ValueType::RowsAtCompileTime, InputType::RowsAtCompileTime>

Converting Eigen::MatrixXd to arma::mat and make a copy on a new object

时光毁灭记忆、已成空白 提交于 2019-12-12 22:44:33
问题 I have a function within which I want to convert an Eigen::MatrixXd object to arma::mat . I am aware of this question but I can't seem to be able to correct the behavior that I'm getting. Calling matrixxd_to_armamat from R would cause no issues, the problem is when I have this conversion in another function in C. This is a little confusing and I would like to understand what's going on. #include <RcppArmadillo.h> #include <RcppEigen.h> // [[Rcpp::depends(RcppEigen)]] // [[Rcpp::depends

Disable temporary binding of Eigen expression to const references

别来无恙 提交于 2019-12-12 22:32:16
问题 I am trying to write a function that accepts only lvalue Eigen expressions passed via const references. My first idea was to keep only the overload const Eigen::MatrixBase<Derived>& and delete the Eigen::MatrixBase<Derived>&& one. To my surprise, the delete d function was not part of the overload candidate set. So I tried the code below #include <iostream> #include <Eigen/Dense> #define PRINT_MY_NAME std::cout << __PRETTY_FUNCTION__ << '\n' template<typename Derived> void f(const Eigen:

Eigen, rotate a vector3d with a quaternion?

旧街凉风 提交于 2019-12-12 19:35:25
问题 I have an array of 3d point, as an std::vector<Eigen::Vector3d> . I need to transform these points with a position and quaternion. My questions are: How can i rotate these points with a quaternion? And is there a faster way than: Eigen::Vector3d Trans; // position to move by Eigen::Quaterniond quats; // quat to rotate by for (int p = 0; p < objectPoints.size(); p++) { Eigen::Vector3d pnt; //add pose pnt.x = objectPointsTri[p].x + -Trans.x(); pnt.y = objectPointsTri[p].y + -Trans.y(); pnt.z =

Pass C++ Eigen matrix to Matlab mex output

久未见 提交于 2019-12-12 16:37:29
问题 How can I pass an Eigen Matrix as a Matlab output parameter? I tried this from [EIGEN] How to get in and out data from Eigen matrix: MatrixXd resultEigen; // Eigen matrix with some result (non NULL!) double *resultC; // NULL pointer Map<MatrixXd>( resultC, resultEigen.rows(), resultEigen.cols() ) = resultEigen; But it lack information, how to pass the info in resultC to plhs[0] ? Also, when I run the code using this Map, Matlab closes. 回答1: You need to first allocate the output MATLAB array,

What's the right type for a join_rows() function?

﹥>﹥吖頭↗ 提交于 2019-12-12 12:04:41
问题 I wrote a function that joins the rows of two 2D arrays: template <typename S, typename T> Array<typename S::Scalar, Dynamic, Dynamic> join_rows(const ArrayBase<S> & A, const ArrayBase<T> & B) { Array<typename S::Scalar, Dynamic, Dynamic> C (A.rows(), A.cols()+B.cols()); C << A, B; return C; } I would like to write a more general function that can join more than two arrays. It should be able to work with any iterable container, eg. std::list or std::vector , so I would use a template template