Skip to content

Instantly share code, notes, and snippets.

@jey
Created October 23, 2012 04:17
Show Gist options
  • Save jey/3936616 to your computer and use it in GitHub Desktop.
Save jey/3936616 to your computer and use it in GitHub Desktop.
// compile in C++11 mode
#include <Eigen/Dense>
using namespace Eigen;
typedef Matrix<double, Dynamic, Dynamic, RowMajor> RowMajorMatrix;
typedef Matrix<double, Dynamic, Dynamic, ColMajor> ColMajorMatrix;
int main()
{
unsigned p = 50000;
unsigned q = 4;
const auto &rnds = RowMajorMatrix::Random(q, p).eval().transpose();
ColMajorMatrix nu = ColMajorMatrix::Random(p, q);
ColMajorMatrix eta(p, q);
for(unsigned j = 0; j < q; ++j) {
eta.col(j) = rnds.col(j).array() * nu.col(j).array();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment