eigen3

correctly registering a plugin to use Eigen via Rcpp

偶尔善良 提交于 2019-12-13 14:35:11
问题 I'm trying to be able to use a c++ class template in R . This was my first try at a small reproducible example. library(inline) library(Rcpp) inc <- "#include <Eigen/Dense> template <size_t dim> class SillyWrapper { public: Eigen::Matrix<double,dim,1> m_vec; SillyWrapper(const Eigen::Matrix<int,dim,1>& vec) : m_vec(vec); };" src <- 'SillyWrapper mything(Rcpp::as<Eigen::Map<Eigen::Matrix<double,dim,1>>>(x));' library(inline) fun <- cxxfunction(signature(x="numeric"), body=src, includes=inc,

Eigen: how can I substitute matrix positive values with 1 and 0 otherwise?

吃可爱长大的小学妹 提交于 2019-12-13 07:06:22
问题 I want to write the following matlab code in Eigen (where K is pxp and W is pxb ): H = (K*W)>0; However the only thing that I came up so far is: H = ((K*W.array() > 0).select(1,0)); This code doesn't work as explained here, but replacing 0 with VectorXd::Constant(p,0) (as suggested in the link question) generates a runtime error: Eigen::internal::variable_if_dynamic<T, Value>::variable_if_dynamic(T) [with T = long int; int Value = 1]: Assertion `v == T(Value)' failed. How can I solve this?

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>

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:

bool multiplication with exclusive-or, not or (with Eigen Matrix Library)

我是研究僧i 提交于 2019-12-12 11:34:17
问题 I'm trying to implement hamming error correcting codes, and to do this I need to take a bool Vector (the data) and multiply it with a bool Matrix(hamming generator matrix), performing XOR operations (instead of what looks like OR as Eigen's default bool behavior). An example of what I am doing is found in this simple tutorial: http://michael.dipperstein.com/hamming/ I don't necessarily have to use Eigen, so please feel free to suggest something other than Eigen if you have the solution. So

How to use custom preconditioner with Eigen

女生的网名这么多〃 提交于 2019-12-12 05:18:08
问题 I am trying to use a custom preconditioner for an iterative solver (CG for instance) with Eigen. Specifically, I have to solve a similar problem multiple times: the matrix changes slightly but stays close to a mean matrix. I would like to compute a Cholesky decomposition of my mean matrix and then use this as a preconditioner. What I had in mind is something like: ConjugateGradient< SparseMatrix<double>, Lower, CholmodSupernodalLLT<SparseMatrix<double>> > solver(meanMatrix); solver

Eigen: Modifyable Custom Expression

北慕城南 提交于 2019-12-12 04:54:21
问题 I'm trying to implement a modifyable custom expression using Eigen, similar to this question. Basically, what I want is something similar to the indexing example in the tutorial, but with the possibility to assign new values to the selected coefficients. As suggested in the accepted answer in the question mentioned above, I have looked into the Transpose implementation and tried many things, yet without success. Basically, my attempts are failing with errors like 'Eigen::internal::evaluator

Eigen and parallellization makes no difference for conjugate gradient. Precondition also fails

故事扮演 提交于 2019-12-12 02:33:36
问题 This is related to this question. I have today experimented a bit with Conjugate Gradient, in particular I experimented with max_iterations and tolerance . It is faster but not fast enough. According to the documentation it should be enough to add -fopenmp in the compilation to enable multi-threading . I have tested using both `omp_set_num_threads(nbrThreads); Eigen::setNbThreads(nbrThreads);` It makes no difference in time if I use 5 threads or 1 thread, and that I think is a bit strange.