2013-08-08 09:54:33 +00:00
|
|
|
/*=============================================================================
|
2016-02-25 09:48:28 +00:00
|
|
|
Copyright (c) 2011-2016 Bolero MURAKAMI
|
2013-08-08 09:54:33 +00:00
|
|
|
https://github.com/bolero-MURAKAMI/Sprout
|
|
|
|
|
|
|
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
=============================================================================*/
|
2012-08-28 16:16:12 +00:00
|
|
|
#ifndef SPROUT_COMPLEX_NEAREST_HPP
|
|
|
|
#define SPROUT_COMPLEX_NEAREST_HPP
|
|
|
|
|
|
|
|
#include <sprout/config.hpp>
|
|
|
|
#include <sprout/complex/complex.hpp>
|
|
|
|
#include <sprout/math/ceil.hpp>
|
|
|
|
#include <sprout/math/floor.hpp>
|
|
|
|
#include <sprout/math/trunc.hpp>
|
|
|
|
#include <sprout/math/round.hpp>
|
|
|
|
|
|
|
|
namespace sprout {
|
2014-07-19 11:03:13 +00:00
|
|
|
//
|
|
|
|
// ceil
|
|
|
|
//
|
2012-08-28 16:16:12 +00:00
|
|
|
template<typename T>
|
2012-10-05 15:58:56 +00:00
|
|
|
inline SPROUT_CONSTEXPR sprout::complex<T>
|
|
|
|
ceil(sprout::complex<T> const& x) {
|
2013-05-06 14:57:38 +00:00
|
|
|
return sprout::complex<T>(sprout::math::ceil(x.real()), sprout::math::ceil(x.imag()));
|
2012-08-28 16:16:12 +00:00
|
|
|
}
|
2014-07-19 11:03:13 +00:00
|
|
|
//
|
|
|
|
// floor
|
|
|
|
//
|
2012-08-28 16:16:12 +00:00
|
|
|
template<typename T>
|
2012-10-05 15:58:56 +00:00
|
|
|
inline SPROUT_CONSTEXPR sprout::complex<T>
|
|
|
|
floor(sprout::complex<T> const& x) {
|
2013-05-06 14:57:38 +00:00
|
|
|
return sprout::complex<T>(sprout::math::floor(x.real()), sprout::math::floor(x.imag()));
|
2012-08-28 16:16:12 +00:00
|
|
|
}
|
2014-07-19 11:03:13 +00:00
|
|
|
//
|
|
|
|
// trunc
|
|
|
|
//
|
2012-08-28 16:16:12 +00:00
|
|
|
template<typename T>
|
2012-10-05 15:58:56 +00:00
|
|
|
inline SPROUT_CONSTEXPR sprout::complex<T>
|
|
|
|
trunc(sprout::complex<T> const& x) {
|
2013-04-25 06:36:19 +00:00
|
|
|
return sprout::complex<T>(sprout::math::trunc(x.real()), sprout::math::trunc(x.imag()));
|
2012-08-28 16:16:12 +00:00
|
|
|
}
|
2014-07-19 11:03:13 +00:00
|
|
|
//
|
|
|
|
// round
|
|
|
|
//
|
2012-08-28 16:16:12 +00:00
|
|
|
template<typename T>
|
2012-10-05 15:58:56 +00:00
|
|
|
inline SPROUT_CONSTEXPR sprout::complex<T>
|
|
|
|
round(sprout::complex<T> const& x) {
|
2013-05-06 14:57:38 +00:00
|
|
|
return sprout::complex<T>(sprout::math::round(x.real()), sprout::math::round(x.imag()));
|
2012-08-28 16:16:12 +00:00
|
|
|
}
|
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_COMPLEX_NEAREST_HPP
|