#include <stdio.h>
#include <math.h>
#include "bsp1.h"
#define MODULO_I        ((unsigned long int)2147483647)
#define A_1_I           ((unsigned long int)241748845)
static unsigned long int local_seed=100;
void            init_2_random(unsigned int value)
{
      	local_seed=value;   
}

int             get_2_random(unsigned int range)
{
  return((int)1);
}

void init_params () 
{
   init_2_random(11);
}
void get_params (int *d, int *n, int *range, int *offset) 
{
   init_2_random(11);
   fprintf(stderr, "String size  ---------------------> ") ;
   scanf("%d", d) ;
   fprintf(stderr, "Number of elements to generate ---> ") ;
   scanf("%d", n) ;
   fprintf(stderr, "Range of characters (1...256) ----> ") ;
   scanf("%d", range) ;
   fprintf(stderr, "Offset (0...255) -----------------> ") ;
   scanf("%d", offset) ;
}

void printrandoms (byte *data, t_type n, t_type sbytes)
{
  register t_type i ;

  while (n) {
     n--;
     printf("%5d:", n);
     for(i=0;i<sbytes;i++) 
        printf("%2x ", (char)data[n*sbytes+i]);
/*
        printf("%c ", (char)data[n*sbytes+i]);
        printf("%3d ", (char)data[n*sbytes+i]);
*/
     printf("\n");
  }
}

void genrandoms (byte *data, int d, int n, int range, int offset)
{
   int i, j ;

   init_2_random(get_2_random(range)+11);
   srandom(21);

   for (i = 0 ; i < n ; ++i) {
   for (j = 0 ; j < d ; ++j)
            {
/*
	     data[i*d+j]=(char)((unsigned char)(get_2_random(range)) + offset) ;
*/
	     data[i*d+j]= (char) ((random()%range) +offset);
            }
      }
}

double findmin(double *d,int n)
{
 register int i;
 register double pmin;

 pmin = 1000000.0;
 for(i=0;i<n;i++)
  if (d[i] < pmin) pmin =d[i];
 return(pmin);
}
double findmax(double *d,int n)
{
 register int i;
 register double pmin;

 pmin = -1000000.0;
 for(i=0;i<n;i++)
  if (d[i] > pmin) pmin =d[i];
 return(pmin);
}
