/*-------------------------------------------------------------------------- */
/*                         Modulo Generator                                  */
/*-------------------------------------------------------------------------- */
#ifdef  __STDC__
int ModGenerator(
    int             modul,
    int             multi,
    int             inc,
    int             seed,
    int             max_sweeps,
    float           *x)
#else
int ModGenerator(modul,multi,inc,seed,max_sweeps,x)
    int             modul;
    int             multi;
    int             inc;
    int             seed;
    int             max_sweeps;
    float           *x;
#endif
{
    /*---------------------------------------------------------- */
    /*                     Declarations                          */
    /*---------------------------------------------------------- */
    int i;
    double r;
    double factor, increment, modulus;
    /*---------------------------------------------------------- */
    /*                End of declares                            */
    /*---------------------------------------------------------- */

    r         = (double) seed;
    factor    = (double) multi;
    increment = (double) inc;
    modulus   = (double) modul;

    for(i=0; i< max_sweeps; i++) {
      r=fmod(r*factor + increment,modulus);
      x[i] = (float) r / modulus;
    }
    return 0;
}
