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
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 write
// 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.
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.