Registered Member
|
So I have this code, which mulitplies the Kronecker product $Q_1 \otimes Q_2 \otimes \cdots \otimes Q_n$ with a vector, $v$, so that $b=(Q_1 \otimes Q_2 \otimes \cdots \otimes Q_n)v$. The input is a std::vector of sparse matrices , an input vector and an output vector.
In the code below, the innermost loops
copies parts of a vector into a smaller one, and a smaller one into a bigger one, and I suspect this implementation hampers performance a bit. What I would like, is something similar to a block, but with variable jumps between the values it takes out. I thinking about using a map with strides, but I didn't get it to work properly. Does anyone have a good idea on how to optimise this?
|
Moderator
|
you could indeed use a:
Map<Matrix<Scalar,Dynamic,1>,0,InnerStride<> > sub(&outVec.coeffRef(index1), sizeInner, InnerStride<>(nright)); but I'm not sure you will get much speedup. |
Registered Member
|
Thanks for the tips. I managed to get the code a bit more expressive, using this trick. It is about 5% faster.
One thing that bothers me though, is how to get the proper const_casting to work (as in http://eigen.tuxfamily.org/dox/TopicFun ... Types.html). The following const_cast does not work
|
Moderator
|
outMap is not const so why would you want to const_cast it?
|
Registered Member
|
I don't need it to be const, but I try to conform to the guidelines at http://eigen.tuxfamily.org/dox/TopicFunctionTakingEigenTypes.html when I write code, in order to avoid possible caveats in later development. I also found a way to have constness at the same address.
Please regard this post as solved. I include the code, for completeness, in case other users need it.
|
Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]