Added max argument to init_rand function.
This commit is contained in:
4
tensor.c
4
tensor.c
@@ -119,14 +119,14 @@ int tensor_init_zero(tensor t, int dimension, const int *size)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int tensor_init_rand(tensor t, int dimension, const int *size)
|
||||
int tensor_init_rand(tensor t, int dimension, const int *size, int max)
|
||||
{
|
||||
int i;
|
||||
srand(time(NULL));
|
||||
|
||||
if(!_tensor_set_size(t, size, dimension)) return 0;
|
||||
for(i = 0; i < t->num_elem; i++) {
|
||||
t->elements[i] = (t_type) rand();
|
||||
t->elements[i] = (t_type) (rand() % max);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
2
tensor.h
2
tensor.h
@@ -31,7 +31,7 @@ t_type tensor_get(const tensor t, const int *index, int *success);
|
||||
|
||||
int tensor_init_one(tensor t, int dimension, const int *size);
|
||||
int tensor_init_zero(tensor t, int dimension, const int *size);
|
||||
int tensor_init_rand(tensor t, int dimension, const int *size);
|
||||
int tensor_init_rand(tensor t, int dimension, const int *size, int max);
|
||||
|
||||
void tensor_for_each_elem(tensor t, t_type (*func)(t_type));
|
||||
void tensor_print(const tensor t);
|
||||
|
||||
Reference in New Issue
Block a user