|Re: [eigen] Optimization for special complex operations|
[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Optimization for special complex operations
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Mon, 16 Aug 2010 09:34:02 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type; bh=ZXO28dr9mVwNbO8wJo2m0If57LIMZzlYL4JTNQYJnyU=; b=RJr7fMrkZRvUbHT5ku8f2VX9TiRQ0zG4dXDkuL6LJfoo5IITmujdtsy5aHAbPTYGPe aeR0Qel4NC0dFLEMSjDptMn/yjKKKJRsKlpFHzYYycwihNKPglWnPRTNhJQLOf0yhxH/ 4xEzw0ggcX/Ux8WUzHP78TtxQkhe8uHwNPa4I=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=bGPJ0/rx/8s2yqWyXAOu+vwo2c+MwPzjuio62eXAGlcqS6SlznMHTnm/gihUij3Yg/ 4hwRjX3J01JaB4eTgAO3clvPxmMoECZ/VwjhDueNXR8jfw3HLDKO9s+p5z4Dlsol46z1 vNpS7ZweZmoDMFLtngZVIk08EI6eLXNbUrbPI=
2010/8/16 Carlos Becker <carlosbecker@xxxxxxxxx>:
> Hi everyone again. Lately I've been using Eigen with complex numbers to
> calculate things such as calculating the maximum of the real part or
> imaginary part of a certain vector. I suppose that trying to take the real
> part and then use maxCoeff() or minCoeff() would create a possible
> unnecessary temporary.
No, it wouldn't :-)
> Another thing is to be able to do something like:
> MatrixXf nn,xx;
> xx = nn.colwise().normalized();
Hm. If we start going that route, won't we end up offering every
possible vector operation as colwise() operation?
So we have to draw a line in the sand, somewhere.
One good place to put this limit, is according to the question: "does
this enable any better performance over a for loop?"
in your case,
xx = nn.colwise().normalized();
I would say yes, this can enable better vectorization. Indeed if nn
has 3 rows-at-compile-time, each individual normalization operation
can't be vectorized at all, but the global colwise().normalized()
operation could be completely vectorized in the horizontal direction.
This can already be achieved today with a complex enough expression:
xx = nn.array().colwise() / nn.array().abs2().colwise().sum().sqrt();
(if I am not mistaken...)
> Here there are two very different concepts:
> I guess there could be some special functions, in this case only for complex
> numbers, to be able to perform some special optimizations. I remember we
> were talking a bit about a special case with Gael on the chat channel.
> Regarding the .normalized() snippet above, I know I am breaking reduction
Oh, I wouldn't talk about "rules" here. Your operation isn't a
reduction, it would be a "vector-wise operation". That's just
The biggest reason not to do it now is that it really isn't necessary
to release Eigen 3.0 .... ;-)
> since I am expecting xx and nn to be of the same size in the end.
> However, I don't know how much is lost if this normalization is done
> manually with, for instance, a for loop.
> Does this make sense? I would like to work on these but I don't want to
> introduce code that would not make sense or break rules. I only have a small
> insight of what eigen looks like inside.