Skip to content

Instantly share code, notes, and snippets.

@mtao
Last active December 28, 2017 23:14
Show Gist options
  • Save mtao/4936c8f639687eebfd83472de37dcad4 to your computer and use it in GitHub Desktop.
Save mtao/4936c8f639687eebfd83472de37dcad4 to your computer and use it in GitHub Desktop.
#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