Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Thorsten Ohl <ohl@hep.tu-darmstadt.de>
To: Stefan Monnier <monnier+lists/caml/news/@tequila.cs.yale.edu>
Cc: caml-list@inria.fr
Subject: Re: polymorphically comparable Maps?
Date: Tue, 23 Feb 1999 19:10:03 +0100 (CET)	[thread overview]
Message-ID: <14034.61179.248680.469064@heplix4.ikp.physik.tu-darmstadt.de> (raw)
In-Reply-To: <5lww199iaq.fsf@tequila.cs.yale.edu>

Stefan Monnier <monnier+lists/caml/news/@tequila.cs.yale.edu> writes:

> I can't think of any obvious good answer, but if you can live with
> explicit `canonicalization' (linear time) steps in order to then get
> logarithmical access and identical representation, then some kind of
> binary tree can do the job.

Insertion is also important.  Before I fell back to sorted lists, I
tried canonicalization at every insertion and it killed performance.

Since I can live with a small probability for failing matches in early
phases (they will only hurt performance, but never correctness), I
might attempt a staged approach with delayed canonicalization.

> So why exactly do you want that representation to be `identical' ?

I represent elements of freely generated abelian groups as maps from
the generators to their multiplicity in the element.  These abelian
groups appear in recursive data structures (e.g. to represent
algebraic expressions).  Therefore the easiest approach uses the
polymorphic comparison function in the maps.

I might eventually replace the polymorphic comparison by specific
comparison functions stored with the maps or in closures, but this
doesn't help me because deciding whether two trees represent the same
map is at least linear (but with a smaller N, there might be some
gain).  Actually, none of the available Bignum packages for O'Caml
supports polymorphic comparison.  Therefore I might have to make that
change soon.

BTW: how many unreleased symbolic math packages have been witten in
O'Caml?  I can't possibly be the first to discover how neatly one can
build rings from groups, algebras from modules, etc. using O'Caml's
module system ...  One of thy creators might explain why my
representation is a dumb idea!

Cheers,
-Thorsten
-- 
Thorsten Ohl, Physics Department, TU Darmstadt -- ohl@hep.tu-darmstadt.de
http://heplix.ikp.physik.tu-darmstadt.de/~ohl/ [<=== PGP public key here]




      parent reply	other threads:[~1999-02-25  9:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-02-22 17:37 Thorsten Ohl
1999-02-22 18:20 ` Jean-Francois Monin
1999-02-23 16:49 ` Stefan Monnier
1999-02-23 17:28   ` Adam P. Jenkins
1999-02-23 18:10   ` Thorsten Ohl [this message]

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=14034.61179.248680.469064@heplix4.ikp.physik.tu-darmstadt.de \
    --to=ohl@hep.tu-darmstadt.de \
    --cc=caml-list@inria.fr \
    --cc=monnier+lists/caml/news/@tequila.cs.yale.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