diff options
Diffstat (limited to 'OASIS/C/inc')
-rw-r--r-- | OASIS/C/inc/ekd_blas.h | 49 | ||||
-rw-r--r-- | OASIS/C/inc/ekd_cv.h | 45 | ||||
-rw-r--r-- | OASIS/C/inc/ekd_pca.h | 38 | ||||
-rw-r--r-- | OASIS/C/inc/ekd_svm.h | 40 | ||||
-rw-r--r-- | OASIS/C/inc/main.h | 28 |
5 files changed, 0 insertions, 200 deletions
diff --git a/OASIS/C/inc/ekd_blas.h b/OASIS/C/inc/ekd_blas.h deleted file mode 100644 index 4c9919d..0000000 --- a/OASIS/C/inc/ekd_blas.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef EKD_BLAS_H
-#define EKD_BLAS_H
-
-#include <stdint.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <math.h>
-#include <omp.h>
-#include <cblas.h>
-
-typedef enum {
- MM_ADD,
- MM_SUBTRACT,
- MM_MULTIPLY,
- MM_MULTIPLY_OMP,
- MM_MULTIPLY_GEMM
-} matrix_matrix_operation_e;
-
-typedef enum {
- MV_MULTIPLY,
- MV_MULTIPLY_GEMV
-} matrix_vector_operation_e;
-
-typedef enum {
- SHIFT_ADD,
- SHIFT_SUBTRACT
-} shift_matrix_operation_e;
-
-// Prototypes
-void print_matrix(float** matrix, uint32_t rows, uint32_t cols);
-void print_vector(float* vector, uint32_t size);
-void copy_matrix(float** input_matrix, float** resultant_matrix, uint32_t rows, uint32_t cols);
-void copy_vector(float* input_vector, float* resultant_vector, uint32_t size);
-void shift_matrix(float** input_matrix, uint32_t size, float trace, shift_matrix_operation_e operation);
-float trace_matrix(float** input_matrix, uint32_t size);
-void eye(float** input_matrix, uint32_t size);
-void outer_product(float* input_vector, uint32_t size, float** resultant_matrix); // outer_productes itself
-float inner_product(float* input_vector_1, float* input_vector_2, uint32_t size); // Dots itself
-void matrix_operation(float** input_matrix_A, uint32_t rows_A, uint32_t cols_A, float** input_matrix_B, uint32_t rows_B, uint32_t cols_B, float** resultant_matrix, matrix_matrix_operation_e operation);
-void transpose(float** input_matrix, uint32_t rows, uint32_t cols, float** transposed_matrix);
-uint8_t sign(float num);
-void vector_normalize(float* vector, uint32_t size);
-float vector_norm(float* vector, uint32_t size);
-float matrix_norm(float** input_matrix_A1, float** input_matrix_A, uint32_t rows, uint32_t cols);
-float cosine_similarity(float* curr_vector, float* new_vector, uint32_t size);
-void matrix_vector_multiply(float** input_matrix, uint32_t rows, uint32_t cols, float* input_vector, float* resultant_vector, matrix_vector_operation_e operation);
-
-#endif /* EKD_BLAS_H */
diff --git a/OASIS/C/inc/ekd_cv.h b/OASIS/C/inc/ekd_cv.h deleted file mode 100644 index 146144c..0000000 --- a/OASIS/C/inc/ekd_cv.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef EKD_CV_H
-#define EKD_CV_H
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <dirent.h>
-#include <string.h>
-#include <time.h>
-
-#define NUM_DNEG_IMAGES 134
-#define NUM_DPOS_IMAGES 99
-#define NUM_IMAGES 233
-#define IMAGE_WIDTH 144
-#define IMAGE_HEIGHT 176
-#define FEATURE_VECTOR_SIZE 25344
-
-typedef struct {
- uint16_t signature;
- uint32_t file_size;
- uint32_t reserved;
- uint32_t data_offset;
-} bmp_header_t;
-
-typedef struct {
- uint32_t size;
- uint32_t width;
- uint32_t height;
- uint16_t planes;
- uint16_t bit_depth;
- uint32_t compression;
- uint32_t image_size;
- uint32_t x_pixels_per_meter;
- uint32_t y_pixels_per_meter;
- uint32_t colours_used;
- uint32_t important_colours;
-} bmp_info_t;
-
-// Prototypes
-void read_bmp(char* filename, uint8_t** data_flatten);
-void read_dir(char* dneg_path, char* dpos_path, char** file_name_arr);
-void flatten_image(uint8_t** image, float* image_flattened);
-void shuffle_data_labels(float** data, int32_t* labels, uint8_t num_images);
-
-#endif /* EKD_CV_H */
\ No newline at end of file diff --git a/OASIS/C/inc/ekd_pca.h b/OASIS/C/inc/ekd_pca.h deleted file mode 100644 index 842e485..0000000 --- a/OASIS/C/inc/ekd_pca.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef EKD_PCA_H
-#define EKD_PCA_H
-
-#include <stdint.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <math.h>
-
-#include "ekd_blas.h"
-
-#define NUM_DNEG_IMAGES 134
-#define NUM_DPOS_IMAGES 99
-#define NUM_IMAGES 233
-#define IMAGE_WIDTH 144
-#define IMAGE_HEIGHT 176
-#define FEATURE_VECTOR_SIZE 25344
-#define MAX_ITERATIONS 100
-#define TOLERANCE 1e-3
-
-typedef enum {
- MEAN_UNIT_VARIANCE,
- MEAN
-} centre_scale_operation_e;
-
-// Prototypes
-void centre_scale(float** input_matrix, uint32_t rows, uint32_t cols, centre_scale_operation_e operation);
-void covariance(float** input_matrix, uint32_t rows, uint32_t cols, float** covariance_matrix);
-void house_holder_vector(float* input_vector, uint32_t size);
-void house_holder_transformation(float* house_holder_vector, uint32_t size, float** house_holder_matrix);
-void qr_decomposition(float** input_matrix, uint32_t size, float** resultant_matrix);
-void qr_algorithm(float** input_matrix, uint32_t rows, uint32_t cols, float** resultant_matrix);
-void power_iteration(float** input_matrix, uint32_t size, float* eigen_vector);
-float eigen_value_compute(float* eigen_vector, float** input_matrix, uint32_t size);
-void subtract_eigen(float* eigen_vector, float** input_matrix, float** resultant_matrix, float eigen_value, uint32_t size);
-void pca_covariance_method(float** input_matrix, uint32_t rows, uint32_t cols, float** resultant_matrix, uint32_t components);
-
-#endif /* EKD_PCA_H */
\ No newline at end of file diff --git a/OASIS/C/inc/ekd_svm.h b/OASIS/C/inc/ekd_svm.h deleted file mode 100644 index 259eb5c..0000000 --- a/OASIS/C/inc/ekd_svm.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef EKD_SVM_H -#define EKD_SVM_H - -#include <stdint.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> -#include <float.h> - -#include "ekd_pca.h" -#include "ekd_blas.h" - -#define NUM_DNEG_IMAGES 134 -#define NUM_DPOS_IMAGES 99 -#define NUM_IMAGES 233 -#define IMAGE_WIDTH 144 -#define IMAGE_HEIGHT 176 -#define FEATURE_VECTOR_SIZE 25344 -#define MAX_SVM_PASSES 100 -#define GAMMA 0.9 -#define SVM_TOLERANCE 1e-3 - -void svm_preprocess(float** input_matrix, uint32_t rows, uint32_t cols); -float rbf_kernel(float* sample_1, float* sample_2, uint32_t features, float gamma); -void kernel_matrix_transform(float** input_matrix, float** resultant_matrix, uint32_t samples, uint32_t features, float gamma); -void kernel_row_transform(float** input_matrix, float* query_row, float* resultant_row, uint32_t samples, uint32_t features, float gamma); -float get_error(uint32_t index, float* alphas, float** kernel_matrix, int32_t* labels, uint32_t num_samples); -uint32_t find_second_alpha(uint32_t first_index, float first_error_val, float* alphas, float** kernel_matrix, int32_t* labels, uint32_t num_samples); -void calculate_bounds(float first_label, float second_label, float first_alpha, float second_alpha, float penalty, float* lower_bound, float* upper_bound); -float clip_second_alpha_new(float second_alpha_new, float lower_bound, float upper_bound); -void update_alphas(float first_alpha_new, float second_alpha_new, float* alphas, uint32_t first_index, uint32_t second_index); -float calculate_bias(float first_error_val, float second_error_val, float first_alpha_new, float first_alpha, float second_alpha_new, float second_alpha, float kernel_val_ii, float kernel_val_ij, float kernel_val_jj, float first_label, float second_label, float penalty); -void update_errors(float* errors, uint32_t num_samples, uint32_t first_index, uint32_t second_index, float first_label, float second_label, float first_alpha_new, float first_alpha, float second_alpha_new, float second_alpha, float* bias, float** kernel_matrix); -uint8_t optimize_alphas(uint32_t first_index, uint32_t second_index, float* alphas, float* bias, float* errors, float** kernel_matrix, int32_t* labels, uint32_t num_samples, float penalty); -uint8_t verify_kkt(uint32_t first_index, float tolerance, float* alphas, float* bias, float* errors, float** kernel_matrix, int32_t* labels, uint32_t num_samples, float penalty); -void train_svm(float** data_matrix, uint32_t samples, uint32_t features, float* alphas, float* bias, int32_t* labels, float penalty); -float test_svm(float** data_test, int32_t* labels_test, uint32_t num_test, uint32_t num_components, float* alphas, float bias); - -#endif /* EKD_SVM_H */
\ No newline at end of file diff --git a/OASIS/C/inc/main.h b/OASIS/C/inc/main.h deleted file mode 100644 index 040877e..0000000 --- a/OASIS/C/inc/main.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef MAIN_H
-#define MAIN_H
-
-#include <stdint.h>
-#include <string.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <time.h>
-
-#include "ekd_cv.h"
-#include "ekd_pca.h"
-#include "ekd_blas.h"
-#include "ekd_svm.h"
-
-#define NUM_DNEG_IMAGES 134
-#define NUM_DPOS_IMAGES 99
-#define NUM_IMAGES 233
-#define DNEG_FOLDER_PATH "/home/eric/URA/OASIS/Dataset/BMP/DNEG/"
-#define DPOS_FOLDER_PATH "/home/eric/URA/OASIS/Dataset/BMP/DPOS/"
-#define IMAGE_WIDTH 144
-#define IMAGE_HEIGHT 176
-#define FEATURE_VECTOR_SIZE 25344
-#define FILE_NAME_SIZE 150
-#define NUM_COMPONENTS 2
-#define PENALTY_PARAM 1
-
-#endif /* MAIN_H */
\ No newline at end of file |