[eigen] A vector indexed by another vector

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Hi,

I'd like to replace some of my code that consits of a indexed for loop by a pure Eigen statement. 

In fact, I have several of these loops, but the most simple one is the following:

  Vector vector;
  vector.resize(size);

  for(long j = 0; j < size; ++j)
  {
    long i = offset[j];
    float tmp = t02 + h2[i] * val[0];
    vector[j] =  tmp > 0.0f ? std::sqrt(tmp) + tsdiff[i] : -1000.f;
  }

The issue is that h2 is not accessed in order, but with values from the offset vector. Is there a way to efficiently write this kind of loop with Eigen?

Cheers,

Matthieu
--
Information System Engineer, Ph.D.
Blog: http://matt.eifelle.com
LinkedIn: http://www.linkedin.com/in/matthieubrucher
Music band: http://liliejay.com/



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/