Browse thread
[Caml-list] interesting array efficiency observations
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | briand@a... |
| Subject: | Re: [Caml-list] interesting array efficiency observations |
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