List of commits:
Subject Hash Author Date (UTC)
simslope.c: type change 707e5be5af137023c28c12d54af35394cc32c9cc Josiah_Mullins_Optiplex_Mini 2019-12-01 22:21:44
Indentation 8606ab9f5e9d3b01f698a3303f5e6d39418b7bd5 Josiah_Mullins_Optiplex_Mini 2019-12-01 21:41:16
Simslope Initial commit. e9ccd3d49b4b1342341f1866a3f7a941af503b30 Josiah_Mullins_Optiplex_Mini 2019-12-01 21:24:04
Commit 707e5be5af137023c28c12d54af35394cc32c9cc - simslope.c: type change
This commit changes the type of rand_j and rand_k from
type int to type unsigned char. All neccessary changes
to the alogrithms were also done. In the function main,
the unused variable i was removed and some ambiguous
code was clarified.
Author: Josiah_Mullins_Optiplex_Mini
Author date (UTC): 2019-12-01 22:21
Committer name: Josiah_Mullins_Optiplex_Mini
Committer date (UTC): 2019-12-01 22:21
Parent(s): 8606ab9f5e9d3b01f698a3303f5e6d39418b7bd5
Signing key:
Tree: 4a12ffc6d6b35f4970dd00efd8e6644854eb758d
File Lines added Lines deleted
00_simslope/simslope.c 13 8
File 00_simslope/simslope.c changed (mode: 100644) (index 062672f..ed16c04)
14 14 #include <time.h> #include <time.h>
15 15
16 16 static unsigned int rand_x[56],rand_y[256],rand_z; /* used for normal dist */ static unsigned int rand_x[56],rand_y[256],rand_z; /* used for normal dist */
17 static int rand_j, rand_k; /* used for normal dist */
17 static unsigned char rand_j, rand_k; /* used for normal dist */
18 18
19 19
20 20 unsigned urand0 (void) unsigned urand0 (void)
21 21 { {
22 if (--rand_j == 0) rand_j = 55;
23 if (--rand_k == 0) rand_k = 55;
22 if (rand_j == 0) rand_j = 55;
23 else rand_j -= 1;
24 if (rand_k == 0) rand_k = 55;
25 else rand_k -= 1;
24 26 return rand_x[rand_k] += rand_x[rand_j]; return rand_x[rand_k] += rand_x[rand_j];
25 27 } }
26 28
 
... ... unsigned urand (void)
50 52
51 53 i = rand_z % 256; i = rand_z % 256;
52 54 rand_z = rand_y[i]; rand_z = rand_y[i];
53 if (--rand_j == 0) rand_j = 55;
54 if (--rand_k == 0) rand_k = 55;
55 if (rand_j == 0) rand_j = 55;
56 else rand_j -= 1;
57 if (rand_k == 0) rand_k = 55;
58 else rand_j -= 1;
55 59 rand_y[i] = rand_x[rand_k] += rand_x[rand_j]; rand_y[i] = rand_x[rand_k] += rand_x[rand_j];
56 60 return rand_z; return rand_z;
57 61 } }
 
... ... double normal_rand (void)
72 76 } }
73 77 flag = 1; flag = 1;
74 78 do { do {
75 v1 = urand()/a - 1;
76 v2 = urand()/a - 1;
79 v1 = urand()/(double)a - 1.0;
80 v2 = urand()/(double)a - 1.0;
77 81 } }
78 82 while ((s = v1*v1 + v2*v2) > 1.0); while ((s = v1*v1 + v2*v2) > 1.0);
79 83 s = sqrt (-2.0 * log(s) / s); s = sqrt (-2.0 * log(s) / s);
 
... ... double uniform_rand (void)
96 100 #define DATA 1000 #define DATA 1000
97 101 #define SAMPLES_PER_DATA 20 #define SAMPLES_PER_DATA 20
98 102
103
99 104 int main(void) int main(void)
100 105 { {
101 int i,j;
106 int j;
102 107 int d,slope; int d,slope;
103 108 double base,n,step; double base,n,step;
104 109
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/ORpKTKoVQnFhs/Public_Research

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/ORpKTKoVQnFhs/Public_Research

Clone this repository using git:
git clone git://git.rocketgit.com/user/ORpKTKoVQnFhs/Public_Research

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main