Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b0787e7
Move .clang-format to top level
steppi Mar 9, 2025
1b9e8d0
Add CMakeLists files for testing
steppi Mar 9, 2025
ab25a3b
Add catch generator for test cases from parquet files
steppi Mar 9, 2025
1771bad
Change the inputs for test case generator wrapper
steppi Mar 9, 2025
e944a55
Update .gitignore with CMake stuff
steppi Mar 10, 2025
ba4dad4
Check in working stub catch2 config
steppi Mar 10, 2025
5a3eb93
Add .tcl to gitignore for DartConfiguration.tcl
steppi Mar 10, 2025
391114e
Automatically pick up tests
steppi Mar 10, 2025
c3402fb
Add .test extension to .gitignore
steppi Mar 10, 2025
d632644
Check in working test_hyp2f1 example
steppi Mar 11, 2025
06cb79e
Update INFO string to match what CAPTURE would do if it worked well
steppi Mar 11, 2025
bc4ca96
Adjust function to add wiggle room to tolerance
steppi Mar 11, 2025
9476b85
Add real hyp2f1 tests
steppi Mar 11, 2025
6f1fcbd
Try to add a github workflow for initial tests
steppi Mar 11, 2025
77eee1b
Try to make workflow work in CI
steppi Mar 11, 2025
ab37967
Add missing :
steppi Mar 11, 2025
97af811
Checkout xsref from my fork since relevant PR not merged yet
steppi Mar 11, 2025
dc7edcb
Update how arrow is installed in workflow
steppi Mar 11, 2025
e2504ea
Use apt-get instead of apt because apt has unstable API
steppi Mar 11, 2025
42814b2
Add missing apt-get update
steppi Mar 11, 2025
74aab45
Fix typo
steppi Mar 11, 2025
63c5c0a
Try to figure out this directory stuff
steppi Mar 11, 2025
6f7f150
Trying more stuff
steppi Mar 11, 2025
f407e40
Make sure xsf repo is checked out
steppi Mar 11, 2025
5fb1dbd
Put XSREF_TABLES_PATH in right spot
steppi Mar 11, 2025
4f76610
Add XSREF_TABLES_PATH as environment variable
steppi Mar 12, 2025
e8447e5
Stub out get_platform_str instead of hard coding platform
steppi Mar 25, 2025
48d659f
TST: Add scipy_special_tests
steppi Apr 4, 2025
e5e12d6
BUG: Make fixes to get tests to pass
steppi Apr 4, 2025
d967f88
MAINT: Change workflow to checkout xsref from main
steppi Apr 4, 2025
c096091
MAINT: Check xsref org from fork to scipy
steppi Apr 4, 2025
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
File renamed without changes.
71 changes: 63 additions & 8 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,65 @@
name: Linux Tests

on:
push:
branches:
- main
- catch-test-setup
pull_request:
- main
- catch-test-setup
on: [ push, pull_request ]

permissions:
contents: read # to fetch code (actions/checkout)

env:
CCACHE_DIR: "${{ github.workspace }}/.ccache"
INSTALLDIR: "build-install"

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
gcc_x86_64_linux:
name: GCC X86_64 Linux
runs-on: ubuntu-22.04
env:
XSREF_TABLES_PATH: "${{ github.workspace }}/xsref/tables"

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Checkout xsref
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
repository: 'scipy/xsref'
path: 'xsref'
ref: 'main'

- name: Checkout Catch2
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
repository: 'catchorg/Catch2'
path: 'Catch2'
ref: 'v3.8.0'

- name: Install Ubuntu dependencies
run: |
sudo apt-get update
wget https://apache.jfrog.io/artifactory/arrow/$(lsb_release --id --short | tr 'A-Z' 'a-z')/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
sudo apt-get install -y -V ./apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
sudo apt-get update
sudo apt-get install -y -V libarrow-dev # For C++
sudo apt-get install -y -V libarrow-glib-dev # For GLib (C)
sudo apt-get install -y -V libarrow-dataset-dev # For Apache Arrow Dataset C++
sudo apt-get install -y -V libparquet-dev # For Apache Parquet C++
sudo apt-get install -y -V libparquet-glib-dev # For Apache Parquet GLib (C)
sudo apt-get install -y libzstd-dev ccache

- name: Install Catch2
run: |
cmake -Bbuild -H. -DBUILD_TESTING=OFF
sudo cmake --build build/ --target install
working-directory: ./Catch2

- name: Configure and build
run: |
cmake .
make

- name: run tests
run: |
ctest --output-on-failure
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,22 @@
*.exe
*.out
*.app

# CMake stuff
CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps
CMakeUserPresets.json
*.cmake
DartConfiguration.tcl

# test executable extension
*.test
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.14)
project(xsf)

# Scipy is restricted to C++17
# https://docs.scipy.org/doc/scipy/dev/toolchain.html#c-language-standards
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Tests
enable_testing()
add_subdirectory(tests)
139 changes: 70 additions & 69 deletions include/xsf/cephes/cbrt.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,80 +52,81 @@ namespace cephes {

namespace detail {

constexpr double CBRT2 = 1.2599210498948731647672;
constexpr double CBRT4 = 1.5874010519681994747517;
constexpr double CBRT2I = 0.79370052598409973737585;
constexpr double CBRT4I = 0.62996052494743658238361;
inline constexpr double CBRT2 = 1.2599210498948731647672;
inline constexpr double CBRT4 = 1.5874010519681994747517;
inline constexpr double CBRT2I = 0.79370052598409973737585;
inline constexpr double CBRT4I = 0.62996052494743658238361;

XSF_HOST_DEVICE inline double cbrt(double x) {
int e, rem, sign;
double z;
}

if (!std::isfinite(x)) {
return x;
}
if (x == 0) {
return (x);
}
if (x > 0) {
sign = 1;
} else {
sign = -1;
x = -x;
}
XSF_HOST_DEVICE inline double cbrt(double x) {
int e, rem, sign;
double z;

z = x;
/* extract power of 2, leaving
* mantissa between 0.5 and 1
*/
x = std::frexp(x, &e);
if (!std::isfinite(x)) {
return x;
}
if (x == 0) {
return (x);
}
if (x > 0) {
sign = 1;
} else {
sign = -1;
x = -x;
}

z = x;
/* extract power of 2, leaving
* mantissa between 0.5 and 1
*/
x = std::frexp(x, &e);

/* Approximate cube root of number between .5 and 1,
* peak relative error = 9.2e-6
*/
x = (((-1.3466110473359520655053e-1 * x + 5.4664601366395524503440e-1) * x - 9.5438224771509446525043e-1) *
x +
1.1399983354717293273738e0) *
x +
4.0238979564544752126924e-1;

/* exponent divided by 3 */
if (e >= 0) {
rem = e;
e /= 3;
rem -= 3 * e;
if (rem == 1) {
x *= detail::CBRT2;
} else if (rem == 2) {
x *= detail::CBRT4;
}
}
/* argument less than 1 */
else {
e = -e;
rem = e;
e /= 3;
rem -= 3 * e;
if (rem == 1) {
x *= detail::CBRT2I;
} else if (rem == 2) {
x *= detail::CBRT4I;
}
e = -e;
}

/* Approximate cube root of number between .5 and 1,
* peak relative error = 9.2e-6
*/
x = (((-1.3466110473359520655053e-1 * x + 5.4664601366395524503440e-1) * x - 9.5438224771509446525043e-1) *
x +
1.1399983354717293273738e0) *
x +
4.0238979564544752126924e-1;
/* multiply by power of 2 */
x = std::ldexp(x, e);

/* Newton iteration */
x -= (x - (z / (x * x))) * 0.33333333333333333333;
x -= (x - (z / (x * x))) * 0.33333333333333333333;

/* exponent divided by 3 */
if (e >= 0) {
rem = e;
e /= 3;
rem -= 3 * e;
if (rem == 1) {
x *= CBRT2;
} else if (rem == 2) {
x *= CBRT4;
}
}
/* argument less than 1 */
else {
e = -e;
rem = e;
e /= 3;
rem -= 3 * e;
if (rem == 1) {
x *= CBRT2I;
} else if (rem == 2) {
x *= CBRT4I;
}
e = -e;
}

/* multiply by power of 2 */
x = std::ldexp(x, e);

/* Newton iteration */
x -= (x - (z / (x * x))) * 0.33333333333333333333;
x -= (x - (z / (x * x))) * 0.33333333333333333333;

if (sign < 0)
x = -x;
return (x);
}
} // namespace detail
if (sign < 0)
x = -x;
return (x);
}

} // namespace cephes
} // namespace xsf
2 changes: 2 additions & 0 deletions include/xsf/cephes/exp10.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
#include "../config.h"
#include "../error.h"

#include "polevl.h"

namespace xsf {
namespace cephes {

Expand Down
4 changes: 2 additions & 2 deletions include/xsf/cephes/gdtr.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ namespace cephes {
XSF_HOST_DEVICE inline double gdtr(double a, double b, double x) {

if (x < 0.0) {
sf_error("gdtr", SF_ERROR_DOMAIN, NULL);
set_error("gdtr", SF_ERROR_DOMAIN, NULL);
return (std::numeric_limits<double>::quiet_NaN());
}
return (igam(b, a * x));
Expand All @@ -129,7 +129,7 @@ namespace cephes {
XSF_HOST_DEVICE inline double gdtri(double a, double b, double y) {

if ((y < 0.0) || (y > 1.0) || (a <= 0.0) || (b < 0.0)) {
sf_error("gdtri", SF_ERROR_DOMAIN, NULL);
set_error("gdtri", SF_ERROR_DOMAIN, NULL);
return (std::numeric_limits<double>::quiet_NaN());
}

Expand Down
1 change: 1 addition & 0 deletions include/xsf/cephes/ndtr.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
#pragma once

#include "../config.h"
#include "../error.h"

#include "const.h"
#include "polevl.h"
Expand Down
20 changes: 10 additions & 10 deletions include/xsf/cephes/shichi.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ namespace cephes {
} // namespace detail

/* Sine and cosine integrals */
XSF_HOST_DEVICE inline int shichi(double x, double *si, double *ci) {
XSF_HOST_DEVICE inline int shichi(double x, double &si, double &ci) {
double k, z, c, s, a, b;
short sign;

Expand All @@ -163,8 +163,8 @@ namespace cephes {
}

if (x == 0.0) {
*si = 0.0;
*ci = -std::numeric_limits<double>::infinity();
si = 0.0;
ci = -std::numeric_limits<double>::infinity();
return (0);
}

Expand Down Expand Up @@ -216,20 +216,20 @@ namespace cephes {

asymp:
if (x > 1000) {
*si = std::numeric_limits<double>::infinity();
*ci = std::numeric_limits<double>::infinity();
si = std::numeric_limits<double>::infinity();
ci = std::numeric_limits<double>::infinity();
} else {
/* Asymptotic expansions
* http://functions.wolfram.com/GammaBetaErf/CoshIntegral/06/02/
* http://functions.wolfram.com/GammaBetaErf/SinhIntegral/06/02/0001/
*/
a = detail::hyp3f0(0.5, 1, 1, 4.0 / (x * x));
b = detail::hyp3f0(1, 1, 1.5, 4.0 / (x * x));
*si = std::cosh(x) / x * a + std::sinh(x) / (x * x) * b;
*ci = std::sinh(x) / x * a + std::cosh(x) / (x * x) * b;
si = std::cosh(x) / x * a + std::sinh(x) / (x * x) * b;
ci = std::sinh(x) / x * a + std::cosh(x) / (x * x) * b;
}
if (sign) {
*si = -*si;
si = -si;
}
return 0;

Expand All @@ -238,9 +238,9 @@ namespace cephes {
s = -s;
}

*si = s;
si = s;

*ci = detail::SCIPY_EULER + std::log(x) + c;
ci = detail::SCIPY_EULER + std::log(x) + c;
return (0);
}

Expand Down
Loading