Last active
December 28, 2017 23:14
-
-
Save mtao/4936c8f639687eebfd83472de37dcad4 to your computer and use it in GitHub Desktop.
see https://gist.github.com/mtao/172c73a4a7abdf7a5724b71523a5fbe8, but for matlab; mtao imports are findable here: https://github.com/mtao/core/blob/master/include/mtao/eigen/stack.h
This file contains hidden or 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
#include <Eigen/Dense> | |
#include <mtao/types.h> | |
#include <mtao/eigen/stack.h> | |
#include <iostream> | |
#include <numeric> | |
mtao::RowVectorX<int> range(int n) { | |
mtao::RowVectorX<int> ret(n); | |
std::iota(ret.data(),ret.data()+n,0); | |
return ret; | |
} | |
template <typename D> | |
mtao::RowVectorX<int> range(const Eigen::MatrixBase<D>& n) { | |
return range(n.size()); | |
} | |
int main() { | |
mtao::RowVector<int,5> list; list << 1,5,4,3,2; | |
auto pairs = mtao::eigen::vstack(range(list),list); | |
std::cout << pairs << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment