caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Ville-Pertti Keinonen <will@exomi.com>
To: nr@eecs.harvard.edu (Norman Ramsey)
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] implementing bit vectors in OCaml
Date: Sun, 1 Jun 2003 20:50:57 +0300	[thread overview]
Message-ID: <990DE004-9459-11D7-B7B0-000393863F70@exomi.com> (raw)
In-Reply-To: <20030601170317.002EF12F9CE@flatcoat.eecs.harvard.edu>


> We have a program that is spending a lot of time in set operations,
> and we're thinking of trying an imperative implementation based on bit 
> vectors.
> I would hope that the basis of such an implementation would be an array
> of native integers, but on scrutinizing the manual (espeically the 
> chapter
> on interfacing to C), I have concluded that such a thing is not 
> possible.
> Our choices appear to be
>
>   * An array of native integers, which will be implemented as an array
>     of pointers to native integers, because integers are boxed.
>
>   * An array of tagged integers, which will be less efficient as
>     dividing by 31 is more expensive than shifting.

I'd think that an obvious alternative would be to use custom blocks, 
which can basically be arrays of abstract values of whatever size you 
want to treat them as.

This should be evident based on the information on interfacing to C, if 
you are willing to implement the interface in C.  Of course the obvious 
problem with this approach would be the inefficiency of not being able 
to inline operations on this array.

If the optimizer were smart enough (I don't think it currently is), 
OCaml code treating strings (or even arrays of floats) as bit vectors 
might be a reasonably efficient approach.

-------------------
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


  reply	other threads:[~2003-06-01 17:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-01 17:03 Norman Ramsey
2003-06-01 17:50 ` Ville-Pertti Keinonen [this message]
2003-06-02  8:21 ` Diego Olivier Fernandez Pons
2003-06-02  8:54 ` Hendrik Tews
2003-06-02  8:59 ` Claude Marche
2003-06-02  9:26 ` Xavier Leroy
2003-06-02 10:11   ` Marcin 'Qrczak' Kowalczyk
2003-06-02 10:10 ` Fabrice Le Fessant
2003-06-02 13:29 Gregory Morrisett

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=990DE004-9459-11D7-B7B0-000393863F70@exomi.com \
    --to=will@exomi.com \
    --cc=caml-list@inria.fr \
    --cc=nr@eecs.harvard.edu \
    /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).