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-09 (21:55)
From: Andrej Bauer <Andrej.Bauer@f...>
Subject: Re: [Caml-list] Multiplication of matrix in C and OCaml
I hate to add to this long discussion, but since when is floating point 
multiplication associative?

# 1.3 *. (0.7 *. 2.1) = (1.3 *. 0.7) *. 2.1 ;;
- : bool = false

The suggestion that the results be tested for validity by checking the 
associative law of multipliciation won't worky very well, and neither 
will commutativity. In this case, instead of checking that A = B holds, 
it's better to output the difference between A and B (in case A and B 
are matrices, output the sup norm of the difference to keep it down to a 
single number).