Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Array Optimizations
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: David McClain <barabh@q...>
Subject: Re: [Caml-list] Array Optimizations

> P.S.: At the moment I write a wrapper for interfacing with a subset of
> I use Bigarray float64 as a complex array with re(i) = v.{2*i} and
> Does anybody have a better idea?

FWIW, some time ago (a couple of years perhaps) I was faced with this
decision, and more, in terms of interfacing to foreign numeric code and
Matlab. As it happens, Matlab likes to allocate complex arrays as separate
arrays of real and imaginary components. That may simplify some of their
numeric coding, but I found that on PII and PIII architectures, the
performance suffers tremendously due to cache thrashing. Better to use
adjacent real and imaginary components.

When I did the adjacent real and imaginary components, I did it just like
you ask about above. What I find is that the OCaml performance, even with
this doubling and offset by one, indexing is quite good. Especially
important is to precompute these indices in the event of several array
accesses inside of "for" loops. That helps enormously. My OCaml speeds
indicate performance better than C/C++ coded internals in languages like
RSI/IDL, by almost 2x. One can only wonder about the quality of the C/C++
code against which I was comparing -- that was out of my control.

- David McClain
Bug reports:  FAQ:
To unsubscribe, mail  Archives: