Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CI1164 - Utils
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Harbor Registry
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Armando Luiz Nicolini Delgado
CI1164 - Utils
Commits
46a25dab
Commit
46a25dab
authored
1 year ago
by
Armando Luiz Nicolini Delgado
Browse files
Options
Downloads
Patches
Plain Diff
/* Adicionados algumas alternativas de funções, mas ainda comentadas */
parent
ca72d61e
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
utils/randomNR.c
+15
-2
15 additions, 2 deletions
utils/randomNR.c
utils/randomNR.h
+8
-1
8 additions, 1 deletion
utils/randomNR.h
with
23 additions
and
3 deletions
utils/randomNR.c
+
15
−
2
View file @
46a25dab
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
// Gerador de números pseudo-aleatórios
// Gerador de números pseudo-aleatórios
// Período do gerador: 3.138e57 (aprox.)
// Período do gerador: 3.138e57 (aprox.)
// Fonte: Press, W.H.; "Numerical Recipes, 3rd ed.", pp.342)
// Fonte: Press, W.H.; "Numerical Recipes, 3rd ed.",
Cap. 7,
pp.342)
static
struct
Ran
{
static
struct
Ran
{
Ullong
u
,
v
,
w
;
Ullong
u
,
v
,
w
;
...
@@ -35,12 +35,25 @@ Ullong nrRandom64()
...
@@ -35,12 +35,25 @@ Ullong nrRandom64()
return
(
x
+
randomNR
.
v
)
^
randomNR
.
w
;
return
(
x
+
randomNR
.
v
)
^
randomNR
.
w
;
}
}
// Retorna
int
-64 bits entre 0 e 1.0
// Retorna
double
-64 bits entre 0 e 1.0
Doub
nrDrandom
()
{
return
5.42101086242752217E-20
*
nrRandom64
();
}
Doub
nrDrandom
()
{
return
5.42101086242752217E-20
*
nrRandom64
();
}
// Retorna int-32 bits entre 0 e 2³² - 1
// Retorna int-32 bits entre 0 e 2³² - 1
Uint
nrRandom32
()
{
return
(
Uint
)
nrRandom64
();
}
Uint
nrRandom32
()
{
return
(
Uint
)
nrRandom64
();
}
/*
static Ullong (* randFunc) ( void ) = random;
static Doub (* drandFunc) ( void ) = random;
static void (* randSeed) ( Ullong ) = srandom;
void setRandGen(Randtype t)
{
if (t == UNIX) { drandFunc = randFunc = random; randSeed = srandom;}
else if (t == UNIX48) { drandFunc = drand48; randFunc = lrand48; randSeed = srand48;}
else if (t == NR) { drandFunc = nrDrandom; randFunc = nrRandom64; randSeed = nrSeed;}
}
*/
/*
/*
struct Ranq1 {
struct Ranq1 {
Ullong v;
Ullong v;
...
...
This diff is collapsed.
Click to expand it.
utils/randomNR.h
+
8
−
1
View file @
46a25dab
...
@@ -40,7 +40,7 @@ typedef unsigned char Bool;
...
@@ -40,7 +40,7 @@ typedef unsigned char Bool;
// Functions
// Functions
// Período do gerador: 3.138e57 (aprox.)
// Período do gerador: 3.138e57 (aprox.)
// Fonte: Press, W.H.; "Numerical Recipes, 3rd ed.", pp.342)
// Fonte: Press, W.H.; "Numerical Recipes, 3rd ed.",
Cap. 7,
pp.342)
// Define a semente
// Define a semente
void
nrSeed
(
Ullong
j
);
void
nrSeed
(
Ullong
j
);
...
@@ -51,4 +51,11 @@ Doub nrDrandom();
...
@@ -51,4 +51,11 @@ Doub nrDrandom();
// Retorna int-32 bits entre 0 e 2³² - 1
// Retorna int-32 bits entre 0 e 2³² - 1
Uint
nrRandom32
();
Uint
nrRandom32
();
/*
// Tipos de geradores
typedef enum {UNIX, UNIX48, NR} Randtype;
// Define o tipo de gerador
void setRandGen(Randtype t);
*/
#endif
/* _RANDOMNR_H_ */
#endif
/* _RANDOMNR_H_ */
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment