Registered Member
|
I need to compute element-wise products of all pairwise combinations of rows of two arrays (one row from each array). There are two problems:
1. The matrices are generated by R, which is column-major always (I think), so I am taking big hits on memory access. It isn't obvious to me how best to convert. Making a copy in row-major fashion is the apparent choice. 2. I also would like to parallelize this operation and want to optimize for cache by using chunking. Since this is a ubiquitous technique, I am sure Eigen uses it, so I would like to know whether there is generic code in Eigen I can use for chunking. Thanks a lot.
Last edited by di4jc8732 on Wed Sep 28, 2011 10:24 pm, edited 1 time in total.
|
Registered Member
|
As for 1: "If the storage order is not specified, then Eigen normally defaults to storing the entry in column-major order."
// http://eigen.tuxfamily.org/dox-devel/To ... rders.html |
Registered Member
|
Thanks for the reply.
Like I said, the two arrays are passed in from R, another program, which isn't as flexible in storage order as Eigen. |
Moderator
|
you can keep your column major storage and do scalar * vector products,
for(int k=0; k<mat.rows();++k) #pragma omp parallel for for(int j=0; j<mat.cols();++j) res[k].col(j) = mat(k,j) * mat.col(j); |
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]