eigen

Why does std::less<Eigen::VectorXd> fail to compile?

流过昼夜 提交于 2019-12-07 01:44:42
问题 I implemented a comparison operator operator< for Eigen::VectorXd , and sometimes, I need to pass a compare function to another of my function, I am tired of wrapping the operator< into [](const VectorXd& v1, const VectorXd& v2)->bool{return v1 < v2} , so I think the std::less class would be useful, as, to my understanding, it can generate the lambda function as long as operator< is defined. However, I found that std::less<VectorXd> didn't work for me, for example, the below code works fine:

Visual studio 2015. c++ compiler error C2280 attempting to reference a deleted function

偶尔善良 提交于 2019-12-06 19:13:31
What i am trying to do is to compile project which was built by CMake. In my code i have next method: /** "in-place" version of TriangularView::solve() where the result is written in \a other * * \warning The parameter is only marked 'const' to make the C++ compiler accept a temporary expression here. * This function will const_cast it, so constness isn't honored here. * * See TriangularView:solve() for the details. */ template<typename MatrixType, unsigned int Mode> template<int Side, typename OtherDerived> void TriangularView<MatrixType,Mode>::solveInPlace(const MatrixBase<OtherDerived>&

Boost::uBLAS vs Eigen

倖福魔咒の 提交于 2019-12-06 18:50:10
问题 I am used to Eigen for almost all my mathematical linear algebra work. Recently, I have discovered that Boost also provides a C++ template class library that provides Basic Linear Algebra Library (Boost::uBLAS). This got me wondering if I can get all my work based only on boost as it is already a major library for my code. A closer look at both didn't really got me a clearer distinction between them: Boost::uBLAS : uBLAS provides templated C++ classes for dense, unit and sparse vectors, dense

Problems using eigens Tensor class

两盒软妹~` 提交于 2019-12-06 14:59:54
I would like to use eigens Tensor class from the unsupported module . This site suggests to include something like #include <Eigen/CXX11/Tensor> to be able to use it. I installed eigen via Homebrew (Version 3.2.4) on my Mac on OS X Yosemite. Although I get eigen to work properly, I cannot find the necessary module in the unsupported folder: #include <eigen3/unsupported/Eigen/???> What might I have forgotten or done wrong? Or do I have an outdated version which does not have yet the Tensor class? The unsupported Tensor module is only found in the unstable version for now (Current stable: 3.2.5)

Comparing two matrices with eigen

て烟熏妆下的殇ゞ 提交于 2019-12-06 13:51:14
Let's say I have two eigen matrices A and B, and I want to create a third matrix defined by C(i,j) = 5.0 if A(i,j) > B(i,j), 0 otherwise I guess it is possible to do it without an explicit for loop. But I am not very proficient with Eigen yet. What whould be the best approach? Assuming A , B and C are MatrixXd you can do: C = (A.array()>B.Array()).cast<double>() * 5.0; 来源: https://stackoverflow.com/questions/22228332/comparing-two-matrices-with-eigen

solving a singular matrix

此生再无相见时 提交于 2019-12-06 13:49:09
I am trying to write a little unwrapper for meshes. This uses a finite-element-method to solve for minimal linear stress between flattened and the raw surface. At the moment there are some vertices pinned to get a result. Without this the triangles are rotated and translated randomly... But as this pinning isn't necessary for the problem, the better solution would be to directly solve the singular matrix. Petsc does provide some methodes to solve a singular system by providing some information on the nullspace. http://www.mcs.anl.gov/petsc/petsc-current/docs/manual.pdf#section.4.6 I wonder if

evaluate multivariate Normal/Gaussian Density in c++

最后都变了- 提交于 2019-12-06 12:52:21
问题 Right now I have the following function to evaluate the Gaussian density: double densities::evalMultivNorm(const Eigen::VectorXd &x, const Eigen::VectorXd &meanVec, const Eigen::MatrixXd &covMat) { double inv_sqrt_2pi = 0.3989422804014327; double quadform = (x - meanVec).transpose() * covMat.inverse() * (x-meanVec); double normConst = pow(inv_sqrt_2pi, covMat.rows()) * pow(covMat.determinant(), -.5); return normConst * exp(-.5* quadform); } This is just transcribing the formula. However I get

Replicating TensorFlows Conv2D Operating using Eigen Tensors

戏子无情 提交于 2019-12-06 12:22:13
I'm trying to implement a lightweight (minimal library dependencies) version of a TensorFlow graph in c++ and I'm trying to use Eigen Tensor objects to perform the graphs operations. Right now I'm stuck trying to use the Eigen Tensor.convolve() method to try and replicate the behaviour of TensorFlow's Conv2D operation. To keep things simple my initial Conv2D operation has no padding and strides of one. The input to convolutional layer is a 51x51x1 tensor which is being convolved with a filter bank of size 3x3x1x16. In tensorflow this generates an output tensor of size 49x49x16. Setting up this

Convert Eigen Affine3d to Affine2d

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 11:33:20
I have an affine transform in 3D and I wish to discard any z-axis information from. Is there a convenient way to convert from an Affine3d to and Affine2d ? Try following: Affine2d S2d = Translation2d(S3d.translation().topRows<2>()) * S3d.linear().topLeftCorner<2,2>(); Demo: #include <Eigen/Dense> #include <iostream> #include <string> int main() { using namespace Eigen; using namespace std; Vector3d p3d(1.,2.,3.); cout << p3d << endl << endl; Affine3d S3d = Translation3d(2.,2.,2.)*Scaling(3.,2.,5.); Vector3d scalled = S3d*p3d; cout << S3d.matrix() << endl << endl; cout << scalled << endl <<

PCA in OpenCV using the new C++ interface

时光总嘲笑我的痴心妄想 提交于 2019-12-06 09:45:13
问题 As an aside: Apologies if I'm flooding SO with OpenCV questions :p I'm currently trying to port over my old C code to use the new C++ interface and I've got to the point where I'm rebuilidng my Eigenfaces face recogniser class. Mat img = imread("1.jpg"); Mat img2 = imread("2.jpg"); FaceDetector* detect = new HaarDetector("haarcascade_frontalface_alt2.xml"); // convert to grey scale Mat g_img, g_img2; cvtColor(img, g_img, CV_BGR2GRAY); cvtColor(img2, g_img2, CV_BGR2GRAY); // find the faces in