From: Pierre Weis <weis@pauillac.inria.fr>
To: osman.buyukisik@ae.ge.com (U-E59264-Osman Buyukisik)
Cc: caml-list@pauillac.inria.fr
Subject: Re: vector dot multiply
Date: Thu, 8 Jun 1995 20:29:15 +0200 (MET DST) [thread overview]
Message-ID: <199506081829.UAA01903@pauillac.inria.fr> (raw)
In-Reply-To: <199506081716.NAA01690@thomas.ge.com> from "U-E59264-Osman Buyukisik" at Jun 8, 95 01:16:29 pm
> Hi,
> What would be 1). elegant
> 2). efficient
> way to write a "dot multiply" function in caml-light?
You're recursive version seems good (except that you (re)compute
the vect_length of vector a at each recursive call). You may prefer an
imperative version (as yours, this function assumes a and b to have the
same length):
let dot a b =
let s = ref 0.0 in
for i = 0 to vect_length a - 1 do
s := a.(i) *. b.(i) +. !s
done;
!s;;
> Also, is there a similar construct to Haskell array/list comprehensions?
No. This is very difficult to get in a strict language, where these
lists cannot be computed as necessary as is done in lazy languages...
Pierre Weis
----------------------------------------------------------------------------
WWW Home Page: http://pauillac.inria.fr/~weis
Projet Cristal
INRIA, BP 105, F-78153 Le Chesnay Cedex (France)
E-mail: Pierre.Weis@inria.fr
Telephone: +33 1 39 63 55 98
Fax: +33 1 39 63 53 30
----------------------------------------------------------------------------
next prev parent reply other threads:[~1995-06-08 18:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
1995-06-08 17:16 U-E59264-Osman Buyukisik
1995-06-08 18:29 ` Pierre Weis [this message]
1995-06-08 23:02 ` Ascander Suarez
1995-06-08 23:17 ` Bob Buckley
1995-06-09 7:29 ` Pascal Nicolas
1995-06-09 10:42 ` Judicael Courant
1995-06-09 11:50 Chet Murthy
1995-06-09 13:20 ` nikhil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199506081829.UAA01903@pauillac.inria.fr \
--to=weis@pauillac.inria.fr \
--cc=caml-list@pauillac.inria.fr \
--cc=osman.buyukisik@ae.ge.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox