mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2024-12-23 21:25:49 +00:00
add c++14 constexpr spectrum and wave genarator algorithms
This commit is contained in:
parent
d1fc657c1f
commit
cc48f3585a
29 changed files with 506 additions and 77 deletions
|
@ -16,8 +16,8 @@
|
|||
#include <sprout/iterator/next.hpp>
|
||||
#include <sprout/iterator/prev.hpp>
|
||||
#include <sprout/iterator/distance.hpp>
|
||||
#include <sprout/numeric/dft/fixed/sawtooth.hpp>
|
||||
#include <sprout/utility/swap.hpp>
|
||||
#include <sprout/numeric/dft/detail/sawtooth.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
|
@ -97,7 +97,7 @@ namespace sprout {
|
|||
}
|
||||
SPROUT_CONSTEXPR reference operator*() const {
|
||||
return amplitude_ == 0 ? 0
|
||||
: amplitude_ * sprout::fixed::detail::sawtooth_value(frequency_ * value_type(index_) + phase_)
|
||||
: sprout::detail::sawtooth_value(frequency_, amplitude_, phase_, index_)
|
||||
;
|
||||
}
|
||||
SPROUT_CONSTEXPR pointer operator->() const {
|
||||
|
@ -139,7 +139,7 @@ namespace sprout {
|
|||
}
|
||||
SPROUT_CONSTEXPR reference operator[](difference_type n) const {
|
||||
return amplitude_ == 0 ? 0
|
||||
: amplitude_ * sprout::fixed::detail::sawtooth_value(frequency_ * value_type(index_ + n) + phase_)
|
||||
: sprout::detail::sawtooth_value(frequency_, amplitude_, phase_, index_ + n)
|
||||
;
|
||||
}
|
||||
SPROUT_CONSTEXPR sawtooth_iterator next() const {
|
||||
|
|
|
@ -16,9 +16,8 @@
|
|||
#include <sprout/iterator/next.hpp>
|
||||
#include <sprout/iterator/prev.hpp>
|
||||
#include <sprout/iterator/distance.hpp>
|
||||
#include <sprout/math/constants.hpp>
|
||||
#include <sprout/math/sin.hpp>
|
||||
#include <sprout/utility/swap.hpp>
|
||||
#include <sprout/numeric/dft/detail/sinusoid.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
|
@ -60,7 +59,7 @@ namespace sprout {
|
|||
, frequency_(1)
|
||||
, amplitude_(1)
|
||||
, phase_(0)
|
||||
, d_(sprout::math::two_pi<value_type>())
|
||||
, d_(sprout::detail::sinusoid_value_d(frequency_))
|
||||
{}
|
||||
sinusoid_iterator(sinusoid_iterator const&) = default;
|
||||
explicit SPROUT_CONSTEXPR sinusoid_iterator(
|
||||
|
@ -73,7 +72,7 @@ namespace sprout {
|
|||
, frequency_(frequency)
|
||||
, amplitude_(amplitude)
|
||||
, phase_(phase)
|
||||
, d_(sprout::math::two_pi<value_type>() * frequency)
|
||||
, d_(sprout::detail::sinusoid_value_d(frequency_))
|
||||
{}
|
||||
template<typename U>
|
||||
SPROUT_CONSTEXPR sinusoid_iterator(sinusoid_iterator<U> const& it)
|
||||
|
@ -102,9 +101,8 @@ namespace sprout {
|
|||
return phase_;
|
||||
}
|
||||
SPROUT_CONSTEXPR reference operator*() const {
|
||||
using sprout::sin;
|
||||
return amplitude_ == 0 ? 0
|
||||
: amplitude_ * sin(d_ * value_type(index_) + phase_)
|
||||
: sprout::detail::sinusoid_value(amplitude_, phase_, d_, index_)
|
||||
;
|
||||
}
|
||||
SPROUT_CONSTEXPR pointer operator->() const {
|
||||
|
@ -145,9 +143,8 @@ namespace sprout {
|
|||
return *this;
|
||||
}
|
||||
SPROUT_CONSTEXPR reference operator[](difference_type n) const {
|
||||
using sprout::sin;
|
||||
return amplitude_ == 0 ? 0
|
||||
: amplitude_ * sin(d_ * value_type(index_ + n) + phase_)
|
||||
: sprout::detail::sinusoid_value(amplitude_, phase_, d_, index_ + n)
|
||||
;
|
||||
}
|
||||
SPROUT_CONSTEXPR sinusoid_iterator next() const {
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
#include <sprout/iterator/next.hpp>
|
||||
#include <sprout/iterator/prev.hpp>
|
||||
#include <sprout/iterator/distance.hpp>
|
||||
#include <sprout/numeric/dft/fixed/square.hpp>
|
||||
#include <sprout/utility/swap.hpp>
|
||||
#include <sprout/numeric/dft/detail/square.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
|
@ -106,7 +106,7 @@ namespace sprout {
|
|||
}
|
||||
SPROUT_CONSTEXPR reference operator*() const {
|
||||
return amplitude_ == 0 ? 0
|
||||
: amplitude_ * sprout::fixed::detail::square_value(frequency_ * value_type(index_) + phase_, duty_)
|
||||
: sprout::detail::square_value(frequency_, amplitude_, phase_, duty_, index_)
|
||||
;
|
||||
}
|
||||
SPROUT_CONSTEXPR pointer operator->() const {
|
||||
|
@ -148,7 +148,7 @@ namespace sprout {
|
|||
}
|
||||
SPROUT_CONSTEXPR reference operator[](difference_type n) const {
|
||||
return amplitude_ == 0 ? 0
|
||||
: amplitude_ * sprout::fixed::detail::square_value(frequency_ * value_type(index_ + n) + phase_, duty_)
|
||||
: sprout::detail::square_value(frequency_, amplitude_, phase_, duty_, index_ + n)
|
||||
;
|
||||
}
|
||||
SPROUT_CONSTEXPR square_iterator next() const {
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
#include <sprout/iterator/next.hpp>
|
||||
#include <sprout/iterator/prev.hpp>
|
||||
#include <sprout/iterator/distance.hpp>
|
||||
#include <sprout/numeric/dft/fixed/triangle.hpp>
|
||||
#include <sprout/utility/swap.hpp>
|
||||
#include <sprout/numeric/dft/detail/triangle.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
|
@ -97,7 +97,7 @@ namespace sprout {
|
|||
}
|
||||
SPROUT_CONSTEXPR reference operator*() const {
|
||||
return amplitude_ == 0 ? 0
|
||||
: amplitude_ * sprout::fixed::detail::triangle_value(frequency_ * value_type(index_) + phase_)
|
||||
: sprout::detail::triangle_value(frequency_, amplitude_, phase_, index_)
|
||||
;
|
||||
}
|
||||
SPROUT_CONSTEXPR pointer operator->() const {
|
||||
|
@ -139,7 +139,7 @@ namespace sprout {
|
|||
}
|
||||
SPROUT_CONSTEXPR reference operator[](difference_type n) const {
|
||||
return amplitude_ == 0 ? 0
|
||||
: amplitude_ * sprout::fixed::detail::triangle_value(frequency_ * value_type(index_ + n) + phase_)
|
||||
: sprout::detail::triangle_value(frequency_, amplitude_, phase_, index_ + n)
|
||||
;
|
||||
}
|
||||
SPROUT_CONSTEXPR triangle_iterator next() const {
|
||||
|
|
|
@ -11,5 +11,6 @@
|
|||
#include <sprout/config.hpp>
|
||||
#include <sprout/numeric/dft/fixed/amplitude_spectrum.hpp>
|
||||
#include <sprout/numeric/dft/fit/amplitude_spectrum.hpp>
|
||||
#include <sprout/numeric/dft/cxx14/amplitude_spectrum.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_DFT_AMPLITUDE_SPECTRUM_HPP
|
||||
|
|
15
sprout/numeric/dft/cxx14.hpp
Normal file
15
sprout/numeric/dft/cxx14.hpp
Normal file
|
@ -0,0 +1,15 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2014 Bolero MURAKAMI
|
||||
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)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_NUMERIC_DFT_CXX14_HPP
|
||||
#define SPROUT_NUMERIC_DFT_CXX14_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/numeric/dft/cxx14/spectrum.hpp>
|
||||
#include <sprout/numeric/dft/cxx14/wave.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_DFT_CXX14_HPP
|
33
sprout/numeric/dft/cxx14/amplitude_spectrum.hpp
Normal file
33
sprout/numeric/dft/cxx14/amplitude_spectrum.hpp
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2014 Bolero MURAKAMI
|
||||
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)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_NUMERIC_DFT_CXX14_AMPLITUDE_SPECTRUM_HPP
|
||||
#define SPROUT_NUMERIC_DFT_CXX14_AMPLITUDE_SPECTRUM_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
|
||||
#include <sprout/type_traits/enabler_if.hpp>
|
||||
#include <sprout/numeric/dft/amplitude_spectrum_value.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// amplitude_spectrum
|
||||
//
|
||||
template<
|
||||
typename InputIterator, typename OutputIterator,
|
||||
typename sprout::enabler_if<sprout::is_iterator_outputable<OutputIterator>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CXX14_CONSTEXPR OutputIterator
|
||||
amplitude_spectrum(InputIterator first, InputIterator last, OutputIterator result) {
|
||||
while (first != last) {
|
||||
*result++ = sprout::amplitude_spectrum_value(*first++);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_DFT_CXX14_AMPLITUDE_SPECTRUM_HPP
|
33
sprout/numeric/dft/cxx14/phase_spectrum.hpp
Normal file
33
sprout/numeric/dft/cxx14/phase_spectrum.hpp
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2014 Bolero MURAKAMI
|
||||
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)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_NUMERIC_DFT_CXX14_PHASE_SPECTRUM_HPP
|
||||
#define SPROUT_NUMERIC_DFT_CXX14_PHASE_SPECTRUM_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
|
||||
#include <sprout/type_traits/enabler_if.hpp>
|
||||
#include <sprout/numeric/dft/phase_spectrum_value.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// phase_spectrum
|
||||
//
|
||||
template<
|
||||
typename InputIterator, typename OutputIterator,
|
||||
typename sprout::enabler_if<sprout::is_iterator_outputable<OutputIterator>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CXX14_CONSTEXPR OutputIterator
|
||||
phase_spectrum(InputIterator first, InputIterator last, OutputIterator result) {
|
||||
while (first != last) {
|
||||
*result++ = sprout::phase_spectrum_value(*first++);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_DFT_CXX14_PHASE_SPECTRUM_HPP
|
38
sprout/numeric/dft/cxx14/sawtooth.hpp
Normal file
38
sprout/numeric/dft/cxx14/sawtooth.hpp
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2014 Bolero MURAKAMI
|
||||
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)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_NUMERIC_DFT_CXX14_SAWTOOTH_HPP
|
||||
#define SPROUT_NUMERIC_DFT_CXX14_SAWTOOTH_HPP
|
||||
|
||||
#include <iterator>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/distance.hpp>
|
||||
#include <sprout/numeric/dft/detail/sawtooth.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// sawtooth
|
||||
//
|
||||
template<typename ForwardIterator>
|
||||
inline SPROUT_CXX14_CONSTEXPR void
|
||||
sawtooth(
|
||||
ForwardIterator first, ForwardIterator last,
|
||||
typename std::iterator_traits<ForwardIterator>::value_type const& frequency = 1,
|
||||
typename std::iterator_traits<ForwardIterator>::value_type const& amplitude = 1,
|
||||
typename std::iterator_traits<ForwardIterator>::value_type const& phase = 0
|
||||
)
|
||||
{
|
||||
typedef typename std::iterator_traits<ForwardIterator>::difference_type difference_type;
|
||||
difference_type i = 0;
|
||||
while (first != last) {
|
||||
*first++ = sprout::detail::sawtooth_value(frequency, amplitude, phase, i);
|
||||
++i;
|
||||
}
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_DFT_CXX14_SAWTOOTH_HPP
|
40
sprout/numeric/dft/cxx14/sinusoid.hpp
Normal file
40
sprout/numeric/dft/cxx14/sinusoid.hpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2014 Bolero MURAKAMI
|
||||
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)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_NUMERIC_DFT_CXX14_SINUSOID_HPP
|
||||
#define SPROUT_NUMERIC_DFT_CXX14_SINUSOID_HPP
|
||||
|
||||
#include <iterator>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/distance.hpp>
|
||||
#include <sprout/numeric/dft/detail/sinusoid.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// sinusoid
|
||||
//
|
||||
template<typename ForwardIterator>
|
||||
inline SPROUT_CXX14_CONSTEXPR void
|
||||
sinusoid(
|
||||
ForwardIterator first, ForwardIterator last,
|
||||
typename std::iterator_traits<ForwardIterator>::value_type const& frequency = 1,
|
||||
typename std::iterator_traits<ForwardIterator>::value_type const& amplitude = 1,
|
||||
typename std::iterator_traits<ForwardIterator>::value_type const& phase = 0
|
||||
)
|
||||
{
|
||||
typedef typename std::iterator_traits<ForwardIterator>::value_type value_type;
|
||||
typedef typename std::iterator_traits<ForwardIterator>::difference_type difference_type;
|
||||
value_type const d = sprout::detail::sinusoid_value_d(frequency, sprout::distance(first, last));
|
||||
difference_type i = 0;
|
||||
while (first != last) {
|
||||
*first++ = sprout::detail::sinusoid_value(amplitude, phase, d, i);
|
||||
++i;
|
||||
}
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_DFT_CXX14_SINUSOID_HPP
|
31
sprout/numeric/dft/cxx14/spectrum.hpp
Normal file
31
sprout/numeric/dft/cxx14/spectrum.hpp
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2014 Bolero MURAKAMI
|
||||
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)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_NUMERIC_DFT_CXX14_SPECTRUM_HPP
|
||||
#define SPROUT_NUMERIC_DFT_CXX14_SPECTRUM_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
|
||||
#include <sprout/type_traits/enabler_if.hpp>
|
||||
#include <sprout/numeric/dft/amplitude_spectrum.hpp>
|
||||
#include <sprout/numeric/dft/phase_spectrum.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// spectrum
|
||||
//
|
||||
template<
|
||||
typename InputIterator, typename OutputIterator,
|
||||
typename sprout::enabler_if<sprout::is_iterator_outputable<OutputIterator>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CXX14_CONSTEXPR OutputIterator
|
||||
spectrum(InputIterator first, InputIterator last, OutputIterator result) {
|
||||
return sprout::amplitude_spectrum(first, last, result);
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_DFT_CXX14_SPECTRUM_HPP
|
38
sprout/numeric/dft/cxx14/square.hpp
Normal file
38
sprout/numeric/dft/cxx14/square.hpp
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2014 Bolero MURAKAMI
|
||||
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)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_NUMERIC_DFT_CXX14_SAWTOOTH_HPP
|
||||
#define SPROUT_NUMERIC_DFT_CXX14_SAWTOOTH_HPP
|
||||
|
||||
#include <iterator>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/distance.hpp>
|
||||
#include <sprout/numeric/dft/detail/square.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// square
|
||||
//
|
||||
template<typename ForwardIterator>
|
||||
inline SPROUT_CXX14_CONSTEXPR void
|
||||
square(
|
||||
ForwardIterator first, ForwardIterator last,
|
||||
typename std::iterator_traits<ForwardIterator>::value_type const& frequency = 1,
|
||||
typename std::iterator_traits<ForwardIterator>::value_type const& amplitude = 1,
|
||||
typename std::iterator_traits<ForwardIterator>::value_type const& phase = 0
|
||||
)
|
||||
{
|
||||
typedef typename std::iterator_traits<ForwardIterator>::difference_type difference_type;
|
||||
difference_type i = 0;
|
||||
while (first != last) {
|
||||
*first++ = sprout::detail::square_value(frequency, amplitude, phase, i);
|
||||
++i;
|
||||
}
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_DFT_CXX14_SAWTOOTH_HPP
|
39
sprout/numeric/dft/cxx14/triangle.hpp
Normal file
39
sprout/numeric/dft/cxx14/triangle.hpp
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2014 Bolero MURAKAMI
|
||||
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)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_NUMERIC_DFT_CXX14_SAWTOOTH_HPP
|
||||
#define SPROUT_NUMERIC_DFT_CXX14_SAWTOOTH_HPP
|
||||
|
||||
#include <iterator>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/distance.hpp>
|
||||
#include <sprout/numeric/dft/detail/triangle.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// triangle
|
||||
//
|
||||
template<typename ForwardIterator>
|
||||
inline SPROUT_CXX14_CONSTEXPR void
|
||||
triangle(
|
||||
ForwardIterator first, ForwardIterator last,
|
||||
typename std::iterator_traits<ForwardIterator>::value_type const& frequency = 1,
|
||||
typename std::iterator_traits<ForwardIterator>::value_type const& amplitude = 1,
|
||||
typename std::iterator_traits<ForwardIterator>::value_type const& phase = 0,
|
||||
typename std::iterator_traits<ForwardIterator>::value_type const& duty = 0.5
|
||||
)
|
||||
{
|
||||
typedef typename std::iterator_traits<ForwardIterator>::difference_type difference_type;
|
||||
difference_type i = 0;
|
||||
while (first != last) {
|
||||
*first++ = sprout::detail::triangle_value(frequency, amplitude, phase, duty, i);
|
||||
++i;
|
||||
}
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_DFT_CXX14_SAWTOOTH_HPP
|
17
sprout/numeric/dft/cxx14/wave.hpp
Normal file
17
sprout/numeric/dft/cxx14/wave.hpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2014 Bolero MURAKAMI
|
||||
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)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_NUMERIC_DFT_CXX14_WAVE_HPP
|
||||
#define SPROUT_NUMERIC_DFT_CXX14_WAVE_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/numeric/dft/cxx14/sinusoid.hpp>
|
||||
#include <sprout/numeric/dft/cxx14/sawtooth.hpp>
|
||||
#include <sprout/numeric/dft/cxx14/triangle.hpp>
|
||||
#include <sprout/numeric/dft/cxx14/square.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_DFT_CXX14_WAVE_HPP
|
30
sprout/numeric/dft/detail/sawtooth.hpp
Normal file
30
sprout/numeric/dft/detail/sawtooth.hpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2014 Bolero MURAKAMI
|
||||
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)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_NUMERIC_DFT_DETAIL_SAWTOOTH_HPP
|
||||
#define SPROUT_NUMERIC_DFT_DETAIL_SAWTOOTH_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/math/floor.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR T
|
||||
sawtooth_value_impl(T const& t) {
|
||||
using sprout::floor;
|
||||
return 2 * (t - floor(t + T(0.5)));
|
||||
}
|
||||
template<typename T, typename Index>
|
||||
inline SPROUT_CONSTEXPR T
|
||||
sawtooth_value(T const& frequency, T const& amplitude, T const& phase, Index i) {
|
||||
return amplitude * sprout::detail::sawtooth_value_impl(frequency * T(i) + phase);
|
||||
}
|
||||
} // namespace detail
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_DFT_DETAIL_SAWTOOTH_HPP
|
36
sprout/numeric/dft/detail/sinusoid.hpp
Normal file
36
sprout/numeric/dft/detail/sinusoid.hpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2014 Bolero MURAKAMI
|
||||
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)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_NUMERIC_DFT_DETAIL_SINUSOID_HPP
|
||||
#define SPROUT_NUMERIC_DFT_DETAIL_SINUSOID_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/math/constants.hpp>
|
||||
#include <sprout/math/sin.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
template<typename T, typename Index>
|
||||
inline SPROUT_CONSTEXPR T
|
||||
sinusoid_value(T const& amplitude, T const& phase, T const& d, Index i) {
|
||||
using sprout::sin;
|
||||
return amplitude * sin(d * T(i) + phase);
|
||||
}
|
||||
template<typename T, typename Size>
|
||||
inline SPROUT_CONSTEXPR T
|
||||
sinusoid_value_d(T const& frequency, Size size) {
|
||||
return sprout::math::two_pi<T>() * frequency / T(size);
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR T
|
||||
sinusoid_value_d(T const& frequency) {
|
||||
return sprout::math::two_pi<T>() * frequency;
|
||||
}
|
||||
} // namespace detail
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_DFT_DETAIL_SINUSOID_HPP
|
29
sprout/numeric/dft/detail/square.hpp
Normal file
29
sprout/numeric/dft/detail/square.hpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2014 Bolero MURAKAMI
|
||||
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)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_NUMERIC_DFT_DETAIL_SQUARE_HPP
|
||||
#define SPROUT_NUMERIC_DFT_DETAIL_SQUARE_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/numeric/dft/detail/sawtooth.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR T
|
||||
square_value_impl(T const& t, T const& duty) {
|
||||
return sprout::detail::sawtooth_value_impl(t) - sprout::detail::sawtooth_value_impl(t - duty);
|
||||
}
|
||||
template<typename T, typename Index>
|
||||
inline SPROUT_CONSTEXPR T
|
||||
square_value(T const& frequency, T const& amplitude, T const& phase, T const& duty, Index i) {
|
||||
return amplitude * sprout::detail::square_value_impl(frequency * T(i) + phase, duty);
|
||||
}
|
||||
} // namespace detail
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_DFT_DETAIL_SQUARE_HPP
|
34
sprout/numeric/dft/detail/triangle.hpp
Normal file
34
sprout/numeric/dft/detail/triangle.hpp
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2014 Bolero MURAKAMI
|
||||
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)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_NUMERIC_DFT_DETAIL_TRINAGLE_HPP
|
||||
#define SPROUT_NUMERIC_DFT_DETAIL_TRINAGLE_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/math/constants.hpp>
|
||||
#include <sprout/math/sin.hpp>
|
||||
#include <sprout/math/asin.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR T
|
||||
triangle_value_impl(T const& t) {
|
||||
typedef double elem_type;
|
||||
using sprout::sin;
|
||||
using sprout::asin;
|
||||
return T(sprout::math::two_div_pi<elem_type>()) * asin(sin(T(sprout::math::two_pi<elem_type>()) * t));
|
||||
}
|
||||
template<typename T, typename Index>
|
||||
inline SPROUT_CONSTEXPR T
|
||||
triangle_value(T const& frequency, T const& amplitude, T const& phase, Index i) {
|
||||
return amplitude * sprout::detail::triangle_value_impl(frequency * T(i) + phase);
|
||||
}
|
||||
} // namespace detail
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_DFT_DETAIL_TRINAGLE_HPP
|
|
@ -11,6 +11,7 @@
|
|||
#include <sprout/config.hpp>
|
||||
#include <sprout/algorithm/fit/results.hpp>
|
||||
#include <sprout/numeric/dft/fit/amplitude_spectrum.hpp>
|
||||
#include <sprout/numeric/dft/fit/phase_spectrum.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace fit {
|
||||
|
@ -31,6 +32,4 @@ namespace sprout {
|
|||
} // namespace fit
|
||||
} // namespace sprout
|
||||
|
||||
#include <sprout/numeric/dft/fit/phase_spectrum.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_DFT_FIT_SPECTRUM_HPP
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#include <sprout/container/indexes.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/iterator/amplitude_spectrum_iterator.hpp>
|
||||
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
|
||||
#include <sprout/type_traits/enabler_if.hpp>
|
||||
#include <sprout/algorithm/fixed/results.hpp>
|
||||
#include <sprout/pit/pit.hpp>
|
||||
#include <sprout/math/less.hpp>
|
||||
|
@ -60,26 +62,26 @@ namespace sprout {
|
|||
);
|
||||
}
|
||||
|
||||
template<typename ForwardIterator, typename Result, typename... Args>
|
||||
template<typename InputIterator, typename Result, typename... Args>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::container_traits<Result>::static_size == sizeof...(Args),
|
||||
typename sprout::fixed::results::algorithm<Result>::type
|
||||
>::type
|
||||
amplitude_spectrum_impl(
|
||||
ForwardIterator, ForwardIterator, Result const& result,
|
||||
InputIterator, InputIterator, Result const& result,
|
||||
typename sprout::container_traits<Result>::size_type,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sprout::remake<Result>(result, sprout::size(result), args...);
|
||||
}
|
||||
template<typename ForwardIterator, typename Result, typename... Args>
|
||||
template<typename InputIterator, typename Result, typename... Args>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::container_traits<Result>::static_size != sizeof...(Args),
|
||||
typename sprout::fixed::results::algorithm<Result>::type
|
||||
>::type
|
||||
amplitude_spectrum_impl(
|
||||
ForwardIterator first, ForwardIterator last, Result const& result,
|
||||
InputIterator first, InputIterator last, Result const& result,
|
||||
typename sprout::container_traits<Result>::size_type size,
|
||||
Args const&... args
|
||||
)
|
||||
|
@ -92,10 +94,10 @@ namespace sprout {
|
|||
: sprout::detail::container_complate(result, args...)
|
||||
;
|
||||
}
|
||||
template<typename ForwardIterator, typename Result>
|
||||
template<typename InputIterator, typename Result>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fixed::results::algorithm<Result>::type
|
||||
amplitude_spectrum(
|
||||
ForwardIterator first, ForwardIterator last, Result const& result,
|
||||
InputIterator first, InputIterator last, Result const& result,
|
||||
std::forward_iterator_tag*
|
||||
)
|
||||
{
|
||||
|
@ -134,14 +136,27 @@ namespace sprout {
|
|||
return sprout::fixed::detail::amplitude_spectrum(first, last, result);
|
||||
}
|
||||
|
||||
template<typename Result, typename ForwardIterator>
|
||||
template<typename Result, typename InputIterator>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fixed::results::algorithm<Result>::type
|
||||
amplitude_spectrum(ForwardIterator first, ForwardIterator last) {
|
||||
amplitude_spectrum(InputIterator first, InputIterator last) {
|
||||
return sprout::fixed::amplitude_spectrum(first, last, sprout::pit<Result>());
|
||||
}
|
||||
} // namespace fixed
|
||||
|
||||
using sprout::fixed::amplitude_spectrum;
|
||||
template<
|
||||
typename InputIterator, typename Result,
|
||||
typename sprout::enabler_if<!sprout::is_iterator_outputable<Result>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fixed::results::algorithm<Result>::type
|
||||
amplitude_spectrum(InputIterator first, InputIterator last, Result const& result) {
|
||||
return sprout::fixed::amplitude_spectrum(first, last, result);
|
||||
}
|
||||
|
||||
template<typename Result, typename InputIterator>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fixed::results::algorithm<Result>::type
|
||||
amplitude_spectrum(InputIterator first, InputIterator last) {
|
||||
return sprout::fixed::amplitude_spectrum<Result>(first, last);
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_DFT_FIXED_AMPLITUDE_SPECTRUM_HPP
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#include <sprout/container/indexes.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/iterator/phase_spectrum_iterator.hpp>
|
||||
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
|
||||
#include <sprout/type_traits/enabler_if.hpp>
|
||||
#include <sprout/algorithm/fixed/results.hpp>
|
||||
#include <sprout/pit/pit.hpp>
|
||||
#include <sprout/math/less.hpp>
|
||||
|
@ -60,26 +62,26 @@ namespace sprout {
|
|||
);
|
||||
}
|
||||
|
||||
template<typename ForwardIterator, typename Result, typename... Args>
|
||||
template<typename InputIterator, typename Result, typename... Args>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::container_traits<Result>::static_size == sizeof...(Args),
|
||||
typename sprout::fixed::results::algorithm<Result>::type
|
||||
>::type
|
||||
phase_spectrum_impl(
|
||||
ForwardIterator, ForwardIterator, Result const& result,
|
||||
InputIterator, InputIterator, Result const& result,
|
||||
typename sprout::container_traits<Result>::size_type,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sprout::remake<Result>(result, sprout::size(result), args...);
|
||||
}
|
||||
template<typename ForwardIterator, typename Result, typename... Args>
|
||||
template<typename InputIterator, typename Result, typename... Args>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::container_traits<Result>::static_size != sizeof...(Args),
|
||||
typename sprout::fixed::results::algorithm<Result>::type
|
||||
>::type
|
||||
phase_spectrum_impl(
|
||||
ForwardIterator first, ForwardIterator last, Result const& result,
|
||||
InputIterator first, InputIterator last, Result const& result,
|
||||
typename sprout::container_traits<Result>::size_type size,
|
||||
Args const&... args
|
||||
)
|
||||
|
@ -92,10 +94,10 @@ namespace sprout {
|
|||
: sprout::detail::container_complate(result, args...)
|
||||
;
|
||||
}
|
||||
template<typename ForwardIterator, typename Result>
|
||||
template<typename InputIterator, typename Result>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fixed::results::algorithm<Result>::type
|
||||
phase_spectrum(
|
||||
ForwardIterator first, ForwardIterator last, Result const& result,
|
||||
InputIterator first, InputIterator last, Result const& result,
|
||||
std::forward_iterator_tag*
|
||||
)
|
||||
{
|
||||
|
@ -134,14 +136,27 @@ namespace sprout {
|
|||
return sprout::fixed::detail::phase_spectrum(first, last, result);
|
||||
}
|
||||
|
||||
template<typename Result, typename ForwardIterator>
|
||||
template<typename Result, typename InputIterator>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fixed::results::algorithm<Result>::type
|
||||
phase_spectrum(ForwardIterator first, ForwardIterator last) {
|
||||
phase_spectrum(InputIterator first, InputIterator last) {
|
||||
return sprout::fixed::phase_spectrum(first, last, sprout::pit<Result>());
|
||||
}
|
||||
} // namespace fixed
|
||||
|
||||
using sprout::fixed::phase_spectrum;
|
||||
template<
|
||||
typename InputIterator, typename Result,
|
||||
typename sprout::enabler_if<!sprout::is_iterator_outputable<Result>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fixed::results::algorithm<Result>::type
|
||||
phase_spectrum(InputIterator first, InputIterator last, Result const& result) {
|
||||
return sprout::fixed::phase_spectrum(first, last, result);
|
||||
}
|
||||
|
||||
template<typename Result, typename InputIterator>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fixed::results::algorithm<Result>::type
|
||||
phase_spectrum(InputIterator first, InputIterator last) {
|
||||
return sprout::fixed::phase_spectrum<Result>(first, last);
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_DFT_FIXED_PHASE_SPECTRUM_HPP
|
||||
|
|
|
@ -15,19 +15,12 @@
|
|||
#include <sprout/container/indexes.hpp>
|
||||
#include <sprout/algorithm/fixed/results.hpp>
|
||||
#include <sprout/pit/pit.hpp>
|
||||
#include <sprout/math/floor.hpp>
|
||||
#include <sprout/detail/container_complate.hpp>
|
||||
#include <sprout/numeric/dft/detail/sawtooth.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace fixed {
|
||||
namespace detail {
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR T
|
||||
sawtooth_value(T const& t) {
|
||||
using sprout::floor;
|
||||
return 2 * (t - floor(t + T(0.5)));
|
||||
}
|
||||
|
||||
template<typename Container, sprout::index_t... Indexes>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fixed::results::algorithm<Container>::type
|
||||
sawtooth_impl(
|
||||
|
@ -40,11 +33,10 @@ namespace sprout {
|
|||
typename sprout::container_traits<Container>::size_type size
|
||||
)
|
||||
{
|
||||
typedef typename sprout::container_traits<Container>::value_type value_type;
|
||||
return sprout::remake<Container>(
|
||||
cont, size,
|
||||
(Indexes >= offset && Indexes < offset + size
|
||||
? amplitude * sprout::fixed::detail::sawtooth_value(frequency * value_type(Indexes) + phase)
|
||||
? sprout::detail::sawtooth_value(frequency, amplitude, phase, Indexes)
|
||||
: *sprout::next(sprout::internal_begin(cont), Indexes)
|
||||
)...
|
||||
);
|
||||
|
|
|
@ -15,9 +15,8 @@
|
|||
#include <sprout/container/indexes.hpp>
|
||||
#include <sprout/algorithm/fixed/results.hpp>
|
||||
#include <sprout/pit/pit.hpp>
|
||||
#include <sprout/math/constants.hpp>
|
||||
#include <sprout/math/sin.hpp>
|
||||
#include <sprout/detail/container_complate.hpp>
|
||||
#include <sprout/numeric/dft/detail/sinusoid.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace fixed {
|
||||
|
@ -35,11 +34,10 @@ namespace sprout {
|
|||
)
|
||||
{
|
||||
typedef typename sprout::container_traits<Container>::value_type value_type;
|
||||
using sprout::sin;
|
||||
return sprout::remake<Container>(
|
||||
cont, size,
|
||||
(Indexes >= offset && Indexes < offset + size
|
||||
? amplitude * sin(d * value_type(Indexes) + phase)
|
||||
? sprout::detail::sinusoid_value(amplitude, phase, d, Indexes)
|
||||
: *sprout::next(sprout::internal_begin(cont), Indexes)
|
||||
)...
|
||||
);
|
||||
|
@ -56,7 +54,7 @@ namespace sprout {
|
|||
typedef typename sprout::container_traits<Container>::value_type value_type;
|
||||
return sprout::fixed::detail::sinusoid_impl(
|
||||
cont,
|
||||
sprout::math::two_pi<value_type>() * frequency / value_type(sprout::size(cont)),
|
||||
sprout::detail::sinusoid_value_d(frequency, sprout::size(cont)),
|
||||
amplitude,
|
||||
phase,
|
||||
sprout::container_indexes<Container>::make(),
|
||||
|
|
|
@ -9,8 +9,11 @@
|
|||
#define SPROUT_NUMERIC_DFT_FIXED_SPECTRUM_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/type_traits/is_iterator_of.hpp>
|
||||
#include <sprout/type_traits/enabler_if.hpp>
|
||||
#include <sprout/algorithm/fixed/results.hpp>
|
||||
#include <sprout/numeric/dft/fixed/amplitude_spectrum.hpp>
|
||||
#include <sprout/numeric/dft/fixed/phase_spectrum.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace fixed {
|
||||
|
@ -30,9 +33,20 @@ namespace sprout {
|
|||
}
|
||||
} // namespace fixed
|
||||
|
||||
using sprout::fixed::spectrum;
|
||||
template<
|
||||
typename InputIterator, typename Result,
|
||||
typename sprout::enabler_if<!sprout::is_iterator_outputable<Result>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fixed::results::algorithm<Result>::type
|
||||
spectrum(InputIterator first, InputIterator last, Result const& result) {
|
||||
return sprout::fixed::spectrum(first, last, result);
|
||||
}
|
||||
|
||||
template<typename Result, typename InputIterator>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fixed::results::algorithm<Result>::type
|
||||
spectrum(InputIterator first, InputIterator last) {
|
||||
return sprout::fixed::spectrum<Result>(first, last);
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#include <sprout/numeric/dft/fixed/phase_spectrum.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_DFT_FIXED_SPECTRUM_HPP
|
||||
|
|
|
@ -15,18 +15,12 @@
|
|||
#include <sprout/container/indexes.hpp>
|
||||
#include <sprout/algorithm/fixed/results.hpp>
|
||||
#include <sprout/pit/pit.hpp>
|
||||
#include <sprout/numeric/dft/fixed/sawtooth.hpp>
|
||||
#include <sprout/detail/container_complate.hpp>
|
||||
#include <sprout/numeric/dft/detail/square.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace fixed {
|
||||
namespace detail {
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR T
|
||||
square_value(T const& t, T const& d) {
|
||||
return sprout::fixed::detail::sawtooth_value(t) - sprout::fixed::detail::sawtooth_value(t - d);
|
||||
}
|
||||
|
||||
template<typename Container, sprout::index_t... Indexes>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fixed::results::algorithm<Container>::type
|
||||
square_impl(
|
||||
|
@ -40,11 +34,10 @@ namespace sprout {
|
|||
typename sprout::container_traits<Container>::size_type size
|
||||
)
|
||||
{
|
||||
typedef typename sprout::container_traits<Container>::value_type value_type;
|
||||
return sprout::remake<Container>(
|
||||
cont, size,
|
||||
(Indexes >= offset && Indexes < offset + size
|
||||
? amplitude * sprout::fixed::detail::square_value(frequency * value_type(Indexes) + phase, duty)
|
||||
? sprout::detail::square_value(frequency, amplitude, phase, duty, Indexes)
|
||||
: *sprout::next(sprout::internal_begin(cont), Indexes)
|
||||
)...
|
||||
);
|
||||
|
|
|
@ -15,22 +15,12 @@
|
|||
#include <sprout/container/indexes.hpp>
|
||||
#include <sprout/algorithm/fixed/results.hpp>
|
||||
#include <sprout/pit/pit.hpp>
|
||||
#include <sprout/math/sin.hpp>
|
||||
#include <sprout/math/asin.hpp>
|
||||
#include <sprout/math/constants.hpp>
|
||||
#include <sprout/detail/container_complate.hpp>
|
||||
#include <sprout/numeric/dft/detail/triangle.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace fixed {
|
||||
namespace detail {
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR T
|
||||
triangle_value(T const& t) {
|
||||
using sprout::sin;
|
||||
using sprout::asin;
|
||||
return T(sprout::math::two_div_pi<double>()) * asin(sin(T(sprout::math::two_pi<double>()) * t));
|
||||
}
|
||||
|
||||
template<typename Container, sprout::index_t... Indexes>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fixed::results::algorithm<Container>::type
|
||||
triangle_impl(
|
||||
|
@ -43,11 +33,10 @@ namespace sprout {
|
|||
typename sprout::container_traits<Container>::size_type size
|
||||
)
|
||||
{
|
||||
typedef typename sprout::container_traits<Container>::value_type value_type;
|
||||
return sprout::remake<Container>(
|
||||
cont, size,
|
||||
(Indexes >= offset && Indexes < offset + size
|
||||
? amplitude * sprout::fixed::detail::triangle_value(frequency * value_type(Indexes) + phase)
|
||||
? sprout::detail::triangle_value(frequency, amplitude, phase, Indexes)
|
||||
: *sprout::next(sprout::internal_begin(cont), Indexes)
|
||||
)...
|
||||
);
|
||||
|
|
|
@ -11,5 +11,6 @@
|
|||
#include <sprout/config.hpp>
|
||||
#include <sprout/numeric/dft/fixed.hpp>
|
||||
#include <sprout/numeric/dft/fit.hpp>
|
||||
#include <sprout/numeric/dft/cxx14.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_DFT_MODIFYIING_HPP
|
||||
|
|
|
@ -11,5 +11,6 @@
|
|||
#include <sprout/config.hpp>
|
||||
#include <sprout/numeric/dft/fixed/phase_spectrum.hpp>
|
||||
#include <sprout/numeric/dft/fit/phase_spectrum.hpp>
|
||||
#include <sprout/numeric/dft/cxx14/phase_spectrum.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_DFT_PHASE_SPECTRUM_HPP
|
||||
|
|
|
@ -11,5 +11,6 @@
|
|||
#include <sprout/config.hpp>
|
||||
#include <sprout/numeric/dft/fixed/spectrum.hpp>
|
||||
#include <sprout/numeric/dft/fit/spectrum.hpp>
|
||||
#include <sprout/numeric/dft/cxx14/spectrum.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_DFT_SPECTRUM_HPP
|
||||
|
|
Loading…
Reference in a new issue