mirror of
https://github.com/boostorg/math.git
synced 2026-01-19 04:22:09 +00:00
Special functions, octonions, quaternions by Hubert Holin
[SVN r10404]
This commit is contained in:
96
.gitattributes
vendored
Normal file
96
.gitattributes
vendored
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
* text=auto !eol svneol=native#text/plain
|
||||||
|
*.gitattributes text svneol=native#text/plain
|
||||||
|
|
||||||
|
# Scriptish formats
|
||||||
|
*.bat text svneol=native#text/plain
|
||||||
|
*.bsh text svneol=native#text/x-beanshell
|
||||||
|
*.cgi text svneol=native#text/plain
|
||||||
|
*.cmd text svneol=native#text/plain
|
||||||
|
*.js text svneol=native#text/javascript
|
||||||
|
*.php text svneol=native#text/x-php
|
||||||
|
*.pl text svneol=native#text/x-perl
|
||||||
|
*.pm text svneol=native#text/x-perl
|
||||||
|
*.py text svneol=native#text/x-python
|
||||||
|
*.sh eol=lf svneol=LF#text/x-sh
|
||||||
|
configure eol=lf svneol=LF#text/x-sh
|
||||||
|
|
||||||
|
# Image formats
|
||||||
|
*.bmp binary svneol=unset#image/bmp
|
||||||
|
*.gif binary svneol=unset#image/gif
|
||||||
|
*.ico binary svneol=unset#image/ico
|
||||||
|
*.jpeg binary svneol=unset#image/jpeg
|
||||||
|
*.jpg binary svneol=unset#image/jpeg
|
||||||
|
*.png binary svneol=unset#image/png
|
||||||
|
*.tif binary svneol=unset#image/tiff
|
||||||
|
*.tiff binary svneol=unset#image/tiff
|
||||||
|
*.svg text svneol=native#image/svg%2Bxml
|
||||||
|
|
||||||
|
# Data formats
|
||||||
|
*.pdf binary svneol=unset#application/pdf
|
||||||
|
*.avi binary svneol=unset#video/avi
|
||||||
|
*.doc binary svneol=unset#application/msword
|
||||||
|
*.dsp text svneol=crlf#text/plain
|
||||||
|
*.dsw text svneol=crlf#text/plain
|
||||||
|
*.eps binary svneol=unset#application/postscript
|
||||||
|
*.gz binary svneol=unset#application/gzip
|
||||||
|
*.mov binary svneol=unset#video/quicktime
|
||||||
|
*.mp3 binary svneol=unset#audio/mpeg
|
||||||
|
*.ppt binary svneol=unset#application/vnd.ms-powerpoint
|
||||||
|
*.ps binary svneol=unset#application/postscript
|
||||||
|
*.psd binary svneol=unset#application/photoshop
|
||||||
|
*.rdf binary svneol=unset#text/rdf
|
||||||
|
*.rss text svneol=unset#text/xml
|
||||||
|
*.rtf binary svneol=unset#text/rtf
|
||||||
|
*.sln text svneol=native#text/plain
|
||||||
|
*.swf binary svneol=unset#application/x-shockwave-flash
|
||||||
|
*.tgz binary svneol=unset#application/gzip
|
||||||
|
*.vcproj text svneol=native#text/xml
|
||||||
|
*.vcxproj text svneol=native#text/xml
|
||||||
|
*.vsprops text svneol=native#text/xml
|
||||||
|
*.wav binary svneol=unset#audio/wav
|
||||||
|
*.xls binary svneol=unset#application/vnd.ms-excel
|
||||||
|
*.zip binary svneol=unset#application/zip
|
||||||
|
|
||||||
|
# Text formats
|
||||||
|
.htaccess text svneol=native#text/plain
|
||||||
|
*.bbk text svneol=native#text/xml
|
||||||
|
*.cmake text svneol=native#text/plain
|
||||||
|
*.css text svneol=native#text/css
|
||||||
|
*.dtd text svneol=native#text/xml
|
||||||
|
*.htm text svneol=native#text/html
|
||||||
|
*.html text svneol=native#text/html
|
||||||
|
*.ini text svneol=native#text/plain
|
||||||
|
*.log text svneol=native#text/plain
|
||||||
|
*.mak text svneol=native#text/plain
|
||||||
|
*.qbk text svneol=native#text/plain
|
||||||
|
*.rst text svneol=native#text/plain
|
||||||
|
*.sql text svneol=native#text/x-sql
|
||||||
|
*.txt text svneol=native#text/plain
|
||||||
|
*.xhtml text svneol=native#text/xhtml%2Bxml
|
||||||
|
*.xml text svneol=native#text/xml
|
||||||
|
*.xsd text svneol=native#text/xml
|
||||||
|
*.xsl text svneol=native#text/xml
|
||||||
|
*.xslt text svneol=native#text/xml
|
||||||
|
*.xul text svneol=native#text/xul
|
||||||
|
*.yml text svneol=native#text/plain
|
||||||
|
boost-no-inspect text svneol=native#text/plain
|
||||||
|
CHANGES text svneol=native#text/plain
|
||||||
|
COPYING text svneol=native#text/plain
|
||||||
|
INSTALL text svneol=native#text/plain
|
||||||
|
Jamfile text svneol=native#text/plain
|
||||||
|
Jamroot text svneol=native#text/plain
|
||||||
|
Jamfile.v2 text svneol=native#text/plain
|
||||||
|
Jamrules text svneol=native#text/plain
|
||||||
|
Makefile* text svneol=native#text/plain
|
||||||
|
README text svneol=native#text/plain
|
||||||
|
TODO text svneol=native#text/plain
|
||||||
|
|
||||||
|
# Code formats
|
||||||
|
*.c text svneol=native#text/plain
|
||||||
|
*.cpp text svneol=native#text/plain
|
||||||
|
*.h text svneol=native#text/plain
|
||||||
|
*.hpp text svneol=native#text/plain
|
||||||
|
*.ipp text svneol=native#text/plain
|
||||||
|
*.tpp text svneol=native#text/plain
|
||||||
|
*.jam text svneol=native#text/plain
|
||||||
|
*.java text svneol=native#text/plain
|
||||||
3696
include/boost/math/octonion.hpp
Normal file
3696
include/boost/math/octonion.hpp
Normal file
File diff suppressed because it is too large
Load Diff
1606
include/boost/math/quaternion.hpp
Normal file
1606
include/boost/math/quaternion.hpp
Normal file
File diff suppressed because it is too large
Load Diff
155
include/boost/math/special_functions/atanh.hpp
Normal file
155
include/boost/math/special_functions/atanh.hpp
Normal file
@@ -0,0 +1,155 @@
|
|||||||
|
// boost atanh.hpp header file
|
||||||
|
|
||||||
|
// (C) Copyright Hubert Holin 2001. Permission to copy, use, modify, sell and
|
||||||
|
// distribute this software is granted provided this copyright notice appears
|
||||||
|
// in all copies. This software is provided "as is" without express or implied
|
||||||
|
// warranty, and with no claim as to its suitability for any purpose.
|
||||||
|
|
||||||
|
// See http://www.boost.org for updates, documentation, and revision history.
|
||||||
|
|
||||||
|
#ifndef BOOST_ATANH_HPP
|
||||||
|
#define BOOST_ATANH_HPP
|
||||||
|
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
#include <limits>
|
||||||
|
#include <string>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
|
|
||||||
|
// This is the inverse of the hyperbolic tangent function.
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
// These are implementation details (for main fare see below)
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
template <
|
||||||
|
typename T,
|
||||||
|
bool InfinitySupported
|
||||||
|
>
|
||||||
|
struct atanh_helper1_t
|
||||||
|
{
|
||||||
|
static T get_pos_infinity()
|
||||||
|
{
|
||||||
|
return(+std::numeric_limits<T>::infinity());
|
||||||
|
}
|
||||||
|
|
||||||
|
static T get_neg_infinity()
|
||||||
|
{
|
||||||
|
return(-std::numeric_limits<T>::infinity());
|
||||||
|
}
|
||||||
|
}; // boost::detail::atanh_helper1_t
|
||||||
|
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct atanh_helper1_t<T, false>
|
||||||
|
{
|
||||||
|
static T get_pos_infinity()
|
||||||
|
{
|
||||||
|
::std::string error_reporting("Argument to atanh is +1 (result: +Infinity)!");
|
||||||
|
::std::out_of_range bad_argument(error_reporting);
|
||||||
|
|
||||||
|
throw(bad_argument);
|
||||||
|
}
|
||||||
|
|
||||||
|
static T get_neg_infinity()
|
||||||
|
{
|
||||||
|
::std::string error_reporting("Argument to atanh is -1 (result: -Infinity)!");
|
||||||
|
::std::out_of_range bad_argument(error_reporting);
|
||||||
|
|
||||||
|
throw(bad_argument);
|
||||||
|
}
|
||||||
|
}; // boost::detail::atanh_helper1_t
|
||||||
|
|
||||||
|
|
||||||
|
template <
|
||||||
|
typename T,
|
||||||
|
bool QuietNanSupported
|
||||||
|
>
|
||||||
|
struct atanh_helper2_t
|
||||||
|
{
|
||||||
|
static T get_pos_NaN()
|
||||||
|
{
|
||||||
|
return(+std::numeric_limits<T>::quiet_NaN());
|
||||||
|
}
|
||||||
|
|
||||||
|
static T get_neg_NaN()
|
||||||
|
{
|
||||||
|
return(-std::numeric_limits<T>::quiet_NaN());
|
||||||
|
}
|
||||||
|
}; // boost::detail::atanh_helper2_t
|
||||||
|
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct atanh_helper2_t<T, false>
|
||||||
|
{
|
||||||
|
static T get_pos_NaN()
|
||||||
|
{
|
||||||
|
::std::string error_reporting("Argument to atanh is strictly greater than +1!");
|
||||||
|
::std::domain_error bad_argument(error_reporting);
|
||||||
|
|
||||||
|
throw(bad_argument);
|
||||||
|
}
|
||||||
|
|
||||||
|
static T get_neg_NaN()
|
||||||
|
{
|
||||||
|
::std::string error_reporting("Argument to atanh is strictly smaller than -1!");
|
||||||
|
::std::domain_error bad_argument(error_reporting);
|
||||||
|
|
||||||
|
throw(bad_argument);
|
||||||
|
}
|
||||||
|
}; // boost::detail::atanh_helper2_t
|
||||||
|
|
||||||
|
} // boost::detail
|
||||||
|
|
||||||
|
|
||||||
|
// This is the main fare
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline T atanh(const T x)
|
||||||
|
{
|
||||||
|
using ::std::abs;
|
||||||
|
using ::std::sqrt;
|
||||||
|
|
||||||
|
using ::std::numeric_limits;
|
||||||
|
|
||||||
|
typedef detail::atanh_helper1_t<T, std::numeric_limits<T>::has_infinity> helper1_type;
|
||||||
|
typedef detail::atanh_helper2_t<T, std::numeric_limits<T>::has_quiet_NaN> helper2_type;
|
||||||
|
|
||||||
|
static T const e0 = sqrt(numeric_limits<T>::epsilon());
|
||||||
|
|
||||||
|
T const one = static_cast<T>(1);
|
||||||
|
T const two = static_cast<T>(2);
|
||||||
|
|
||||||
|
if (x < -one)
|
||||||
|
{
|
||||||
|
return(helper2_type::get_neg_NaN());
|
||||||
|
}
|
||||||
|
else if (x == -one)
|
||||||
|
{
|
||||||
|
return(helper1_type::get_neg_infinity());
|
||||||
|
}
|
||||||
|
else if (x == +one)
|
||||||
|
{
|
||||||
|
return(helper1_type::get_pos_infinity());
|
||||||
|
}
|
||||||
|
else if (x > +one)
|
||||||
|
{
|
||||||
|
return(helper2_type::get_pos_NaN());
|
||||||
|
}
|
||||||
|
else if (abs(x) < e0)
|
||||||
|
{
|
||||||
|
return(x);
|
||||||
|
}
|
||||||
|
else // -one < x <= -e0 or +e0 <= x < +one
|
||||||
|
{
|
||||||
|
using ::std::log;
|
||||||
|
|
||||||
|
return(log( (one + x) / (one - x) ) / two);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* BOOST_ATANH_HPP */
|
||||||
102
include/boost/math/special_functions/sinc.hpp
Normal file
102
include/boost/math/special_functions/sinc.hpp
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
// boost sinc.hpp header file
|
||||||
|
|
||||||
|
// (C) Copyright Hubert Holin 2001. Permission to copy, use, modify, sell and
|
||||||
|
// distribute this software is granted provided this copyright notice appears
|
||||||
|
// in all copies. This software is provided "as is" without express or implied
|
||||||
|
// warranty, and with no claim as to its suitability for any purpose.
|
||||||
|
|
||||||
|
// See http://www.boost.org for updates, documentation, and revision history.
|
||||||
|
|
||||||
|
#ifndef BOOST_SINC_HPP
|
||||||
|
#define BOOST_SINC_HPP
|
||||||
|
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
#include <limits>
|
||||||
|
#include <string>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
|
|
||||||
|
// These are the the "Sinus Cardinal" functions.
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
// This is the "Sinus Cardinal" of index Pi.
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline T sinc_pi(const T x)
|
||||||
|
{
|
||||||
|
using ::std::abs;
|
||||||
|
using ::std::sin;
|
||||||
|
using ::std::sqrt;
|
||||||
|
|
||||||
|
using ::std::numeric_limits;
|
||||||
|
|
||||||
|
static T const e1 = numeric_limits<T>::epsilon();
|
||||||
|
static T const e2 = sqrt(e1);
|
||||||
|
static T const e3 = sqrt(e2);
|
||||||
|
|
||||||
|
if (abs(x) > e3)
|
||||||
|
{
|
||||||
|
return(sin(x)/x);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
T result = static_cast<T>(1);
|
||||||
|
|
||||||
|
if (abs(x) > e1)
|
||||||
|
{
|
||||||
|
T x2 = x*x;
|
||||||
|
|
||||||
|
result -= x2/static_cast<T>(6);
|
||||||
|
|
||||||
|
if (abs(x) > e2)
|
||||||
|
{
|
||||||
|
result += (x2*x2)/static_cast<T>(120);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<typename T, template<typename> class U>
|
||||||
|
inline U<T> sinc_pi(const U<T> x)
|
||||||
|
{
|
||||||
|
using ::std::abs;
|
||||||
|
using ::std::sin;
|
||||||
|
using ::std::sqrt;
|
||||||
|
|
||||||
|
using ::std::numeric_limits;
|
||||||
|
|
||||||
|
static T const e1 = numeric_limits<T>::epsilon();
|
||||||
|
static T const e2 = sqrt(e1);
|
||||||
|
static T const e3 = sqrt(e2);
|
||||||
|
|
||||||
|
if (abs(x) > e3)
|
||||||
|
{
|
||||||
|
return(sin(x)/x);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
U<T> result = static_cast< U<T> >(1);
|
||||||
|
|
||||||
|
if (abs(x) > e1)
|
||||||
|
{
|
||||||
|
U<T> x2 = x*x;
|
||||||
|
|
||||||
|
result -= x2/static_cast<T>(6);
|
||||||
|
|
||||||
|
if (abs(x) > e2)
|
||||||
|
{
|
||||||
|
result += (x2*x2)/static_cast<T>(120);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* BOOST_SINC_HPP */
|
||||||
102
include/boost/math/special_functions/sinhc.hpp
Normal file
102
include/boost/math/special_functions/sinhc.hpp
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
// boost sinhc.hpp header file
|
||||||
|
|
||||||
|
// (C) Copyright Hubert Holin 2001. Permission to copy, use, modify, sell and
|
||||||
|
// distribute this software is granted provided this copyright notice appears
|
||||||
|
// in all copies. This software is provided "as is" without express or implied
|
||||||
|
// warranty, and with no claim as to its suitability for any purpose.
|
||||||
|
|
||||||
|
// See http://www.boost.org for updates, documentation, and revision history.
|
||||||
|
|
||||||
|
#ifndef BOOST_SINHC_HPP
|
||||||
|
#define BOOST_SINHC_HPP
|
||||||
|
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
#include <limits>
|
||||||
|
#include <string>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
|
|
||||||
|
// These are the the "Hyperbolic Sinus Cardinal" functions.
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
// This is the "Hyperbolic Sinus Cardinal" of index Pi.
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline T sinhc_pi(const T x)
|
||||||
|
{
|
||||||
|
using ::std::abs;
|
||||||
|
using ::std::sinh;
|
||||||
|
using ::std::sqrt;
|
||||||
|
|
||||||
|
using ::std::numeric_limits;
|
||||||
|
|
||||||
|
static T const e1 = numeric_limits<T>::epsilon();
|
||||||
|
static T const e2 = sqrt(e1);
|
||||||
|
static T const e3 = sqrt(e2);
|
||||||
|
|
||||||
|
if (abs(x) > e3)
|
||||||
|
{
|
||||||
|
return(sinh(x)/x);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
T result = static_cast<T>(1);
|
||||||
|
|
||||||
|
if (abs(x) > e1)
|
||||||
|
{
|
||||||
|
T x2 = x*x;
|
||||||
|
|
||||||
|
result += x2/static_cast<T>(6);
|
||||||
|
|
||||||
|
if (abs(x) > e2)
|
||||||
|
{
|
||||||
|
result += (x2*x2)/static_cast<T>(120);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<typename T, template<typename> class U>
|
||||||
|
inline U<T> sinhc_pi(const U<T> x)
|
||||||
|
{
|
||||||
|
using ::std::abs;
|
||||||
|
using ::std::sinh;
|
||||||
|
using ::std::sqrt;
|
||||||
|
|
||||||
|
using ::std::numeric_limits;
|
||||||
|
|
||||||
|
static T const e1 = numeric_limits<T>::epsilon();
|
||||||
|
static T const e2 = sqrt(e1);
|
||||||
|
static T const e3 = sqrt(e2);
|
||||||
|
|
||||||
|
if (abs(x) > e3)
|
||||||
|
{
|
||||||
|
return(sinh(x)/x);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
U<T> result = static_cast< U<T> >(1);
|
||||||
|
|
||||||
|
if (abs(x) > e1)
|
||||||
|
{
|
||||||
|
U<T> x2 = x*x;
|
||||||
|
|
||||||
|
result += x2/static_cast<T>(6);
|
||||||
|
|
||||||
|
if (abs(x) > e2)
|
||||||
|
{
|
||||||
|
result += (x2*x2)/static_cast<T>(120);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* BOOST_SINHC_HPP */
|
||||||
Reference in New Issue
Block a user