Loading ...
Sorry, an error occurred while loading the content.

Re: "ocaml_beginners"::[] Re: Random number generator

Expand Messages
  • Michał C
    Yeah thanks, I came across it while hours of searching. It worked but it was very slow in my taste, but anyway keep up the good work :). Cheers
    Message 1 of 8 , Oct 1, 2008
    • 0 Attachment
      Yeah thanks, I came across it while hours of searching. It worked but
      it was very slow in my taste, but anyway keep up the good work :).

      Cheers
    • Richard Jones
      ... If you need lots of random numbers, quickly, perhaps the best thing is to implement something in C, having the C code write a block of random numbers to a
      Message 2 of 8 , Oct 2, 2008
      • 0 Attachment
        On Wed, Oct 01, 2008 at 10:55:10AM +0200, Michał C wrote:
        > Yeah thanks, I came across it while hours of searching. It worked but
        > it was very slow in my taste, but anyway keep up the good work :).

        If you need lots of random numbers, quickly, perhaps the best thing is
        to implement something in C, having the C code write a block of random
        numbers to a Bigarray. Bigarrays can be easily shared between C and
        OCaml code, there is no copying involved, and they can store 32 bit or
        64 bit integers directly.

        Rich.

        --
        Richard Jones
        Red Hat
      • Michał C
        Thanks. Yes, probably the best thing would be to do it in C and share it between OCaml as float. But on the other hand, why don t wrote the whole thing in
        Message 3 of 8 , Oct 2, 2008
        • 0 Attachment
          Thanks.

          Yes, probably the best thing would be to do it in C and share it
          between OCaml as float.
          But on the other hand, why don't wrote the whole thing in C/C++
          instead? You know what I mean?
          It is a big downside of OCaml that it has such limitations

          Wiadomo�� napisana w dniu 2008-10-02, o godz. 12:00, przez Richard
          Jones:

          > On Wed, Oct 01, 2008 at 10:55:10AM +0200, Micha� C wrote:
          > > Yeah thanks, I came across it while hours of searching. It worked
          > but
          > > it was very slow in my taste, but anyway keep up the good work :).
          >
          > If you need lots of random numbers, quickly, perhaps the best thing is
          > to implement something in C, having the C code write a block of random
          > numbers to a Bigarray. Bigarrays can be easily shared between C and
          > OCaml code, there is no copying involved, and they can store 32 bit or
          > 64 bit integers directly.
          >
          > Rich.
          >
          > --
          > Richard Jones
          > Red Hat
          >
          >



          [Non-text portions of this message have been removed]
        • Jon Harrop
          ... Indeed. LLVM may well provide a nice escape route here because it allows you to generate high-performance numerical functions using a wide variety of basic
          Message 4 of 8 , Oct 2, 2008
          • 0 Attachment
            On Thursday 02 October 2008 17:41:50 Michał C wrote:
            > Thanks.
            >
            > Yes, probably the best thing would be to do it in C and share it
            > between OCaml as float.
            > But on the other hand, why don't wrote the whole thing in C/C++
            > instead? You know what I mean?
            > It is a big downside of OCaml that it has such limitations...

            Indeed. LLVM may well provide a nice escape route here because it allows you
            to generate high-performance numerical functions using a wide variety of
            basic types and call them from OCaml. I'm working on it...

            --
            Dr Jon Harrop, Flying Frog Consultancy Ltd.
            http://www.ffconsultancy.com/?e
          • Richard Jones
            ... Not sure if OCaml has claimed to be the only language in the world. It s known not to be good at handling things like crypto where you absolutely have to
            Message 5 of 8 , Oct 2, 2008
            • 0 Attachment
              On Thu, Oct 02, 2008 at 06:41:50PM +0200, Michał C wrote:
              > Yes, probably the best thing would be to do it in C and share it
              > between OCaml as float.
              > But on the other hand, why don't wrote the whole thing in C/C++
              > instead? You know what I mean?
              > It is a big downside of OCaml that it has such limitations

              Not sure if OCaml has claimed to be the only language in the world.
              It's known not to be good at handling things like crypto where you
              absolutely have to have 32 or 64 bit fixed-size integers.

              Writing a whole program in C/C++ because of this is silly because of
              the enormous work involved in managing memory and working around
              countless language limitations. Judiciously calling out to C, Perl,
              etc. as necessary on the other hand is perfectly reasonable.

              Rich.

              --
              Richard Jones
              Red Hat
            • JM Nunes
              What kind of random numbers do you want? If it is something other than changing numbers , you might be interested in the GSL library, which is easily and
              Message 6 of 8 , Oct 2, 2008
              • 0 Attachment
                What kind of random numbers do you want?

                If it is something other than "changing numbers", you might be
                interested in the GSL library, which is easily and efficiently usable
                from its ocaml bindings, as it seems to me from my own experience (on
                64bits platform with runs requiring ~ 30000 random floats).
              Your message has been successfully submitted and would be delivered to recipients shortly.