Mathc complexes/Fichiers h : z s
Installer ce fichier dans votre répertoire de travail.
z_r.h |
---|
/* ------------------------------------ */
/* Save as : z_r.h */
/* ------------------------------------ */
/* ------------------------------------
Call : time_t t;
int i;
srand(time(&t));
i = r_I(9);
------------------------------------ */
/* ------------------------------------
positive and negative numbers
------------------------------------ */
int r_I(
int maxI)
{
int x;
x = (rand() % maxI) + 1; /* + 1 : not zero */
x *= pow(-1,rand());
return(x);
}
/* ------------------------------------
positive numbers
------------------------------------ */
int rp_I(
int maxI)
{
return((rand() % maxI) + 1); /* + 1 : not zero */
}
/* ------------------------------------
positive and negative numbers with zero
------------------------------------ */
int r0_I(
int maxI)
{
int x;
x = rand()%maxI;
if(x) x*=pow(-1,rand());
return(x);
}
/* ------------------------------------
positive numbers with zero
------------------------------------ */
int rp0_I(
int maxI)
{
return(rand() % maxI);
}
/* ------------------------------------
positive and negative floating point number
e= 1E-0 -> 1234
e = 1E-1 -> 123.4
e = 1E-2 -> 12.34
e = 1E-3 -> 1.234
------------------------------------ */
double r_E(
int maxI,
double e)
{
double x;
x = (rand() % maxI) + 1 ; /* + 1 : not zero */
x *= pow(-1,rand()) * e;
return(x);
}
/* ------------------------------------ */
/* ------------------------------------
positive and negative floating point number with zero
e= 1E-0 -> 1234
e = 1E-1 -> 123.4
e = 1E-2 -> 12.34
e = 1E-3 -> 1.234
------------------------------------ */
double r0_E(
int maxI,
double e)
{
double x;
x = (rand() % maxI);
x *= pow(-1,rand()) * e;
return(x);
}
/* ------------------------------------ */
/* ------------------------------------ */
Nous allons utiliser ses fonctions pour donner des valeurs aléatoires aux matrices.