Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:36:19

0001 //  Copyright John Maddock 2007.
0002 //  Copyright Matt Borland 2024.
0003 //  Use, modification and distribution are subject to the
0004 //  Boost Software License, Version 1.0. (See accompanying file
0005 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 
0007 #ifndef BOOST_MATH_MODF_HPP
0008 #define BOOST_MATH_MODF_HPP
0009 
0010 #ifdef _MSC_VER
0011 #pragma once
0012 #endif
0013 
0014 #include <boost/math/tools/config.hpp>
0015 #include <boost/math/special_functions/trunc.hpp>
0016 #include <boost/math/policies/policy.hpp>
0017 
0018 #ifndef BOOST_MATH_HAS_NVRTC
0019 #include <boost/math/special_functions/math_fwd.hpp>
0020 #endif
0021 
0022 namespace boost{ namespace math{
0023 
0024 template <class T, class Policy>
0025 BOOST_MATH_GPU_ENABLED inline T modf(const T& v, T* ipart, const Policy& pol)
0026 {
0027    *ipart = trunc(v, pol);
0028    return v - *ipart;
0029 }
0030 template <class T>
0031 BOOST_MATH_GPU_ENABLED inline T modf(const T& v, T* ipart)
0032 {
0033    return modf(v, ipart, policies::policy<>());
0034 }
0035 
0036 template <class T, class Policy>
0037 BOOST_MATH_GPU_ENABLED inline T modf(const T& v, int* ipart, const Policy& pol)
0038 {
0039    *ipart = itrunc(v, pol);
0040    return v - *ipart;
0041 }
0042 template <class T>
0043 BOOST_MATH_GPU_ENABLED inline T modf(const T& v, int* ipart)
0044 {
0045    return modf(v, ipart, policies::policy<>());
0046 }
0047 
0048 template <class T, class Policy>
0049 BOOST_MATH_GPU_ENABLED inline T modf(const T& v, long* ipart, const Policy& pol)
0050 {
0051    *ipart = ltrunc(v, pol);
0052    return v - *ipart;
0053 }
0054 template <class T>
0055 BOOST_MATH_GPU_ENABLED inline T modf(const T& v, long* ipart)
0056 {
0057    return modf(v, ipart, policies::policy<>());
0058 }
0059 
0060 template <class T, class Policy>
0061 BOOST_MATH_GPU_ENABLED inline T modf(const T& v, long long* ipart, const Policy& pol)
0062 {
0063    *ipart = lltrunc(v, pol);
0064    return v - *ipart;
0065 }
0066 template <class T>
0067 BOOST_MATH_GPU_ENABLED inline T modf(const T& v, long long* ipart)
0068 {
0069    return modf(v, ipart, policies::policy<>());
0070 }
0071 
0072 }} // namespaces
0073 
0074 #endif // BOOST_MATH_MODF_HPP