darknet  v3
Macros | Functions
utils.h File Reference
#include <stdio.h>
#include <time.h>
#include "darknet.h"
#include "list.h"
Include dependency graph for utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define TIME(a)
 
#define TWO_PI   6.2831853071795864769252866f
 

Functions

double what_time_is_it_now ()
 
void shuffle (void *arr, size_t n, size_t size)
 
void sorta_shuffle (void *arr, size_t n, size_t size, size_t sections)
 
void free_ptrs (void **ptrs, int n)
 
int alphanum_to_int (char c)
 
char int_to_alphanum (int i)
 
int read_int (int fd)
 
void write_int (int fd, int n)
 
void read_all (int fd, char *buffer, size_t bytes)
 
void write_all (int fd, char *buffer, size_t bytes)
 
int read_all_fail (int fd, char *buffer, size_t bytes)
 
int write_all_fail (int fd, char *buffer, size_t bytes)
 
void find_replace (char *str, char *orig, char *rep, char *output)
 
void malloc_error ()
 
void file_error (char *s)
 
void strip (char *s)
 
void strip_char (char *s, char bad)
 
listsplit_str (char *s, char delim)
 
char * fgetl (FILE *fp)
 
listparse_csv_line (char *line)
 
char * copy_string (char *s)
 
int count_fields (char *line)
 
float * parse_fields (char *line, int n)
 
void translate_array (float *a, int n, float s)
 
float constrain (float min, float max, float a)
 
int constrain_int (int a, int min, int max)
 
float rand_scale (float s)
 
int rand_int (int min, int max)
 
void mean_arrays (float **a, int n, int els, float *avg)
 
float dist_array (float *a, float *b, int n, int sub)
 
float ** one_hot_encode (float *a, int n, int k)
 
float sec (clock_t clocks)
 
void print_statistics (float *a, int n)
 
int int_index (int *a, int val, int n)
 

Macro Definition Documentation

◆ TIME

#define TIME (   a)
Value:
do { \
double start = what_time_is_it_now(); \
a; \
printf("%s took: %f seconds\n", #a, what_time_is_it_now() - start); \
} while (0)
double what_time_is_it_now()
Definition: utils.c:27

Definition at line 8 of file utils.h.

◆ TWO_PI

#define TWO_PI   6.2831853071795864769252866f

Definition at line 15 of file utils.h.

Function Documentation

◆ alphanum_to_int()

int alphanum_to_int ( char  c)

Definition at line 193 of file utils.c.

◆ constrain()

float constrain ( float  min,
float  max,
float  a 
)

Definition at line 531 of file utils.c.

◆ constrain_int()

int constrain_int ( int  a,
int  min,
int  max 
)

Definition at line 524 of file utils.c.

◆ copy_string()

char* copy_string ( char *  s)

Definition at line 423 of file utils.c.

◆ count_fields()

int count_fields ( char *  line)

Definition at line 447 of file utils.c.

◆ dist_array()

float dist_array ( float *  a,
float *  b,
int  n,
int  sub 
)

Definition at line 538 of file utils.c.

◆ fgetl()

char* fgetl ( FILE *  fp)

Definition at line 335 of file utils.c.

◆ file_error()

void file_error ( char *  s)

Definition at line 281 of file utils.c.

◆ find_replace()

void find_replace ( char *  str,
char *  orig,
char *  rep,
char *  output 
)

Definition at line 216 of file utils.c.

◆ free_ptrs()

void free_ptrs ( void **  ptrs,
int  n 
)

Definition at line 328 of file utils.c.

◆ int_index()

int int_index ( int *  a,
int  val,
int  n 
)

Definition at line 633 of file utils.c.

◆ int_to_alphanum()

char int_to_alphanum ( int  i)

Definition at line 197 of file utils.c.

◆ malloc_error()

void malloc_error ( )

Definition at line 275 of file utils.c.

◆ mean_arrays()

void mean_arrays ( float **  a,
int  n,
int  els,
float *  avg 
)

Definition at line 492 of file utils.c.

◆ one_hot_encode()

float** one_hot_encode ( float *  a,
int  n,
int  k 
)

Definition at line 715 of file utils.c.

◆ parse_csv_line()

list* parse_csv_line ( char *  line)

Definition at line 430 of file utils.c.

◆ parse_fields()

float* parse_fields ( char *  line,
int  n 
)

Definition at line 459 of file utils.c.

◆ print_statistics()

void print_statistics ( float *  a,
int  n 
)

Definition at line 507 of file utils.c.

◆ rand_int()

int rand_int ( int  min,
int  max 
)

Definition at line 642 of file utils.c.

◆ rand_scale()

float rand_scale ( float  s)

Definition at line 708 of file utils.c.

◆ read_all()

void read_all ( int  fd,
char *  buffer,
size_t  bytes 
)

Definition at line 402 of file utils.c.

◆ read_all_fail()

int read_all_fail ( int  fd,
char *  buffer,
size_t  bytes 
)

Definition at line 380 of file utils.c.

◆ read_int()

int read_int ( int  fd)

Definition at line 366 of file utils.c.

◆ sec()

float sec ( clock_t  clocks)

Definition at line 232 of file utils.c.

◆ shuffle()

void shuffle ( void *  arr,
size_t  n,
size_t  size 
)

Definition at line 85 of file utils.c.

◆ sorta_shuffle()

void sorta_shuffle ( void *  arr,
size_t  n,
size_t  size,
size_t  sections 
)

Definition at line 74 of file utils.c.

◆ split_str()

list* split_str ( char *  s,
char  delim 
)

Definition at line 287 of file utils.c.

◆ strip()

void strip ( char *  s)

Definition at line 302 of file utils.c.

◆ strip_char()

void strip_char ( char *  s,
char  bad 
)

Definition at line 315 of file utils.c.

◆ translate_array()

void translate_array ( float *  a,
int  n,
float  s 
)

Definition at line 566 of file utils.c.

◆ what_time_is_it_now()

double what_time_is_it_now ( )

Definition at line 27 of file utils.c.

◆ write_all()

void write_all ( int  fd,
char *  buffer,
size_t  bytes 
)

Definition at line 412 of file utils.c.

◆ write_all_fail()

int write_all_fail ( int  fd,
char *  buffer,
size_t  bytes 
)

Definition at line 391 of file utils.c.

◆ write_int()

void write_int ( int  fd,
int  n 
)

Definition at line 374 of file utils.c.