.\" -*- coding: UTF-8 -*- '\" t .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) .\" .\" SPDX-License-Identifier: Linux-man-pages-copyleft .\" .\" References consulted: .\" Linux libc source code .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) .\" 386BSD man pages .\" Modified Sun Mar 28 00:25:51 1993, David Metcalfe .\" Modified Sat Jul 24 18:13:39 1993 by Rik Faith (faith@cs.unc.edu) .\" Modified Sun Aug 20 21:47:07 2000, aeb .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH random 3 "20 juillet 2023" "Pages du manuel de Linux 6.05.01" .SH NOM random, srandom, initstate, setstate \- Gnrateur de nombres alatoires .SH BIBLIOTHÈQUE Bibliothèque C standard (\fIlibc\fP, \fI\-lc\fP) .SH SYNOPSIS .nf \fB#include \fP .PP \fBlong random(void);\fP \fBvoid srandom(unsigned int \fP\fIgraine\fP\fB);\fP .PP \fBchar *initstate(unsigned int \fP\fIgraine\fP\fB, char \fP\fItat\fP\fB, size_t \fP\fIn\fP\fB);\fP \fBchar *setstate(char *\fP\fItat\fP\fB);\fP .fi .PP .RS -4 Exigences de macros de test de fonctionnalités pour la glibc (consulter \fBfeature_test_macros\fP(7))\ : .RE .PP \fBrandom\fP(), \fBsrandom\fP(), \fBinitstate\fP(), \fBsetstate\fP(): .nf .\" || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED _XOPEN_SOURCE >= 500 || /* glibc >= 2.19 : */ _DEFAULT_SOURCE || /* glibc <= 2.19 : */ _SVID_SOURCE || _BSD_SOURCE .fi .SH DESCRIPTION La fonction \fBrandom\fP() utilise un gnrateur de nombre alatoire non linaire (non\-linear additive feedback random number generator) utilisant une table par dfaut de 31 entiers longs pour renvoyer successivement des nombres pseudoalatoires entre 0 et 2\[ha]31\ \-\ 1. La priode de ce gnrateur est trs grande, approximativement \fI16\ *\ ((2\[ha]31)\ \-\ 1)\fP. .PP La fonction \fBsrandom\fP() utilise son argument comme \ graine\ pour engendrer une nouvelle squence de nombres pseudoalatoires qui seront fournis lors des appels \fBrandom\fP(). Ces squences sont reproductibles en invoquant \fBsrandom\fP() avec la mme graine. Si aucune graine n'est fournie, La fonction \fBrandom\fP() utilise automatiquement une graine originale de valeur \fB1\fP. .PP La fonction \fBinitstate\fP() permet d'initialiser une table d'tats \fIstate\fP pour l'utiliser avec \fBrandom\fP(). La taille \fIn\fP de la table est utilise par \fBinitstate\fP() pour dterminer le niveau de sophistication du gnrateur de nombres alatoires. Plus grande est la table d'tats, meilleurs seront les nombres alatoires. Les valeurs optimales pour la taille de la table d'tats \fIn\fP sont \fB8\fP, \fB32\fP, \fB64\fP, \fB128\fP et \fB256\fPoctets; les autres montants seront arrondis au montant connu le plus proche. Utiliser moins de huit octets provoque une erreur. \fIgraine\fP est la graine utilise pour l'initialisation, indiquant un point de dpart pour la squence de nombres alatoires, et permet de redmarrer au mme endroit. .PP La fonction \fBsetstate\fP() modifie la table d'tats utilise par la fonction \fBrandom\fP(). La table d'tats \fItat\fP est alors utilise comme gnrateur de nombres alatoires jusqu'au prochain appel de \fBinitstate\fP() ou \fBsetstate\fP(). \fItat\fP doit d'abord tre initialise avec \fBinitstate\fP() ou tre le rsultat d'un appel prcdent \fBsetstate\fP(). .SH "VALEUR RENVOYÉE" La fonction \fBrandom\fP() renvoie une valeur entre\fB0\fP et \fB(2\[ha]31)\ \-\ 1\fP. La fonction \fBsrandom\fP() ne renvoie pas de valeur. .PP La fonction \fBinitstate\fP() renvoie un pointeur sur la table d'tats prcdente. En cas d'chec, elle renvoie \fBNULL\fP et \fIerrno\fP contient le code d'erreur. .PP La fonction \fBsetstate\fP() renvoie un pointeur sur la table d'tats prcdente. En cas d'chec, \fBNULL\fP est renvoy et \fIerrno\fP est dfini pour indiquer l'erreur. .SH ERREURS .TP \fBEINVAL\fP Le paramtre \fItat\fP de \fBsetstate\fP() tait NULL. .TP \fBEINVAL\fP Une table d'tats de moins de 8\ octets a t fournie \fBinitstate\fP(). .SH ATTRIBUTS Pour une explication des termes utilisés dans cette section, consulter \fBattributes\fP(7). .TS allbox; lbx lb lb l l l. Interface Attribut Valeur T{ .na .nh \fBrandom\fP(), \fBsrandom\fP(), \fBinitstate\fP(), \fBsetstate\fP() T} Sécurité des threads MT\-Safe .TE .sp 1 .SH STANDARDS POSIX.1\-2008. .SH HISTORIQUE POSIX.1\-2001, 4.3BSD. .SH NOTES La gnration de nombres alatoires est un sujet complexe. \fINumerical Recipes in C: The Art of Scientific Computing\fP (William H. Press, Brian P. Flannery, Saul A. Teukolsky, William T. Vetterling; New York: Cambridge University Press, 2007, 3ed.) fournit une excellente discussion sur les problmes pratiques de gnration de noms alatoires dans le chapitre7 (Random Numbers). .PP Pour une discussion plus thorique, qui aborde galement en profondeur d'autres domaines, voir le chapitre3 (Random Numbers) du livre de Donald E. Knuth \fIThe Art of Computer Programming\fP, volume2 (Seminumerical Algorithms), 2ed.; Reading, Massachusetts: Addison\-Wesley Publishing Company, 1981. .SH CAVEATS La fonction \fBrandom\fP() ne doit pas tre utilise dans des programmes multithreads o le comportement doit tre reproductible. Utilisez \fBrandom_r\fP(3) dans ce cas. .SH BOGUES .\" http://sourceware.org/bugzilla/show_bug.cgi?id=15380 D'aprs POSIX, \fBinitstate\fP() devrait renvoyer NULL en cas d'erreur. Dans la mise en uvre de la glibc, \fIerrno\fP est renseign en cas d'erreur comme spcifi, mais la fonction ne renvoie pas \fBNULL\fP. .SH "VOIR AUSSI" \fBgetrandom\fP(2), \fBdrand48\fP(3), \fBrand\fP(3), \fBrandom_r\fP(3), \fBsrand\fP(3) .PP .SH TRADUCTION La traduction française de cette page de manuel a été créée par #-#-#-#-# min-002-occurences.po (perkamon) #-#-#-#-#, Christophe Blaess , Stéphan Rafin , Thierry Vignaud , François Micaux, Alain Portal , Jean-Philippe Guérard , Jean-Luc Coulon (f5ibh) , Julien Cristau , Thomas Huriaux , Nicolas François , Florentin Duneau , Simon Paillard , Denis Barbier , David Prévot , Jean-Philippe MENGUAL , Jean-Pierre Giraud , #-#-#-#-# min-003-occurences.po (perkamon) #-#-#-#-#, Christophe Blaess , Stéphan Rafin , Thierry Vignaud , François Micaux, Alain Portal , Jean-Philippe Guérard , Jean-Luc Coulon (f5ibh) , Julien Cristau , Thomas Huriaux , Nicolas François , Florentin Duneau , Simon Paillard , Denis Barbier , David Prévot , Jean-Philippe MENGUAL , Jean-Pierre Giraud , #-#-#-#-# min-004-occurences.po (perkamon) #-#-#-#-#, Christophe Blaess , Stéphan Rafin , Thierry Vignaud , François Micaux, Alain Portal , Jean-Philippe Guérard , Jean-Luc Coulon (f5ibh) , Julien Cristau , Thomas Huriaux , Nicolas François , Florentin Duneau , Simon Paillard , Denis Barbier , David Prévot , Jean-Philippe MENGUAL , Jean-Pierre Giraud , #-#-#-#-# min-010-occurences.po (perkamon) #-#-#-#-#, Christophe Blaess , Stéphan Rafin , Thierry Vignaud , François Micaux, Alain Portal , Jean-Philippe Guérard , Jean-Luc Coulon (f5ibh) , Julien Cristau , Thomas Huriaux , Nicolas François , Florentin Duneau , Simon Paillard , Denis Barbier , David Prévot , Thomas Vincent , #-#-#-#-# min-020-occurences.po (perkamon) #-#-#-#-#, Christophe Blaess , Stéphan Rafin , Thierry Vignaud , François Micaux, Alain Portal , Jean-Philippe Guérard , Jean-Luc Coulon (f5ibh) , Julien Cristau , Thomas Huriaux , Nicolas François , Florentin Duneau , Simon Paillard , Denis Barbier , David Prévot , Jean-Philippe MENGUAL , Jean-Pierre Giraud , #-#-#-#-# min-100-occurences.po (perkamon) #-#-#-#-#, Christophe Blaess , Stéphan Rafin , Thierry Vignaud , François Micaux, Alain Portal , Jean-Philippe Guérard , Jean-Luc Coulon (f5ibh) , Julien Cristau , Thomas Huriaux , Nicolas François , Florentin Duneau , Simon Paillard , Denis Barbier , David Prévot , Jean-Philippe MENGUAL , Jean-Pierre Giraud et # . .PP Cette traduction est une documentation libre ; veuillez vous reporter à la .UR https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License version 3 .UE concernant les conditions de copie et de distribution. Il n'y a aucune RESPONSABILITÉ LÉGALE. .PP Si vous découvrez un bogue dans la traduction de cette page de manuel, veuillez envoyer un message à .MT debian-l10n-french@lists.debian.org .ME .