File:  [local] / rpl / src / generateurs_aleatoires.c
Revision 1.66: download - view: text, annotated - select for diffs - revision graph
Fri Jan 10 11:15:42 2020 UTC (4 years, 2 months ago) by bertrand
Branches: MAIN
CVS tags: rpl-4_1_32, HEAD
Modification du copyright.

    1: /*
    2: ================================================================================
    3:   RPL/2 (R) version 4.1.32
    4:   Copyright (C) 1989-2020 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, integer8 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,
   55:                 (unsigned long int) racine);
   56:     }
   57: 
   58:     return;
   59: }
   60: 
   61: 
   62: void
   63: liberation_generateur_aleatoire(struct_processus *s_etat_processus)
   64: {
   65:     gsl_rng_free((*s_etat_processus).generateur_aleatoire);
   66:     (*s_etat_processus).generateur_aleatoire = NULL;
   67:     (*s_etat_processus).type_generateur_aleatoire = NULL;
   68: 
   69:     return;
   70: }
   71: 
   72: // vim: ts=4

CVSweb interface <joel.bertrand@systella.fr>