From: Thorsten Ohl <ohl@crunch.ikp.physik.th-darmstadt.de>
To: caml-list@margaux.inria.fr
Cc: Xavier Leroy <Xavier.Leroy@inria.fr>
Subject: Re: Q: float arrays
Date: Wed, 30 Oct 1996 15:52:28 +0100 [thread overview]
Message-ID: <9610301452.AA34276@crunch> (raw)
In-Reply-To: <199610301340.OAA26778@pauillac.inria.fr>
>>>>> "Xavier" == Xavier Leroy <Xavier.Leroy@inria.fr> 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
next prev parent reply other threads:[~1996-10-31 15:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-10-29 11:12 Jocelyn Serot
1996-10-30 13:40 ` Xavier Leroy
1996-10-30 14:08 ` Jocelyn Serot
1996-10-30 14:52 ` Thorsten Ohl [this message]
1996-10-31 15:26 ` Xavier Leroy
1996-11-05 16:56 ` Controlling inlining [was Re: Q: float arrays] rowan+
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=9610301452.AA34276@crunch \
--to=ohl@crunch.ikp.physik.th-darmstadt.de \
--cc=Xavier.Leroy@inria.fr \
--cc=caml-list@margaux.inria.fr \
/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;
as well as URLs for NNTP newsgroup(s).