Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: boostmath
Title: 'R' Bindings for the 'Boost' Math Functions
Version: 1.3.0
Version: 1.4.0
Authors@R:
person(c("Andrew", "R."), "Johnson", , "andrew.johnson@arjohnsonau.com", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-7000-8065"))
Expand All @@ -16,7 +16,7 @@ Depends:
R (>= 3.0.2)
LinkingTo:
cpp11,
BH (>= 1.87.0)
BH (>= 1.90.0)
NeedsCompilation: yes
Suggests:
knitr,
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,8 @@ export(logistic_lcdf)
export(logistic_lpdf)
export(logistic_pdf)
export(logistic_quantile)
export(logistic_sigmoid)
export(logit)
export(lognormal_cdf)
export(lognormal_distribution)
export(lognormal_lcdf)
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# boostmath 1.4.0
* Added `logit` and `logistic_sigmoid` functions
* Added `log_pi` constant
* Ooura fourier integrals now supported on platforms without long double support

# boostmath 1.3.0
* Added support for all Boost distribution functions (e.g., `pdf`, `kurtosis`, `variance`, etc.)
* Exposed additional distribution utility functions (e.g., `binomial_find_lower_bound_on_p`, `chi_squared_find_degrees_of_freedom`)
Expand Down
25 changes: 25 additions & 0 deletions R/logistic_functions.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#' @title Logistic Functions
#' @name logistic_functions
#' @description Functions to compute the logit and logistic sigmoid functions
#' @seealso [Boost Documentation](https://www.boost.org/doc/libs/latest/libs/math/doc/html/math_toolkit/logistic.html)
#' for more details on the mathematical background.
#' @param x Numeric value for which to compute the functions
#' @return A single numeric value with the computed logit or logistic sigmoid function.
#' @examples
#' # Logistic Sigmoid Function
#' logistic_sigmoid(0.5)
#' # Logit Function
#' logit(0.7)
NULL

#' @rdname logistic_functions
#' @export
logistic_sigmoid <- function(x) {
.Call(`logistic_sigmoid_`, x)
}

#' @rdname logistic_functions
#' @export
logit <- function(x) {
.Call(`logit_`, x)
}
2 changes: 0 additions & 2 deletions R/quadrature_and_differentiation.R
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,10 @@ exp_sinh <- function(f, a, b, tol = sqrt(.Machine$double.eps), max_refinements =
#' @param levels The number of levels of refinement to apply. Default is 8.
#' @return A single numeric value with the computed Fourier sine or cosine integral, with attribute 'relative_error' indicating the relative error of the approximation.
#' @examples
#' \dontrun{
#' # Fourier sine integral of sin(x) with omega = 1
#' ooura_fourier_sin(function(x) { 1 / x }, omega = 1)
#' # Fourier cosine integral of cos(x) with omega = 1
#' ooura_fourier_cos(function(x) { 1/ (x * x + 1) }, omega = 1)
#' }
NULL

#' @rdname ooura_fourier_integrals
Expand Down
31 changes: 31 additions & 0 deletions man/logistic_functions.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions man/ooura_fourier_integrals.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/Makevars
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ OBJECTS = $(SOURCES:.cpp=.o)
BOOST_SOURCES = \
constants.cpp \
filters.cpp \
bezier_polynomial.cpp \
interpolators.cpp \
quadrature_and_differentiation.cpp \
rootfinding_and_minimisation.cpp \
Expand Down
7 changes: 7 additions & 0 deletions src/bezier_polynomial.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <boost/math/interpolators/bezier_polynomial.hpp>
#include "boostmath/macros.hpp"

POLYNOMIAL_UNARY_INIT_BOOST(bezier_polynomial, std::vector<std::array<double COMMA 3>>, std::vector<std::array<double COMMA 3>>)
POLYNOMIAL_UNARY_EVAL_BOOST(bezier_polynomial, std::vector<std::array<double COMMA 3>>, double)
POLYNOMIAL_UNARY_CALL_BOOST(bezier_polynomial, prime, std::vector<std::array<double COMMA 3>>, double)
POLYNOMIAL_BINARY_CALL_VOID_BOOST(bezier_polynomial, edit_control_point, std::vector<std::array<double COMMA 3>>, std::array<double COMMA 3>, std::size_t)
1 change: 1 addition & 0 deletions src/boostmath/macros.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef BOOSTMATH_MACROS_HPP
#define BOOSTMATH_MACROS_HPP

#include <cpp11/declarations.hpp>
#include "sexp.hpp"

#define NOARG_BOOST_MEMBER(name) \
Expand Down
1 change: 1 addition & 0 deletions src/constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ extern "C" SEXP constants_() {
constants.push_back({"four_thirds_pi"_nm = boost::math::constants::four_thirds_pi<double>()});
constants.push_back({"one_div_two_pi"_nm = boost::math::constants::one_div_two_pi<double>()});
constants.push_back({"one_div_root_two_pi"_nm = boost::math::constants::one_div_root_two_pi<double>()});
constants.push_back({"log_pi"_nm = boost::math::constants::log_pi<double>()});
constants.push_back({"root_pi"_nm = boost::math::constants::root_pi<double>()});
constants.push_back({"root_half_pi"_nm = boost::math::constants::root_half_pi<double>()});
constants.push_back({"root_two_pi"_nm = boost::math::constants::root_two_pi<double>()});
Expand Down
3 changes: 0 additions & 3 deletions src/cyl_hankel_1.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#include <cpp11.hpp>
#include <cpp11/declarations.hpp>
#include <boost/math/special_functions/hankel.hpp>
#include "boostmath/sexp.hpp"
#include "boostmath/macros.hpp"

BINARY_BOOST_FUNCTION(cyl_hankel_1, double, double)
3 changes: 0 additions & 3 deletions src/cyl_hankel_2.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#include <cpp11.hpp>
#include <cpp11/declarations.hpp>
#include <boost/math/special_functions/hankel.hpp>
#include "boostmath/sexp.hpp"
#include "boostmath/macros.hpp"

BINARY_BOOST_FUNCTION(cyl_hankel_2, double, double)
2 changes: 0 additions & 2 deletions src/distribution_member_functions.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include <cpp11.hpp>
#include <cpp11/declarations.hpp>
#include <boost/math/distributions.hpp>
#include "boostmath/macros.hpp"

Expand Down
3 changes: 0 additions & 3 deletions src/fp_utilities.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
#include <cpp11.hpp>
#include <cpp11/declarations.hpp>
#include <boost/math/special_functions/next.hpp>
#include <boost/math/special_functions/ulp.hpp>
#include <boost/math/special_functions/relative_difference.hpp>
#include <boost/math/tools/condition_numbers.hpp>
#include "boostmath/sexp.hpp"
#include "boostmath/macros.hpp"

UNARY_BOOST_FUNCTION(float_next, double)
Expand Down
8 changes: 8 additions & 0 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ extern "C" {
SEXP jacobi_prime_(SEXP n_, SEXP alpha_, SEXP beta_, SEXP x_);
SEXP jacobi_double_prime_(SEXP n_, SEXP alpha_, SEXP beta_, SEXP x_);

// logistic_functions.cpp
SEXP logit_(SEXP x_);
SEXP logistic_sigmoid_(SEXP x_);

// bessel_functions.cpp
SEXP cyl_bessel_j_(SEXP v_, SEXP x_);
SEXP cyl_neumann_(SEXP v_ , SEXP x_);
Expand Down Expand Up @@ -584,6 +588,10 @@ extern "C" {
{"jacobi_prime_", (DL_FUNC) &jacobi_prime_, 4},
{"jacobi_double_prime_", (DL_FUNC) &jacobi_double_prime_, 4},

// logistic_functions.cpp
{"logit_", (DL_FUNC) &logit_, 1},
{"logistic_sigmoid_", (DL_FUNC) &logistic_sigmoid_, 1},

// bessel_functions.cpp
{"cyl_bessel_j_", (DL_FUNC) &cyl_bessel_j_, 2},
{"cyl_neumann_", (DL_FUNC) &cyl_neumann_, 2},
Expand Down
11 changes: 1 addition & 10 deletions src/interpolators.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
#include <cpp11.hpp>
#include <cpp11/declarations.hpp>
#include "boostmath/macros.hpp"
#include <boost/math/interpolators/barycentric_rational.hpp>
#include <boost/math/interpolators/bezier_polynomial.hpp>
#include <boost/math/interpolators/bilinear_uniform.hpp>
#include <boost/math/interpolators/cardinal_cubic_b_spline.hpp>
#include <boost/math/interpolators/cardinal_quadratic_b_spline.hpp>
Expand All @@ -13,16 +9,12 @@
#include <boost/math/interpolators/pchip.hpp>
#include <boost/math/interpolators/quintic_hermite.hpp>
#include <boost/math/interpolators/whittaker_shannon.hpp>
#include "boostmath/macros.hpp"

POLYNOMIAL_TERNARY_INIT_BOOST(barycentric_rational, double, std::vector<double>, std::vector<double>, std::size_t)
POLYNOMIAL_UNARY_EVAL_BOOST(barycentric_rational, double, double)
POLYNOMIAL_UNARY_CALL_BOOST(barycentric_rational, prime, double, double)

POLYNOMIAL_UNARY_INIT_BOOST(bezier_polynomial, std::vector<std::array<double COMMA 3>>, std::vector<std::array<double COMMA 3>>)
POLYNOMIAL_UNARY_EVAL_BOOST(bezier_polynomial, std::vector<std::array<double COMMA 3>>, double)
POLYNOMIAL_UNARY_CALL_BOOST(bezier_polynomial, prime, std::vector<std::array<double COMMA 3>>, double)
POLYNOMIAL_BINARY_CALL_VOID_BOOST(bezier_polynomial, edit_control_point, std::vector<std::array<double COMMA 3>>, std::array<double COMMA 3>, std::size_t)

POLYNOMIAL_HEPTA_INIT_BOOST(bilinear_uniform, std::vector<double>, std::vector<double>, size_t, size_t, double, double, double, double)
POLYNOMIAL_BINARY_EVAL_BOOST(bilinear_uniform, std::vector<double>, double, double)

Expand Down Expand Up @@ -83,4 +75,3 @@ POLYNOMIAL_NOARG_CALL_BOOST(cardinal_quintic_hermite, domain, std::vector<double
POLYNOMIAL_TERNARY_INIT_BOOST(whittaker_shannon, std::vector<double>, std::vector<double>, double, double)
POLYNOMIAL_UNARY_EVAL_BOOST(whittaker_shannon, std::vector<double>, double)
POLYNOMIAL_UNARY_CALL_BOOST(whittaker_shannon, prime, std::vector<double>, double)

12 changes: 0 additions & 12 deletions src/quadrature_and_differentiation/fourier_integrals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

extern "C" {
SEXP ooura_fourier_sin_(SEXP f_, SEXP omega_, SEXP relative_error_tolerance_, SEXP levels_) {
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
std::pair<double, double> result_pair = {std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN()};
SEXP err = R_NilValue;
char buf[8192] = "";
Expand Down Expand Up @@ -35,15 +34,9 @@ extern "C" {
result.push_back(std::move(result_pair.first));
result.attr("relative_error") = std::move(result_pair.second);
return cpp11::as_sexp(result);
#else
BEGIN_CPP11
cpp11::stop("Ooura Fourier integrals are not supported on this platform as they require long double precision");
END_CPP11
#endif
}

SEXP ooura_fourier_cos_(SEXP f_, SEXP omega_, SEXP relative_error_tolerance_, SEXP levels_) {
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
std::pair<double, double> result_pair = {std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN()};
SEXP err = R_NilValue;
char buf[8192] = "";
Expand Down Expand Up @@ -74,10 +67,5 @@ extern "C" {
result.push_back(std::move(result_pair.first));
result.attr("relative_error") = std::move(result_pair.second);
return cpp11::as_sexp(result);
#else
BEGIN_CPP11
cpp11::stop("Ooura Fourier integrals are not supported on this platform as they require long double precision");
END_CPP11
#endif
}
}
2 changes: 0 additions & 2 deletions src/rootfinding_and_minimisation/polynomial_roots.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include <cpp11.hpp>
#include <cpp11/declarations.hpp>
#include <boost/math/tools/cubic_roots.hpp>
#include <boost/math/tools/quartic_roots.hpp>
#include <boost/math/tools/roots.hpp>
Expand Down
1 change: 0 additions & 1 deletion src/rootfinding_and_minimisation/with_derivatives.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <cpp11.hpp>
#include <cpp11/declarations.hpp>
#include <boost/math/tools/roots.hpp>
#include "../boostmath/sexp.hpp"
Expand Down
1 change: 0 additions & 1 deletion src/rootfinding_and_minimisation/without_derivatives.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <cpp11.hpp>
#include <cpp11/declarations.hpp>
#include <boost/math/tools/roots.hpp>

Expand Down
1 change: 1 addition & 0 deletions src/special_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "special_functions/jacobi_elliptic_functions.cpp"
#include "special_functions/jacobi_theta_functions.cpp"
#include "special_functions/lambert_w_function.cpp"
#include "special_functions/logistic_functions.cpp"
#include "special_functions/number_series.cpp"
#include "special_functions/owens_t_function.cpp"
#include "special_functions/polynomials.cpp"
Expand Down
2 changes: 0 additions & 2 deletions src/special_functions/airy_functions.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include <cpp11.hpp>
#include <cpp11/declarations.hpp>
#include <boost/math/special_functions/airy.hpp>
#include "../boostmath/macros.hpp"

Expand Down
2 changes: 0 additions & 2 deletions src/special_functions/basic_functions.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include <cpp11.hpp>
#include <cpp11/declarations.hpp>
#include <boost/math/special_functions/sin_pi.hpp>
#include <boost/math/special_functions/cos_pi.hpp>
#include <boost/math/special_functions/log1p.hpp>
Expand Down
2 changes: 0 additions & 2 deletions src/special_functions/bessel_functions.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include <cpp11.hpp>
#include <cpp11/declarations.hpp>
#include <boost/math/special_functions/bessel.hpp>
#include <boost/math/special_functions/bessel_prime.hpp>
#include "../boostmath/macros.hpp"
Expand Down
2 changes: 0 additions & 2 deletions src/special_functions/beta_functions.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include <cpp11.hpp>
#include <cpp11/declarations.hpp>
#include <boost/math/special_functions/beta.hpp>
#include "../boostmath/macros.hpp"

Expand Down
2 changes: 0 additions & 2 deletions src/special_functions/elliptic_integrals.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include <cpp11.hpp>
#include <cpp11/declarations.hpp>
#include <boost/math/special_functions/ellint_rf.hpp>
#include <boost/math/special_functions/ellint_rd.hpp>
#include <boost/math/special_functions/ellint_rj.hpp>
Expand Down
2 changes: 0 additions & 2 deletions src/special_functions/error_functions.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include <cpp11.hpp>
#include <cpp11/declarations.hpp>
#include <boost/math/special_functions/erf.hpp>
#include "../boostmath/macros.hpp"

Expand Down
2 changes: 0 additions & 2 deletions src/special_functions/exponential_integrals.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include <cpp11.hpp>
#include <cpp11/declarations.hpp>
#include <boost/math/special_functions/expint.hpp>
#include "../boostmath/macros.hpp"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include <cpp11.hpp>
#include <cpp11/declarations.hpp>
#include <boost/math/special_functions/factorials.hpp>
#include <boost/math/special_functions/binomial.hpp>
#include "../boostmath/macros.hpp"
Expand Down
2 changes: 0 additions & 2 deletions src/special_functions/gamma_functions.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include <cpp11.hpp>
#include <cpp11/declarations.hpp>
#include <boost/math/special_functions/gamma.hpp>
#include <boost/math/special_functions/digamma.hpp>
#include <boost/math/special_functions/trigamma.hpp>
Expand Down
5 changes: 1 addition & 4 deletions src/special_functions/hypergeometric_functions.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include <cpp11.hpp>
#include <cpp11/declarations.hpp>
#include <boost/math/special_functions/hypergeometric_1F0.hpp>
#include <boost/math/special_functions/hypergeometric_0F1.hpp>
#include <boost/math/special_functions/hypergeometric_2F0.hpp>
Expand All @@ -20,9 +18,8 @@ extern "C" SEXP log_hypergeometric_1F1_(SEXP a_, SEXP b_, SEXP z_) {
const double b = cpp11::as_cpp<double>(b_);
const double z = cpp11::as_cpp<double>(z_);
int value_sign;
const double value = boost::math::log_hypergeometric_1F1(a, b, z, &value_sign);
cpp11::writable::doubles result;
result.push_back(std::move(value));
result.push_back(std::move(boost::math::log_hypergeometric_1F1(a, b, z, &value_sign)));
result.attr("sign") = std::move(value_sign);

return cpp11::as_sexp(result);
Expand Down
2 changes: 0 additions & 2 deletions src/special_functions/inverse_hyperbolic_functions.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include <cpp11.hpp>
#include <cpp11/declarations.hpp>
#include <boost/math/special_functions/acosh.hpp>
#include <boost/math/special_functions/asinh.hpp>
#include <boost/math/special_functions/atanh.hpp>
Expand Down
2 changes: 0 additions & 2 deletions src/special_functions/jacobi_elliptic_functions.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include <cpp11.hpp>
#include <cpp11/declarations.hpp>
#include <boost/math/special_functions/jacobi_elliptic.hpp>
#include "../boostmath/macros.hpp"

Expand Down
2 changes: 0 additions & 2 deletions src/special_functions/jacobi_theta_functions.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include <cpp11.hpp>
#include <cpp11/declarations.hpp>
#include <boost/math/special_functions/jacobi_theta.hpp>
#include "../boostmath/macros.hpp"

Expand Down
2 changes: 0 additions & 2 deletions src/special_functions/lambert_w_function.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include <cpp11.hpp>
#include <cpp11/declarations.hpp>
#include <boost/math/special_functions/lambert_w.hpp>
#include "../boostmath/macros.hpp"

Expand Down
6 changes: 6 additions & 0 deletions src/special_functions/logistic_functions.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <boost/math/special_functions/logit.hpp>
#include <boost/math/special_functions/logistic_sigmoid.hpp>
#include "../boostmath/macros.hpp"

UNARY_BOOST_FUNCTION(logit, double)
UNARY_BOOST_FUNCTION(logistic_sigmoid, double)
Loading
Loading