Skip to content

Commit f8c7124

Browse files
committed
Implemented suffix array construction of a long 16-bit array (libsais16x64).
1 parent d4f940b commit f8c7124

10 files changed

+7958
-15
lines changed

CHANGES

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
Changes in 2.8.3 (June 11, 2024)
2+
- Implemented suffix array construction of a long 16-bit array (libsais16x64).
3+
14
Changes in 2.8.2 (May 27, 2024)
2-
- Implemented suffix array construction of a long integer array (libsais64).
5+
- Implemented suffix array construction of a long 64-bit array (libsais64).
36

47
Changes in 2.8.1 (April 5, 2024)
58
- Fixed out-of-bound memory access issue for large inputs (libsais64).

CMakeLists.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.10)
22

3-
project(libsais VERSION 2.8.2 LANGUAGES C DESCRIPTION "libsais is a library for linear time suffix array, longest common prefix array and burrows wheeler transform construction based on induced sorting algorithm.")
3+
project(libsais VERSION 2.8.3 LANGUAGES C DESCRIPTION "libsais is a library for linear time suffix array, longest common prefix array and burrows wheeler transform construction based on induced sorting algorithm.")
44

55
set(CMAKE_C_STANDARD 99)
66
set(CMAKE_C_STANDARD_REQUIRED ON)
@@ -20,9 +20,11 @@ add_library(libsais ${LIBSAIS_LIBRARY_TYPE})
2020
target_sources(libsais PRIVATE
2121
include/libsais.h
2222
include/libsais16.h
23+
include/libsais16x64.h
2324
include/libsais64.h
2425
src/libsais.c
2526
src/libsais16.c
27+
src/libsais16x64.c
2628
src/libsais64.c
2729
)
2830

README.md

+9-6
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ The libsais provides simple C99 API to construct suffix array and Burrows-Wheele
2323
The libsais is released under the [Apache License Version 2.0](LICENSE "Apache license")
2424

2525
## Changes
26+
* June 11, 2024 (2.8.3)
27+
* Implemented suffix array construction of a long 16-bit array (libsais16x64).
2628
* May 27, 2024 (2.8.2)
27-
* Implemented suffix array construction of a long integer array (libsais64).
29+
* Implemented suffix array construction of a long 64-bit array (libsais64).
2830
* April 5, 2024 (2.8.1)
2931
* Fixed out-of-bound memory access issue for large inputs (libsais64).
3032
* March 3, 2024 (2.8.0)
@@ -65,11 +67,12 @@ The libsais is released under the [Apache License Version 2.0](LICENSE "Apache l
6567

6668
## Versions of the libsais
6769
* [libsais.c](src/libsais.c) (and corresponding [libsais.h](include/libsais.h)) is for suffix array, PLCP, LCP, forward BWT and reverse BWT construction over 8-bit inputs smaller than 2GB (2147483648 bytes).
68-
* This version of the library could also be used to construct suffix array of an integer array (with a caveat that input array must be mutable).
69-
* [libsais64.c](src/libsais64.c) (and corresponding [libsais64.h](include/libsais64.h)) is optional extension of the library for inputs larger or equlas to 2GB (2147483648 bytes).
70-
* [libsais16.c](src/libsais16.c) (and corresponding [libsais16.h](include/libsais16.h)) is independent version of the library for 16-bit inputs.
70+
* [libsais64.c](src/libsais64.c) (and corresponding [libsais64.h](include/libsais64.h)) is optional extension of the library for inputs larger or equlas to 2GB (2147483648 bytes).
71+
* This versions of the library could also be used to construct suffix array of an integer array (with a caveat that input array must be mutable).
72+
* [libsais16.c](src/libsais16.c) + [libsais16x64.c](src/libsais16x64.c) (and corresponding [libsais16.h](include/libsais16.h) + [libsais16x64.h](include/libsais16x64.h)) is independent version of the library for 16-bit inputs.
73+
* This version of the library could also be used to construct suffix array and BWT of a set of strings by adding a unique end-of-string symbol to each string and then computing the result for the concatenated string.
7174

72-
## Examples of APIs (see [libsais.h](include/libsais.h), [libsais16.h](include/libsais16.h) and [libsais64.h](include/libsais64.h) for complete APIs list)
75+
## Examples of APIs (see [libsais.h](include/libsais.h), [libsais16.h](include/libsais16.h), [libsais16x64.h](include/libsais16x64.h) and [libsais64.h](include/libsais64.h) for complete APIs list)
7376
```c
7477
/**
7578
* Constructs the suffix array of a given string.
@@ -124,7 +127,7 @@ The libsais is released under the [Apache License Version 2.0](LICENSE "Apache l
124127
CPMAddPackage(
125128
NAME libsais
126129
GITHUB_REPOSITORY IlyaGrebnov/libsais
127-
GIT_TAG v2.8.1
130+
GIT_TAG v2.8.3
128131
OPTIONS
129132
"LIBSAIS_USE_OPENMP OFF"
130133
"LIBSAIS_BUILD_SHARED_LIB OFF"

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.8.2
1+
2.8.3

include/libsais.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ Please see the file LICENSE for full copyright information.
2626

2727
#define LIBSAIS_VERSION_MAJOR 2
2828
#define LIBSAIS_VERSION_MINOR 8
29-
#define LIBSAIS_VERSION_PATCH 2
30-
#define LIBSAIS_VERSION_STRING "2.8.2"
29+
#define LIBSAIS_VERSION_PATCH 3
30+
#define LIBSAIS_VERSION_STRING "2.8.3"
3131

3232
#ifdef _WIN32
3333
#ifdef LIBSAIS_SHARED

include/libsais16.h

+27-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ Please see the file LICENSE for full copyright information.
2626

2727
#define LIBSAIS16_VERSION_MAJOR 2
2828
#define LIBSAIS16_VERSION_MINOR 8
29-
#define LIBSAIS16_VERSION_PATCH 2
30-
#define LIBSAIS16_VERSION_STRING "2.8.2"
29+
#define LIBSAIS16_VERSION_PATCH 3
30+
#define LIBSAIS16_VERSION_STRING "2.8.3"
3131

3232
#ifdef _WIN32
3333
#ifdef LIBSAIS_SHARED
@@ -83,6 +83,18 @@ extern "C" {
8383
*/
8484
LIBSAIS16_API int32_t libsais16(const uint16_t * T, int32_t * SA, int32_t n, int32_t fs, int32_t * freq);
8585

86+
/**
87+
* Constructs the suffix array of a given integer array.
88+
* Note, during construction input array will be modified, but restored at the end if no errors occurred.
89+
* @param T [0..n-1] The input integer array.
90+
* @param SA [0..n-1+fs] The output array of suffixes.
91+
* @param n The length of the integer array.
92+
* @param k The alphabet size of the input integer array.
93+
* @param fs Extra space available at the end of SA array (can be 0, but 4k or better 6k is recommended for optimal performance).
94+
* @return 0 if no error occurred, -1 or -2 otherwise.
95+
*/
96+
LIBSAIS16_API int32_t libsais16_int(int32_t * T, int32_t * SA, int32_t n, int32_t k, int32_t fs);
97+
8698
/**
8799
* Constructs the suffix array of a given 16-bit string using libsais16 context.
88100
* @param ctx The libsais16 context.
@@ -107,6 +119,19 @@ extern "C" {
107119
* @return 0 if no error occurred, -1 or -2 otherwise.
108120
*/
109121
LIBSAIS16_API int32_t libsais16_omp(const uint16_t * T, int32_t * SA, int32_t n, int32_t fs, int32_t * freq, int32_t threads);
122+
123+
/**
124+
* Constructs the suffix array of a given integer array in parallel using OpenMP.
125+
* Note, during construction input array will be modified, but restored at the end if no errors occurred.
126+
* @param T [0..n-1] The input integer array.
127+
* @param SA [0..n-1+fs] The output array of suffixes.
128+
* @param n The length of the integer array.
129+
* @param k The alphabet size of the input integer array.
130+
* @param fs Extra space available at the end of SA array (can be 0, but 4k or better 6k is recommended for optimal performance).
131+
* @param threads The number of OpenMP threads to use (can be 0 for OpenMP default).
132+
* @return 0 if no error occurred, -1 or -2 otherwise.
133+
*/
134+
LIBSAIS16_API int32_t libsais16_int_omp(int32_t * T, int32_t * SA, int32_t n, int32_t k, int32_t fs, int32_t threads);
110135
#endif
111136

112137
/**

0 commit comments

Comments
 (0)