]> git.donarmstrong.com Git - rsem.git/blob - boost/math/special_functions/modf.hpp
Updated boost to v1.55.0
[rsem.git] / boost / math / special_functions / modf.hpp
1 //  Copyright John Maddock 2007.
2 //  Use, modification and distribution are subject to the
3 //  Boost Software License, Version 1.0. (See accompanying file
4 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6 #ifndef BOOST_MATH_MODF_HPP
7 #define BOOST_MATH_MODF_HPP
8
9 #ifdef _MSC_VER
10 #pragma once
11 #endif
12
13 #include <boost/math/tools/config.hpp>
14 #include <boost/math/special_functions/trunc.hpp>
15
16 namespace boost{ namespace math{
17
18 template <class T, class Policy>
19 inline T modf(const T& v, T* ipart, const Policy& pol)
20 {
21    *ipart = trunc(v, pol);
22    return v - *ipart;
23 }
24 template <class T>
25 inline T modf(const T& v, T* ipart)
26 {
27    return modf(v, ipart, policies::policy<>());
28 }
29
30 template <class T, class Policy>
31 inline T modf(const T& v, int* ipart, const Policy& pol)
32 {
33    *ipart = itrunc(v, pol);
34    return v - *ipart;
35 }
36 template <class T>
37 inline T modf(const T& v, int* ipart)
38 {
39    return modf(v, ipart, policies::policy<>());
40 }
41
42 template <class T, class Policy>
43 inline T modf(const T& v, long* ipart, const Policy& pol)
44 {
45    *ipart = ltrunc(v, pol);
46    return v - *ipart;
47 }
48 template <class T>
49 inline T modf(const T& v, long* ipart)
50 {
51    return modf(v, ipart, policies::policy<>());
52 }
53
54 #ifdef BOOST_HAS_LONG_LONG
55 template <class T, class Policy>
56 inline T modf(const T& v, boost::long_long_type* ipart, const Policy& pol)
57 {
58    *ipart = lltrunc(v, pol);
59    return v - *ipart;
60 }
61 template <class T>
62 inline T modf(const T& v, boost::long_long_type* ipart)
63 {
64    return modf(v, ipart, policies::policy<>());
65 }
66 #endif
67
68 }} // namespaces
69
70 #endif // BOOST_MATH_MODF_HPP