Where is the sorce code of stdlib ?

L

Lingyun Yang

Hi,

I want to use rand() in standard libray to
generate over 10^8 random numbers to do
simulation. But this version seems very slow compared
with some code in Numerical Recipes.

I want to know how's the grnerator and what is
the algorithm. Does any one know where is the source code of
the rand() function in stdlib or is it open source ?
I am in Linux OS.

Thank you !

Lingyun Yang
 
T

Thomas Matthews

Lingyun said:
Hi,

I want to use rand() in standard libray to
generate over 10^8 random numbers to do
simulation. But this version seems very slow compared
with some code in Numerical Recipes.

I want to know how's the grnerator and what is
the algorithm. Does any one know where is the source code of
the rand() function in stdlib or is it open source ?
I am in Linux OS.

Thank you !

Lingyun Yang

There is no standard code for the standard library.
Each function has specifications that must be met. Some
functions may exceed these specifications, such as being
faster or occupying less code space. The exact implementation
depends on the compiler vendor.

There has been much discussion about the random number
generator and its limitations. Many serious programs
use different random number generators. Search the
newsgroups for "random number".

The Free Software Foundation has source code for a
random number generator that the GNU GCC compiler uses.
Perhaps this may help. Check it out at www.fsf.org.


--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library
 
C

Cy Edmunds

Lingyun Yang said:
Hi,

I want to use rand() in standard libray to
generate over 10^8 random numbers to do
simulation. But this version seems very slow compared
with some code in Numerical Recipes.

I want to know how's the grnerator and what is
the algorithm. Does any one know where is the source code of
the rand() function in stdlib or is it open source ?
I am in Linux OS.

Thank you !

Lingyun Yang

I recommend you stay away from rand(). There are many good portable number
generators around. Follow my sig for a C++ implementation of some Numerical
Recipes algorithms or just go to www.boost.org to get some of their stuff.
 
A

Arne Schmitz

Lingyun said:
I want to know how's the grnerator and what is
the algorithm. Does any one know where is the source code of
the rand() function in stdlib or is it open source ?
I am in Linux OS.

If you are on Linux, better use random(). Anyway: Since Linux uses the GNU
libc, you can get it at your local GNU mirror. Main site is here:

ftp://ftp.gnu.org/gnu/glibc

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top