Re: [eigen] help speeding up an expression?

[ Thread Index | Date Index | More Archives ]

I haven't tested speed, but you could pobably avoid some mults by creating temporaries, which you should have allocated previously.  And I think that in later Eigen versions you may use min() to clip the array under a given value:

z += 0.175;
zz = z*z;
zzz = zz*z;
z = z.max(zzz/(zzz+zz+0.1), 0);

Disclaimer:  haven't tried it.

On Sat, Aug 3, 2013 at 7:37 AM, Márton Danóczy <marton78@xxxxxxxxx> wrote:

What about z*z*z + z*z = z*z*(z+1)?


On 2 Aug 2013 23:26, "Dick Lyon" <dicklyon@xxxxxxxxxx> wrote:
Has anyone got tips on how to speed up this eigen code that is the slowest part of my process?

Simplified, I have this in an inline function definition with argument ArrayXf& z:

  z += 0.175;
  z = (z < 0).select(0.0, (z*z*z) / (z*z*z + z*z + 0.1));

Can this be sped up by clever use of pre-allocated temp arrays?  Or is eigen already more clever than anything I'd likely come up with?  And how can I tell, or where should I look to learn more about how to think about optimizing such things?

Is select fast?  Or are there better ways to threshold things?

I'm on an Intel platform, but ultimately also targeting Arm NEON, in case that matters.



Mail converted by MHonArc 2.6.19+