darknet  v3
utils.h
Go to the documentation of this file.
1 #ifndef UTILS_H
2 #define UTILS_H
3 #include <stdio.h>
4 #include <time.h>
5 #include "darknet.h"
6 #include "list.h"
7 
8 #define TIME(a) \
9  do { \
10  double start = what_time_is_it_now(); \
11  a; \
12  printf("%s took: %f seconds\n", #a, what_time_is_it_now() - start); \
13  } while (0)
14 
15 #define TWO_PI 6.2831853071795864769252866f
16 
17 double what_time_is_it_now();
18 void shuffle(void *arr, size_t n, size_t size);
19 void sorta_shuffle(void *arr, size_t n, size_t size, size_t sections);
20 void free_ptrs(void **ptrs, int n);
21 int alphanum_to_int(char c);
22 char int_to_alphanum(int i);
23 int read_int(int fd);
24 void write_int(int fd, int n);
25 void read_all(int fd, char *buffer, size_t bytes);
26 void write_all(int fd, char *buffer, size_t bytes);
27 int read_all_fail(int fd, char *buffer, size_t bytes);
28 int write_all_fail(int fd, char *buffer, size_t bytes);
29 void find_replace(char *str, char *orig, char *rep, char *output);
30 void malloc_error();
31 void file_error(char *s);
32 void strip(char *s);
33 void strip_char(char *s, char bad);
34 list *split_str(char *s, char delim);
35 char *fgetl(FILE *fp);
36 list *parse_csv_line(char *line);
37 char *copy_string(char *s);
38 int count_fields(char *line);
39 float *parse_fields(char *line, int n);
40 void translate_array(float *a, int n, float s);
41 float constrain(float min, float max, float a);
42 int constrain_int(int a, int min, int max);
43 float rand_scale(float s);
44 int rand_int(int min, int max);
45 void mean_arrays(float **a, int n, int els, float *avg);
46 float dist_array(float *a, float *b, int n, int sub);
47 float **one_hot_encode(float *a, int n, int k);
48 float sec(clock_t clocks);
49 void print_statistics(float *a, int n);
50 int int_index(int *a, int val, int n);
51 
52 #endif
53 
void print_statistics(float *a, int n)
Definition: utils.c:507
void malloc_error()
Definition: utils.c:275
int constrain_int(int a, int min, int max)
Definition: utils.c:524
double what_time_is_it_now()
Definition: utils.c:27
void read_all(int fd, char *buffer, size_t bytes)
Definition: utils.c:402
void strip(char *s)
Definition: utils.c:302
void shuffle(void *arr, size_t n, size_t size)
Definition: utils.c:85
int alphanum_to_int(char c)
Definition: utils.c:193
char * fgetl(FILE *fp)
Definition: utils.c:335
int count_fields(char *line)
Definition: utils.c:447
float constrain(float min, float max, float a)
Definition: utils.c:531
float rand_scale(float s)
Definition: utils.c:708
list * split_str(char *s, char delim)
Definition: utils.c:287
void strip_char(char *s, char bad)
Definition: utils.c:315
float dist_array(float *a, float *b, int n, int sub)
Definition: utils.c:538
void write_int(int fd, int n)
Definition: utils.c:374
void find_replace(char *str, char *orig, char *rep, char *output)
Definition: utils.c:216
void translate_array(float *a, int n, float s)
Definition: utils.c:566
void write_all(int fd, char *buffer, size_t bytes)
Definition: utils.c:412
char * copy_string(char *s)
Definition: utils.c:423
int read_all_fail(int fd, char *buffer, size_t bytes)
Definition: utils.c:380
char int_to_alphanum(int i)
Definition: utils.c:197
int int_index(int *a, int val, int n)
Definition: utils.c:633
float * parse_fields(char *line, int n)
Definition: utils.c:459
int write_all_fail(int fd, char *buffer, size_t bytes)
Definition: utils.c:391
int rand_int(int min, int max)
Definition: utils.c:642
float ** one_hot_encode(float *a, int n, int k)
Definition: utils.c:715
void sorta_shuffle(void *arr, size_t n, size_t size, size_t sections)
Definition: utils.c:74
Definition: darknet.h:602
void free_ptrs(void **ptrs, int n)
Definition: utils.c:328
list * parse_csv_line(char *line)
Definition: utils.c:430
float sec(clock_t clocks)
Definition: utils.c:232
void mean_arrays(float **a, int n, int els, float *avg)
Definition: utils.c:492
int read_int(int fd)
Definition: utils.c:366
void file_error(char *s)
Definition: utils.c:281