aboutsummaryrefslogtreecommitdiff
path: root/src/gensvm_init.c
diff options
context:
space:
mode:
authorGertjan van den Burg <burg@ese.eur.nl>2016-09-20 16:43:00 +0200
committerGertjan van den Burg <burg@ese.eur.nl>2016-09-20 16:43:00 +0200
commitfd58e0e97ca46d337ce96c5e0750fdfb8414b902 (patch)
tree34461440b5b425f7d64d91d7e9c45a0ceefb9934 /src/gensvm_init.c
parentRobustness improvements reading dataset (diff)
downloadgensvm-fd58e0e97ca46d337ce96c5e0750fdfb8414b902.tar.gz
gensvm-fd58e0e97ca46d337ce96c5e0750fdfb8414b902.zip
Remove inline rand function
Diffstat (limited to 'src/gensvm_init.c')
-rw-r--r--src/gensvm_init.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/gensvm_init.c b/src/gensvm_init.c
index 670e60b..aa96ca6 100644
--- a/src/gensvm_init.c
+++ b/src/gensvm_init.c
@@ -16,10 +16,8 @@
#include "gensvm_init.h"
#include "gensvm_print.h"
-inline double rnd() { return (double) rand()/0x7FFFFFFF; }
-
/**
- * @brief seed the matrix V from an existing model or using rand
+ * @brief Seed the matrix V from an existing model or using rand
*
* @details
* The matrix V must be seeded before the main_loop() can start.
@@ -36,7 +34,7 @@ void gensvm_init_V(struct GenModel *from_model,
struct GenModel *to_model, struct GenData *data)
{
long i, j, k;
- double cmin, cmax, value;
+ double cmin, cmax, value, rnd;
long n = data->n;
long m = data->m;
@@ -54,7 +52,8 @@ void gensvm_init_V(struct GenModel *from_model,
for (j=0; j<K-1; j++) {
cmin = (abs(cmin) < 1e-10) ? -1 : cmin;
cmax = (abs(cmax) < 1e-10) ? 1 : cmax;
- value = 1.0/cmin + (1.0/cmax - 1.0/cmin)*rnd();
+ rnd = ((double) rand()) / RAND_MAX;
+ value = 1.0/cmin + (1.0/cmax - 1.0/cmin)*rnd;
matrix_set(to_model->V, K-1, i, j, value);
}
}