Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Re: OCaml speed
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Thorsten Ohl <ohl@h...>
Subject: Re: [Caml-list] Re: complex bigarrays
Xavier Leroy writes:

> while in Fortran some codes use the C representation (one array of
> pairs) while others use a pair of arrays.

>From section 4.3.1.3 of the Fortran standard:
    
    The values a complex type are ordered pairs of real values.  The
    first real value is called the real second real value is called
    the imaginary part.

and from section 14.6.3.1 of the Fortran standard:

    (1) A nonpointer scalar object of type default integer, default
    real, or default logic occupies a single numeric storage unit;

    (2) A nonpointer scalar object of type double precision real or
    default complex occupies two contiguous numeric storage units;

If you declare

      COMPLEX C(2)

it is layed out as

      Re[C(1)] Im[C(1)] Re[C(2)] Im[C(2)]

Fortran compilers have no freedom here, because they must support
EQUIVALENCE and COMMON aliasing.

OTOH, there are many numerical libraries (e.g. LAPACK) that
explicitely declare two REAL arrays and use the entries as real and
imaginary parts.  However, this is a library choice and sidesteps
Fortran's COMPLEX type altogether.

-- 
Thorsten Ohl, Physics Department, TU Darmstadt -- ohl@hep.tu-darmstadt.de
http://heplix.ikp.physik.tu-darmstadt.de/~ohl/ [<=== PGP public key here]
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr