From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id VAA10449; Thu, 17 Oct 2002 21:07:17 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id VAA10851 for ; Thu, 17 Oct 2002 21:07:16 +0200 (MET DST) Received: from xanadu.ece.ucsb.edu (xanadu.ece.ucsb.edu [128.111.56.51]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g9HJ7F519132 for ; Thu, 17 Oct 2002 21:07:15 +0200 (MET DST) Received: from ece.ucsb.edu (gimli.ece.ucsb.edu [128.111.56.252]) by xanadu.ece.ucsb.edu (8.12.2/8.12.2) with ESMTP id g9HJ7APq018289 for ; Thu, 17 Oct 2002 12:07:10 -0700 (PDT) Date: Thu, 17 Oct 2002 12:08:01 -0700 Subject: Re: [Caml-list] Re: Camlp4 optimizations (was: productivity improvement) Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v546) From: Shivkumar Chandrasekaran To: Caml-list@inria.fr Content-Transfer-Encoding: 7bit In-Reply-To: <4.3.2.7.2.20021017112600.0318b410@mail.d6.com> Message-Id: X-Mailer: Apple Mail (2.546) Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Thursday, October 17, 2002, at 11:32 AM, Chris Hecker wrote: > The biggest problem with making ocaml look nice and pretty for > numerical code is that there is no overloading (of functions or > operators), I have written thousands of lines of numerical linear algebra code in Clean (where such overloading is possible) and in OCaml. I don't miss it one bit. (Let me concentrate on matrix multiplication since that was what the post talked about.) The reason for not missing overloading is that in coding *efficient* matrix algorithms, matrix multiplications usually have a well-defined end-place for the result. This end-place is usually a sub-matrix of an existing matrix (canonical examples are classical factorizations: LU, QR). Hence I don't just need "a * b", I really need to say "c = a * b, but don't generate new space for a * b, just use the space allocated for c instead". Luckily in OCaml and Clean we can solve this by making a HOF of type ( |*| ) : matrix * matrix -> (matrix -> unit) Then I can say (a |*| b) c, or, with one more definition, c =$ a |*| b Note, that even Clean will not allow you to replace |*| with *, since the only way to overload * in Clean is as (matrix matrix -> matrix) which is not what I want. Secondly I also need to say, in Matlab notation, a' * b. One cumbersome way around is to define a function called transpose that just flags its argument to be transposed without actually doing it. This creates its own nightmare. A better solution for me (in Clean and OCaml) has been to define a ~* b to mean a' * b, and variations thereof. However, for casual coding a la Matlab style, the lack of overloading could be seen as a problem. Of course one must then be prepared to live with unnecessary copying and memory accesses. --shiv-- ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners