From 0e20b3c142e516fe35fdd343c4b3565568c7e6cb Mon Sep 17 00:00:00 2001 From: KOLANICH Date: Wed, 18 Aug 2021 15:44:49 +0300 Subject: [PATCH] Added ksa.h for ksa. --- C/ksa/CMakeLists.txt | 4 ++-- C/ksa/ksa32.h | 30 ++++++++++++++++++++++++++++++ C/ksa/ksa64.h | 30 ++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 C/ksa/ksa32.h create mode 100644 C/ksa/ksa64.h diff --git a/C/ksa/CMakeLists.txt b/C/ksa/CMakeLists.txt index 70c7c66..0d56192 100644 --- a/C/ksa/CMakeLists.txt +++ b/C/ksa/CMakeLists.txt @@ -4,7 +4,7 @@ buildAndPackageLib("ksa32" COMPONENT "ksa32" DESCRIPTION "${PROJECT_DESCRIPTION}\n\n${DESCR}\n\nUses 32-bit integers." CMAKE_EXPORT_NAMESPACE "${PROJECT_NAME}" - PUBLIC_INCLUDES "${CMAKE_CURRENT_LIST_DIR}" + PUBLIC_INCLUDES "${CMAKE_CURRENT_LIST_DIR}/ksa32.h" INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}" ) @@ -12,7 +12,7 @@ buildAndPackageLib("ksa64" COMPONENT "ksa64" DESCRIPTION "${PROJECT_DESCRIPTION}\n\n${DESCR}\n\nUses 64-bit integers." CMAKE_EXPORT_NAMESPACE "${PROJECT_NAME}" - PUBLIC_INCLUDES "${CMAKE_CURRENT_LIST_DIR}" + PUBLIC_INCLUDES "${CMAKE_CURRENT_LIST_DIR}/ksa64.h" INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}" ) diff --git a/C/ksa/ksa32.h b/C/ksa/ksa32.h new file mode 100644 index 0000000..34967e6 --- /dev/null +++ b/C/ksa/ksa32.h @@ -0,0 +1,30 @@ +#pragma once + +int ksa_bwt(unsigned char *T, int n, int k); + +/** + * Recursively construct the suffix array for a string containing multiple + * sentinels. NULL is taken as the sentinel. + * + * @param T NULL terminated input string (there can be multiple NULLs) + * @param SA output suffix array + * @param fs working space available in SA (typically 0 when first called) + * @param n length of T, including the trailing NULL + * @param k size of the alphabet (typically 256 when first called) + * @param cs # bytes per element in T; 1 or sizeof(saint_t) (typically 1 when first called) + * + * @return 0 upon success + */ +int ksa_core(unsigned char const *T, int *SA, int fs, int n, int k, int cs); + +/** + * Construct the suffix array for a NULL terminated string possibly containing + * multiple sentinels (NULLs). + * + * @param T[0..n-1] NULL terminated input string + * @param SA[0..n-1] output suffix array + * @param n length of the given string, including NULL + * @param k size of the alphabet including the sentinel; no more than 256 + * @return 0 upon success + */ +int ksa_sa(unsigned char const *T, int *SA, int n, int k); diff --git a/C/ksa/ksa64.h b/C/ksa/ksa64.h new file mode 100644 index 0000000..dbe277a --- /dev/null +++ b/C/ksa/ksa64.h @@ -0,0 +1,30 @@ +#pragma once + +int ksa_bwt64(unsigned char *T, long int n, int k); + +/** + * Recursively construct the suffix array for a string containing multiple + * sentinels. NULL is taken as the sentinel. + * + * @param T NULL terminated input string (there can be multiple NULLs) + * @param SA output suffix array + * @param fs working space available in SA (typically 0 when first called) + * @param n length of T, including the trailing NULL + * @param k size of the alphabet (typically 256 when first called) + * @param cs # bytes per element in T; 1 or sizeof(saint_t) (typically 1 when first called) + * + * @return 0 upon success + */ +int ksa_core64(unsigned char const *T, long int *SA, long int fs, long int n, long int k, int cs); + +/** + * Construct the suffix array for a NULL terminated string possibly containing + * multiple sentinels (NULLs). + * + * @param T[0..n-1] NULL terminated input string + * @param SA[0..n-1] output suffix array + * @param n length of the given string, including NULL + * @param k size of the alphabet including the sentinel; no more than 256 + * @return 0 upon success + */ +int ksa_sa64(unsigned char const *T, long int *SA, long int n, int k);