caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jan Kybic <kybic@fel.cvut.cz>
To: David MENTRE <dmentre@linux-france.org>
Cc: caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] Looking for information regarding use of OCaml in scientific computing and simulation
Date: Sun, 29 Nov 2009 00:23:14 +0100	[thread overview]
Message-ID: <87ocmmdyjh.fsf@fel.cvut.cz> (raw)
In-Reply-To: <3d13dcfc0911250305i43a684e4u5a96ec420b6ce350@mail.gmail.com> (David MENTRE's message of "Wed, 25 Nov 2009 12:05:14 +0100")

> I'm considering doing a short presentation of OCaml to my colleagues
> in my research lab. They are working in the telecommunication and
> power electronic sectors, mainly doing signal processing and
> simulations. I know OCaml[1] but not specifically those domains.
>
> Therefore, I'm looking for reusable material for a presentation:
>  - Slides on the use of OCaml in the signal processing and simulation domains;
>
>  - Code snippets of OCaml used in scientific computing or simulation,
> typically for advocacy like "it takes 10 lines in OCaml to do this,
> you would use 50 lines in C++ to do the same thing";
>
>  - Evidence of *actual use* of OCaml for scientific computing or
> simulation, especially regarding usable libraries, bindings, etc.

I am writing this offline, so I cannot provide any pointers now but it
should be easy to find them on the Web.

I used to be a proficient C programmer, currently I am writing a
majority of my code in Ocaml.

There are Ocaml bindings to many libraries for scientific (=numerical)
computing, such as BLAS+LAPACK, GSL, Cubpack, FFTW and others. You can
use MPI for parallel (cluster) programming. For visualization, I have
tried an interface to Gnuplot and OpenGL. For image processing, there
is the CamlImages library.

I have interfaced my Ocaml code with C, C++ (via C), Matlab, and Python.
Because of this interoperability, it is normally relatively easy to
switch to Ocaml gradually, rewriting your programs one by one.

I have been using Ocaml for scientific computing for about seven
years, in domains ranging from solving integral equations to medical
image segmentation (look on my web page for details). However, most of
this is research code (=alpha quality, works good enough for me), so I
am only making it available on request for research purposes. Sadly,
most people that have asked for it have been put off by the fact that
the code was written in Ocaml...

I do not really have any short and self-contained examples of Ocaml's
superiority. My observation is that for simple algorithms based on
high-level operations, I tend to use Matlab or Python, because these
languages are very concise and have comprehensive libraries, and I can
get a proof-of-concept implementation written extremely fast. If
maximum speed is paramount, I write the computational core in
C/C++. Ocaml is the language of choice for me if the algorithm at hand
is complex, uses complicated data structures and/or cannot be
decomposed into a few simple "computational cores". Ocaml is excellent
for this - it is expressive, sufficiently concise, takes care of
memory management, its strong typing prevents many errors and it is
only a few times slower than C (1.5-5, depending on the application).

I used to quote the generalization abilities of Ocaml (polymorphism,
functors, objects) among its advantages, but I have not been using them
much recently because of the rather high computational penalty they
involve. This is in my opinion one of the weak points of Ocaml for
high performance numerical computing.

As for Ocaml syntax, I got used to it. I quite liked the indentation
(Haskel/Python-like) based syntax implemented through the TWT
preprocessor. However, I stopped using it because it interfered with
other preprocessors I wanted to use (e.g. macros in Camlp4) and
sometimes confused error reporting. 

For some projects I have written both Ocaml and C++ implementations
and in all cases writing the Ocaml version was a more enjoyable
experience for me, the code was easier and faster to write and there
were less errors - no segmentation faults. 

If you do prepare some presentation about using Ocaml for scientific
computing, I would be interested in seeing it.

Yours,

Jan

-- 
-------------------------------------------------------------------------
Jan Kybic <kybic@fel.cvut.cz>                       tel. +420 2 2435 5721
http://cmp.felk.cvut.cz/~kybic                      ICQ 200569450


  parent reply	other threads:[~2009-11-29 17:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-25 11:05 David MENTRE
2009-11-25 11:59 ` Sylvain Le Gall
2009-11-25 12:32 ` [Caml-list] " blue storm
2009-11-28 23:23 ` Jan Kybic [this message]
2009-11-29 23:11 ` Jon Harrop
     [not found]   ` <4a708d20911291416x2be905f7p93f559543a77d97f@mail.gmail.com>
     [not found]     ` <3ae3aa420911300830h63a04b21r2e09fb4e34cdb7f7@mail.gmail.com>
     [not found]       ` <4a708d20912200638q5e7d72acu9cae3b564ada085d@mail.gmail.com>
2009-12-22  4:40         ` Linas Vepstas
2009-12-22 13:11           ` Eray Ozkural
2009-12-22 13:44             ` Eray Ozkural
2009-12-22 19:49             ` Jon Harrop
2009-12-22 21:11               ` Mike Lin
2009-12-22 13:46           ` Gerd Stolpmann
2009-12-04  9:55 ` David MENTRE

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=87ocmmdyjh.fsf@fel.cvut.cz \
    --to=kybic@fel.cvut.cz \
    --cc=caml-list@inria.fr \
    --cc=dmentre@linux-france.org \
    --cc=kybic@cmp.felk.cvut.cz \
    /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).