473,806 Members | 2,565 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Where is the sorce code of stdlib ?

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
Jul 22 '05 #1
3 6015
Lingyun Yang wrote:
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.l earn.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

Jul 22 '05 #2
"Lingyun Yang" <ji********@ins ightbb.com> wrote in message
news:wd8sd.1301 88$V41.97170@at tbi_s52...
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.

--
Cy
http://home.rochester.rr.com/cyhome/
Jul 22 '05 #3
Lingyun Yang schrieb:
IÂ*wantÂ*toÂ*kn owÂ*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

--
[--- PGP key FD05BED7 --- http://www.root42.de/ ---]
Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
2300
by: Fronsac | last post by:
Hi, I've been asked in a job interview how to make C code look like C++ code, and honestly I didn't know what to answer because I have never really done a lot of C. Now, I've been searching around the web about web sites that talk about this subject, but I've had no luck. Can anyone point me to some web site about this subject? Thanks a lot!
5
1589
by: Prashanth Badabagni | last post by:
Hi , can any one please help me to get the source code of the c library ( stdio.h , stdlib.h ....) .... Thanks in advance Prashanth ( Man who saw the end of war )
38
2565
by: Red Dragon | last post by:
I am self study C student. I got stuck in the program below on quadratic equation and will be most grateful if someone could help me to unravel the mystery. Why does the computer refuse to execute my scanf ("%c",&q); On input 3 4 1 (for a,b and c) I had real roots OK On input 1 8 16 I had same real roots OK. However on 4 2 5, (for imaginary roots ) the computer cannot see the scanf ("%c",&q); statement. It just jumps...
232
13384
by: robert maas, see http://tinyurl.com/uh3t | last post by:
I'm working on examples of programming in several languages, all (except PHP) running under CGI so that I can show both the source files and the actually running of the examples online. The first set of examples, after decoding the HTML FORM contents, merely verifies the text within a field to make sure it is a valid representation of an integer, without any junk thrown in, i.e. it must satisfy the regular expression: ^ *?+ *$ If the...
7
1925
by: william | last post by:
My question is: Specific memory block where my pointer pointing to changed strangely, seemingly that no statement changed it. Here are two examples I got: ***********1***************** I was about to read from a floppy image and build a tree for all the directories and files. My question is only about a small portion where I had debugging problem, and I marked the place below at two places using "<======================"(you can try to...
21
5444
by: Anton Dec | last post by:
Just curious about this... malloc is defined in stdlib.h, right? But if I write a program without #include<stdlib.hand use malloc, it still works as expected. Why is this? Is malloc automatically linked from somewhere else magically?
2
2597
by: msnews.microsoft.com | last post by:
The crystal report in VS2005 used to work well. But now it doesn't work. I open the report (rpt file) in VS2005 and try to refresh database connection, it gives the error message like: Cyrstal Reports ActiveX Designer Not Implemented Details: Error Code: 0x Sorce: ADODB.Connection ..........
38
42984
by: copx | last post by:
Are the macros min() and max() part of stdlib.h or not? (according to the standard?) I have the following problem: I defined my own min() / max() macros because my compiler (MinGW) does NOT define them. When I tried to compile my program with lcc-win32 the compiler complained about macro redefinition, because min() and max() are defined in lcc's stdlib.h.. So do these macros belong there or not?
7
1227
by: Taygun Kekec | last post by:
Hello , I have been curious about the speed of 2 version of a matris filling program and got suprised by the results. Actually , I am having Data Structures lecture on university though our professor claimed "using IF structures are costly , so you better use immediate data addressing " so he gave us the pseudo codes that i implemented in language C. Here are the source codes : /* Optimized.c * / #include <stdio.h>
0
9719
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9597
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10620
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10372
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10110
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7650
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3851
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.