I have a large matrix, side-length is about $n\geq 1000$. I need to do element-wise multiplication of this matrix with another matrix many, many times. I make this process by:
- Vectorizing (through armadillo) this matrix, i.e., flattening it in a single array.
- Splitting this array over many cores. Each core will take a part of this matrix and do its multiplication.
Now I realized that for Mathematical reasons, I only need the upper-triangular part of this matrix. How can I vectorize only the upper-triangular part and discard the other components of the matrix? Simply looping is not that good. Do I have any other options?
My matrices are Armadillo complex matrices of
arma::cx_mat. And my current vectorization function is:
typedef double Real; typedef std::vector<std::complex<Real> > VecType; arma::cx_mat myMatrix; //fill my matrix... VecType vectorizedMatrix = arma::conv_to<VecType>::from(myMatrix);
std::vector very useful, because I do element-wise multiplication very efficiently using standard algorithms with
std::transform(), which is best optimized (AFAIK).