This is the mail archive of the egcs-bugs@egcs.cygnus.com mailing list for the EGCS project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: single precision complex bug in g77 - was Testing g77 with LAPACK 3.0


Billinghurst, David (RTD) wrote:

> Here is a test case.

Thanks for trimming this down.  Unfortunately (as was to be expected) it
doesn't fail on my i686-pc-linux-gnu system - it prints nothing, and not
just because I called the executable `test' :-)

> ############################################################
>       program labug3
>       implicit none
> 
> *  This program gives the wrong answer on mips-sgi-irix6.5
> *  when compiled with g77 from egcs-19990629 (gcc 2.95 prerelease)
> *
> *  Works with:  -femulate-complex
> *               egcs-1.1.2
> *
> *  Originally derived from LAPACK 3.0 test suite.
> *
> *  David Billinghurst, (David.Billinghurst@riotinto.com.au)
> *  7 July 1999
> *
>       complex one, z
>       real    a,cabs1
>       CABS1( Z) = ABS( REAL( Z)) + ABS( AIMAG(Z))
>       one = (1.,0.)
>       a = cabs1(one)
>       if ( abs(a-one) .gt. 1.0e-5 ) then
>          write(6,*) 'A should be 1.0'
>          call abort()
>       end if
>       end
> ###############################################################

Could someone with an Alpha at hand try this example (it might be that
the problem is "Single precision COMPLEX on 64-bit target").

Some explanation:

CABS1( Z) = ABS( REAL( Z)) + ABS( AIMAG(Z))

is a "statement function" (sort of macro: the rhs is subsituted with z
replaced with whatever is the argument of cabs1).  Note that both abs's
in this expression are REAL ones, because REAL(Z) and AIMAG(Z) are
REALS.  Therefore, CABS1 (in spite of its name) is a REAL valued
statement function, as is expressed by the declaration "real cabs1".

Contrast this with the `abs' in "if ( abs(a-one) ...".  The promotion
rules of Fortran make the expression `a-one' (which is of the type
REAL+COMPLEX) of type COMPLEX, so `abs(a-one)' is COMPLEX absolute value
of the result of CMPLX(a, 0.) - (1., 0.) = (0., 0.)

Even with gcc-2.95[-pre], g77 still codes a call to the libg2c routine
"c_abs" for computing the absolute value of a complex expression (I
didn't have the time to open code that one, in addition to complex
division - at least not before April 21).

I hope someone with an Alpha can help out (or a MIPS guru - if the above
explanation is sufficiently clear.  Jim ?).

Thanks in advance,

-- 
Toon Moene (toon@moene.indiv.nluug.nl)
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
Phone: +31 346 214290; Fax: +31 346 214286
GNU Fortran: http://world.std.com/~burley/g77.html

The very last thing we want to do for this release is reinstate
-femulate-complex as the default.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]