/*****************/ /* GLOBAL VALUES */ /*****************/ /** * The number of data points per Fourier transform. */ #define ITEMS_PER_TRANS 1024 /** * Infinity */ #define inf 1.0/0.0 /**************/ /* DATA TYPES */ /**************/ /** * A neuron */ typedef struct _neuron { double value; /**< The value stored in the neuron */ struct _edge* weights; /**< The array of weighted connections into the neuron */ double num_weights; /**< The length of the connection array */ } neuron; /** * An edge connecting two neurons */ typedef struct _edge { struct _neuron* source; /**< The neuron to which this neuron is connected */ double weight; /**< The weight assigned to that neuron's value */ } edge; /** * A neural network */ typedef struct _net { struct _neuron* inputs; /**< The array of input neurons */ struct _neuron* hidden; /**< The array of hidden neurons */ struct _neuron* outputs; /**< The array of output neurons */ double num_inputs; /**< The number of input neurons */ double num_hidden; /**< The number of hidden neurons */ double num_outputs; /**< The number of output neurons */ } net; /** * A matrix */ typedef struct _matrix { int rows; /**< The number of rows */ int cols; /**< The number of columns */ double** array; /**< The matrix data */ int rows_filled; /**< The number of rows filled so far, for the add_row function */ } matrix; /*************/ /* FUNCTIONS */ /*************/ /* input.c */ int input(char* filename, double** arrayptr); /* trans.c */ double** transforms(double* datas, int size); /* frac.c */ double variation(double* datas, int size); double anam(double* datas, int size); /* neural.c */ net* create_network(int num_inputs, int num_outputs, int num_hidden); void process_inputs(net* n, double inputs[]); double get_output(net* n, int output); double input_scale(double value); double rescale(double value); /* matrix.c */ matrix* create_matrix(int rows, int cols); matrix* matrix_from_array(int rows, int cols, double** array); matrix* mtx_copy(matrix* mtx); int add(matrix* mtx, matrix* addend); void mul_scalar(matrix* mtx, double c); matrix* mul_matrix(matrix* mtx, matrix* mul); void inverse(matrix* mtx); int add_row(matrix* mtx, double* row); void mtx_row_swap(matrix* mtx, int r1, int r2); void mtx_row_mul(matrix* mtx, int r, double mul); void mtx_row_mul_add(matrix* mtx, int r1, double mul, int r2); int rref(matrix* mtx); void destroy(matrix* mtx); void mtx_print(matrix* mtx);