<discocaml>
<gabyfle> Hi ! For some reasons I don't have any ocaml stubs in my system. I'm using opam to install ocaml compilers. Does anyone knows how to get them properly ? Thanks a lot in advance :p
raskol has quit [Ping timeout: 260 seconds]
<discocaml>
<gabyfle> Hi ! For some reasons I don't have any ocaml stubs in my system. I'm using opam to install ocaml compilers. Does anyone knows how to get them properly ?
<discocaml>
<lukstafi> Ah I don't think that the first approach works with dynamic first-class modules either, I need the following bloat / workaround: `let module M = (val get_m ()) in let u = M.get_u () in f (module M) u`. So I'm guessing explicits will not make it any worse.
<discocaml>
<lukstafi> Or `let module M = (val get_m ()) in f1 (module M) ()` where `let f : (module M : MT) -> unit -> unit` and `MT` has abstract types -- `f1 (get_m ()) ()` doesn't work.
omniscient has joined #ocaml
neiluj has joined #ocaml
bartholin has quit [Quit: Leaving]
omniscient has quit [Ping timeout: 255 seconds]
omniscient has joined #ocaml
alexherbo2 has joined #ocaml
<discocaml>
<lukstafi> The last part is wrong, if the abstract types are not used dynamic first-class modules are ok.
<discocaml>
<gabyfle> Hi ! I'm currently working on this: <https://github.com/gabyfle/SoundML> and I'm having a bottleneck in my computations due to a type conversion problem. When computing a spectrogram, the output is a Complex Biggarray (in fact, a Owl's Ndarray but it's just bigarrays under the hood). The problem is that sometimes we only want the real parts of the complex values inside this array that is, if our array is {z | z € A} with z € C (the complex
<discocaml>
<gabyfle>
<discocaml>
<gabyfle> ```ocaml
<discocaml>
<gabyfle> let real (x : (Complex.t, Bigarray.complex32_elt) Owl.Dense.Ndarray.Generic.t) =
<discocaml>
<gabyfle> let ttime = Unix.gettimeofday () in
<discocaml>
<gabyfle> let dims = Audio.G.shape x in
<discocaml>
<gabyfle> let re = Audio.G.create Bigarray.Float32 dims 0. in
<discocaml>
<gabyfle> Audio.G.iteri_nd (fun i z -> Audio.G.set re i Complex.(z.re)) x ;
<discocaml>
<gabyfle> Owl.Log.debug "Elapsed time for Complex z -> Re(z) compute: %f"
<discocaml>
<gabyfle> Under the hood, `iteri_nd` is just a `for` loop on the elements of the bigarray. Here comes the bottleneck:
<discocaml>
<gabyfle>
<discocaml>
<gabyfle>
<discocaml>
<gabyfle> This is the elapsed time for the computation of the complex spectrogram and the evaluation of `real c` where `c` is our complex bigarray:
<discocaml>
<gabyfle>
<discocaml>
<gabyfle> ```ocaml
<discocaml>
<gabyfle> 2024-10-28 12:22:16.311 DEBUG : Elapsed time for specgram compute: 0.134960
<discocaml>
<gabyfle> 2024-10-28 12:22:16.785 DEBUG : Elapsed time for Complex z -> Re(z) compute: 0.473705
<discocaml>
<gabyfle> ```
<discocaml>
<gabyfle>
<discocaml>
<gabyfle> As you can see, `real c` takes as much as 3 times the time to compute the specgram which is absolutely not wanted. Does anyone have any idea on how could I make this way faster ?
<discocaml>
<gabyfle> Hi ! I'm currently working on this: <https://github.com/gabyfle/SoundML> and I'm having a bottleneck in my computations due to a type conversion problem. When computing a spectrogram, the output is a Complex Biggarray (in fact, a Owl's Ndarray but it's just bigarrays under the hood). The problem is that sometimes we only want the real parts of the complex values inside this array that is, if our array is {z | z € A} with z € C (the complex
<discocaml>
<gabyfle>
<discocaml>
<gabyfle> ```ocaml
<discocaml>
<gabyfle> let real (x : (Complex.t, Bigarray.complex32_elt) Owl.Dense.Ndarray.Generic.t) =
<discocaml>
<gabyfle> let ttime = Unix.gettimeofday () in
<discocaml>
<gabyfle> let dims = Audio.G.shape x in
<discocaml>
<gabyfle> let re = Audio.G.create Bigarray.Float32 dims 0. in
<discocaml>
<gabyfle> Audio.G.iteri_nd (fun i z -> Audio.G.set re i Complex.(z.re)) x ;
<discocaml>
<gabyfle> Owl.Log.debug "Elapsed time for Complex z -> Re(z) compute: %f"
<discocaml>
<gabyfle> Under the hood, `iteri_nd` is just a `for` loop on the elements of the bigarray. Here comes the bottleneck:
<discocaml>
<gabyfle>
<discocaml>
<gabyfle>
<discocaml>
<gabyfle> This is the elapsed time for the computation of the complex spectrogram and the evaluation of `real c` where `c` is our complex bigarray:
<discocaml>
<gabyfle>
<discocaml>
<gabyfle> ```ocaml
<discocaml>
<gabyfle> 2024-10-28 12:22:16.311 DEBUG : Elapsed time for specgram compute: 0.134960
<discocaml>
<gabyfle> 2024-10-28 12:22:16.785 DEBUG : Elapsed time for Complex z -> Re(z) compute: 0.473705
<discocaml>
<gabyfle> ```
<discocaml>
<gabyfle>
<discocaml>
<gabyfle> As you can see, `real c` takes as much as 3 times the time to compute the specgram which is absolutely not wanted. Does anyone have any idea on how could I make this way faster ?
<discocaml>
<gabyfle>
<discocaml>
<gabyfle> I've tried using `Owl.Dense.Ndarray.re_c2s`, but looks like under the hood it does exactly the same thing:
<discocaml>
<gabyfle>
<discocaml>
<gabyfle> ```c
<discocaml>
<gabyfle> #define FUN14 re_c2s
<discocaml>
<gabyfle> #define NUMBER complex_float
<discocaml>
<gabyfle> #define NUMBER1 float
omniscient has quit [Ping timeout: 248 seconds]
<companion_cube>
Bigarrays are way slower if the compiler doesn't know the exact type
<companion_cube>
It's better to always annotate and monomorphize if you can
omniscient has joined #ocaml
omniscient has quit [Remote host closed the connection]
neiluj has quit [Ping timeout: 252 seconds]
YuGiOhJCJ has quit [Quit: YuGiOhJCJ]
neiluj has joined #ocaml
spew has joined #ocaml
<Fardale1>
I am looking at Bechamel. I want to use Test.make_with_resource, what is the argument kind for? Looking at the code I don't understand what it is useful for.
mbuf has joined #ocaml
neiluj has quit [Read error: Connection reset by peer]
neiluj has joined #ocaml
neiluj_ has joined #ocaml
neiluj has quit [Ping timeout: 245 seconds]
<discocaml>
<softwaresirppi> Guys what do you think about exceptions and the oddly names `exn`?
<discocaml>
<softwaresirppi> Why not the ability to raise any value?
<companion_cube>
how would you typecheck `try … with e -> …`? what's the type of `e`?
<discocaml>
<softwaresirppi> Maybe it has a tagged union inside it?
<discocaml>
<softwaresirppi> So that I could pattern match?
<discocaml>
<softwaresirppi> Okay that's why exceptions are their own tupe
<discocaml>
<softwaresirppi> 😂😂 thanks
<discocaml>
<._null._> As for the "oddly named exn", `exception` was already a keyword so it was taken
<discocaml>
<softwaresirppi> How was life before exn?!
<discocaml>
<softwaresirppi> Also tell me anything cool or nice to know about exceptions
<discocaml>
<softwaresirppi> I'm foreign to ocaml's exceptions
<discocaml>
<softwaresirppi> You define an exception like `exception OhFuk of string`
<discocaml>
<softwaresirppi> And then you raise it like `raise OhFuk "doesn't work brotha"`
<discocaml>
<softwaresirppi> Also a thing to be noted is ... Exception declaration doesn't have an = sign
<companion_cube>
I don't think there was life before exceptions
<companion_cube>
it's a feature that was in the early MLs afaict
<companion_cube>
it was there in caml light
<discocaml>
<softwaresirppi> I see
<discocaml>
<softwaresirppi> Also the signature of raise is `exn -> 'a`
<discocaml>
<softwaresirppi> Poor alpha never gets returned 🫠
<discocaml>
<softwaresirppi> I don't know if I'm just being unfamiliar to syntax or this syntax bad lol
<discocaml>
<softwaresirppi> I'll have to spend some time
<discocaml>
<deepspacejohn> you raise any value as long as you defined an exception to wrap it in: `exception Exn_int of int exception Exn_string of string` etc.
<discocaml>
<deepspacejohn> You can't have a polymorphic exception though (without GADTs) because that would not be type safe `exception Bad of 'a`
<discocaml>
<lukstafi> I'd prefer if it was `throw` instead of `raise` because the opposite of `raise` is `lower`
<discocaml>
<lecondorduplateau> exceptions are in fact an extensible variant
<discocaml>
<lecondorduplateau> and `exception Foo of string` is actualy syntaxic sugar for `type exn += Foo of string`
<discocaml>
<softwaresirppi> @lecondorduplateau I'm watching/reading the Ocaml book... Do you have any other resources that get deep into these things?
<discocaml>
<lecondorduplateau> maybe it's possible to get the number of constructors with unsafe function of module `Obj`
<discocaml>
<softwaresirppi> I see
<discocaml>
<gooby_clown> It's okay, can just write a ppx
<discocaml>
<deepspacejohn> Constructors can be added to an extensible type dynamically. This is also why matching an extensible variant always needs a wildcard `| _ ->` case to be exhaustive.
<discocaml>
<lecondorduplateau> oh yes
<discocaml>
<softwaresirppi> can i tell you guys something? `failwith` is mumble case but `invalid_arg` is snake case
<discocaml>
<deepspacejohn> (the fact that some features are in the extensions section is part of why I dislike the manual's organization.)
euphores has joined #ocaml
<neiluj_>
hey! I'm using an Lru cache https://opam.ocaml.org/packages/lru/ in a mutable field, but by the first time I access it (through Lru.find), my application becomes stuck
<neiluj_>
how would you debug this?
<neiluj_>
on an other note, do you know if there are themes for odoc pages?
pi3ce has quit [Ping timeout: 265 seconds]
pi3ce has joined #ocaml
<discocaml>
<contificate> Can you elaborate, does your program block indefinitely?
olle__ has joined #ocaml
olle__ has quit [Ping timeout: 265 seconds]
bartholin has joined #ocaml
Anarchos has joined #ocaml
mbuf has quit [Quit: Leaving]
semarie has quit [Ping timeout: 252 seconds]
neiluj_ has quit [Quit: WeeChat 4.2.1]
f[x] has joined #ocaml
Anarchos has quit [Read error: Connection reset by peer]
motherfsck has quit [Ping timeout: 252 seconds]
Tuplanolla has joined #ocaml
motherfsck has joined #ocaml
Everything has joined #ocaml
euphores has quit [Ping timeout: 244 seconds]
euphores has joined #ocaml
Everything has quit [Read error: Connection reset by peer]