You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.6 KiB

8 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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. namespace DN{
  8. #define TWO_PI 6.2831853071795864769252866
  9. double what_time_is_it_now();
  10. void shuffle(void *arr, size_t n, size_t size);
  11. void sorta_shuffle(void *arr, size_t n, size_t size, size_t sections);
  12. void free_ptrs(void **ptrs, int n);
  13. int alphanum_to_int(char c);
  14. char int_to_alphanum(int i);
  15. int read_int(int fd);
  16. void write_int(int fd, int n);
  17. void read_all(int fd, char *buffer, size_t bytes);
  18. void write_all(int fd, char *buffer, size_t bytes);
  19. int read_all_fail(int fd, char *buffer, size_t bytes);
  20. int write_all_fail(int fd, char *buffer, size_t bytes);
  21. void find_replace(char *str, char *orig, char *rep, char *output);
  22. void malloc_error();
  23. void file_error(char *s);
  24. void strip(char *s);
  25. void strip_char(char *s, char bad);
  26. list *split_str(char *s, char delim);
  27. char *fgetl(FILE *fp);
  28. list *parse_csv_line(char *line);
  29. char *copy_string(char *s);
  30. int count_fields(char *line);
  31. float *parse_fields(char *line, int n);
  32. void scale_array(float *a, int n, float s);
  33. void translate_array(float *a, int n, float s);
  34. float constrain(float min, float max, float a);
  35. int constrain_int(int a, int min, int max);
  36. float rand_uniform(float min, float max);
  37. float rand_scale(float s);
  38. int rand_int(int min, int max);
  39. float sum_array(float *a, int n);
  40. void mean_arrays(float **a, int n, int els, float *avg);
  41. float dist_array(float *a, float *b, int n, int sub);
  42. float **one_hot_encode(float *a, int n, int k);
  43. float sec(clock_t clocks);
  44. void print_statistics(float *a, int n);
  45. };
  46. #endif