From: Jon Harrop <jon@ffconsultancy.com>
To: caml-list <caml-list@inria.fr>
Subject: Mandelbrot renderer
Date: Wed, 23 Nov 2005 01:50:58 +0000 [thread overview]
Message-ID: <200511230150.59163.jon@ffconsultancy.com> (raw)
Following Oliver's objections regarding the lack of serious software written
in OCaml (e.g. web servers), I have written a very serious Mandelbrot
renderer. The program is 35 lines of OCaml and renders using OpenGL. This
page breaks it down and describes how it works:
http://www.ffconsultancy.com/free/fractal
I've written a simple, recursive C++ version as well. It weighs in at 45 lines
but only 6% more bytes. If you specialise the complex-number arithmetic in
the OCaml:
let rec mandelbrot i cx cy zx zy =
if i = 63 || zx *. zx +. zy *. zy > 4. then i else
let zx = zx *. zx -. zy *. zy and zy = 2. *. zx *. zy in
mandelbrot (i+1) cx cy (zx +. cx) (zy +. cy)
then, with only -O3, the C++ is actually significantly slower. The performance
of the C++ improves considerably with -ffast-math so that it is slightly
faster. The performance of the C++ can be further improved by using an
imperative style. This is on both AMD64 and x86.
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
Objective CAML for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists
next reply other threads:[~2005-11-23 1:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-23 1:50 Jon Harrop [this message]
2005-11-23 8:00 ` [Caml-list] " David Baelde
2005-11-23 10:10 ` Yaron Minsky
2005-11-23 14:58 ` Christophe Raffalli
2005-11-24 14:43 ` Chris Campbell
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=200511230150.59163.jon@ffconsultancy.com \
--to=jon@ffconsultancy.com \
--cc=caml-list@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