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.
75 lines
2.3 KiB
75 lines
2.3 KiB
#ifndef __CORTEX_UTILS_HEADERS__
|
|
#define __CORTEX_UTILS_HEADERS__
|
|
#include <stdio.h>
|
|
#include <time.h>
|
|
#include <vector>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <math.h>
|
|
#include <assert.h>
|
|
#ifdef __linux__
|
|
#include <unistd.h>
|
|
#else
|
|
#include <io.h>
|
|
#endif
|
|
#include <float.h>
|
|
#include <limits.h>
|
|
#include <stdint.h>
|
|
|
|
typedef std::vector<char *> cortexList;
|
|
|
|
#if defined(_MSC_VER) && _MSC_VER < 1900
|
|
#ifndef snprintf
|
|
#define snprintf(buf,len, format,...) _snprintf_s(buf, len,len, format, __VA_ARGS__)
|
|
#endif
|
|
#endif
|
|
|
|
#define TWO_PI (6.2831853071795864769252866f)
|
|
|
|
void free_cortexList(cortexList * l);
|
|
void normalize_array(float *a, int n);
|
|
void top_k(float *a, int n, int k, int *index);
|
|
int *read_intlist(char *gpu_list, int *ngpus, int d);
|
|
double what_time_is_it_now( void );
|
|
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 );
|
|
void file_error(char *s);
|
|
void strip(char *s);
|
|
void strip_char(char *s, char bad);
|
|
cortexList *split_str(char *s, char delim);
|
|
char *fgetl(FILE *fp);
|
|
cortexList *parse_csv_line(char *line);
|
|
char *copy_string(char *s);
|
|
int count_fields(char *line);
|
|
float *parse_fields(char *line, int n);
|
|
void scale_array(float *a, int n, float s);
|
|
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_uniform(float min, float max);
|
|
float rand_scale(float s);
|
|
int rand_int(int min, int max);
|
|
float sum_array(float *a, int n);
|
|
float mag_array(float *a, int n);
|
|
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);
|
|
float rand_normal(void);
|
|
uint32_t *read_map(char *filename);
|
|
//void print_statistics(float *a, int n);
|
|
|
|
#endif
|
|
|