1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2024-11-12 21:09:01 +00:00

add dft/sawtooth, triangle, square, phase_spectrum, ...

This commit is contained in:
bolero-MURAKAMI 2012-07-08 21:05:24 +09:00
parent 3b6ba46f17
commit e4a4d17207
33 changed files with 2216 additions and 79 deletions

View file

@ -15,6 +15,10 @@
#include <sprout/math/log.hpp>
#include <sprout/math/pow.hpp>
#include <sprout/math/sqrt.hpp>
#include <sprout/math/ceil.hpp>
#include <sprout/math/floor.hpp>
#include <sprout/math/trunc.hpp>
#include <sprout/math/round.hpp>
namespace sprout {
template<typename T>
@ -545,7 +549,7 @@ namespace sprout {
}
template<typename T>
SPROUT_CONSTEXPR sprout::complex<T> sqrt_impl_2(sprout::complex<T> const& x, T const& t) {
return sqrt_impl_2(x, t, t / 2);
return sprout::detail::sqrt_impl_2_1(x, t, t / 2);
}
} // namespace detail
template<typename T>
@ -562,6 +566,23 @@ namespace sprout {
SPROUT_CONSTEXPR sprout::complex<T> tanh(sprout::complex<T> const& x) {
return sprout::sinh(x) / sprout::cosh(x);
}
template<typename T>
SPROUT_CONSTEXPR sprout::complex<T> ceil(sprout::complex<T> const& x) {
return sprout::complex<T>(sprout::ceil(x.real()), sprout::ceil(x.imag()));
}
template<typename T>
SPROUT_CONSTEXPR sprout::complex<T> floor(sprout::complex<T> const& x) {
return sprout::complex<T>(sprout::floor(x.real()), sprout::floor(x.imag()));
}
template<typename T>
SPROUT_CONSTEXPR sprout::complex<T> trunc(sprout::complex<T> const& x) {
return sprout::complex<T>(sprout::trunc(x.real()), sprout::trunc(x.imag()));
}
template<typename T>
SPROUT_CONSTEXPR sprout::complex<T> round(sprout::complex<T> const& x) {
return sprout::complex<T>(sprout::round(x.real()), sprout::round(x.imag()));
}
} // namespace sprout
#endif // #ifndef SPROUT_COMPLEX_HPP

View file

@ -0,0 +1,273 @@
#ifndef SPROUT_ITERATOR_SAWTOOTH_ITERATOR_HPP
#define SPROUT_ITERATOR_SAWTOOTH_ITERATOR_HPP
#include <cstddef>
#include <iterator>
#include <utility>
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/next.hpp>
#include <sprout/iterator/prev.hpp>
#include <sprout/iterator/distance.hpp>
#include <sprout/numeric/dft/fixed/sawtooth.hpp>
namespace sprout {
//
// sawtooth_iterator
//
template<typename Value>
class sawtooth_iterator
: public std::iterator<
std::random_access_iterator_tag,
Value,
std::ptrdiff_t,
Value*,
Value
>
{
public:
typedef std::random_access_iterator_tag iterator_category;
typedef Value value_type;
typedef std::ptrdiff_t difference_type;
typedef value_type* pointer;
typedef value_type reference;
private:
difference_type index_;
value_type frequency_;
value_type amplitude_;
value_type phase_;
private:
explicit SPROUT_CONSTEXPR sawtooth_iterator(sawtooth_iterator const& other, difference_type index)
: index_(index)
, frequency_(other.frequency_)
, amplitude_(other.amplitude_)
, phase_(other.phase_)
{}
public:
SPROUT_CONSTEXPR sawtooth_iterator()
: index_()
, frequency_(1)
, amplitude_(1)
, phase_(0)
{}
sawtooth_iterator(sawtooth_iterator const&) = default;
explicit SPROUT_CONSTEXPR sawtooth_iterator(
difference_type index,
value_type const& frequency = 1,
value_type const& amplitude = 1,
value_type const& phase = 0
)
: index_(index)
, frequency_(frequency)
, amplitude_(amplitude)
, phase_(phase)
{}
template<typename U>
SPROUT_CONSTEXPR sawtooth_iterator(sawtooth_iterator<U> const& it)
: index_(it.index_)
, frequency_(it.frequency_)
, amplitude_(it.amplitude_)
, phase_(it.phase_)
{}
template<typename U>
sawtooth_iterator& operator=(sawtooth_iterator<U> const& it) {
sawtooth_iterator temp(it);
temp.swap(*this);
return *this;
}
SPROUT_CONSTEXPR difference_type index() const {
return index_;
}
SPROUT_CONSTEXPR value_type const& frequency() const {
return frequency_;
}
SPROUT_CONSTEXPR value_type const& amplitude() const {
return amplitude_;
}
SPROUT_CONSTEXPR value_type const& phase() const {
return phase_;
}
SPROUT_CONSTEXPR reference operator*() const {
return amplitude_ * sprout::fixed::detail::sawtooth_value(frequency_ * value_type(index_) + phase_);
}
SPROUT_CONSTEXPR pointer operator->() const {
return &operator*()();
}
sawtooth_iterator& operator++() {
++index_;
return *this;
}
sawtooth_iterator operator++(int) {
sawtooth_iterator result(*this);
++index_;
return result;
}
sawtooth_iterator& operator--() {
--index_;
return *this;
}
sawtooth_iterator operator--(int) {
sawtooth_iterator temp(*this);
--index_;
return temp;
}
SPROUT_CONSTEXPR sawtooth_iterator operator+(difference_type n) const {
return sawtooth_iterator(*this, index_ + n);
}
SPROUT_CONSTEXPR sawtooth_iterator operator-(difference_type n) const {
return sawtooth_iterator(*this, index_ - n);
}
sawtooth_iterator& operator+=(difference_type n) {
sawtooth_iterator temp(*this, index_ + n);
temp.swap(*this);
return *this;
}
sawtooth_iterator& operator-=(difference_type n) {
sawtooth_iterator temp(*this, index_ - n);
temp.swap(*this);
return *this;
}
SPROUT_CONSTEXPR reference operator[](difference_type n) const {
return amplitude_ * sprout::fixed::detail::sawtooth_value(frequency_ * value_type(index_ + n) + phase_);
}
SPROUT_CONSTEXPR sawtooth_iterator next() const {
return sawtooth_iterator(*this, index_ + 1);
}
SPROUT_CONSTEXPR sawtooth_iterator prev() const {
return sawtooth_iterator(*this, index_ - 1);
}
void swap(sawtooth_iterator& other) {
using std::swap;
swap(index_, other.index_);
swap(frequency_, other.frequency_);
swap(amplitude_, other.amplitude_);
swap(phase_, other.phase_);
}
};
template<typename Value1, typename Value2>
SPROUT_CONSTEXPR bool operator==(
sprout::sawtooth_iterator<Value1> const& lhs,
sprout::sawtooth_iterator<Value2> const& rhs
)
{
return lhs.index() == rhs.index();
}
template<typename Value1, typename Value2>
SPROUT_CONSTEXPR bool operator!=(
sprout::sawtooth_iterator<Value1> const& lhs,
sprout::sawtooth_iterator<Value2> const& rhs
)
{
return !(lhs == rhs);
}
template<typename Value1, typename Value2>
SPROUT_CONSTEXPR bool operator<(
sprout::sawtooth_iterator<Value1> const& lhs,
sprout::sawtooth_iterator<Value2> const& rhs
)
{
return lhs.index() < rhs.index();
}
template<typename Value1, typename Value2>
SPROUT_CONSTEXPR bool operator>(
sprout::sawtooth_iterator<Value1> const& lhs,
sprout::sawtooth_iterator<Value2> const& rhs
)
{
return rhs < lhs;
}
template<typename Value1, typename Value2>
SPROUT_CONSTEXPR bool operator<=(
sprout::sawtooth_iterator<Value1> const& lhs,
sprout::sawtooth_iterator<Value2> const& rhs
)
{
return !(rhs < lhs);
}
template<typename Value1, typename Value2>
SPROUT_CONSTEXPR bool operator>=(
sprout::sawtooth_iterator<Value1> const& lhs,
sprout::sawtooth_iterator<Value2> const& rhs
)
{
return !(lhs < rhs);
}
template<typename Value1, typename Value2>
SPROUT_CONSTEXPR typename sprout::sawtooth_iterator<Value1>::difference_type operator-(
sprout::sawtooth_iterator<Value1> const& lhs,
sprout::sawtooth_iterator<Value2> const& rhs
)
{
return lhs.index() - rhs.index();
}
template<typename Value>
SPROUT_CONSTEXPR sprout::sawtooth_iterator<Value> operator+(
typename sprout::sawtooth_iterator<Value>::difference_type n,
sprout::sawtooth_iterator<Value> const& it
)
{
return it + n;
}
//
// swap
//
template<typename Value>
void swap(sprout::sawtooth_iterator<Value>& lhs, sprout::sawtooth_iterator<Value>& rhs) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(lhs.swap(rhs))) {
lhs.swap(rhs);
}
//
// next
//
template<typename Value>
SPROUT_CONSTEXPR sprout::sawtooth_iterator<Value> next(
sprout::sawtooth_iterator<Value> const& it
)
{
return it.next();
}
template<typename Value>
SPROUT_CONSTEXPR sprout::sawtooth_iterator<Value> next(
sprout::sawtooth_iterator<Value> const& it,
typename sprout::sawtooth_iterator<Value>::difference_type n
)
{
return it + n;
}
//
// prev
//
template<typename Value>
SPROUT_CONSTEXPR sprout::sawtooth_iterator<Value> prev(
sprout::sawtooth_iterator<Value> const& it
)
{
return it.prev();
}
template<typename Value>
SPROUT_CONSTEXPR sprout::sawtooth_iterator<Value> prev(
sprout::sawtooth_iterator<Value> const& it,
typename sprout::sawtooth_iterator<Value>::difference_type n
)
{
return it - n;
}
//
// distance
//
template<typename Value>
SPROUT_CONSTEXPR typename std::iterator_traits<sprout::sawtooth_iterator<Value> >::difference_type
distance(
sprout::sawtooth_iterator<Value> first,
sprout::sawtooth_iterator<Value> last
)
{
return last - first;
}
} // namespace sprout
#endif // #ifndef SPROUT_ITERATOR_SAWTOOTH_ITERATOR_HPP

View file

@ -0,0 +1,283 @@
#ifndef SPROUT_ITERATOR_SQUARE_ITERATOR_HPP
#define SPROUT_ITERATOR_SQUARE_ITERATOR_HPP
#include <cstddef>
#include <iterator>
#include <utility>
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/next.hpp>
#include <sprout/iterator/prev.hpp>
#include <sprout/iterator/distance.hpp>
#include <sprout/numeric/dft/fixed/square.hpp>
namespace sprout {
//
// square_iterator
//
template<typename Value>
class square_iterator
: public std::iterator<
std::random_access_iterator_tag,
Value,
std::ptrdiff_t,
Value*,
Value
>
{
public:
typedef std::random_access_iterator_tag iterator_category;
typedef Value value_type;
typedef std::ptrdiff_t difference_type;
typedef value_type* pointer;
typedef value_type reference;
private:
difference_type index_;
value_type frequency_;
value_type amplitude_;
value_type phase_;
value_type duty_;
private:
explicit SPROUT_CONSTEXPR square_iterator(square_iterator const& other, difference_type index)
: index_(index)
, frequency_(other.frequency_)
, amplitude_(other.amplitude_)
, phase_(other.phase_)
, duty_(other.duty_)
{}
public:
SPROUT_CONSTEXPR square_iterator()
: index_()
, frequency_(1)
, amplitude_(1)
, phase_(0)
, duty_(0.5)
{}
square_iterator(square_iterator const&) = default;
explicit SPROUT_CONSTEXPR square_iterator(
difference_type index,
value_type const& frequency = 1,
value_type const& amplitude = 1,
value_type const& phase = 0,
value_type const& duty = 0.5
)
: index_(index)
, frequency_(frequency)
, amplitude_(amplitude)
, phase_(phase)
, duty_(duty)
{}
template<typename U>
SPROUT_CONSTEXPR square_iterator(square_iterator<U> const& it)
: index_(it.index_)
, frequency_(it.frequency_)
, amplitude_(it.amplitude_)
, phase_(it.phase_)
, duty_(it.duty_)
{}
template<typename U>
square_iterator& operator=(square_iterator<U> const& it) {
square_iterator temp(it);
temp.swap(*this);
return *this;
}
SPROUT_CONSTEXPR difference_type index() const {
return index_;
}
SPROUT_CONSTEXPR value_type const& frequency() const {
return frequency_;
}
SPROUT_CONSTEXPR value_type const& amplitude() const {
return amplitude_;
}
SPROUT_CONSTEXPR value_type const& phase() const {
return phase_;
}
SPROUT_CONSTEXPR value_type const& duty() const {
return duty_;
}
SPROUT_CONSTEXPR reference operator*() const {
return amplitude_ * sprout::fixed::detail::square_value(frequency_ * value_type(index_) + phase_, duty_);
}
SPROUT_CONSTEXPR pointer operator->() const {
return &operator*()();
}
square_iterator& operator++() {
++index_;
return *this;
}
square_iterator operator++(int) {
square_iterator result(*this);
++index_;
return result;
}
square_iterator& operator--() {
--index_;
return *this;
}
square_iterator operator--(int) {
square_iterator temp(*this);
--index_;
return temp;
}
SPROUT_CONSTEXPR square_iterator operator+(difference_type n) const {
return square_iterator(*this, index_ + n);
}
SPROUT_CONSTEXPR square_iterator operator-(difference_type n) const {
return square_iterator(*this, index_ - n);
}
square_iterator& operator+=(difference_type n) {
square_iterator temp(*this, index_ + n);
temp.swap(*this);
return *this;
}
square_iterator& operator-=(difference_type n) {
square_iterator temp(*this, index_ - n);
temp.swap(*this);
return *this;
}
SPROUT_CONSTEXPR reference operator[](difference_type n) const {
return amplitude_ * sprout::fixed::detail::square_value(frequency_ * value_type(index_ + n) + phase_, duty_);
}
SPROUT_CONSTEXPR square_iterator next() const {
return square_iterator(*this, index_ + 1);
}
SPROUT_CONSTEXPR square_iterator prev() const {
return square_iterator(*this, index_ - 1);
}
void swap(square_iterator& other) {
using std::swap;
swap(index_, other.index_);
swap(frequency_, other.frequency_);
swap(amplitude_, other.amplitude_);
swap(phase_, other.phase_);
swap(duty_, other.duty_);
}
};
template<typename Value1, typename Value2>
SPROUT_CONSTEXPR bool operator==(
sprout::square_iterator<Value1> const& lhs,
sprout::square_iterator<Value2> const& rhs
)
{
return lhs.index() == rhs.index();
}
template<typename Value1, typename Value2>
SPROUT_CONSTEXPR bool operator!=(
sprout::square_iterator<Value1> const& lhs,
sprout::square_iterator<Value2> const& rhs
)
{
return !(lhs == rhs);
}
template<typename Value1, typename Value2>
SPROUT_CONSTEXPR bool operator<(
sprout::square_iterator<Value1> const& lhs,
sprout::square_iterator<Value2> const& rhs
)
{
return lhs.index() < rhs.index();
}
template<typename Value1, typename Value2>
SPROUT_CONSTEXPR bool operator>(
sprout::square_iterator<Value1> const& lhs,
sprout::square_iterator<Value2> const& rhs
)
{
return rhs < lhs;
}
template<typename Value1, typename Value2>
SPROUT_CONSTEXPR bool operator<=(
sprout::square_iterator<Value1> const& lhs,
sprout::square_iterator<Value2> const& rhs
)
{
return !(rhs < lhs);
}
template<typename Value1, typename Value2>
SPROUT_CONSTEXPR bool operator>=(
sprout::square_iterator<Value1> const& lhs,
sprout::square_iterator<Value2> const& rhs
)
{
return !(lhs < rhs);
}
template<typename Value1, typename Value2>
SPROUT_CONSTEXPR typename sprout::square_iterator<Value1>::difference_type operator-(
sprout::square_iterator<Value1> const& lhs,
sprout::square_iterator<Value2> const& rhs
)
{
return lhs.index() - rhs.index();
}
template<typename Value>
SPROUT_CONSTEXPR sprout::square_iterator<Value> operator+(
typename sprout::square_iterator<Value>::difference_type n,
sprout::square_iterator<Value> const& it
)
{
return it + n;
}
//
// swap
//
template<typename Value>
void swap(sprout::square_iterator<Value>& lhs, sprout::square_iterator<Value>& rhs) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(lhs.swap(rhs))) {
lhs.swap(rhs);
}
//
// next
//
template<typename Value>
SPROUT_CONSTEXPR sprout::square_iterator<Value> next(
sprout::square_iterator<Value> const& it
)
{
return it.next();
}
template<typename Value>
SPROUT_CONSTEXPR sprout::square_iterator<Value> next(
sprout::square_iterator<Value> const& it,
typename sprout::square_iterator<Value>::difference_type n
)
{
return it + n;
}
//
// prev
//
template<typename Value>
SPROUT_CONSTEXPR sprout::square_iterator<Value> prev(
sprout::square_iterator<Value> const& it
)
{
return it.prev();
}
template<typename Value>
SPROUT_CONSTEXPR sprout::square_iterator<Value> prev(
sprout::square_iterator<Value> const& it,
typename sprout::square_iterator<Value>::difference_type n
)
{
return it - n;
}
//
// distance
//
template<typename Value>
SPROUT_CONSTEXPR typename std::iterator_traits<sprout::square_iterator<Value> >::difference_type
distance(
sprout::square_iterator<Value> first,
sprout::square_iterator<Value> last
)
{
return last - first;
}
} // namespace sprout
#endif // #ifndef SPROUT_ITERATOR_SQUARE_ITERATOR_HPP

View file

@ -0,0 +1,273 @@
#ifndef SPROUT_ITERATOR_TRIANGLE_ITERATOR_HPP
#define SPROUT_ITERATOR_TRIANGLE_ITERATOR_HPP
#include <cstddef>
#include <iterator>
#include <utility>
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/iterator/next.hpp>
#include <sprout/iterator/prev.hpp>
#include <sprout/iterator/distance.hpp>
#include <sprout/numeric/dft/fixed/triangle.hpp>
namespace sprout {
//
// triangle_iterator
//
template<typename Value>
class triangle_iterator
: public std::iterator<
std::random_access_iterator_tag,
Value,
std::ptrdiff_t,
Value*,
Value
>
{
public:
typedef std::random_access_iterator_tag iterator_category;
typedef Value value_type;
typedef std::ptrdiff_t difference_type;
typedef value_type* pointer;
typedef value_type reference;
private:
difference_type index_;
value_type frequency_;
value_type amplitude_;
value_type phase_;
private:
explicit SPROUT_CONSTEXPR triangle_iterator(triangle_iterator const& other, difference_type index)
: index_(index)
, frequency_(other.frequency_)
, amplitude_(other.amplitude_)
, phase_(other.phase_)
{}
public:
SPROUT_CONSTEXPR triangle_iterator()
: index_()
, frequency_(1)
, amplitude_(1)
, phase_(0)
{}
triangle_iterator(triangle_iterator const&) = default;
explicit SPROUT_CONSTEXPR triangle_iterator(
difference_type index,
value_type const& frequency = 1,
value_type const& amplitude = 1,
value_type const& phase = 0
)
: index_(index)
, frequency_(frequency)
, amplitude_(amplitude)
, phase_(phase)
{}
template<typename U>
SPROUT_CONSTEXPR triangle_iterator(triangle_iterator<U> const& it)
: index_(it.index_)
, frequency_(it.frequency_)
, amplitude_(it.amplitude_)
, phase_(it.phase_)
{}
template<typename U>
triangle_iterator& operator=(triangle_iterator<U> const& it) {
triangle_iterator temp(it);
temp.swap(*this);
return *this;
}
SPROUT_CONSTEXPR difference_type index() const {
return index_;
}
SPROUT_CONSTEXPR value_type const& frequency() const {
return frequency_;
}
SPROUT_CONSTEXPR value_type const& amplitude() const {
return amplitude_;
}
SPROUT_CONSTEXPR value_type const& phase() const {
return phase_;
}
SPROUT_CONSTEXPR reference operator*() const {
return amplitude_ * sprout::fixed::detail::triangle_value(frequency_ * value_type(index_) + phase_);
}
SPROUT_CONSTEXPR pointer operator->() const {
return &operator*()();
}
triangle_iterator& operator++() {
++index_;
return *this;
}
triangle_iterator operator++(int) {
triangle_iterator result(*this);
++index_;
return result;
}
triangle_iterator& operator--() {
--index_;
return *this;
}
triangle_iterator operator--(int) {
triangle_iterator temp(*this);
--index_;
return temp;
}
SPROUT_CONSTEXPR triangle_iterator operator+(difference_type n) const {
return triangle_iterator(*this, index_ + n);
}
SPROUT_CONSTEXPR triangle_iterator operator-(difference_type n) const {
return triangle_iterator(*this, index_ - n);
}
triangle_iterator& operator+=(difference_type n) {
triangle_iterator temp(*this, index_ + n);
temp.swap(*this);
return *this;
}
triangle_iterator& operator-=(difference_type n) {
triangle_iterator temp(*this, index_ - n);
temp.swap(*this);
return *this;
}
SPROUT_CONSTEXPR reference operator[](difference_type n) const {
return amplitude_ * sprout::fixed::detail::triangle_value(frequency_ * value_type(index_ + n) + phase_);
}
SPROUT_CONSTEXPR triangle_iterator next() const {
return triangle_iterator(*this, index_ + 1);
}
SPROUT_CONSTEXPR triangle_iterator prev() const {
return triangle_iterator(*this, index_ - 1);
}
void swap(triangle_iterator& other) {
using std::swap;
swap(index_, other.index_);
swap(frequency_, other.frequency_);
swap(amplitude_, other.amplitude_);
swap(phase_, other.phase_);
}
};
template<typename Value1, typename Value2>
SPROUT_CONSTEXPR bool operator==(
sprout::triangle_iterator<Value1> const& lhs,
sprout::triangle_iterator<Value2> const& rhs
)
{
return lhs.index() == rhs.index();
}
template<typename Value1, typename Value2>
SPROUT_CONSTEXPR bool operator!=(
sprout::triangle_iterator<Value1> const& lhs,
sprout::triangle_iterator<Value2> const& rhs
)
{
return !(lhs == rhs);
}
template<typename Value1, typename Value2>
SPROUT_CONSTEXPR bool operator<(
sprout::triangle_iterator<Value1> const& lhs,
sprout::triangle_iterator<Value2> const& rhs
)
{
return lhs.index() < rhs.index();
}
template<typename Value1, typename Value2>
SPROUT_CONSTEXPR bool operator>(
sprout::triangle_iterator<Value1> const& lhs,
sprout::triangle_iterator<Value2> const& rhs
)
{
return rhs < lhs;
}
template<typename Value1, typename Value2>
SPROUT_CONSTEXPR bool operator<=(
sprout::triangle_iterator<Value1> const& lhs,
sprout::triangle_iterator<Value2> const& rhs
)
{
return !(rhs < lhs);
}
template<typename Value1, typename Value2>
SPROUT_CONSTEXPR bool operator>=(
sprout::triangle_iterator<Value1> const& lhs,
sprout::triangle_iterator<Value2> const& rhs
)
{
return !(lhs < rhs);
}
template<typename Value1, typename Value2>
SPROUT_CONSTEXPR typename sprout::triangle_iterator<Value1>::difference_type operator-(
sprout::triangle_iterator<Value1> const& lhs,
sprout::triangle_iterator<Value2> const& rhs
)
{
return lhs.index() - rhs.index();
}
template<typename Value>
SPROUT_CONSTEXPR sprout::triangle_iterator<Value> operator+(
typename sprout::triangle_iterator<Value>::difference_type n,
sprout::triangle_iterator<Value> const& it
)
{
return it + n;
}
//
// swap
//
template<typename Value>
void swap(sprout::triangle_iterator<Value>& lhs, sprout::triangle_iterator<Value>& rhs) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(lhs.swap(rhs))) {
lhs.swap(rhs);
}
//
// next
//
template<typename Value>
SPROUT_CONSTEXPR sprout::triangle_iterator<Value> next(
sprout::triangle_iterator<Value> const& it
)
{
return it.next();
}
template<typename Value>
SPROUT_CONSTEXPR sprout::triangle_iterator<Value> next(
sprout::triangle_iterator<Value> const& it,
typename sprout::triangle_iterator<Value>::difference_type n
)
{
return it + n;
}
//
// prev
//
template<typename Value>
SPROUT_CONSTEXPR sprout::triangle_iterator<Value> prev(
sprout::triangle_iterator<Value> const& it
)
{
return it.prev();
}
template<typename Value>
SPROUT_CONSTEXPR sprout::triangle_iterator<Value> prev(
sprout::triangle_iterator<Value> const& it,
typename sprout::triangle_iterator<Value>::difference_type n
)
{
return it - n;
}
//
// distance
//
template<typename Value>
SPROUT_CONSTEXPR typename std::iterator_traits<sprout::triangle_iterator<Value> >::difference_type
distance(
sprout::triangle_iterator<Value> first,
sprout::triangle_iterator<Value> last
)
{
return last - first;
}
} // namespace sprout
#endif // #ifndef SPROUT_ITERATOR_TRIANGLE_ITERATOR_HPP

View file

@ -6,7 +6,12 @@
#include <sprout/numeric/dft/idft.hpp>
#include <sprout/numeric/dft/dft_element.hpp>
#include <sprout/numeric/dft/idft_element.hpp>
#include <sprout/numeric/dft/amplitude_spectrum.hpp>
#include <sprout/numeric/dft/phase_spectrum.hpp>
#include <sprout/numeric/dft/spectrum.hpp>
#include <sprout/numeric/dft/sinusoid.hpp>
#include <sprout/numeric/dft/sawtooth.hpp>
#include <sprout/numeric/dft/triangle.hpp>
#include <sprout/numeric/dft/square.hpp>
#endif // #ifndef SPROUT_NUMERIC_DFT_HPP

View file

@ -0,0 +1,8 @@
#ifndef SPROUT_NUMERIC_DFT_AMPLITUDE_SPECTRUM_HPP
#define SPROUT_NUMERIC_DFT_AMPLITUDE_SPECTRUM_HPP
#include <sprout/config.hpp>
#include <sprout/numeric/dft/fixed/amplitude_spectrum.hpp>
#include <sprout/numeric/dft/fit/amplitude_spectrum.hpp>
#endif // #ifndef SPROUT_NUMERIC_DFT_AMPLITUDE_SPECTRUM_HPP

View file

@ -0,0 +1,46 @@
#ifndef SPROUT_NUMERIC_DFT_FIT_AMPLITUDE_SPECTRUM_HPP
#define SPROUT_NUMERIC_DFT_FIT_AMPLITUDE_SPECTRUM_HPP
#include <sprout/config.hpp>
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/numeric/dft/fixed/amplitude_spectrum.hpp>
#include <sprout/algorithm/fit/result_of.hpp>
#include <sprout/sub_array.hpp>
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
namespace sprout {
namespace fit {
namespace detail {
template<typename InputIterator, typename Result>
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Result>::type amplitude_spectrum_impl(
InputIterator first,
InputIterator last,
Result const& result,
typename sprout::container_traits<Result>::difference_type offset
)
{
return sprout::sub_copy(
sprout::get_internal(sprout::fixed::amplitude_spectrum(first, last, result)),
offset,
offset + NS_SSCRISK_CEL_OR_SPROUT::min(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last), sprout::size(result))
);
}
} // namespace detail
//
// amplitude_spectrum
//
template<typename InputIterator, typename Result>
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Result>::type amplitude_spectrum(
InputIterator first,
InputIterator last,
Result const& result
)
{
return sprout::fit::detail::amplitude_spectrum_impl(first, last, result, sprout::internal_begin_offset(result));
}
} // namespace fit
} // namespace sprout
#endif // #ifndef SPROUT_NUMERIC_DFT_FIT_AMPLITUDE_SPECTRUM_HPP

View file

@ -0,0 +1,46 @@
#ifndef SPROUT_NUMERIC_DFT_FIT_PHASE_SPECTRUM_HPP
#define SPROUT_NUMERIC_DFT_FIT_PHASE_SPECTRUM_HPP
#include <sprout/config.hpp>
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/numeric/dft/fixed/phase_spectrum.hpp>
#include <sprout/algorithm/fit/result_of.hpp>
#include <sprout/sub_array.hpp>
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
namespace sprout {
namespace fit {
namespace detail {
template<typename InputIterator, typename Result>
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Result>::type phase_spectrum_impl(
InputIterator first,
InputIterator last,
Result const& result,
typename sprout::container_traits<Result>::difference_type offset
)
{
return sprout::sub_copy(
sprout::get_internal(sprout::fixed::phase_spectrum(first, last, result)),
offset,
offset + NS_SSCRISK_CEL_OR_SPROUT::min(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last), sprout::size(result))
);
}
} // namespace detail
//
// phase_spectrum
//
template<typename InputIterator, typename Result>
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Result>::type phase_spectrum(
InputIterator first,
InputIterator last,
Result const& result
)
{
return sprout::fit::detail::phase_spectrum_impl(first, last, result, sprout::internal_begin_offset(result));
}
} // namespace fit
} // namespace sprout
#endif // #ifndef SPROUT_NUMERIC_DFT_FIT_PHASE_SPECTRUM_HPP

View file

@ -0,0 +1,46 @@
#ifndef SPROUT_NUMERIC_DFT_FIT_SAWTOOTH_HPP
#define SPROUT_NUMERIC_DFT_FIT_SAWTOOTH_HPP
#include <sprout/config.hpp>
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/numeric/dft/fixed/sawtooth.hpp>
#include <sprout/algorithm/fit/result_of.hpp>
#include <sprout/sub_array.hpp>
namespace sprout {
namespace fit {
namespace detail {
template<typename Container>
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Container>::type sawtooth_impl(
Container const& cont,
typename sprout::container_traits<Container>::value_type const& frequency,
typename sprout::container_traits<Container>::value_type const& amplitude,
typename sprout::container_traits<Container>::value_type const& phase,
typename sprout::container_traits<Container>::difference_type offset
)
{
return sprout::sub_copy(
sprout::get_internal(sprout::fixed::sawtooth(cont, frequency, amplitude, phase)),
offset,
offset + sprout::size(cont)
);
}
} // namespace detail
//
// sawtooth
//
template<typename Container>
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Container>::type sawtooth(
Container const& cont,
typename sprout::container_traits<Container>::value_type const& frequency = 1,
typename sprout::container_traits<Container>::value_type const& amplitude = 1,
typename sprout::container_traits<Container>::value_type const& phase = 0
)
{
return sprout::fit::detail::sawtooth_impl(cont, frequency, amplitude, sprout::internal_begin_offset(cont));
}
} // namespace fit
} // namespace sprout
#endif // #ifndef SPROUT_NUMERIC_DFT_FIT_SAWTOOTH_HPP

View file

@ -2,32 +2,11 @@
#define SPROUT_NUMERIC_DFT_FIT_SPECTRUM_HPP
#include <sprout/config.hpp>
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/numeric/dft/fixed/spectrum.hpp>
#include <sprout/algorithm/fit/result_of.hpp>
#include <sprout/sub_array.hpp>
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
#include <sprout/numeric/dft/fit/amplitude_spectrum.hpp>
namespace sprout {
namespace fit {
namespace detail {
template<typename InputIterator, typename Result>
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Result>::type spectrum_impl(
InputIterator first,
InputIterator last,
Result const& result,
typename sprout::container_traits<Result>::difference_type offset
)
{
return sprout::sub_copy(
sprout::get_internal(sprout::fixed::spectrum(first, last, result)),
offset,
offset + NS_SSCRISK_CEL_OR_SPROUT::min(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last), sprout::size(result))
);
}
} // namespace detail
//
// spectrum
//
@ -38,7 +17,7 @@ namespace sprout {
Result const& result
)
{
return sprout::fit::detail::spectrum_impl(first, last, result, sprout::internal_begin_offset(result));
return sprout::fit::amplitude_spectrum(first, last, result);
}
} // namespace fit
} // namespace sprout

View file

@ -0,0 +1,48 @@
#ifndef SPROUT_NUMERIC_DFT_FIT_SQUARE_HPP
#define SPROUT_NUMERIC_DFT_FIT_SQUARE_HPP
#include <sprout/config.hpp>
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/numeric/dft/fixed/square.hpp>
#include <sprout/algorithm/fit/result_of.hpp>
#include <sprout/sub_array.hpp>
namespace sprout {
namespace fit {
namespace detail {
template<typename Container>
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Container>::type square_impl(
Container const& cont,
typename sprout::container_traits<Container>::value_type const& frequency,
typename sprout::container_traits<Container>::value_type const& amplitude,
typename sprout::container_traits<Container>::value_type const& phase,
typename sprout::container_traits<Container>::value_type const& duty,
typename sprout::container_traits<Container>::difference_type offset
)
{
return sprout::sub_copy(
sprout::get_internal(sprout::fixed::square(cont, frequency, amplitude, phase, duty)),
offset,
offset + sprout::size(cont)
);
}
} // namespace detail
//
// square
//
template<typename Container>
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Container>::type square(
Container const& cont,
typename sprout::container_traits<Container>::value_type const& frequency = 1,
typename sprout::container_traits<Container>::value_type const& amplitude = 1,
typename sprout::container_traits<Container>::value_type const& phase = 0,
typename sprout::container_traits<Container>::value_type const& duty = 0.5
)
{
return sprout::fit::detail::square_impl(cont, frequency, amplitude, duty, sprout::internal_begin_offset(cont));
}
} // namespace fit
} // namespace sprout
#endif // #ifndef SPROUT_NUMERIC_DFT_FIT_SQUARE_HPP

View file

@ -0,0 +1,46 @@
#ifndef SPROUT_NUMERIC_DFT_FIT_TRINAGLE_HPP
#define SPROUT_NUMERIC_DFT_FIT_TRINAGLE_HPP
#include <sprout/config.hpp>
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/numeric/dft/fixed/triangle.hpp>
#include <sprout/algorithm/fit/result_of.hpp>
#include <sprout/sub_array.hpp>
namespace sprout {
namespace fit {
namespace detail {
template<typename Container>
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Container>::type triangle_impl(
Container const& cont,
typename sprout::container_traits<Container>::value_type const& frequency,
typename sprout::container_traits<Container>::value_type const& amplitude,
typename sprout::container_traits<Container>::value_type const& phase,
typename sprout::container_traits<Container>::difference_type offset
)
{
return sprout::sub_copy(
sprout::get_internal(sprout::fixed::triangle(cont, frequency, amplitude, phase)),
offset,
offset + sprout::size(cont)
);
}
} // namespace detail
//
// triangle
//
template<typename Container>
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Container>::type triangle(
Container const& cont,
typename sprout::container_traits<Container>::value_type const& frequency = 1,
typename sprout::container_traits<Container>::value_type const& amplitude = 1,
typename sprout::container_traits<Container>::value_type const& phase = 0
)
{
return sprout::fit::detail::triangle_impl(cont, frequency, amplitude, sprout::internal_begin_offset(cont));
}
} // namespace fit
} // namespace sprout
#endif // #ifndef SPROUT_NUMERIC_DFT_FIT_TRINAGLE_HPP

View file

@ -0,0 +1,80 @@
#ifndef SPROUT_NUMERIC_DFT_FIXED_AMPLITUDE_SPECTRUM_HPP
#define SPROUT_NUMERIC_DFT_FIXED_AMPLITUDE_SPECTRUM_HPP
#include <sprout/config.hpp>
#include <sprout/index_tuple.hpp>
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp>
#include <sprout/complex.hpp>
#include <sprout/math/sqrt.hpp>
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
namespace sprout {
namespace fixed {
namespace detail {
template<typename InputIterator, typename Result, sprout::index_t... Indexes>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
amplitude_spectrum_impl(
InputIterator first,
InputIterator last,
Result const& result,
sprout::index_tuple<Indexes...>,
typename sprout::container_traits<Result>::difference_type offset,
typename sprout::container_traits<Result>::size_type size,
typename sprout::container_traits<Result>::size_type input_size
)
{
using sprout::real;
using sprout::imag;
return sprout::remake<Result>(
result,
size,
(Indexes >= offset && Indexes < offset + size && Indexes < offset + input_size
? sprout::sqrt(
real(*sprout::next(first, Indexes)) * real(*sprout::next(first, Indexes))
+ imag(*sprout::next(first, Indexes)) * imag(*sprout::next(first, Indexes))
)
: *sprout::next(sprout::internal_begin(result), Indexes)
)...
);
}
template<typename InputIterator, typename Result>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
amplitude_spectrum(
InputIterator first,
InputIterator last,
Result const& result
)
{
return sprout::fixed::detail::amplitude_spectrum_impl(
first,
last,
result,
sprout::index_range<0, sprout::container_traits<Result>::static_size>::make(),
sprout::internal_begin_offset(result),
sprout::size(result),
NS_SSCRISK_CEL_OR_SPROUT::distance(first, last)
);
}
} // namespace detail
//
// amplitude_spectrum
//
template<typename InputIterator, typename Result>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
amplitude_spectrum(
InputIterator first,
InputIterator last,
Result const& result
)
{
return sprout::fixed::detail::amplitude_spectrum(first, last, result);
}
} // namespace fixed
using sprout::fixed::amplitude_spectrum;
} // namespace sprout
#endif // #ifndef SPROUT_NUMERIC_DFT_FIXED_AMPLITUDE_SPECTRUM_HPP

View file

@ -0,0 +1,81 @@
#ifndef SPROUT_NUMERIC_DFT_FIXED_PHASE_SPECTRUM_HPP
#define SPROUT_NUMERIC_DFT_FIXED_PHASE_SPECTRUM_HPP
#include <sprout/config.hpp>
#include <sprout/index_tuple.hpp>
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp>
#include <sprout/complex.hpp>
#include <sprout/math/atan2.hpp>
#include <sprout/math/llround.hpp>
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
namespace sprout {
namespace fixed {
namespace detail {
template<typename InputIterator, typename Result, sprout::index_t... Indexes>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
phase_spectrum_impl(
InputIterator first,
InputIterator last,
Result const& result,
sprout::index_tuple<Indexes...>,
typename sprout::container_traits<Result>::difference_type offset,
typename sprout::container_traits<Result>::size_type size,
typename sprout::container_traits<Result>::size_type input_size
)
{
using sprout::real;
using sprout::imag;
return sprout::remake<Result>(
result,
size,
(Indexes >= offset && Indexes < offset + size && Indexes < offset + input_size
? sprout::atan2(
sprout::llround(imag(*sprout::next(first, Indexes))),
sprout::llround(real(*sprout::next(first, Indexes)))
)
: *sprout::next(sprout::internal_begin(result), Indexes)
)...
);
}
template<typename InputIterator, typename Result>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
phase_spectrum(
InputIterator first,
InputIterator last,
Result const& result
)
{
return sprout::fixed::detail::phase_spectrum_impl(
first,
last,
result,
sprout::index_range<0, sprout::container_traits<Result>::static_size>::make(),
sprout::internal_begin_offset(result),
sprout::size(result),
NS_SSCRISK_CEL_OR_SPROUT::distance(first, last)
);
}
} // namespace detail
//
// phase_spectrum
//
template<typename InputIterator, typename Result>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
phase_spectrum(
InputIterator first,
InputIterator last,
Result const& result
)
{
return sprout::fixed::detail::phase_spectrum(first, last, result);
}
} // namespace fixed
using sprout::fixed::phase_spectrum;
} // namespace sprout
#endif // #ifndef SPROUT_NUMERIC_DFT_FIXED_PHASE_SPECTRUM_HPP

View file

@ -0,0 +1,84 @@
#ifndef SPROUT_NUMERIC_DFT_FIXED_SAWTOOTH_HPP
#define SPROUT_NUMERIC_DFT_FIXED_SAWTOOTH_HPP
#include <sprout/config.hpp>
#include <sprout/index_tuple.hpp>
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/container/indexes.hpp>
#include <sprout/algorithm/fixed/result_of.hpp>
#include <sprout/math/floor.hpp>
namespace sprout {
namespace fixed {
namespace detail {
template<typename T>
inline SPROUT_CONSTEXPR T
sawtooth_value(T const& t) {
using sprout::floor;
return T(2) * (t - floor(t + T(0.5)));
}
template<typename Container, sprout::index_t... Indexes>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Container>::type
sawtooth_impl(
Container const& cont,
typename sprout::container_traits<Container>::value_type const& frequency,
typename sprout::container_traits<Container>::value_type const& amplitude,
typename sprout::container_traits<Container>::value_type const& phase,
sprout::index_tuple<Indexes...>,
typename sprout::container_traits<Container>::difference_type offset,
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::next(sprout::internal_begin(cont), Indexes)
)...
);
}
template<typename Container>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Container>::type
sawtooth(
Container const& cont,
typename sprout::container_traits<Container>::value_type const& frequency,
typename sprout::container_traits<Container>::value_type const& amplitude,
typename sprout::container_traits<Container>::value_type const& phase
)
{
typedef typename sprout::container_traits<Container>::value_type value_type;
return sprout::fixed::detail::sawtooth_impl(
cont,
frequency,
amplitude,
phase,
sprout::container_indexes<Container>::make(),
sprout::internal_begin_offset(cont),
sprout::size(cont)
);
}
} // namespace detail
//
// sawtooth
//
template<typename Container>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Container>::type
sawtooth(
Container const& cont,
typename sprout::container_traits<Container>::value_type const& frequency = 1,
typename sprout::container_traits<Container>::value_type const& amplitude = 1,
typename sprout::container_traits<Container>::value_type const& phase = 0
)
{
return sprout::fixed::detail::sawtooth(cont, frequency, amplitude, phase);
}
} // namespace fixed
using sprout::fixed::sawtooth;
} // namespace sprout
#endif // #ifndef SPROUT_NUMERIC_DFT_FIXED_SAWTOOTH_HPP

View file

@ -2,64 +2,11 @@
#define SPROUT_NUMERIC_DFT_FIXED_SPECTRUM_HPP
#include <sprout/config.hpp>
#include <sprout/index_tuple.hpp>
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/algorithm/fixed/result_of.hpp>
#include <sprout/complex.hpp>
#include <sprout/math/sqrt.hpp>
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
#include <sprout/numeric/dft/fixed/amplitude_spectrum.hpp>
namespace sprout {
namespace fixed {
namespace detail {
template<typename InputIterator, typename Result, sprout::index_t... Indexes>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
spectrum_impl(
InputIterator first,
InputIterator last,
Result const& result,
sprout::index_tuple<Indexes...>,
typename sprout::container_traits<Result>::difference_type offset,
typename sprout::container_traits<Result>::size_type size,
typename sprout::container_traits<Result>::size_type input_size
)
{
using sprout::sqrt;
using sprout::real;
using sprout::imag;
return sprout::remake<Result>(
result,
size,
(Indexes >= offset && Indexes < offset + size && Indexes < offset + input_size
? sqrt(
real(*sprout::next(first, Indexes)) * real(*sprout::next(first, Indexes))
+ imag(*sprout::next(first, Indexes)) * imag(*sprout::next(first, Indexes))
)
: *sprout::next(sprout::internal_begin(result), Indexes)
)...
);
}
template<typename InputIterator, typename Result>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
spectrum(
InputIterator first,
InputIterator last,
Result const& result
)
{
return sprout::fixed::detail::spectrum_impl(
first,
last,
result,
sprout::index_range<0, sprout::container_traits<Result>::static_size>::make(),
sprout::internal_begin_offset(result),
sprout::size(result),
NS_SSCRISK_CEL_OR_SPROUT::distance(first, last)
);
}
} // namespace detail
//
// spectrum
//
@ -71,7 +18,7 @@ namespace sprout {
Result const& result
)
{
return sprout::fixed::detail::spectrum(first, last, result);
return sprout::fixed::amplitude_spectrum(first, last, result);
}
} // namespace fixed

View file

@ -0,0 +1,87 @@
#ifndef SPROUT_NUMERIC_DFT_FIXED_SQUARE_HPP
#define SPROUT_NUMERIC_DFT_FIXED_SQUARE_HPP
#include <sprout/config.hpp>
#include <sprout/index_tuple.hpp>
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/container/indexes.hpp>
#include <sprout/algorithm/fixed/result_of.hpp>
#include <sprout/numeric/dft/fixed/sawtooth.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::result_of::algorithm<Container>::type
square_impl(
Container const& cont,
typename sprout::container_traits<Container>::value_type const& frequency,
typename sprout::container_traits<Container>::value_type const& amplitude,
typename sprout::container_traits<Container>::value_type const& phase,
typename sprout::container_traits<Container>::value_type const& duty,
sprout::index_tuple<Indexes...>,
typename sprout::container_traits<Container>::difference_type offset,
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::next(sprout::internal_begin(cont), Indexes)
)...
);
}
template<typename Container>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Container>::type
square(
Container const& cont,
typename sprout::container_traits<Container>::value_type const& frequency,
typename sprout::container_traits<Container>::value_type const& amplitude,
typename sprout::container_traits<Container>::value_type const& phase,
typename sprout::container_traits<Container>::value_type const& duty
)
{
typedef typename sprout::container_traits<Container>::value_type value_type;
return sprout::fixed::detail::square_impl(
cont,
frequency,
amplitude,
phase,
duty,
sprout::container_indexes<Container>::make(),
sprout::internal_begin_offset(cont),
sprout::size(cont)
);
}
} // namespace detail
//
// square
//
template<typename Container>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Container>::type
square(
Container const& cont,
typename sprout::container_traits<Container>::value_type const& frequency = 1,
typename sprout::container_traits<Container>::value_type const& amplitude = 1,
typename sprout::container_traits<Container>::value_type const& phase = 0,
typename sprout::container_traits<Container>::value_type const& duty = 0.5
)
{
return sprout::fixed::detail::square(cont, frequency, amplitude, phase, duty);
}
} // namespace fixed
using sprout::fixed::square;
} // namespace sprout
#endif // #ifndef SPROUT_NUMERIC_DFT_FIXED_SQUARE_HPP

View file

@ -0,0 +1,87 @@
#ifndef SPROUT_NUMERIC_DFT_FIXED_TRINAGLE_HPP
#define SPROUT_NUMERIC_DFT_FIXED_TRINAGLE_HPP
#include <sprout/config.hpp>
#include <sprout/index_tuple.hpp>
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/container/indexes.hpp>
#include <sprout/algorithm/fixed/result_of.hpp>
#include <sprout/math/sin.hpp>
#include <sprout/math/asin.hpp>
#include <sprout/math/constants.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(2) / T(sprout::math::pi<double>()) * asin(sin(T(2) * T(sprout::math::pi<double>()) * t));
}
template<typename Container, sprout::index_t... Indexes>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Container>::type
triangle_impl(
Container const& cont,
typename sprout::container_traits<Container>::value_type const& frequency,
typename sprout::container_traits<Container>::value_type const& amplitude,
typename sprout::container_traits<Container>::value_type const& phase,
sprout::index_tuple<Indexes...>,
typename sprout::container_traits<Container>::difference_type offset,
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::next(sprout::internal_begin(cont), Indexes)
)...
);
}
template<typename Container>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Container>::type
triangle(
Container const& cont,
typename sprout::container_traits<Container>::value_type const& frequency,
typename sprout::container_traits<Container>::value_type const& amplitude,
typename sprout::container_traits<Container>::value_type const& phase
)
{
typedef typename sprout::container_traits<Container>::value_type value_type;
return sprout::fixed::detail::triangle_impl(
cont,
frequency,
amplitude,
phase,
sprout::container_indexes<Container>::make(),
sprout::internal_begin_offset(cont),
sprout::size(cont)
);
}
} // namespace detail
//
// triangle
//
template<typename Container>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Container>::type
triangle(
Container const& cont,
typename sprout::container_traits<Container>::value_type const& frequency = 1,
typename sprout::container_traits<Container>::value_type const& amplitude = 1,
typename sprout::container_traits<Container>::value_type const& phase = 0
)
{
return sprout::fixed::detail::triangle(cont, frequency, amplitude, phase);
}
} // namespace fixed
using sprout::fixed::triangle;
} // namespace sprout
#endif // #ifndef SPROUT_NUMERIC_DFT_FIXED_TRINAGLE_HPP

View file

@ -0,0 +1,8 @@
#ifndef SPROUT_NUMERIC_DFT_PHASE_SPECTRUM_HPP
#define SPROUT_NUMERIC_DFT_PHASE_SPECTRUM_HPP
#include <sprout/config.hpp>
#include <sprout/numeric/dft/fixed/phase_spectrum.hpp>
#include <sprout/numeric/dft/fit/phase_spectrum.hpp>
#endif // #ifndef SPROUT_NUMERIC_DFT_PHASE_SPECTRUM_HPP

View file

@ -0,0 +1,8 @@
#ifndef SPROUT_NUMERIC_DFT_SAWTOOTH_HPP
#define SPROUT_NUMERIC_DFT_SAWTOOTH_HPP
#include <sprout/config.hpp>
#include <sprout/numeric/dft/fixed/sawtooth.hpp>
#include <sprout/numeric/dft/fit/sawtooth.hpp>
#endif // #ifndef SPROUT_NUMERIC_DFT_SAWTOOTH_HPP

View file

@ -0,0 +1,8 @@
#ifndef SPROUT_NUMERIC_DFT_SQUARE_HPP
#define SPROUT_NUMERIC_DFT_SQUARE_HPP
#include <sprout/config.hpp>
#include <sprout/numeric/dft/fixed/square.hpp>
#include <sprout/numeric/dft/fit/square.hpp>
#endif // #ifndef SPROUT_NUMERIC_DFT_SQUARE_HPP

View file

@ -0,0 +1,8 @@
#ifndef SPROUT_NUMERIC_DFT_TRINAGLE_HPP
#define SPROUT_NUMERIC_DFT_TRINAGLE_HPP
#include <sprout/config.hpp>
#include <sprout/numeric/dft/fixed/triangle.hpp>
#include <sprout/numeric/dft/fit/triangle.hpp>
#endif // #ifndef SPROUT_NUMERIC_DFT_TRINAGLE_HPP

View file

@ -9,5 +9,8 @@
#include <sprout/range/adaptor/sized.hpp>
#include <sprout/range/adaptor/size_enumed.hpp>
#include <sprout/range/adaptor/sinusoidal.hpp>
#include <sprout/range/adaptor/sawtooth_wave.hpp>
#include <sprout/range/adaptor/triangle_wave.hpp>
#include <sprout/range/adaptor/square_wave.hpp>
#endif // #ifndef SPROUT_RANGE_ADAPTOR_HPP

View file

@ -0,0 +1,172 @@
#ifndef SPROUT_RANGE_ADAPTOR_SAWTOOTH_WAVE_HPP
#define SPROUT_RANGE_ADAPTOR_SAWTOOTH_WAVE_HPP
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/pit.hpp>
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/iterator/sawtooth_iterator.hpp>
#include <sprout/range/range_container.hpp>
#include <sprout/range/algorithm/copy.hpp>
#include <sprout/type_traits/lvalue_reference.hpp>
#include <sprout/utility/forward.hpp>
#include <sprout/utility/lvalue_forward.hpp>
namespace sprout {
namespace adaptors {
//
// sawtooth_wave_range
//
template<typename Value, typename Range = void>
class sawtooth_wave_range
: public sprout::range::range_container<
sprout::sawtooth_iterator<Value>
>
, public sprout::detail::container_nosy_static_size<Range>
, public sprout::detail::container_nosy_fixed_size<Range>
{
public:
typedef Range range_type;
typedef sprout::range::range_container<
sprout::sawtooth_iterator<Value>
> base_type;
typedef typename base_type::iterator iterator;
typedef typename base_type::value_type value_type;
typedef typename base_type::difference_type difference_type;
public:
sawtooth_wave_range() = default;
sawtooth_wave_range(sawtooth_wave_range const&) = default;
explicit SPROUT_CONSTEXPR sawtooth_wave_range(
range_type& range,
value_type const& frequency = 1,
value_type const& amplitude = 1,
value_type const& phase = 0
)
: base_type(
iterator(0, frequency, amplitude, phase),
iterator(sprout::size(range), frequency, amplitude, phase)
)
{}
SPROUT_CONSTEXPR value_type const& frequency() const {
return base_type::begin().frequency();
}
SPROUT_CONSTEXPR value_type const& amplitude() const {
return base_type::begin().amplitude();
}
SPROUT_CONSTEXPR value_type const& phase() const {
return base_type::begin().phase();
}
};
template<typename Value>
class sawtooth_wave_range<Value, void>
: public sprout::range::range_container<
sprout::sawtooth_iterator<Value>
>
{
public:
typedef sprout::range::range_container<
sprout::sawtooth_iterator<Value>
> base_type;
typedef typename base_type::iterator iterator;
typedef typename base_type::value_type value_type;
typedef typename base_type::difference_type difference_type;
public:
sawtooth_wave_range() = default;
sawtooth_wave_range(sawtooth_wave_range const&) = default;
explicit SPROUT_CONSTEXPR sawtooth_wave_range(
value_type const& frequency = 1,
value_type const& amplitude = 1,
value_type const& phase = 0
)
: base_type(
iterator(0, frequency, amplitude, phase),
iterator(-1, frequency, amplitude, phase)
)
{}
SPROUT_CONSTEXPR value_type const& frequency() const {
return base_type::begin().frequency();
}
SPROUT_CONSTEXPR value_type const& amplitude() const {
return base_type::begin().amplitude();
}
SPROUT_CONSTEXPR value_type const& phase() const {
return base_type::begin().phase();
}
};
//
// sawtooth_wave_forwarder
//
class sawtooth_wave_forwarder {
public:
template<typename Value>
SPROUT_CONSTEXPR sprout::adaptors::sawtooth_wave_range<Value>
operator()(
Value const& frequency = 1,
Value const& amplitude = 1,
Value const& phase = 0
)
{
return sprout::adaptors::sawtooth_wave_range<Value>(frequency, amplitude, phase);
}
};
//
// sawtooth_wave
//
namespace {
SPROUT_STATIC_CONSTEXPR sprout::adaptors::sawtooth_wave_forwarder sawtooth_wave{};
} // anonymous-namespace
//
// operator|
//
template<typename Range, typename Value>
inline SPROUT_CONSTEXPR sprout::adaptors::sawtooth_wave_range<
Value,
typename std::remove_reference<typename sprout::lvalue_reference<Range>::type>::type
>
operator|(Range&& lhs, sprout::adaptors::sawtooth_wave_range<Value> const& rhs) {
return sprout::adaptors::sawtooth_wave_range<
Value,
typename std::remove_reference<typename sprout::lvalue_reference<Range>::type>::type
>(
sprout::lvalue_forward<Range>(lhs),
rhs.frequency(),
rhs.amplitude(),
rhs.phase()
);
}
} // namespace adaptors
//
// container_construct_traits
//
template<typename Value, typename Range>
struct container_construct_traits<sprout::adaptors::sawtooth_wave_range<Value, Range> > {
public:
typedef typename sprout::container_construct_traits<Range>::copied_type copied_type;
public:
template<typename Cont>
static SPROUT_CONSTEXPR copied_type deep_copy(Cont&& cont) {
return sprout::range::fixed::copy(sprout::forward<Cont>(cont), sprout::pit<copied_type>());
}
template<typename... Args>
static SPROUT_CONSTEXPR copied_type make(Args&&... args) {
return sprout::make<copied_type>(sprout::forward<Args>(args)...);
}
template<typename Cont, typename... Args>
static SPROUT_CONSTEXPR copied_type remake(
Cont&& cont,
typename sprout::container_traits<sprout::adaptors::sawtooth_wave_range<Value, Range> >::difference_type size,
Args&&... args
)
{
return sprout::remake<copied_type>(sprout::forward<Cont>(cont), size, sprout::forward<Args>(args)...);
}
};
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ADAPTOR_SAWTOOTH_WAVE_HPP

View file

@ -0,0 +1,182 @@
#ifndef SPROUT_RANGE_ADAPTOR_SQUARE_WAVE_HPP
#define SPROUT_RANGE_ADAPTOR_SQUARE_WAVE_HPP
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/pit.hpp>
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/iterator/square_iterator.hpp>
#include <sprout/range/range_container.hpp>
#include <sprout/range/algorithm/copy.hpp>
#include <sprout/type_traits/lvalue_reference.hpp>
#include <sprout/utility/forward.hpp>
#include <sprout/utility/lvalue_forward.hpp>
namespace sprout {
namespace adaptors {
//
// square_wave_range
//
template<typename Value, typename Range = void>
class square_wave_range
: public sprout::range::range_container<
sprout::square_iterator<Value>
>
, public sprout::detail::container_nosy_static_size<Range>
, public sprout::detail::container_nosy_fixed_size<Range>
{
public:
typedef Range range_type;
typedef sprout::range::range_container<
sprout::square_iterator<Value>
> base_type;
typedef typename base_type::iterator iterator;
typedef typename base_type::value_type value_type;
typedef typename base_type::difference_type difference_type;
public:
square_wave_range() = default;
square_wave_range(square_wave_range const&) = default;
explicit SPROUT_CONSTEXPR square_wave_range(
range_type& range,
value_type const& frequency = 1,
value_type const& amplitude = 1,
value_type const& phase = 0,
value_type const& duty = 0.5
)
: base_type(
iterator(0, frequency, amplitude, phase, duty),
iterator(sprout::size(range), frequency, amplitude, phase, duty)
)
{}
SPROUT_CONSTEXPR value_type const& frequency() const {
return base_type::begin().frequency();
}
SPROUT_CONSTEXPR value_type const& amplitude() const {
return base_type::begin().amplitude();
}
SPROUT_CONSTEXPR value_type const& phase() const {
return base_type::begin().phase();
}
SPROUT_CONSTEXPR value_type const& duty() const {
return base_type::begin().duty();
}
};
template<typename Value>
class square_wave_range<Value, void>
: public sprout::range::range_container<
sprout::square_iterator<Value>
>
{
public:
typedef sprout::range::range_container<
sprout::square_iterator<Value>
> base_type;
typedef typename base_type::iterator iterator;
typedef typename base_type::value_type value_type;
typedef typename base_type::difference_type difference_type;
public:
square_wave_range() = default;
square_wave_range(square_wave_range const&) = default;
explicit SPROUT_CONSTEXPR square_wave_range(
value_type const& frequency = 1,
value_type const& amplitude = 1,
value_type const& phase = 0,
value_type const& duty = 0.5
)
: base_type(
iterator(0, frequency, amplitude, phase, duty),
iterator(-1, frequency, amplitude, phase, duty)
)
{}
SPROUT_CONSTEXPR value_type const& frequency() const {
return base_type::begin().frequency();
}
SPROUT_CONSTEXPR value_type const& amplitude() const {
return base_type::begin().amplitude();
}
SPROUT_CONSTEXPR value_type const& phase() const {
return base_type::begin().phase();
}
SPROUT_CONSTEXPR value_type const& duty() const {
return base_type::begin().duty();
}
};
//
// square_wave_forwarder
//
class square_wave_forwarder {
public:
template<typename Value>
SPROUT_CONSTEXPR sprout::adaptors::square_wave_range<Value>
operator()(
Value const& frequency = 1,
Value const& amplitude = 1,
Value const& phase = 0,
Value const& duty = 0.5
)
{
return sprout::adaptors::square_wave_range<Value>(frequency, amplitude, phase, duty);
}
};
//
// square_wave
//
namespace {
SPROUT_STATIC_CONSTEXPR sprout::adaptors::square_wave_forwarder square_wave{};
} // anonymous-namespace
//
// operator|
//
template<typename Range, typename Value>
inline SPROUT_CONSTEXPR sprout::adaptors::square_wave_range<
Value,
typename std::remove_reference<typename sprout::lvalue_reference<Range>::type>::type
>
operator|(Range&& lhs, sprout::adaptors::square_wave_range<Value> const& rhs) {
return sprout::adaptors::square_wave_range<
Value,
typename std::remove_reference<typename sprout::lvalue_reference<Range>::type>::type
>(
sprout::lvalue_forward<Range>(lhs),
rhs.frequency(),
rhs.amplitude(),
rhs.phase(),
rhs.duty()
);
}
} // namespace adaptors
//
// container_construct_traits
//
template<typename Value, typename Range>
struct container_construct_traits<sprout::adaptors::square_wave_range<Value, Range> > {
public:
typedef typename sprout::container_construct_traits<Range>::copied_type copied_type;
public:
template<typename Cont>
static SPROUT_CONSTEXPR copied_type deep_copy(Cont&& cont) {
return sprout::range::fixed::copy(sprout::forward<Cont>(cont), sprout::pit<copied_type>());
}
template<typename... Args>
static SPROUT_CONSTEXPR copied_type make(Args&&... args) {
return sprout::make<copied_type>(sprout::forward<Args>(args)...);
}
template<typename Cont, typename... Args>
static SPROUT_CONSTEXPR copied_type remake(
Cont&& cont,
typename sprout::container_traits<sprout::adaptors::square_wave_range<Value, Range> >::difference_type size,
Args&&... args
)
{
return sprout::remake<copied_type>(sprout::forward<Cont>(cont), size, sprout::forward<Args>(args)...);
}
};
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ADAPTOR_SQUARE_WAVE_HPP

View file

@ -0,0 +1,172 @@
#ifndef SPROUT_RANGE_ADAPTOR_TRIANGLE_WAVE_HPP
#define SPROUT_RANGE_ADAPTOR_TRIANGLE_WAVE_HPP
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/pit.hpp>
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/iterator/triangle_iterator.hpp>
#include <sprout/range/range_container.hpp>
#include <sprout/range/algorithm/copy.hpp>
#include <sprout/type_traits/lvalue_reference.hpp>
#include <sprout/utility/forward.hpp>
#include <sprout/utility/lvalue_forward.hpp>
namespace sprout {
namespace adaptors {
//
// triangle_wave_range
//
template<typename Value, typename Range = void>
class triangle_wave_range
: public sprout::range::range_container<
sprout::triangle_iterator<Value>
>
, public sprout::detail::container_nosy_static_size<Range>
, public sprout::detail::container_nosy_fixed_size<Range>
{
public:
typedef Range range_type;
typedef sprout::range::range_container<
sprout::triangle_iterator<Value>
> base_type;
typedef typename base_type::iterator iterator;
typedef typename base_type::value_type value_type;
typedef typename base_type::difference_type difference_type;
public:
triangle_wave_range() = default;
triangle_wave_range(triangle_wave_range const&) = default;
explicit SPROUT_CONSTEXPR triangle_wave_range(
range_type& range,
value_type const& frequency = 1,
value_type const& amplitude = 1,
value_type const& phase = 0
)
: base_type(
iterator(0, frequency, amplitude, phase),
iterator(sprout::size(range), frequency, amplitude, phase)
)
{}
SPROUT_CONSTEXPR value_type const& frequency() const {
return base_type::begin().frequency();
}
SPROUT_CONSTEXPR value_type const& amplitude() const {
return base_type::begin().amplitude();
}
SPROUT_CONSTEXPR value_type const& phase() const {
return base_type::begin().phase();
}
};
template<typename Value>
class triangle_wave_range<Value, void>
: public sprout::range::range_container<
sprout::triangle_iterator<Value>
>
{
public:
typedef sprout::range::range_container<
sprout::triangle_iterator<Value>
> base_type;
typedef typename base_type::iterator iterator;
typedef typename base_type::value_type value_type;
typedef typename base_type::difference_type difference_type;
public:
triangle_wave_range() = default;
triangle_wave_range(triangle_wave_range const&) = default;
explicit SPROUT_CONSTEXPR triangle_wave_range(
value_type const& frequency = 1,
value_type const& amplitude = 1,
value_type const& phase = 0
)
: base_type(
iterator(0, frequency, amplitude, phase),
iterator(-1, frequency, amplitude, phase)
)
{}
SPROUT_CONSTEXPR value_type const& frequency() const {
return base_type::begin().frequency();
}
SPROUT_CONSTEXPR value_type const& amplitude() const {
return base_type::begin().amplitude();
}
SPROUT_CONSTEXPR value_type const& phase() const {
return base_type::begin().phase();
}
};
//
// triangle_wave_forwarder
//
class triangle_wave_forwarder {
public:
template<typename Value>
SPROUT_CONSTEXPR sprout::adaptors::triangle_wave_range<Value>
operator()(
Value const& frequency = 1,
Value const& amplitude = 1,
Value const& phase = 0
)
{
return sprout::adaptors::triangle_wave_range<Value>(frequency, amplitude, phase);
}
};
//
// triangle_wave
//
namespace {
SPROUT_STATIC_CONSTEXPR sprout::adaptors::triangle_wave_forwarder triangle_wave{};
} // anonymous-namespace
//
// operator|
//
template<typename Range, typename Value>
inline SPROUT_CONSTEXPR sprout::adaptors::triangle_wave_range<
Value,
typename std::remove_reference<typename sprout::lvalue_reference<Range>::type>::type
>
operator|(Range&& lhs, sprout::adaptors::triangle_wave_range<Value> const& rhs) {
return sprout::adaptors::triangle_wave_range<
Value,
typename std::remove_reference<typename sprout::lvalue_reference<Range>::type>::type
>(
sprout::lvalue_forward<Range>(lhs),
rhs.frequency(),
rhs.amplitude(),
rhs.phase()
);
}
} // namespace adaptors
//
// container_construct_traits
//
template<typename Value, typename Range>
struct container_construct_traits<sprout::adaptors::triangle_wave_range<Value, Range> > {
public:
typedef typename sprout::container_construct_traits<Range>::copied_type copied_type;
public:
template<typename Cont>
static SPROUT_CONSTEXPR copied_type deep_copy(Cont&& cont) {
return sprout::range::fixed::copy(sprout::forward<Cont>(cont), sprout::pit<copied_type>());
}
template<typename... Args>
static SPROUT_CONSTEXPR copied_type make(Args&&... args) {
return sprout::make<copied_type>(sprout::forward<Args>(args)...);
}
template<typename Cont, typename... Args>
static SPROUT_CONSTEXPR copied_type remake(
Cont&& cont,
typename sprout::container_traits<sprout::adaptors::triangle_wave_range<Value, Range> >::difference_type size,
Args&&... args
)
{
return sprout::remake<copied_type>(sprout::forward<Cont>(cont), size, sprout::forward<Args>(args)...);
}
};
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ADAPTOR_TRIANGLE_WAVE_HPP

View file

@ -4,6 +4,8 @@
#include <sprout/config.hpp>
#include <sprout/range/numeric/dft/dft.hpp>
#include <sprout/range/numeric/dft/idft.hpp>
#include <sprout/range/numeric/dft/amplitude_spectrum.hpp>
#include <sprout/range/numeric/dft/phase_spectrum.hpp>
#include <sprout/range/numeric/dft/spectrum.hpp>
#endif // #ifndef SPROUT_RANGE_NUMERIC_DFT_HPP

View file

@ -0,0 +1,8 @@
#ifndef SPROUT_RANGE_NUMERIC_DFT_AMPLITUDE_SPECTRUM_HPP
#define SPROUT_RANGE_NUMERIC_DFT_AMPLITUDE_SPECTRUM_HPP
#include <sprout/config.hpp>
#include <sprout/range/numeric/dft/fixed/amplitude_spectrum.hpp>
#include <sprout/range/numeric/dft/fit/amplitude_spectrum.hpp>
#endif // #ifndef SPROUT_RANGE_NUMERIC_DFT_AMPLITUDE_SPECTRUM_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_RANGE_NUMERIC_DFT_FIT_AMPLITUDE_SPECTRUM_HPP
#define SPROUT_RANGE_NUMERIC_DFT_FIT_AMPLITUDE_SPECTRUM_HPP
#include <sprout/config.hpp>
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/algorithm/fit/result_of.hpp>
#include <sprout/numeric/dft/fit/amplitude_spectrum.hpp>
namespace sprout {
namespace range {
namespace fit {
//
// amplitude_spectrum
//
template<typename Input, typename Result>
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Result>::type amplitude_spectrum(
Input const& input,
Result const& result
)
{
return sprout::fit::amplitude_spectrum(sprout::begin(input), sprout::end(input), result);
}
} // namespace fit
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_NUMERIC_DFT_FIT_AMPLITUDE_SPECTRUM_HPP

View file

@ -0,0 +1,28 @@
#ifndef SPROUT_RANGE_NUMERIC_DFT_FIT_PHASE_SPECTRUM_HPP
#define SPROUT_RANGE_NUMERIC_DFT_FIT_PHASE_SPECTRUM_HPP
#include <sprout/config.hpp>
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/algorithm/fit/result_of.hpp>
#include <sprout/numeric/dft/fit/phase_spectrum.hpp>
namespace sprout {
namespace range {
namespace fit {
//
// phase_spectrum
//
template<typename Input, typename Result>
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Result>::type phase_spectrum(
Input const& input,
Result const& result
)
{
return sprout::fit::phase_spectrum(sprout::begin(input), sprout::end(input), result);
}
} // namespace fit
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_NUMERIC_DFT_FIT_PHASE_SPECTRUM_HPP

View file

@ -0,0 +1,31 @@
#ifndef SPROUT_RANGE_NUMERIC_DFT_FIXED_AMPLITUDE_SPECTRUM_HPP
#define SPROUT_RANGE_NUMERIC_DFT_FIXED_AMPLITUDE_SPECTRUM_HPP
#include <sprout/config.hpp>
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/algorithm/fixed/result_of.hpp>
#include <sprout/numeric/dft/fixed/amplitude_spectrum.hpp>
namespace sprout {
namespace range {
namespace fixed {
//
// amplitude_spectrum
//
template<typename Input, typename Result>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
amplitude_spectrum(
Input const& input,
Result const& result
)
{
return sprout::fixed::amplitude_spectrum(sprout::begin(input), sprout::end(input), result);
}
} // namespace fixed
using sprout::range::fixed::amplitude_spectrum;
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_NUMERIC_DFT_FIXED_AMPLITUDE_SPECTRUM_HPP

View file

@ -0,0 +1,31 @@
#ifndef SPROUT_RANGE_NUMERIC_DFT_FIXED_PHASE_SPECTRUM_HPP
#define SPROUT_RANGE_NUMERIC_DFT_FIXED_PHASE_SPECTRUM_HPP
#include <sprout/config.hpp>
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/algorithm/fixed/result_of.hpp>
#include <sprout/numeric/dft/fixed/phase_spectrum.hpp>
namespace sprout {
namespace range {
namespace fixed {
//
// phase_spectrum
//
template<typename Input, typename Result>
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
phase_spectrum(
Input const& input,
Result const& result
)
{
return sprout::fixed::phase_spectrum(sprout::begin(input), sprout::end(input), result);
}
} // namespace fixed
using sprout::range::fixed::phase_spectrum;
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_NUMERIC_DFT_FIXED_PHASE_SPECTRUM_HPP

View file

@ -0,0 +1,8 @@
#ifndef SPROUT_RANGE_NUMERIC_DFT_PHASE_SPECTRUM_HPP
#define SPROUT_RANGE_NUMERIC_DFT_PHASE_SPECTRUM_HPP
#include <sprout/config.hpp>
#include <sprout/range/numeric/dft/fixed/phase_spectrum.hpp>
#include <sprout/range/numeric/dft/fit/phase_spectrum.hpp>
#endif // #ifndef SPROUT_RANGE_NUMERIC_DFT_PHASE_SPECTRUM_HPP