Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Statistics #5

Open
wants to merge 27 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
13c0b38
small_int_powers: min max in progress
mysiar Oct 29, 2022
d250188
small_int_powers: gslext.dep to be ignored
mysiar Oct 29, 2022
b569248
small_int_powers: done
mysiar Oct 30, 2022
a7159f8
statistics: GSL_stats_mean
mysiar Nov 12, 2022
37a6d77
Merge branch 'dev' of github.com:mysiar-org/php-ext-gsl into statistics
mysiar Nov 12, 2022
7351379
statistics: GSL_stats_mean removed n param, length of array is calcul…
mysiar Nov 13, 2022
2bea30e
statistics: added: gsl_stats_variance, gsl_stats_variance_m, gsl_stat…
mysiar Nov 13, 2022
36ec1ff
statistics: added: gsl_stats_absdev, gsl_stats_absdev_m
mysiar Nov 13, 2022
052291c
statistics: gh actions - test v3 of checkout & cache
mysiar Nov 13, 2022
5b331a7
statistics: added: gsl_stats_skew, gsl_stats_skew_m_sd, gsl_stats_kur…
mysiar Nov 13, 2022
e7e66dd
statistics: added: gsl_stats_correlation, gsl_stats_spearman
mysiar Nov 13, 2022
6eaa277
statistics: added: gsl_stats_wmean, gsl_stats_wvariance, gsl_stats_wv…
mysiar Nov 13, 2022
8ce04b5
statistics: added: gsl_stats_wvariance_with_fixed_mean, gsl_stats_wsd…
mysiar Nov 13, 2022
1a98384
statistics: added: gsl_stats_wskew, gsl_stats_wskew_m_sd, gsl_stats_w…
mysiar Nov 13, 2022
3d3c29b
statistics: added: gsl_stats_max, gsl_stats_min, gsl_stats_minmax, gs…
mysiar Nov 13, 2022
9b9fb00
statistics: added: gsl_stats_median_from_sorted_data, gsl_stats_media…
mysiar Nov 13, 2022
fab5457
statistics: gsl_stats_select
mysiar Nov 26, 2022
83c073e
statistics: gsl_stats_trmean_from_sorted_data
mysiar Nov 26, 2022
c31ab97
statistics: gsl_stats_gastwirth_from_sorted_data
mysiar Nov 26, 2022
c8464bb
statistics: gsl_stats_mad0 & gsl_stats_mad
mysiar Nov 26, 2022
d561917
statistics: gsl_stats_Sn0_from_sorted_data & gsl_stats_Sn_from_sorted…
mysiar Nov 26, 2022
dfddd01
statistics: gsl_stats_Qn0_from_sorted_data & gsl_stats_Qn_from_sorted…
mysiar Nov 26, 2022
f336a67
statistics: running statistcis without quantiles
mysiar Nov 26, 2022
70c8793
statistics: gsl_stats_Qn_from_sorted_data
mysiar Nov 26, 2022
a72ca48
statistics: gha artifacts
mysiar Nov 26, 2022
86f5b73
statistics: fixing tests
mysiar Nov 26, 2022
ec35ac9
statistics: gha update
mysiar Nov 26, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,24 @@ jobs:
name: 'Tests'
strategy:
matrix:
php: ['8.1.12']
php: ['8.1.13']

runs-on: 'ubuntu-20.04'
env:
PHP_VERSION: ${{ matrix.php }}
steps:
- name: 'Check out repository'
uses: 'actions/checkout@v2'
uses: 'actions/checkout@v3'
with:
path: 'php-ext-gsl'

- uses: actions/cache@v2
- uses: actions/cache@v3
if: ${{ always() }}
with:
path: ~/build-cache/php
key: ${{ runner.os }}-${{ matrix.php }}
restore-keys: |
${{ runner.os }}-${{ matrix.php }}

- name: 'Build PHP'
run: './php-ext-gsl/.github/workflows/test/build-php.sh'
Expand All @@ -37,4 +40,15 @@ jobs:
run: './php-ext-gsl/.github/workflows/test/build-php-ext-gsl.sh'

- name: 'Run tests'
run: './php-ext-gsl/.github/workflows/test/tests.sh'
run: './php-ext-gsl/.github/workflows/test/tests.sh'

- name: Archive test errors
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: test-errors
path: php-ext-gsl/tests/*.diff
retention-days: 5
- name: Download all workflow run artifacts
if: ${{ failure() }}
uses: actions/download-artifact@v3
2 changes: 1 addition & 1 deletion .github/workflows/test/build-php-ext-gsl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ php --version
cd php-ext-gsl

phpize
./configure
./configure --with-gsl CFLAGS="$CFLAGS -Wno-implicit-function-declaration"
php -dmemory_limit=-1 build/gen_stub.php --force-regeneration
sed -i 's/$user_input = fgets($fp, 10);/$user_input = "s";/g' run-tests.php
make
25 changes: 25 additions & 0 deletions CMakeList.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
cmake_minimum_required(VERSION 3.8)
project(gslext C)

set(SOURCE_FILES gslext gslext.c)

execute_process (
COMMAND php-config --include-dir
OUTPUT_VARIABLE PHP_SOURCE
)
string(REGEX REPLACE "\n$" "" PHP_SOURCE "${PHP_SOURCE}")

message("Using source directory: ${PHP_SOURCE}")

include_directories(${PHP_SOURCE})
include_directories(${PHP_SOURCE}/main)
include_directories(${PHP_SOURCE}/Zend)
include_directories(${PHP_SOURCE}/TSRM)
include_directories(${PROJECT_SOURCE_DIR})

add_custom_target(configure
COMMAND phpize && ./configure
DEPENDS ${SOURCE_FILES}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})

add_library(___ EXCLUDE_FROM_ALL ${SOURCE_FILES})
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
# PHP Extension for GNU Scientific Library (GSL)

## TODO
* refactor all functions from GSL_ to gsl_
* refactor to use helper instead converting in each function

## GSL coverage
* [Mathematical Constants](https://www.gnu.org/software/gsl/doc/html/math.html#mathematical-constants)
* [Elementary Functions](https://www.gnu.org/software/gsl/doc/html/math.html#elementary-functions)
* [Small integer powers](https://www.gnu.org/software/gsl/doc/html/math.html#small-integer-powers)
* [Testing for Odd and Even Numbers](https://www.gnu.org/software/gsl/doc/html/math.html#testing-for-odd-and-even-numbers)
* [Maximum and Minimum functions](https://www.gnu.org/software/gsl/doc/html/math.html#maximum-and-minimum-functions)
* [Approximate Comparison of Floating Point Numbers](https://www.gnu.org/software/gsl/doc/html/math.html#approximate-comparison-of-floating-point-numbers)
* []()
* []()
* []()
* []()
* []()
* [Statistics](https://www.gnu.org/software/gsl/doc/html/statistics.html)
* [Running Statistics](https://www.gnu.org/software/gsl/doc/html/rstat.html)

Full list of functions in [PHP stub file](gslext.stub.php)

## Tests
* tests in this extension are only to check if functions are working. Correctness of calculations relays on library
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
make distclean
phpize
./configure --with-gsl
./configure --with-gsl CFLAGS="$CFLAGS -Wno-implicit-function-declaration"
php -dmemory_limit=-1 build/gen_stub.php --force-regeneration
sed -i 's/$user_input = fgets($fp, 10);/$user_input = "s";/g' run-tests.php
make && make test
Expand Down
4 changes: 4 additions & 0 deletions gslext.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@
#endif

#include "php.h"
#include "php_ini.h"
#include "zend_exceptions.h"
#include "ext/standard/info.h"
#include "php_gslext.h"
#include "gslext_arginfo.h"

#include "gslext_helpers.c"

#include "inc/_functions.inc"

/* For compatibility with older PHP versions */
Expand Down
68 changes: 68 additions & 0 deletions gslext.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,71 @@ function GSL_max_float(float $a, float $b): float {}

// fcmp
function GSL_fcmp(float $x, float $y, float $epsilon): int {}

// Statistics
function gsl_stats_mean(array $data, int $stride): float {}
function gsl_stats_variance(array $data, int $stride): float {}
function gsl_stats_variance_m(array $data, int $stride, float $mean): float {}
function gsl_stats_sd(array $data, int $stride): float {}
function gsl_stats_tss(array $data, int $stride): float {}
function gsl_stats_tss_m(array $data, int $stride, float $mean): float {}
function gsl_stats_variance_with_fixed_mean(array $data, int $stride, float $mean): float {}
function gsl_stats_sd_with_fixed_mean(array $data, int $stride, float $mean): float {}
function gsl_stats_absdev(array $data, int $stride): float {}
function gsl_stats_absdev_m(array $data, int $stride, float $mean): float {}
function gsl_stats_skew(array $data, int $stride): float {}
function gsl_stats_skew_m_sd(array $data, int $stride, float $mean, float $sd): float {}
function gsl_stats_kurtosis(array $data, int $stride): float {}
function gsl_stats_kurtosis_m_sd(array $data, int $stride, float $mean, float $sd): float {}
function gsl_stats_lag1_autocorrelation(array $data, int $stride): float {}
function gsl_stats_lag1_autocorrelation_m(array $data, int $stride, float $mean): float {}
function gsl_stats_covariance(array $data1, int $stride1, array $data2, int $stride2): float {}
function gsl_stats_covariance_m(array $data1, int $stride1, array $data2, int $stride2, float $mean1, float $mean2): float {}
function gsl_stats_correlation(array $data1, int $stride1, array $data2, int $stride2): float {}
function gsl_stats_spearman(array $data1, int $stride1, array $data2, int $stride2, array $work): float {}
function gsl_stats_wmean(array $w, int $wstride, array $data, int $stride): float {}
function gsl_stats_wvariance(array $w, int $wstride, array $data, int $stride): float {}
function gsl_stats_wvariance_m(array $w, int $wstride, array $data, int $stride, float $wmean): float {}
function gsl_stats_wsd(array $w, int $wstride, array $data, int $stride): float {}
function gsl_stats_wsd_m(array $w, int $wstride, array $data, int $stride, float $wmean): float {}
function gsl_stats_wvariance_with_fixed_mean(array $w, int $wstride, array $data, int $stride, float $mean): float {}
function gsl_stats_wsd_with_fixed_mean(array $w, int $wstride, array $data, int $stride, float $mean): float {}
function gsl_stats_wtss(array $w, int $wstride, array $data, int $stride): float {}
function gsl_stats_wtss_m(array $w, int $wstride, array $data, int $stride, float $mean): float {}
function gsl_stats_wabsdev(array $w, int $wstride, array $data, int $stride): float {}
function gsl_stats_wabsdev_m(array $w, int $wstride, array $data, int $stride, float $mean): float {}
function gsl_stats_wskew(array $w, int $wstride, array $data, int $stride): float {}
function gsl_stats_wskew_m_sd(array $w, int $wstride, array $data, int $stride, float $wmean, float $wds): float {}
function gsl_stats_wkurtosis(array $w, int $wstride, array $data, int $stride): float {}
function gsl_stats_wkurtosis_m_sd(array $w, int $wstride, array $data, int $stride, float $wmean, float $wds): float {}
function gsl_stats_max(array $data, int $stride): float {}
function gsl_stats_min(array $data, int $stride): float {}
function gsl_stats_minmax(float &$min, float &$max, array $data, int $stride): void {}
function gsl_stats_min_index(array $data, int $stride): int {}
function gsl_stats_max_index(array $data, int $stride): int {}
function gsl_stats_minmax_index(int &$min_index, int &$max_index, array $data, int $stride): void {}
function gsl_stats_median_from_sorted_data(array $sorted_data, int $stride): float {}
function gsl_stats_median(array $data, int $stride): float {}
function gsl_stats_quantile_from_sorted_data(array $sorted_data, int $stride, float $f): float {}
function gsl_stats_select(array $data, int $stride, int $k): float {}
function gsl_stats_trmean_from_sorted_data(float $alpha, array $sorted_data, int $stride): float {}
function gsl_stats_gastwirth_from_sorted_data(array $sorted_data, int $stride): float {}
function gsl_stats_mad0(array $data, int $stride): float {}
function gsl_stats_mad(array $data, int $stride): float {}
function gsl_stats_Sn0_from_sorted_data(array $sorted_data, int $stride): float {}
function gsl_stats_Sn_from_sorted_data(array $sorted_data, int $stride): float {}
function gsl_stats_Qn0_from_sorted_data(array $sorted_data, int $stride): float {}
function gsl_stats_Qn_from_sorted_data(array $sorted_data, int $stride): float {}

// Running Statistics
function gsl_rstat_min(array $data): float {}
function gsl_rstat_max(array $data): float {}
function gsl_rstat_mean(array $data): float {}
function gsl_rstat_variance(array $data): float {}
function gsl_rstat_sd(array $data): float {}
function gsl_rstat_sd_mean(array $data): float {}
function gsl_rstat_rms(array $data): float {}
function gsl_rstat_skew(array $data): float {}
function gsl_rstat_kurtosis(array $data): float {}
function gsl_rstat_median(array $data): float {}
function gsl_rstat_quantile_get(array $data, float $factor): float {}
Loading