eigen

Using Eigen Lib in my Cmake project?

佐手、 提交于 2020-01-22 01:35:09
问题 I am having difficulty using a header-only library (Eigen) in my CMake project. When i take off all the portion related to Eigen library it compiles, but not sure how to build with (Eigen). Note that Eigen has a CmakeLists.txt in Eigen folder, and it has /src folder having (*.h and *.cpp) related to Matrix operation etc... The structure of my program is as follow Myproject (folder) is composed of : CmakeLists.txt /Build /Source The Source folder has bunch of my files (*.h and *.cpp) and the

Do I need to import RccpEigen in the DESCRIPTION file for an R package using it, or is “LinkingTo” enough?

≡放荡痞女 提交于 2020-01-21 08:36:11
问题 I used the RcppEigen.package.skeleton() as a template for adding a small function to an existing R package, so that my DESCRIPTION file now has the lines: Imports: Rcpp (>= 0.11.3), RcppEigen (>= 0.3.2.3.0) LinkingTo: Rcpp, RcppEigen However, doing R CMD check --as-cran <myPackageName_1.0.0>.tar.gz gives the following: "Package in Depends/Imports which should probably only be in LinkingTo: 'RcppEigen'" The Writing R Extensions page says: "Specifying a package in ‘LinkingTo’ suffices if these

学习 Eigen库安装指南(两种方式)

狂风中的少年 提交于 2020-01-20 00:24:15
Eigen库安装指南(两种方式) 1、apt-get方式(假设默认安装到/usr/local/include里(可在终端中输入locate eigen3查看位置),若实际中默认安装到了/usr/include的话,可以对应替换下面命令的相应部分) 运行命令: sudo apt-get install libeigen3-dev 运行命令:(参考第二种方法的最下面的说明) sudo cp -r /usr/local/include/eigen3/Eigen /usr/local/include 执行复制命令,将Eigen文件夹及其内容放在/usr/include 2、源码安装(复杂些) 安装包下载网址: http://eigen.tuxfamily.org/index.php?title=Main_Page 在该网站中,可以下载任意版本对应的文件,本例下载了Eigen 3.3.7. : tar.bz2 格式压缩文件。 文件名:eigen-eigen-323c052e1731.tar.bz2 运行命令: sudo tar -jzvf eigen-eigen-323c052e1731.tar.bz2 -C /usr/local/include 注意:/usr/local/include 也可以换成/usr/include 但是上面对应的位置也要匹配修改,该命令 tar -jzvf

Including Eigen

不问归期 提交于 2020-01-16 08:38:12
问题 I've included the Eigen headers in a C++ project in Eclipse. When I try to build I get this error: Symbol 'Eigen' could not be resolved Semantic Error From what I understand, this is a linker error, but Eigen is a header-only project and thus has no library to link against. The code that throws the error follows the basic tutorial they provide, and the offending snippet looks like this: #include <Eigen/Dense> using namespace Eigen; What am I doing wrong? If it helps, I'm running this on Linux

c++ bad allocation when matrix size exceeds a certain limit with Eigen matrix type

回眸只為那壹抹淺笑 提交于 2020-01-15 13:12:58
问题 In a c++ dynamic library I solve a least square problem using the Eigen Library. This Dll is called inside a python software where the problem configuration is settled. In a small sized problem the code works properly and returns the correct solution. If the number of points increases then the library throws std::bad_alloc . More precisely, The code which creates the error simplified to its most is try { matrixA = new Eigen::MatrixXd(sizeX,NvalidBtuple); // initialize A for (int i=0;i<sizeX;+

Extending Eigen with CWiseNullaryOp: Cannot reproduce example

◇◆丶佛笑我妖孽 提交于 2020-01-15 08:43:43
问题 I am trying to reproduce the second example on this page of the Eigen documentation, but cannot compile my minimal program. I am using Eigen 3.3~beta1-2. When running g++ with the following arguments -std=c++11 -Wall -pipe -O3 -ffast-math -funsafe-math-optimizations -march=native -mtune=native -pedantic -Wno-unused-variable -I/usr/local/include/eigen3 -I/usr/include/eigen3 -c example.cpp , I get this error: example.cpp:8:41 ("Eigen::MatrixXi B = indexing(A, ri, ci)" in program below) /usr

C++文件操作

旧城冷巷雨未停 提交于 2020-01-15 07:27:03
最近经常用来C++读取或者保存txt文件,特此记录一下操作,以便之后查询: 1.打开一个文件 std::ifstream f; f.open("bin/house_model/house.txt"); if (!f) cout << "not open the house.txt"<<endl; 按行读取该文件: while(!f.eof()) { std::string s; std::getline(f,s); if(!s.empty()) { std::stringstream ss; ss << s; double x,y,z; ss >> x; ss >> y; ss >> z; Eigen::Vector4d pt0( x, y, z, 1 ); ss >> x; ss >> y; ss >> z; Eigen::Vector4d pt1( x, y, z, 1 ); } } 先判断是不是到文件末尾了,然后把读取到的一行,给一个文件流ss,该文件流可以按个数进行赋值。 2.保存文件 void save_points(std::string filename, std::vector<Eigen::Vector4d, Eigen::aligned_allocator<Eigen::Vector4d> > points) { std::ofstream save

Not found Eigen3_DIR when configuring a cmake project in Windows

邮差的信 提交于 2020-01-14 10:47:26
问题 I want to compile an open project, it needs Eigen3, I followed its guideline but stuck in this step: "Set environment variable Eigen3_DIR to {YOUR_EIGEN3_DIRECTORY}/eigen3/cmake." I have installed CMake gui and it printed following errors after configuration Make Error at src/CMakeLists.txt:15 (find_package): By not providing "FindEigen3.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "Eigen3", but CMake did not find one. Could not

关于生信常用的PCA算法

送分小仙女□ 提交于 2020-01-13 01:28:56
PCA是一种常用的数据降维算法,主要就是根据特征值提出特征值较大的几个特征向量,并将高维向量投影到特征向量上以达到数据降维的目的。 第一步当然是处理数据,将样本数据按列放入numpy的数据框(比如100个样本,每个样本4个数据,就是4行100列,反过来也可以,不过要注意调换内积的顺序)。 数据需要先做归一化,以减去所有样本的均值来实现。 from sklearn.datasets import load_iris iris = load_iris() data = iris['data'] data = data-np.mean(data, axis=0) 然后要计算出协方差矩阵,并计算出特征值及特征向量 def get_eigen(data): data_cov = np.cov(data, rowvar=0) eigen_val, eigen_vec = np.linalg.eig(data_cov) return eigen_val, eigen_vec 然后对特征值排序,提出特征向量 def sort_eigen(eigen_val, eigen_vec, cut_num): index = np.argsort(-eigen_val) sort_vec = eigen_vec[:, index[:cut_num]] return sort_vec

Quaternion is flipping sign for very similar rotations?

南楼画角 提交于 2020-01-12 10:16:34
问题 Consider the following minimal working example: #include <iostream> #include <math.h> #include <eigen3/Eigen/Dense> int main() { // Set the rotation matrices that give an example of the problem Eigen::Matrix3d rotation_matrix_1, rotation_matrix_2; rotation_matrix_1 << 0.15240781108708346, -0.98618841818279246, -0.064840288106743013, -0.98826031445019891, -0.1527775600229907, 0.00075368177315370682, -0.0106494132438156, 0.063964216524108775, -0.99789536976680049; rotation_matrix_2 << -0