[Cfp-interest 3254] Re: Lingering references to imaginary type

Damian McGuckin damianm at esi.com.au
Wed Aug 28 19:47:55 PDT 2024


On Wed, 28 Aug 2024, Jim Thomas wrote:

> I do not want to pick at straws but in G.3.2#5,
> 
> return x + I * y
> 
> is perfectly legal as 7.3.1 says that I is equivalent to _Complex_I.
> (unless a programmer is crazy enough to redefine the macro I - uggh!)
> 
> 
> It?s legal, but not correct for the use here.

Agreed.

>       I actually think that we could even say in 7.3.9.3#3
>
>       CMPLX(x, y) returns x + I * y
>
>       Because this is exactly what it does! Very succinct.

> If macro I has complex type (which is always the case now) it is generally
> unsuitable for use where infinities or the sign of zeros matter, as they do
> in G.3.2 #5 and #7.

Wise words. Very correct. The new definition of I is unfortunate.

Where I was really going was that I noticed that x + i y had a mix of the 
mathematical with i and the computational with x and y (which may have to 
be type-converted). I was unhappy with my words on 7.3.9.3 and was looking 
for inspirational wisdom (or better words) from the audience. I was also 
trying to stimulate some discussion on my own document.

Lots of the 'Returns' paragraphs in 7.3.9 read (syntactical) like either

 	The ???? functions return the value of ....
or
 	The ???? functions return the <name-of-complex-function> value.

Where <name-of-function> is something like "complex hyperbolic tangent", 
i.e. its mathematical name. In the <name-of-function>, the word "complex" 
qualifies "hyperbolic tangent".  It does not qualify "complex value" 
because that term is not defined. Should it be?  Note that neither is 
the term "real value". That said, the concepts of

 	"value of complex type"
and
 	"value of real floating type"

are precisely defined by "3. Terms, Definitions and Symbols".

Hence for functions like cimag() and creal() which are not strictly a 
mathematical function but a definition, we probably should follow the 
wording of cproj() which follows the first style, so these two are then 
better written as

 	The cimag functions return the value of the imaginary part

 	The creal functions return the value of the real part

The qualification (as a real) is both technically wrong and means that the 
explanation of real and imaginary parts in 6.2.5#17 was inadequate (which 
I do not believe it is not). But maybe we need to cross reference that 
clause in both those return values?

The csqrt() and conj() are in between. Compared to their existing wording, 
the following can be said to (roll off the tongue or) read better as:

 	The csqrt functions return the value of the complex square root.
and
 	The csqrt functions return the value of the complex conjugate.

Also, the current wording implies there is such a thing as a mathematical 
complex conjugate function. At least a I understand the meaning of the 
word function. The concept of conjugate is a definition.

And then we come back to the return value of the CMPLX() macros which is 
the problem child.

This is the value of an expression x + i y. Both x and y are computational 
values and i is a mathematical value where i^2 = -1, the imaginary unit. 
Nowhere else in 7.3 is there a mix of mathematical and computational bits.
Also, both x and y may have their type converted which is not implied by 
the current wording. So, how about ay least

   The CMPLX macros return the value of the expression x + i y

Are the words "(appropriately typed)" in front the word "value" needed?

Are the words "the expression" unnecessary?

Thanks - Damian


More information about the Cfp-interest mailing list