Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


What about implementation in random.cxx and creating random.hxx so all
the random stuff is in one place?

Why do you want this abstraction? Following KISS I would just start
implementing the functions in ScInterpreter and extract commonly used
parts into an own method. If at some point other parts of Libreoffice
also need random functions with known statistical properties we can
still extract them.

I'm happy to propose a patch this way. Just need to be aware that
RANDBETWEEN() which is part of scaddins would also need a replacement
of rand().

Also, another consideration is the way to implement different
non-uniform distribution, just wondering if anyone has a strong
view on this:

(1) implementation similar to rand() and srand(), where the state of
the generator is saved in a global variable (which is not exposed via
a header file and can only be changed by srand), and all other
non-uniform generators draw from the same rand(). this requires an
srand() call ideally at the start of libreoffice or calc, currently
done in
 ./sc/source/core/data/global.cxx

(2) each rand_nonuniform() function draws from it's own private rand()
generator with its own state, which is defined as a static variable
and initialised at the first call.


For a general purpose library one would probably do (1) (or (1) and
encapsulated in a class) but for calc both versions are fine in my
opinion. Memory requirements for boost::mt19937 is
625*sizeof(uint32_t) so I guess even if we had 10 copies (one for each
non-uniform rand) of it that wouldn't be a problem?


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.