<rwmjones>
the string representation is subtle & clever ...
<Mr_Awesome>
hmm, interesting
seafoodX has joined #ocaml
kosmikus has joined #ocaml
G is now known as Nigel
Nigel has quit [Remote closed the connection]
seafoodX has quit []
Mr_Awesome has quit ["time to impregnate a moth"]
<TFK>
Howdy folks.
<TFK>
I have a slight problem: I've installed OCaml GSL on Ubuntu, and would like to try it in the interactive interpreter. I loaded bigarray and gsl, and it seemed to work, but trying to "open Gsl_rng;;" tells me "Unbound module Gsl_rng". There's no gsl_rng.cma to load, so I'm a bit stumped.
<flux>
well, there must be some .cma to load
<flux>
it is doubtful its name would be gsl?rng.cma, however
<flux>
how about doing dpkg -L to the installed package and see what .cma-files it has?
<flux>
you will most likely have ocamlfind installed
<flux>
you can write #use "topfind";; in the toplevel
<flux>
and then #require "somepackagename";;
<xavierbot>
Characters 1-4:
<xavierbot>
Parse error: illegal begin of top_phrase
<xavierbot>
and then #require "somepackagename";;
<xavierbot>
^^^
<flux>
you can list the packages with ocamlfind ocamlfind list
<flux>
uh, drop one of the ocamlfinds
<flux>
ocamlfind list | grep -i gsl will probably show the package name
<flux>
ok, I managed to install the package (took a while, I'm behind a mobile link), and the command is #require "gls";; - after that, the open statement works fine
seafoodX has joined #ocaml
<TFK>
flux, tells me "Unknown directive `require'.", but I'll try your previous suggestion, thanks :-)
<flux>
tfk, #use "topfind";; first
<TFK>
Cannot find file topfind.
<flux>
hmm, do you have file /usr/lib/ocaml/3.09.2/findlib/topfind.mli ? (path depends on your ocaml version)
<flux>
do you have ocaml-findlib installed?
<TFK>
No, but I will in a second!
<flux>
ocamlfind is a really useful thing to have
<TFK>
Seems so. Loading libraries in OCaml is a bit more difficult than what I'm used to in Python and C#...
<TFK>
Coo! It works. Thanks :-)
shawn has quit ["This computer has gone to sleep"]
<rwmjones>
TFK the trick is understanding that ocaml libraries behave exactly the same as C/C++ libraries, w.r.t. how you link to them
<TFK>
I'm too young to understand how those work, too :-P
* TFK
will learn
seafoodX has quit []
seafoodX has joined #ocaml
jlouis_ has joined #ocaml
jlouis has quit [Read error: 110 (Connection timed out)]
gunark has quit [Connection timed out]
gunark has joined #ocaml
G has joined #ocaml
seafoodX has quit []
svenl has quit [Remote closed the connection]
svenl has joined #ocaml
Hadaka has quit [anthony.freenode.net irc.freenode.net]
flux has quit [anthony.freenode.net irc.freenode.net]
G has quit [anthony.freenode.net irc.freenode.net]
slipstream has quit [anthony.freenode.net irc.freenode.net]
scode has quit [anthony.freenode.net irc.freenode.net]
Amorphous has quit [anthony.freenode.net irc.freenode.net]
G has joined #ocaml
slipstream has joined #ocaml
Hadaka has joined #ocaml
Amorphous has joined #ocaml
scode has joined #ocaml
flux has joined #ocaml
ulfdoz has quit [anthony.freenode.net irc.freenode.net]
tty56 has quit [anthony.freenode.net irc.freenode.net]
ulfdoz has joined #ocaml
tty56 has joined #ocaml
love-pingoo has quit ["Connection reset by pear"]
love-pingoo has joined #ocaml
Smerdyakov has quit ["Leaving"]
Amorphous has quit [Read error: 104 (Connection reset by peer)]
Amorphous has joined #ocaml
svenl has quit [Remote closed the connection]
svenl has joined #ocaml
<TFK>
I'm trying to design the most efficient way, space-wise, to store an array of "opcodes", four-bit values. I figure that using an array of ints isn't that good, since an OCaml int is actually 31-bit. So if I can't inspect the MSB, I can only pack 7 opcodes into an int. Right?
<rwmjones>
TFK, several options
<rwmjones>
use a string as a primitive bitstring
<rwmjones>
use something like Bigarray (although the smallest type is IIRC still char, so you'll still have to do some bit ops)
<rwmjones>
use C functions & wrap them in OCaml bindings :-)
<rwmjones>
extlib has a bitstring type which is built on string, so that may or may not save you some work
<rwmjones>
although I think extlib's impl is probably going to be rather inefficient for you, since you know in advance how big your "opcodes" are
<TFK>
Speed should also not be forgotten :-) although it's secondary.
<TFK>
What if I use arrays with int32? Or will it take more than 4 bytes per int32, since it has to store gc data and so on?
<TFK>
Does Bigarray differ from the regular array in performance?
<jlouis_>
TFK: hacking ICFP contest?
<TFK>
Playing around with my port of Nanopond.
<TFK>
Not smart enough for ICFP :-/
<jlouis_>
ah
<jlouis_>
TFK: a single int32 will probably get boxed or need a descriptor-word in the heap
<rwmjones>
arrays of int32 are boxed, so that's a bad idea
<jlouis_>
in MLton, we have 32bit words unboxed in arrays ;)
<TFK>
Hmmm. So now I see three options - an array of ints, at a loss of 1/8 efficiency in space; a bigarray of 8-bit ints or a bigaarray of 32-bit ints.
<rwmjones>
TFK, what's wrong with the string/bitfield suggestion?
<TFK>
Well, what does it cost to convert a char to an int, and vice versa? Is it just like a cast in C?
<rwmjones>
TFK yes, it's free
<rwmjones>
see char.ml and the functions defined as %identity
<TFK>
So! A string would be optimal?
<TFK>
I assume that Pervasives.char_of_int is in fact Char.unsafe_char and Pervasives.int_of_char is Char.code?
* TFK
checks the code
<TFK>
Almost.
<TFK>
Well, I'll go with that :-)
love-pingoo has quit ["Connection reset by pear"]
Smerdyakov has joined #ocaml
<rwmjones>
TFK, yes sorry you need to use the unsafe_* functions to avoid bounds checking overhead
gunark has quit [Connection timed out]
gunark has joined #ocaml
<TFK>
Are there any perforamnce quirks/penalties associated with classes?
leobm has joined #ocaml
<rwmjones>
TFK, yes, there's a penalty for calling methods
<rwmjones>
versus just calling simple functions (eg. in modules)
<TFK>
How big is it?
<rwmjones>
it depends how often you call them :-)
<rwmjones>
also, it depends how you call them, because there is some caching involved
<rwmjones>
so if you call #method1 repeatedly
<rwmjones>
it's faster than calling #method1, #method2, #method1, #method2, ...
<TFK>
Going to be calling them a lot... I think I'll go for the module approach, then.
abez has joined #ocaml
leobm has quit ["ChatZilla 0.9.78.1 [Firefox 2.0.0.4/0000000000]"]
slipstream has quit [Read error: 104 (Connection reset by peer)]
pango has quit [Remote closed the connection]
<abez>
Hi, I want to abstract modules.
<abez>
let summate x = let sumreg = ref 0.0 in for i = 0 to ((X.length x) - 1) do sumreg := !sumreg +. X.get x i done; !sumreg
<abez>
I want type X to abstracted, I don't want to specify it.
<abez>
x will be say an Array or a BigArray or an abstraction of either to match something like:
<abez>
module type HAS_GET = sig type t val get: t -> int -> float end
<abez>
Is there a way to say a collection of modules have the same interface and I want to access them through one interface statically
<abez>
or do I have to make a module which contains summator and is a functor?
<abez>
Possible solutions:
<abez>
* Provide a struct,tuple or list of accessor functions like a getter for summate
<abez>
* redo summate in a functor
<abez>
I don't want run time polymorphism.
slipstream has joined #ocaml
<zmdkrbou>
there is no run time polymorphism in ocaml anyway
<zmdkrbou>
maybe you should use objects
<abez>
If classes have virtual methods that's runtime polymorphism is it not?
<zmdkrbou>
i don't know much about the object layer of ocaml, but there are no types at runtime
<rwmjones>
abez, a functor would work, but there's a (small) penalty
pango has joined #ocaml
<abez>
rwmjones: What is the penalty?
<abez>
So if I define a signature and I say the 2 modules follow it, there is no way to access either of the modules with the signature name?
<rwmjones>
abez, on your other question - there are types (of a sort) at runtime when you use objects, or at least there is what in C++ would be called a vtable
<rwmjones>
method names are hashed and the hashes are looked up in the vtable to make the call
<abez>
Ugh that performance hit from functors really matters for what I'm doing :(
<abez>
I have millions of elements
<abez>
and I have to run algorithms that are O(n^2) or worse on them
<abez>
but sometimes I don't have millions of elements
<TFK>
The general rule of thumb is write something that works, then profile. Although you may already have mapped the performance-intensive areas of your program :-)
<abez>
so I'm wondering if I'm wasting my time worrying about bigarray versus array
CosmicRay has joined #ocaml
<jlouis_>
if you have about no code right now, you are worrying too much
<abez>
I already have the code
<abez>
and I'm looking at jobs which are taking over 40 hrs so far
<abez>
and I'm looking at another batch of jobs I can't run til I convert to bigarray
<jlouis_>
In your case, I'd use functors and eventually defunctorize via rwmjones tool should I find the need
<rwmjones>
it's not my tool :-)
<jlouis_>
heh
<rwmjones>
iirc that tool is version specific to some old version of ocaml
<abez>
I think I'll just use m4 to be honest
<jlouis_>
the tool rwmjones mentioned ;)
<rwmjones>
so probably needs forward-porting
shawn has joined #ocaml
<jlouis_>
rwmjones: again, defunctorization is the default in MLton ;)
<abez>
generate 2 ml files :|
TFKv2 has joined #ocaml
postalchris has joined #ocaml
TFK has quit [Read error: 110 (Connection timed out)]
shawn has quit ["This computer has gone to sleep"]
TFKv3 has joined #ocaml
TFKv2 has quit [Read error: 110 (Connection timed out)]
shawn has joined #ocaml
slipstream-- has joined #ocaml
slipstream has quit [Read error: 110 (Connection timed out)]
shawn has quit [Read error: 110 (Connection timed out)]
CosmicRay has quit [Read error: 110 (Connection timed out)]
shawn has joined #ocaml
CosmicRay has joined #ocaml
Submarine has joined #ocaml
david_koontz has joined #ocaml
Mr_Awesome has joined #ocaml
CosmicRay has quit [Read error: 110 (Connection timed out)]
fmardini has joined #ocaml
david_koontz has quit [Read error: 110 (Connection timed out)]
descender has quit ["Elegance has the disadvantage that hard work is needed to achieve it and a good education to appreciate it. - E. W. Dijkstra"]
david_koontz has joined #ocaml
delamarche has joined #ocaml
_blackdog has joined #ocaml
_blackdog has left #ocaml []
seafoodX has joined #ocaml
CosmicRay has joined #ocaml
CosmicRay has quit [Read error: 104 (Connection reset by peer)]
CosmicRay has joined #ocaml
CosmicRay has quit [Remote closed the connection]
CosmicRay has joined #ocaml
pango has quit [Remote closed the connection]
pango has joined #ocaml
shawn has quit [Read error: 113 (No route to host)]
delamarche has quit []
Hadaka has quit [anthony.freenode.net irc.freenode.net]
Hadaka has joined #ocaml
fmardini has quit []
TFKv3 is now known as TFK
shawn has joined #ocaml
postalchris has quit [Read error: 110 (Connection timed out)]
shawn has quit ["This computer has gone to sleep"]
wojtekk has joined #ocaml
CosmicRay_ has joined #ocaml
wojtekk has quit ["Changing server"]
Mr_Awesome has quit ["time to impregnate a moth"]
CosmicRay has quit [Read error: 104 (Connection reset by peer)]
postalchris has joined #ocaml
postalchris has quit [Client Quit]
seafood has quit [Read error: 110 (Connection timed out)]