Annotation of rpl/src/generateurs_aleatoires.c, revision 1.66

1.1       bertrand    1: /*
                      2: ================================================================================
1.65      bertrand    3:   RPL/2 (R) version 4.1.32
1.66    ! bertrand    4:   Copyright (C) 1989-2020 Dr. BERTRAND Joël
1.1       bertrand    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: 
1.11      bertrand   23: #include "rpl-conv.h"
1.1       bertrand   24: 
                     25: 
                     26: void
                     27: initialisation_generateur_aleatoire(struct_processus *s_etat_processus,
1.42      bertrand   28:        logical1 initialisation_automatique, integer8 racine)
1.1       bertrand   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,
1.37      bertrand   50:                (unsigned long int) (horodatage.tv_usec ^ horodatage.tv_sec));
1.1       bertrand   51:    }
                     52:    else
                     53:    {
1.42      bertrand   54:        gsl_rng_set((*s_etat_processus).generateur_aleatoire,
                     55:                (unsigned long int) racine);
1.1       bertrand   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>