Skip to content

Commit

Permalink
Reflect the library name change.
Browse files Browse the repository at this point in the history
  • Loading branch information
borchehq committed Sep 5, 2024
1 parent 23c5324 commit d813011
Show file tree
Hide file tree
Showing 10 changed files with 156 additions and 156 deletions.
2 changes: 1 addition & 1 deletion .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ignore:
- "src/rstats/test/benchmark_rstats.c"
- "src/incstats/test/benchmark_incstats.c"
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.5)
project(librstats VERSION 1.1.1 LANGUAGES C)
project(libincstats VERSION 1.1.1 LANGUAGES C)

# Force export of all symbols under Windows.
if(WIN32)
Expand Down
52 changes: 26 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# librstats
# libincstats

**librstats** is a C library for efficiently computing running statistics, such as mean, variance, skewness, kurtosis, central moments, and finding the maximum and minimum values in a dataset. The library is designed to handle weighted data points, making it suitable for a wide range of applications.
**incstats** is a C library for efficiently computing running statistics, such as mean, variance, skewness, kurtosis, central moments, and finding the maximum and minimum values in a dataset. The library is designed to handle weighted data points, making it suitable for a wide range of applications.

## Status
[![CI](https://github.com/borchehq/rstats/actions/workflows/ci.yml/badge.svg)](https://github.com/borchehq/rstats/actions/workflows/ci.yml)
[![codecov](https://codecov.io/github/borchehq/rstats/graph/badge.svg?token=H24FODSV01)](https://codecov.io/github/borchehq/rstats)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/427138751ae64c2cafe2036c844e0642)](https://app.codacy.com/gh/borchehq/rstats/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
[![CI](https://github.com/borchehq/incstats/actions/workflows/ci.yml/badge.svg)](https://github.com/borchehq/incstats/actions/workflows/ci.yml)
[![codecov](https://codecov.io/github/borchehq/incstats/graph/badge.svg?token=H24FODSV01)](https://codecov.io/github/borchehq/incstats)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/427138751ae64c2cafe2036c844e0642)](https://app.codacy.com/gh/borchehq/incstats/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
## Features

- Compute running mean, variance, skewness, and kurtosis.
Expand All @@ -21,8 +21,8 @@ To build and install the library, you will need [CMake](https://cmake.org/) vers

1. Clone the repository:
```bash
git clone https://github.com/borchehq/rstats.git
cd rstats
git clone https://github.com/borchehq/incstats.git
cd incstats
```

2. Create a build directory and navigate into it:
Expand Down Expand Up @@ -53,43 +53,43 @@ To build and install the library, you will need [CMake](https://cmake.org/) vers

## Usage

Include the rstats header files in your project to use the library functions.
Include the incstats header files in your project to use the library functions.
Here is a brief overview of the available functions:

Running Mean
```C
inline void rstats_mean(double x, double w, double *buffer);
inline void rstats_mean_finalize(double *mean, double *buffer);
inline void incstats_mean(double x, double w, double *buffer);
inline void incstats_mean_finalize(double *mean, double *buffer);
```
Running Variance
```C
inline void rstats_variance(double x, double w, double *buffer);
inline void rstats_variance_finalize(double *results, double *buffer);
inline void incstats_variance(double x, double w, double *buffer);
inline void incstats_variance_finalize(double *results, double *buffer);
```

Running Skewness
```C
inline void rstats_skewness(double x, double w, double *buffer);
inline void rstats_skewness_finalize(double *results, double *buffer);
inline void incstats_skewness(double x, double w, double *buffer);
inline void incstats_skewness_finalize(double *results, double *buffer);
```
Running Kurtosis
```C
inline void rstats_kurtosis(double x, double w, double *buffer);
inline void rstats_kurtosis_finalize(double *results, double *buffer);
inline void incstats_kurtosis(double x, double w, double *buffer);
inline void incstats_kurtosis_finalize(double *results, double *buffer);
```

Central Moments
```C
inline void rstats_central_moment(double x, double w, double *buffer, uint64_t p);
inline void rstats_central_moment_finalize(double *results, double *buffer, uint64_t p, bool standardize);
inline void incstats_central_moment(double x, double w, double *buffer, uint64_t p);
inline void incstats_central_moment_finalize(double *results, double *buffer, uint64_t p, bool standardize);
```
Maximum and Minimum
```C
inline void rstats_max(double x, double *max);
inline void rstats_min(double x, double *min);
inline void incstats_max(double x, double *max);
inline void incstats_min(double x, double *min);
```


Expand All @@ -102,7 +102,7 @@ measures with minimal passes through the data.
**Example Usage in C**
```C
#include <stdio.h>
#include "rstats.h"
#include "incstats.h"

int main() {
double buffer[5] = {0}; // Initialize buffer for mean, variance, skewness, kurtosis
Expand All @@ -112,12 +112,12 @@ int main() {

// Update statistics with new values
for (int i = 0; i < 20; ++i) {
rstats_kurtosis(data[i], w, buffer); // This will also update mean, variance, and skewness
incstats_kurtosis(data[i], w, buffer); // This will also update mean, variance, and skewness
}

// Finalize and get results
double results[4];
rstats_kurtosis_finalize(results, buffer);
incstats_kurtosis_finalize(results, buffer);

printf("Mean: %f\n", results[0]);
printf("Variance: %f\n", results[1]);
Expand All @@ -133,7 +133,7 @@ int main() {

// Include the C header file with extern "C"
extern "C" {
#include "rstats.h"
#include "incstats.h"
}

int main() {
Expand All @@ -144,12 +144,12 @@ int main() {

// Update statistics with new values
for (int i = 0; i < 20; ++i) {
rstats_kurtosis(data[i], w, buffer); // This will also update mean, variance, and skewness
incstats_kurtosis(data[i], w, buffer); // This will also update mean, variance, and skewness
}

// Finalize and get results
double results[4];
rstats_kurtosis_finalize(results, buffer);
incstats_kurtosis_finalize(results, buffer);

std::cout << "Mean: " << results[0] << std::endl;
std::cout << "Variance: " << results[1] << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
add_subdirectory(rstats)
add_subdirectory(incstats)
28 changes: 14 additions & 14 deletions src/rstats/CMakeLists.txt → src/incstats/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
add_library(rstats SHARED src/rstats.c)
add_library(incstats SHARED src/incstats.c)
# Don't link math library under windows platforms as it causes an linker
# error with MSVC.
if(NOT WIN32)
target_link_libraries(rstats m)
target_link_libraries(incstats m)
endif()
# Define headers for this library. PUBLIC headers are used for
# compiling the library, and will be added to consumers' build
# paths.
target_include_directories(rstats
target_include_directories(incstats
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
Expand All @@ -19,30 +19,30 @@ target_include_directories(rstats
# target_link_libraries()

# 'make install' to the correct locations (provided by GNUInstallDirs).
install(TARGETS rstats EXPORT rstats-export
install(TARGETS incstats EXPORT incstats-export
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} # This is for Windows
)
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# this makes the project importable from the install directory
install(EXPORT rstats-export
install(EXPORT incstats-export
FILE
rstatsConfig.cmake
incstatsConfig.cmake
DESTINATION
${CMAKE_INSTALL_LIBDIR}/cmake/rstats
${CMAKE_INSTALL_LIBDIR}/cmake/incstats
)
# This makes the project importable from the build directory
export(TARGETS rstats FILE rstatsConfig.cmake)
export(TARGETS incstats FILE incstatsConfig.cmake)

# Every library has unit tests, of course
add_executable(testrstats test/test_rstats.c)
add_executable(testincstats test/test_incstats.c)

target_link_libraries(testrstats rstats)
#benchmarkrstats depends on sys/time.h which is not available on Winbdows systems.
target_link_libraries(testincstats incstats)
#benchmarkincstats depends on sys/time.h which is not available on Winbdows systems.
if(NOT WIN32)
add_executable(benchmarkrstats test/benchmark_rstats.c)
target_link_libraries(benchmarkrstats rstats)
add_executable(benchmarkincstats test/benchmark_incstats.c)
target_link_libraries(benchmarkincstats incstats)
endif()
add_test(testrstats testrstats)
add_test(testincstats testincstats)

Loading

0 comments on commit d813011

Please sign in to comment.