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
Multiplication of matrix in C and OCaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-02-10 (14:36)
From: ls-ocaml-developer-2006@m...
Subject: Re: [Caml-list] Multiplication of matrix in C and OCaml

Jon Harrop <> writes:

> On Saturday 10 February 2007 01:41, 
> wrote:
>> Sorry, I wanted to say "optimize (a * b) *c == a * (b * c) to true",
>> i.e. 1. Would the compiler be wrong/incorrect in doing so?
> Yes.

Just to be sure: Would the compiler be wrong to optimize

   c * q > c * k

to just

       q > k

(all floats). And why? If not, why, in the case above? I don't want
letter and verse, but a general hand waving in the right direction
would be nice, since I have the impression, that is exactly what Gcc
4.1. is currently doing (though for the integer case).

> Provided you only specify -O* optimisation flags, I believe that reducing that 
> expression to "true" in the general case would be a compiler bug. If you 
> specify flags like -ffast-math then anything can happen, but it will happen 
> very quickly! ;-)


Regards -- Markus