Version française
Home     About     Download     Resources     Contact us    
Browse thread
vector dot multiply
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: U-E59264-Osman Buyukisik <osman.buyukisik@a...>
Subject: vector dot multiply
Hi,
 What would be 1). elegant
               2). efficient  
 way to write a "dot multiply" function in caml-light? 
This is what I came up with but I am hoping for a better one :

let dot a b = let rec dot_aux a b i sum =
if i< vect_length a then
   dot_aux a b (i+1) (sum +. (a.(i) *. b.(i)) )
 else
   sum
in
 dot_aux a b 0 0.0;;

Also, is there a similar construct to Haskell array/list comprehensions?

Thanks in advance.
Osman