Print

Print


Aleksandar Donev writes:
 > Is it legal to do DOT_PRODUCT(vector, vector) (i.e. an aliased
 > dot-product...

Yes, it is legal.  All of the restrictions against aliasing have to do
with cases where one of the arguments is modified, which doen't come
up if both of the arguments are INTENT(IN), as almost all of the
arguments to intrinsic functions are.  This is no more problematic
than, for example, y=x*x.

Whether or not the result wil be more efficient, I couldn't say.
If it matters, I'd suggest testing and being cautious about variation
among compilers.  There are certainly plenty of cautionary tales
from the f77 (and earlier) days about code intended to speed up
calculations actually slowing them down (x*x instead of x**2 is one
of the examples, which seems awfully comparable - even in that
a good enough compiler ought to recognize them as the same).
Those lessons apply equally well to constructs new to f90.

--
Richard Maine                |  Good judgment comes from experience;
[log in to unmask]   |  experience comes from bad judgment.
                             |        -- Mark Twain