\documentclass[nocolor,memo]{j3}
\renewcommand{\hdate}{2 January 2004}
\renewcommand{\vers}{J3/04-165}
\usepackage{lineno}
\usepackage{longtable}
\usepackage{xr}
\externaldocument{007}
\input pdftest
\begin{document}
\vspace{-10pt}
\begin{tabbing}
Subject: \hspace*{0.25in}\=Updating real and imaginary parts of complex
variables\\
From: \>Van Snyder\\
Reference: \>03-258r1, section 2.2.5\\
\end{tabbing}
\pagewiselinenumbers
\leftlinenumbers
\linenumbers*
\section*{Number}
TBD
\section*{Title}
Updating real and imaginary parts of complex variables.
\section*{Submitted By}
J3
\section*{Status}
For consideration.
\section*{Basic Functionality}
Provide a way to update real and imaginary parts of complex variables
independently of updating the whole variable.
\section*{Rationale}
In some applications it is necessary to update only the real or imaginary
part of a complex variable. To change the real part of a complex variable
{\tt C}, one currently needs to write
{\tt\begin{verbatim}
C = cmplx(new_real,aimag(C))
\end{verbatim}}
This doesn't look too bad, but consider the case of a complicated
reference:
{\tt\begin{verbatim}
MyThing(I,23*(J-11*K),Func(M,I,J,K))%MyField(L+3)%Radiance(1:2,1:2) = &
& cmplx(new_real,&
& aimag(MyThing(I,23*(J-11*K),Func(M,I,J,K))%MyField(L+3)%Radiance(1:2,1:2)))
\end{verbatim}}
A processor might deduce that the LHS and the argument of {\tt aimag} are
the same (but it might be confused by the apparent need to invoke {\tt
Func} twice if {\tt Func} isn't pure), but you must admit that the cost
of maintenance is higher and its reliability lower than with the simpler
alternative proposed below. One could simplify this a little bit by
writing
{\tt\begin{verbatim}
ASSOCIATE ( &
& C => MyThing(I,23*(J-11*K),Func(M,I,J,K))%MyField(L+3)%Radiance(1:2,1:2) )
C = cmplx(new_real,aimag(C))
END ASSOCIATE
\end{verbatim}}
but this is still ickier than necessary.
\section*{Estimated Impact}
Minor.
\section*{Detailed Specification}
It would be nicer if COMPLEX were a parameterized sequence derived type
having two components, the real part and the imaginary part, in that
order called, say, {\tt REAL} and {\tt IMAG}. Then the above assignment
would be simplified to
{\tt\begin{verbatim}
C%real = new_real
\end{verbatim}}
or
{\tt\begin{verbatim}
MyThing(I,23*(J-11*K),Func(M,I,J,K))%MyField(L+3)%Radiance(1:2,1:2)%real = &
& new_real
\end{verbatim}}
A side effect of this change is that there would be a new constructor for
objects of complex type, named COMPLEX. Its syntax of usage would be the
same as for other derived-type constructors. This is a desirable side
effect. It is probably desirable to specify that if either component is
not specified it has a default value of zero; doing so would make the
COMPLEX constructor work more like the CMPLX intrinsic function.
This proposal would interact with the proposal to regularize type
reference, i.e., if COMPLEX is defined to be a sequence derived type, it
would be reasonable to denote it by TYPE(COMPLEX).
If the proposal for accessor procedures is adopted this proposal will be
unnecessary. One feature of that proposal is that the AIMAG, CMPLX and
REAL intrinsic functions ought to be an accessors. I.e., updating the
real part of a complex number would be written
{\tt\begin{verbatim}
real(c) = new_real
\end{verbatim}}
or
{\tt\begin{verbatim}
real(MyThing(I,23*(J-11*K),Func(M,I,J,K))%MyField(L+3)%Radiance(1:2,1:2)) = &
& new_real
\end{verbatim}}
\section*{History}
\label{lastpage}
\end{document}