File:  [local] / rpl / src / generateurs_aleatoires.c
Revision 1.16.2.1: download - view: text, annotated - select for diffs - revision graph
Mon Apr 11 13:02:15 2011 UTC (13 years ago) by bertrand
Branches: rpl-4_0
CVS tags: rpl-4_0_22
Diff to: branchpoint 1.16: preferred, colored
En route vers la 4.0.22.

    1: /*
    2: ================================================================================
    3:   RPL/2 (R) version 4.0.22
    4:   Copyright (C) 1989-2011 Dr. BERTRAND Joël
    5: 
    6:   This file is part of RPL/2.
    7: 
    8:   RPL/2 is free software; you can redistribute it and/or modify it
    9:   under the terms of the CeCILL V2 License as published by the french
   10:   CEA, CNRS and INRIA.
   11:  
   12:   RPL/2 is distributed in the hope that it will be useful, but WITHOUT
   13:   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   14:   FITNESS FOR A PARTICULAR PURPOSE.  See the CeCILL V2 License
   15:   for more details.
   16:  
   17:   You should have received a copy of the CeCILL License
   18:   along with RPL/2. If not, write to info@cecill.info.
   19: ================================================================================
   20: */
   21: 
   22: 
   23: #include "rpl-conv.h"
   24: 
   25: 
   26: void
   27: initialisation_generateur_aleatoire(struct_processus *s_etat_processus,
   28:         logical1 initialisation_automatique, unsigned long int racine)
   29: {
   30:     struct timeval              horodatage;
   31: 
   32:     if ((*s_etat_processus).type_generateur_aleatoire == NULL)
   33:     {
   34:         (*s_etat_processus).type_generateur_aleatoire = gsl_rng_ranlux389;
   35:     }
   36: 
   37:     if (((*s_etat_processus).generateur_aleatoire =
   38:             gsl_rng_alloc((*s_etat_processus).type_generateur_aleatoire))
   39:             == NULL)
   40:     {
   41:         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
   42:         return;
   43:     }
   44: 
   45:     if (initialisation_automatique == d_vrai)
   46:     {
   47:         gettimeofday(&horodatage, NULL);
   48: 
   49:         gsl_rng_set((*s_etat_processus).generateur_aleatoire,
   50:                 (unsigned long int) (horodatage.tv_usec | horodatage.tv_sec));
   51:     }
   52:     else
   53:     {
   54:         gsl_rng_set((*s_etat_processus).generateur_aleatoire, racine);
   55:     }
   56: 
   57:     return;
   58: }
   59: 
   60: 
   61: void
   62: liberation_generateur_aleatoire(struct_processus *s_etat_processus)
   63: {
   64:     gsl_rng_free((*s_etat_processus).generateur_aleatoire);
   65:     (*s_etat_processus).generateur_aleatoire = NULL;
   66:     (*s_etat_processus).type_generateur_aleatoire = NULL;
   67: 
   68:     return;
   69: }
   70: 
   71: // vim: ts=4

CVSweb interface <joel.bertrand@systella.fr>