Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29236 Discussions

How to operate on the imaginary part of complex variable?

nanhui_yu
Beginner
517 Views
Dear Sir/Madam:
How are you?
I have a problem to ask you.
For example, I have a complex typevariable A
and a real type variable B, now I want to
make the value of B as the imaginary part of A.
I use the command like : AIMAG(A)=B ,but it's wrong;
and I try another way like: A=(0,B) ,it's also wrong.
So I don't know what to do.
Maybe this is a very simple question,
however, if you know ,please give some advice.
Thanks a lot!
Yours Sincerely:
Nanhui
0 Kudos
3 Replies
Steven_L_Intel1
Employee
517 Views
B=AIMAG(A)
0 Kudos
nanhui_yu
Beginner
517 Views
Thanks for your reply.
But you seems misunderstanding my meaning.
If use : B=AIMAG(A), then it means totransfer value
of the imaginary part of A to variable B, but now
my case is to transfer value of B to the imaginary part
of variable A. So it's the inverse case.
I f you know,please tell me. Thank you very much!!
Yours Sincerely:
Nanhui
0 Kudos
TimP
Honored Contributor III
517 Views
A = CMPLX(REAL(A),B)
0 Kudos
Reply