Added init function for identity tensor.
This commit is contained in:
11
tensor.h
11
tensor.h
@@ -8,10 +8,10 @@
|
||||
|
||||
#define PRINT_STRING " %4.1f "
|
||||
|
||||
typedef float t_type;
|
||||
typedef float dtype;
|
||||
|
||||
typedef struct _tensor {
|
||||
t_type *elements;
|
||||
dtype *elements;
|
||||
int dimension;
|
||||
int *size;
|
||||
int num_elem;
|
||||
@@ -26,14 +26,15 @@ int tensor_is_empty(const tensor t);
|
||||
int _tensor_check_size(const int *size, int dim);
|
||||
int _tensor_set_size(tensor t, const int *size, int dim);
|
||||
|
||||
int tensor_set(tensor t, const int *index, t_type val);
|
||||
t_type tensor_get(const tensor t, const int *index, int *success);
|
||||
int tensor_set(tensor t, const int *index, dtype val);
|
||||
dtype 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 max);
|
||||
int tensor_init_identity(tensor t, int dimension, int size);
|
||||
|
||||
void tensor_for_each_elem(tensor t, t_type (*func)(t_type));
|
||||
void tensor_for_each_elem(tensor t, dtype (*func)(dtype));
|
||||
void tensor_print(const tensor t);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user