caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: briand@aracnet.com
To: malc <malc@pulsesoft.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] interesting array efficiency observations
Date: Mon, 10 May 2004 22:04:13 -0700	[thread overview]
Message-ID: <16544.24269.920791.984825@soggy.deldotd.com> (raw)
In-Reply-To: <Pine.LNX.4.55.0405091806550.573@home.oyster.ru>


Perfect.

Thanks for the link.

However, I have a question :-)

>From the link:

   let f a x y = 1 + a.{x,y}

has a polymorphic type (int, 'a, 'b) Bigarray.Array2.t -> int -> int -> int
and compiles down to a library function call.  However,

    open Bigarray
    let f (a : (int, int_elt, c_layout) Array2.t) x y = 1 + a.{x,y}

is monomorphic and will be compiled much more efficiently by ocamlopt.

So what if I have declared a variable, i.e.

let the_a = Bigarray.Array2.create Bigarray.float64 Bigarray.c_layout 5 5;;

and now I invoke f 

  f the_a 1 2

Why would the_a be treated polymorphically ??

the_a is very clearly defined as a very specific Bigarray and so the
compiler will know this in the call to f, and will do the correct
thing, right ?

Isn't the type annotation in the function redundant in such a case ?

Thanks


Brian

>>>>> "malc" == malc  <malc@pulsesoft.com> writes:

  malc> On Sat, 8 May 2004 briand@aracnet.com wrote:
  >>  I was investigating the use of 1-D bigarray's vs Array and
  >> noticed that the 1-D bigarray using c_layout seems to be slower
  >> than Array.

  malc> http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=ISO-8859-1&threadm=fa.hj2u7jv.t1ms25%40ifi.uio.no&rnum=1&prev=/groups%3Fq%3Dfa.caml%2Bbigarray%2Bmalc%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DISO-8859-1%26selm%3Dfa.hj2u7jv.t1ms25%2540ifi.uio.no%26rnum%3D1

  malc> -- mailto:malc@pulsesoft.com

-------------------
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:[~2004-05-11  5:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-08 18:13 briand
2004-05-08 21:21 ` Yamagata Yoriyuki
2004-05-08 22:45   ` Olivier Grisel
2004-05-09  0:25   ` Christophe TROESTLER
2004-05-09  0:48     ` Yamagata Yoriyuki
2004-05-09  8:24 ` Xavier Leroy
2004-05-09 14:07 ` malc
2004-05-11  5:04   ` briand [this message]
2004-05-12 15:30     ` Christophe TROESTLER

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=16544.24269.920791.984825@soggy.deldotd.com \
    --to=briand@aracnet.com \
    --cc=caml-list@inria.fr \
    --cc=malc@pulsesoft.com \
    /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).