From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.6.10/8.6.6) id QAA20297 for caml-redistribution; Thu, 31 Oct 1996 16:28:17 +0100 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.6.10/8.6.6) with ESMTP id PAA29148 for ; Wed, 30 Oct 1996 15:57:13 +0100 Received: from margaux.inria.fr (margaux.inria.fr [128.93.8.2]) by concorde.inria.fr (8.7.6/8.7.1) with ESMTP id PAA15008 for ; Wed, 30 Oct 1996 15:57:12 +0100 (MET) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by margaux.inria.fr (8.7.6/8.7.3) with ESMTP id PAA23252 for ; Wed, 30 Oct 1996 15:57:11 +0100 (MET) Received: from rs1.hrz.th-darmstadt.de (rs1.hrz.th-darmstadt.de [130.83.22.60]) by concorde.inria.fr (8.7.6/8.7.1) with SMTP id PAA14995 for ; Wed, 30 Oct 1996 15:56:47 +0100 (MET) Received: from crunch (crunch.ikp.physik.th-darmstadt.de [130.83.24.4]) by rs1.hrz.th-darmstadt.de (8.6.12/8.6.12.0ms) with SMTP id QAA15322; Wed, 30 Oct 1996 16:52:28 +0200 Received: by crunch (AIX 3.2/UCB 5.64/Client-1.5/HRZ-THD) id AA34276; Wed, 30 Oct 1996 15:52:28 +0100 Date: Wed, 30 Oct 1996 15:52:28 +0100 Message-Id: <9610301452.AA34276@crunch> From: Thorsten Ohl To: caml-list@margaux.inria.fr Cc: Xavier Leroy Subject: Re: Q: float arrays In-Reply-To: <199610301340.OAA26778@pauillac.inria.fr> References: <20086.199610291112@tufa.epcc.ed.ac.uk> <199610301340.OAA26778@pauillac.inria.fr> Sender: weis >>>>> "Xavier" == Xavier Leroy writes: Xavier> Polymorphism and higher-order functions don't mix well with Xavier> high performance. If you need Fortran-like performance, there Xavier> are cases where you must write Fortran-style code. I know that I'm asking too much, but wouldn't it be nice it the compiler did it for me? In the example at hand, let f2 = map (function (p,p') -> (p*.p')) the compiler could inline the multiplication automagically, iff it still had access to the definition of the map function. A trivial example is code like the following: let exponentiate make_unit eps norm plus minus times scale x = let u = make_unit x in let rec sumup s n x1 xn = if norm (xn) <= eps *. norm (minus s u) then s else sumup (plus s xn) (n +. 1.0) x1 (scale (1.0 /. n) (times x1 xn)) in (* usually, times x u == x, but u can be a projector which will speed up things for special cases. *) sumup u 2.0 x (times x u) let exp_ = exponentiate (fun _ -> 1.0) 1e-14 abs_float ( +. ) ( -. ) ( *. ) ( *. ) let exp_matrix = exponentiate unit_like 1e-14 infinity_norm add subtract multiply scale_matrix Here partial application really shines and it could shine even brighter if there was no speed penalty ... Cheers, -Thorsten -- Thorsten Ohl, Physics Department, TH Darmstadt --- PGP: AF 38 FF CE 03 8A 2E A7 http://crunch.ikp.physik.th-darmstadt.de/~ohl/ -------- 8F 2A C1 86 8C 06 32 6B