projects
/
physik
/
morpheus.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
first c conc distribution implementation (slow and commented out)
[physik/morpheus.git]
/
random.c
diff --git
a/random.c
b/random.c
index
51b310b
..
51f6774
100644
(file)
--- a/
random.c
+++ b/
random.c
@@
-10,7
+10,7
@@
#include "defines.h"
/* global and extern variables */
#include "defines.h"
/* global and extern variables */
-extern u32
sum_z_cells
;
+extern u32
gr
;
extern int random_fd;
/* return random integer between 0 - max-1 */
extern int random_fd;
/* return random integer between 0 - max-1 */
@@
-27,11
+27,12
@@
u32 rand_get(u32 max)
}
/* get z value (linear growth of probability with depths) */
}
/* get z value (linear growth of probability with depths) */
-u32 rand_get_lgp(int slope_nel,int start_nel)
+u32 rand_get_lgp(int slope_nel,int start_nel
,u32 z_max
)
{
int z;
{
int z;
- u32 i;
- z=rand_get(sum_z_cells)+1; /* +1 as rand_get returns values 0...max-1 */
+ u32 i,weighted_sum_z;
+ weighted_sum_z=z_max*start_nel+slope_nel*gr;
+ z=rand_get(weighted_sum_z)+1; /* +1 as rand_get returns values 0...max-1 */
for(i=1;;i++) {
z-=(start_nel+i*slope_nel);
if(z<=0) break;
for(i=1;;i++) {
z-=(start_nel+i*slope_nel);
if(z<=0) break;