How can I write a function that accepts a std::vector of Eigen matrices of different size?
Date : March 29 2020, 07:55 AM
may help you . I would like to write a function like: , You may use something like: template <std::size_t W, std::size_t H>
void do_sth(const std::vector<Eigen::Matrix<double, W, H>>&);
|
creating sub-matrices inside a big one in Eigen Library
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further Have a look at the page Advanced initialization in Eigen. I think the following (untested) code constructs the matrix you want: MatrixXd F(6, 3 + 3 * N); // you need to specify the size before doing F << ...
F << MatrixXd::Identity(3, 3), // matrix A
MatrixXd::Zero(3, 3 * N), // matrix B
MatrixXd::Zero(3, 3 + 3 * index), // matrix C plus left zero block in D
MatrixXd::Identity(3, 3), // indentity block in D
MatrixXd::Zero(3, 3 * (N - index - 1)); // right zero block in D
|
A vector of matrices using eigen library
Tag : cpp , By : Lathentar
Date : March 29 2020, 07:55 AM
may help you . using the Eigen library: , This is incorrect, as the loop will never execute if i is not 0. for(int i= matrices_vector.size()-1; i=0; i--)
for(int i= matrices_vector.size()-1; i > 0; i--)
|
Set Vector of Eigen Matrices to 0
Tag : cpp , By : firebasket
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further First of all, Eigen::Matrix will by default be aligned to 16 bytes, which on 64bit systems or with C++17 will most likely work properly, but you may otherwise face some caveats. An easy way to workaround any issues regarding alignment is to writetypedef Eigen::Matrix<int,30,150, Eigen::DontAlign> HoughMatrix;
std::vector<HoughMatrix> hough_spaces(num_spaces, HoughMatrix::Zero());
std::vector<HoughMatrix> hough_spaces(num_spaces);
std::memset(hough_spaces.data(), 0, num_spaces*sizeof(HoughMatrix));
// unique_ptr with custom deallocator (use a typedef, if you need this more often):
std::unique_ptr<HoughMatrix[], void(&)(void*)> hough_spaces(static_cast<HoughMatrix*>(std::calloc(num_spaces, sizeof(HoughMatrix))), std::free);
if(!hough_spaces) throw std::bad_alloc(); // Useful, if you actually handle bad-allocs. If you ignore failed callocs, you'll likely segfault when accessing the data.
typedef Eigen::Tensor<int, 3> HoughSpace;
HoughSpace hough_spaces(num_spaces,30,150);
hough_spaces.setZero();
|
Eigen segfaults with AVX on Ivy Bridge when using `std::vector` of fixed-size matrices
Date : March 29 2020, 07:55 AM
I wish did fix the issue. The fact that I was using a std::vector of fixed-size matrices was the key. very much for the request for a minimal example, @rex. While preparing the example, I found out the following. For certain large input sizes (of the std::vector containing the matrices), Eigen throws a runtime error, which led me to this site. Following the instructions there fixed the issue.
|