csci5451/assignments/01/common.h
2023-10-07 19:49:58 -05:00

43 lines
867 B
C

#ifndef COMMON_H_
#define COMMON_H_
#include <stdint.h>
#include <time.h>
#define FLOAT float
#define FLOAT_FORMAT "%f"
/**
* @brief Output the seconds elapsed while execution.
*
* @param seconds Seconds spent on execution, excluding IO.
*/
void print_time(double const seconds);
/**
* @brief Return the number of seconds since an unspecified time (e.g., Unix
* epoch). This is accomplished with a high-resolution monotonic timer,
* suitable for performance timing.
*
* @return The number of seconds.
*/
inline double monotonic_seconds() {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return ts.tv_sec + ts.tv_nsec * 1e-9;
}
struct data {
uint32_t rows, dimensions;
FLOAT *buf;
};
struct labels {
uint32_t rows;
FLOAT *buf;
};
struct data *read_data(char *path);
struct labels *read_labels(char *path);
#endif