#ifndef _CNN_H_
#define _CNN_H_

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "my.h"

extern u8 isrun;

void PrintfArray(float *array, int array_num, int elements_per_line);
void **allocate2DArray(int depth, int num, size_t elementSize);
void free2DArray(float **array, int depth);
void Full(float *inputArray, int input_size, float *outputArray);
void Pooling(float *inputArray, int input_size, int kernel_size, unsigned int step, float *outputArray);
void Convolution(float *inputArray, int input_size, float *kernel, int kernel_size, float *outputArray);
void Combine(float **inputArray, int input_depth, int input_size, float *outputArray);
void Flatten2D(float **inputArray, int input_depth, int input_size, float *outputArray);
float ConnectedLayer(float *inputArray, int input_num, float *input_w, float input_b);
void ReLU1(float *inputArray, int num, float *outputArray);
float ReLU2(float data);
void AddBias(float *inputArray, int input_num, float bias, float *outputArray);

int calculate_probabilities(float *input_array, float *output_array, int input_num);
void generateMatrix(float *get_data, float Max_value, int totalPoints, float CNN_data[100*100]);
void calculate_statistics(float arr[], int size, float *max_val, float *mean, float *std_dev);
int check_threshold(float arr[], int size, float *mean, float *std_dev);

void _cnn_run(void);
void cnn_run(void);
void PrintfResArray(float *array, int array_num, int elements_per_line);

#endif
