Home > Archive > Fortran > May 2005 > cmplx(0.,-x) or -j*x
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
cmplx(0.,-x) or -j*x
|
|
| gh14tq5@yahoo.com 2005-05-26, 3:57 am |
| Hi,
Is there any speed advantage of using
z = cmplx(0,-x) over z = -j*x (or vice-versa)
where x is real and possible an array and j=sqrt(-1). Would this be
something that is compiler dependent?
Thanks,
John
| |
| glen herrmannsfeldt 2005-05-26, 3:57 am |
| gh14tq5@yahoo.com wrote:
> Is there any speed advantage of using
> z = cmplx(0,-x) over z = -j*x (or vice-versa)
> where x is real and possible an array and j=sqrt(-1). Would this be
> something that is compiler dependent?
Well, the CMPLX version should pretty much just copy the data. The
second one possibly will actually do multiplication. I would hope an
optimizing compiler would figure it out, but I wouldn't guarantee it.
-- glen
| |
|
| gh14tq5@yahoo.com writes: > Hi,
>
> Is there any speed advantage of using
>
> z = cmplx(0,-x) over z = -j*x (or vice-versa)
>
> where x is real and possible an array and j=sqrt(-1). Would this be
> something that is compiler dependent?
Isn't J going to be complex?
And therefore j*x is going to involve scalar multiplication
twice (j*0 and j*x).
This will be somewhat longer than using cmplx,
which just does two moves (0 into the real part and
-x to the unreal part).
> Thanks,
> John
|
|
|
|
|