Skip to content

Commit

Permalink
Improvement/c binding (#153)
Browse files Browse the repository at this point in the history
* Use const for input parameters
* Using C++ calls instead of C ones.
* Better error handling.
* Fix documentation issues #98 and #99
* Documentation fix
  • Loading branch information
raulbocanegra authored Apr 28, 2020
1 parent f61cc00 commit c2c7247
Show file tree
Hide file tree
Showing 35 changed files with 1,820 additions and 1,403 deletions.
72 changes: 38 additions & 34 deletions bindings/c/include/khiva_c/array.h

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions bindings/c/include/khiva_c/clustering.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extern "C" {
* @param error_code Allocated pointer to integer, where the resulting error_code is stored.
* @param error_message Allocated char array to KHIVA_ERROR_LENGTH, where the resulting error message is stored.
*/
KHIVA_C_API void k_means(khiva_array *tss, const int *k, khiva_array *centroids, khiva_array *labels, const float *tolerance,
KHIVA_C_API void k_means(const khiva_array *tss, const int *k, khiva_array *centroids, khiva_array *labels, const float *tolerance,
const int *max_iterations, int *error_code, char *error_message);

/**
Expand All @@ -45,7 +45,7 @@ KHIVA_C_API void k_means(khiva_array *tss, const int *k, khiva_array *centroids,
* @param error_code Allocated pointer to integer, where the resulting error_code is stored.
* @param error_message Allocated char array to KHIVA_ERROR_LENGTH, where the resulting error message is stored.
*/
KHIVA_C_API void k_shape(khiva_array *tss, const int *k, khiva_array *centroids, khiva_array *labels, const float *tolerance,
KHIVA_C_API void k_shape(const khiva_array *tss, const int *k, khiva_array *centroids, khiva_array *labels, const float *tolerance,
const int *max_iterations, int *error_code, char *error_message);

#ifdef __cplusplus
Expand Down
21 changes: 13 additions & 8 deletions bindings/c/include/khiva_c/dimensionality.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ extern "C" {
* @param error_code Allocated pointer to integer, where the resulting error_code is stored.
* @param error_message Allocated char array to KHIVA_ERROR_LENGTH, where the resulting error message is stored.
*/
KHIVA_C_API void paa(khiva_array *a, const int *bins, khiva_array *result, int *error_code, char *error_message);
KHIVA_C_API void paa(const khiva_array *a, const int *bins, khiva_array *result, int *error_code, char *error_message);

/**
* @brief Calculates the number of Perceptually Important Points (PIP) in the time series.
Expand All @@ -44,7 +44,8 @@ KHIVA_C_API void paa(khiva_array *a, const int *bins, khiva_array *result, int *
* @param error_code Allocated pointer to integer, where the resulting error_code is stored.
* @param error_message Allocated char array to KHIVA_ERROR_LENGTH, where the resulting error message is stored.
*/
KHIVA_C_API void pip(khiva_array *a, const int *number_ips, khiva_array *result, int *error_code, char *error_message);
KHIVA_C_API void pip(const khiva_array *a, const int *number_ips, khiva_array *result, int *error_code,
char *error_message);

/**
* @brief Applies the Piecewise Linear Approximation (PLA BottomUP) to the time series.
Expand All @@ -59,7 +60,8 @@ KHIVA_C_API void pip(khiva_array *a, const int *number_ips, khiva_array *result,
* @param error_code Allocated pointer to integer, where the resulting error_code is stored.
* @param error_message Allocated char array to KHIVA_ERROR_LENGTH, where the resulting error message is stored.
*/
KHIVA_C_API void pla_bottom_up(khiva_array *ts, const float *max_error, khiva_array *result, int *error_code, char *error_message);
KHIVA_C_API void pla_bottom_up(const khiva_array *ts, const float *max_error, khiva_array *result, int *error_code,
char *error_message);

/**
* @brief Applies the Piecewise Linear Approximation (PLA Sliding Window) to the time series.
Expand All @@ -74,7 +76,8 @@ KHIVA_C_API void pla_bottom_up(khiva_array *ts, const float *max_error, khiva_ar
* @param error_code Allocated pointer to integer, where the resulting error_code is stored.
* @param error_message Allocated char array to KHIVA_ERROR_LENGTH, where the resulting error message is stored.
*/
KHIVA_C_API void pla_sliding_window(khiva_array *ts, const float *max_error, khiva_array *result, int *error_code, char *error_message);
KHIVA_C_API void pla_sliding_window(const khiva_array *ts, const float *max_error, khiva_array *result, int *error_code,
char *error_message);

/**
* @brief The Ramer–Douglas–Peucker algorithm (RDP) is an algorithm for reducing the number of points in a curve
Expand All @@ -96,8 +99,8 @@ KHIVA_C_API void pla_sliding_window(khiva_array *ts, const float *max_error, khi
* @param error_code Allocated pointer to integer, where the resulting error_code is stored.
* @param error_message Allocated char array to KHIVA_ERROR_LENGTH, where the resulting error message is stored.
*/
KHIVA_C_API void ramer_douglas_peucker(khiva_array *points, const double *epsilon, khiva_array *res_points, int *error_code,
char *error_message);
KHIVA_C_API void ramer_douglas_peucker(const khiva_array *points, const double *epsilon, khiva_array *res_points,
int *error_code, char *error_message);

/**
* @brief Symbolic Aggregate approXimation (SAX). It transforms a numeric time series into a time series of symbols with
Expand All @@ -117,7 +120,8 @@ KHIVA_C_API void ramer_douglas_peucker(khiva_array *points, const double *epsilo
* @param error_code Allocated pointer to integer, where the resulting error_code is stored.
* @param error_message Allocated char array to KHIVA_ERROR_LENGTH, where the resulting error message is stored.
*/
KHIVA_C_API void sax(khiva_array *a, const int *alphabet_size, khiva_array *result, int *error_code, char *error_message);
KHIVA_C_API void sax(const khiva_array *a, const int *alphabet_size, khiva_array *result, int *error_code,
char *error_message);

/**
* @brief Reduces a set of points by applying the Visvalingam method (minimum triangle area) until the number
Expand All @@ -134,7 +138,8 @@ KHIVA_C_API void sax(khiva_array *a, const int *alphabet_size, khiva_array *resu
* @param error_code Allocated pointer to integer, where the resulting error_code is stored.
* @param error_message Allocated char array to KHIVA_ERROR_LENGTH, where the resulting error message is stored.
*/
KHIVA_C_API void visvalingam(khiva_array *points, const int *num_points, khiva_array *res_points, int *error_code, char *error_message);
KHIVA_C_API void visvalingam(const khiva_array *points, const int *num_points, khiva_array *res_points, int *error_code,
char *error_message);

#ifdef __cplusplus
}
Expand Down
12 changes: 6 additions & 6 deletions bindings/c/include/khiva_c/distances.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extern "C" {
* @param error_code Allocated pointer to integer, where the resulting error_code is stored.
* @param error_message Allocated char array to KHIVA_ERROR_LENGTH, where the resulting error message is stored.
*/
KHIVA_C_API void dtw(khiva_array *tss, khiva_array *result, int *error_code, char *error_message);
KHIVA_C_API void dtw(const khiva_array *tss, khiva_array *result, int *error_code, char *error_message);

/**
* @brief Calculates euclidean distances between time series.
Expand All @@ -38,7 +38,7 @@ KHIVA_C_API void dtw(khiva_array *tss, khiva_array *result, int *error_code, cha
* @param error_code Allocated pointer to integer, where the resulting error_code is stored.
* @param error_message Allocated char array to KHIVA_ERROR_LENGTH, where the resulting error message is stored.
*/
KHIVA_C_API void euclidean(khiva_array *tss, khiva_array *result, int *error_code, char *error_message);
KHIVA_C_API void euclidean(const khiva_array *tss, khiva_array *result, int *error_code, char *error_message);

/**
* @brief Calculates Hamming distances between time series.
Expand All @@ -51,7 +51,7 @@ KHIVA_C_API void euclidean(khiva_array *tss, khiva_array *result, int *error_cod
* @param error_code Allocated pointer to integer, where the resulting error_code is stored.
* @param error_message Allocated char array to KHIVA_ERROR_LENGTH, where the resulting error message is stored.
*/
KHIVA_C_API void hamming(khiva_array *tss, khiva_array *result, int *error_code, char *error_message);
KHIVA_C_API void hamming(const khiva_array *tss, khiva_array *result, int *error_code, char *error_message);

/**
* @brief Calculates Manhattan distances between time series.
Expand All @@ -65,7 +65,7 @@ KHIVA_C_API void hamming(khiva_array *tss, khiva_array *result, int *error_code,
* @param error_code Allocated pointer to integer, where the resulting error_code is stored.
* @param error_message Allocated char array to KHIVA_ERROR_LENGTH, where the resulting error message is stored.
*/
KHIVA_C_API void manhattan(khiva_array *tss, khiva_array *result, int *error_code, char *error_message);
KHIVA_C_API void manhattan(const khiva_array *tss, khiva_array *result, int *error_code, char *error_message);

/**
* @brief Calculates the Shape-Based distance (SBD). It computes the normalized cross-correlation and it returns 1.0
Expand All @@ -80,7 +80,7 @@ KHIVA_C_API void manhattan(khiva_array *tss, khiva_array *result, int *error_cod
* @param error_code Allocated pointer to integer, where the resulting error_code is stored.
* @param error_message Allocated char array to KHIVA_ERROR_LENGTH, where the resulting error message is stored.
*/
KHIVA_C_API void sbd(khiva_array *tss, khiva_array *result, int *error_code, char *error_message);
KHIVA_C_API void sbd(const khiva_array *tss, khiva_array *result, int *error_code, char *error_message);

/**
* @brief Calculates the non squared version of the euclidean distance.
Expand All @@ -94,7 +94,7 @@ KHIVA_C_API void sbd(khiva_array *tss, khiva_array *result, int *error_code, cha
* @param error_code Allocated pointer to integer, where the resulting error_code is stored.
* @param error_message Allocated char array to KHIVA_ERROR_LENGTH, where the resulting error message is stored.
*/
KHIVA_C_API void squared_euclidean(khiva_array *tss, khiva_array *result, int *error_code, char *error_message);
KHIVA_C_API void squared_euclidean(const khiva_array *tss, khiva_array *result, int *error_code, char *error_message);

#ifdef __cplusplus
}
Expand Down
Loading

0 comments on commit c2c7247

Please sign in to comment.