Created
April 23, 2018 17:28
-
-
Save jefftrull/86b078527b124929b0de71161bd67689 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// std::vector<Eigen::VectorXf> -> Eigen::MatrixXf | |
#include <iostream> | |
#include <vector> | |
#include <Eigen/Dense> | |
int main() { | |
using namespace Eigen; | |
const int cols = 10; | |
const int rows = 10; // or do you get it from the sizes of each entry in *d? | |
std::vector<VectorXf> * d = new std::vector<VectorXf>(cols); | |
for (int col = 0; col < cols; ++col) { | |
(*d)[col] = VectorXf(rows); | |
(*d)[col].setRandom(); | |
} | |
// now create the Matrix and copy from vector of vectors | |
Matrix<float, Dynamic, Dynamic> result(rows, cols); // assuming we know #rows... | |
for (int col = 0; col < cols; ++col) { | |
result.col(col) = (*d)[col]; | |
} | |
IOFormat OctaveFmt(StreamPrecision, 0, ", ", ";\n", "", "", "[", "]"); | |
std::cout << "result matrix=\n" << result.format(OctaveFmt) << "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks.