<commit_before>/*  This file is part of the Vc library. {{{
Copyright © 2012-2015 <NAME> <<EMAIL>>

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
    * Neither the names of contributing organizations nor the
      names of its contributors may be used to endorse or promote products
      derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

}}}*/

// enable bit operators for easier portable bit manipulation on floats
#define Vc_ENABLE_FLOAT_BIT_OPERATORS 1

#include <Vc/vector.h>
#if defined(Vc_IMPL_SSE) || defined(Vc_IMPL_AVX)
#include <common/macros.h>

namespace Vc_VERSIONED_NAMESPACE
{
namespace Common
{

namespace
{
using Vc::Vector;
template <typename Abi> using float_v = Vc::Vector<float, Abi>;
template <typename Abi> using double_v = Vc::Vector<double, Abi>;
template <typename T, typename Abi>
using Const = typename std::conditional<std::is_same<Abi, VectorAbi::Avx>::value,
                                        AVX::Const<T>, SSE::Const<T>>::type;

template <typename V>
using best_int_v_for =
    typename std::conditional<(V::size() <= Vector<int, VectorAbi::Best<int>>::size()),
                              Vector<int, VectorAbi::Best<int>>,
                              SimdArray<int, V::size()>>::type;
template <typename Abi> using float_int_v = best_int_v_for<float_v<Abi>>;
template <typename Abi> using double_int_v = best_int_v_for<double_v<Abi>>;

template <typename T, typename Abi>
static Vc_ALWAYS_INLINE Vector<T, Abi> cosSeries(const Vector<T, Abi> &x)
{
    typedef Const<T, Abi> C;
    const Vector<T, Abi> x2 = x * x;
    return ((C::cosCoeff(2)  * x2 +
             C::cosCoeff(1)) * x2 +
             C::cosCoeff(0)) * (x2 * x2)
        - C::_1_2() * x2 + Vector<T, Abi>::One();
}
template <typename Abi>
static Vc_ALWAYS_INLINE double_v<Abi> cosSeries(const double_v<Abi> &x)
{
    typedef Const<double, Abi> C;
    const double_v<Abi> x2 = x * x;
    return (((((C::cosCoeff(5)  * x2 +
                C::cosCoeff(4)) * x2 +
                C::cosCoeff(3)) * x2 +
                C::cosCoeff(2)) * x2 +
                C::cosCoeff(1)) * x2 +
                C::cosCoeff(0)) * (x2 * x2)
        - C::_1_2() * x2 + double_v<Abi>::One();
}
template <typename T, typename Abi>
static Vc_ALWAYS_INLINE Vector<T, Abi> sinSeries(const Vector<T, Abi> &x)
{
    typedef Const<T, Abi> C;
    const Vector<T, Abi> x2 = x * x;
    return ((C::sinCoeff(2)  * x2 +
             C::sinCoeff(1)) * x2 +
             C::sinCoeff(0)) * (x2 * x)
        + x;
}
template <typename Abi>
static Vc_ALWAYS_INLINE double_v<Abi> sinSeries(const double_v<Abi> &x)
{
    typedef Const<double, Abi> C;
    const double_v<Abi> x2 = x * x;
    return (((((C::sinCoeff(5)  * x2 +
                C::sinCoeff(4)) * x2 +
                C::sinCoeff(3)) * x2 +
                C::sinCoeff(2)) * x2 +
                C::sinCoeff(1)) * x2 +
                C::sinCoeff(0)) * (x2 * x)
        + x;
}

template <typename _T, typename IV, typename Abi>
static Vc_ALWAYS_INLINE Vector<_T, Abi> foldInput(const Vector<_T, Abi> &_x, IV &quadrant)
{
    typedef Vector<_T, Abi> V;
    typedef Const<_T, Abi> C;

        const V x = abs(_x);
#if defined(Vc_IMPL_FMA4) || defined(Vc_IMPL_FMA)
        quadrant = simd_cast<IV>(x * C::_4_pi() + V::One()); // prefer the fma here
        quadrant &= ~IV::One();
#else
        quadrant = simd_cast<IV>(x * C::_4_pi());
        quadrant += quadrant & IV::One();
#endif
        const V y = simd_cast<V>(quadrant);
        quadrant &= 7;

        return ((x - y * C::_pi_4_hi()) - y * C::_pi_4_rem1()) - y * C::_pi_4_rem2();
    }
template <typename Abi>
static Vc_ALWAYS_INLINE double_v<Abi> foldInput(const double_v<Abi> &_x,
                                                double_int_v<Abi> &quadrant)
{
    typedef Vector<double, Abi> V;
    typedef Const<double, Abi> C;

        const V x = abs(_x);
        V y = trunc(x / C::_pi_4()); // * C::_4_pi() would work, but is >twice as imprecise
        V z = y - trunc(y * C::_1_16()) * C::_16(); // y modulo 16<commit_msg>MSVC: use different type names to un-confuse the compiler<commit_after>/*  This file is part of the Vc library. {{{
Copyright © 2012-2015 <NAME> <<EMAIL>>

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
    * Neither the names of contributing organizations nor the
      names of its contributors may be used to endorse or promote products
      derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

}}}*/

// enable bit operators for easier portable bit manipulation on floats
#define Vc_ENABLE_FLOAT_BIT_OPERATORS 1

#include <Vc/vector.h>
#if defined(Vc_IMPL_SSE) || defined(Vc_IMPL_AVX)
#include <common/macros.h>

namespace Vc_VERSIONED_NAMESPACE
{
namespace Common
{

namespace
{
using Vc::Vector;
template <typename Abi> using float_v_for = Vc::Vector<float, Abi>;
template <typename Abi> using double_v_for = Vc::Vector<double, Abi>;
template <typename T, typename Abi>
using Const = typename std::conditional<std::is_same<Abi, VectorAbi::Avx>::value,
                                        AVX::Const<T>, SSE::Const<T>>::type;

template <typename V>
using best_int_v_for =
    typename std::conditional<(V::size() <= Vector<int, VectorAbi::Best<int>>::size()),
                              Vector<int, VectorAbi::Best<int>>,
                              SimdArray<int, V::size()>>::type;
template <typename Abi> using float_int_v = best_int_v_for<float_v_for<Abi>>;
template <typename Abi> using double_int_v = best_int_v_for<double_v_for<Abi>>;

template <typename T, typename Abi>
static Vc_ALWAYS_INLINE Vector<T, Abi> cosSeries(const Vector<T, Abi> &x)
{
    typedef Const<T, Abi> C;
    const Vector<T, Abi> x2 = x * x;
    return ((C::cosCoeff(2)  * x2 +
             C::cosCoeff(1)) * x2 +
             C::cosCoeff(0)) * (x2 * x2)
        - C::_1_2() * x2 + Vector<T, Abi>::One();
}
template <typename Abi>
static Vc_ALWAYS_INLINE double_v_for<Abi> cosSeries(const double_v_for<Abi> &x)
{
    typedef Const<double, Abi> C;
    const double_v_for<Abi> x2 = x * x;
    return (((((C::cosCoeff(5)  * x2 +
                C::cosCoeff(4)) * x2 +
                C::cosCoeff(3)) * x2 +
                C::cosCoeff(2)) * x2 +
                C::cosCoeff(1)) * x2 +
                C::cosCoeff(0)) * (x2 * x2)
        - C::_1_2() * x2 + double_v_for<Abi>::One();
}
template <typename T, typename Abi>
static Vc_ALWAYS_INLINE Vector<T, Abi> sinSeries(const Vector<T, Abi> &x)
{
    typedef Const<T, Abi> C;
    const Vector<T, Abi> x2 = x * x;
    return ((C::sinCoeff(2)  * x2 +
             C::sinCoeff(1)) * x2 +
             C::sinCoeff(0)) * (x2 * x)
        + x;
}
template <typename Abi>
static Vc_ALWAYS_INLINE double_v_for<Abi> sinSeries(const double_v_for<Abi> &x)
{
    typedef Const<double, Abi> C;
    const double_v_for<Abi> x2 = x * x;
    return (((((C::sinCoeff(5)  * x2 +
                C::sinCoeff(4)) * x2 +
                C::sinCoeff(3)) * x2 +
                C::sinCoeff(2)) * x2 +
                C::sinCoeff(1)) * x2 +
                C::sinCoeff(0)) * (x2 * x)
        + x;
}

template <typename Abi>
static Vc_ALWAYS_INLINE float_v_for<Abi> foldInput(float_v_for<Abi> x, float_int_v<Abi> &quadrant)
{
    typedef float_v_for<Abi> V;
    typedef Const<float, Abi> C;
    typedef float_int_v<Abi> IV;

    x = abs(x);
#if defined(Vc_IMPL_FMA4) || defined(Vc_IMPL_FMA)
        quadrant = simd_cast<IV>(x * C::_4_pi() + V::One()); // prefer the fma here
        quadrant &= ~IV::One();
#else
        quadrant = simd_cast<IV>(x * C::_4_pi());
        quadrant += quadrant & IV::One();
#endif
        const V y = simd_cast<V>(quadrant);
        quadrant &= 7;

        return ((x - y * C::_pi_4_hi()) - y * C::_pi_4_rem1()) - y * C::_pi_4_rem2();
    }
template <typename Abi>
static Vc_ALWAYS_INLINE double_v_for<Abi> foldInput(double_v_for<Abi> x,
                                                double_int_v<Abi> &quadrant)
{
    typedef double_v_for<Abi> V;
    typedef Const<double, Abi> C;

    x = abs(x);
        V y = trunc(x / C::_pi_4()); // * C::_4_pi() would work, but is >twice as imprecise
        V z = y - trunc(y * C::_1_16()) * C::_16(); // y modulo 16
{'fraction_non_alphanumeric': 0.12043968539751729, 'fraction_numerical': 0.01421396759215389, 'mean_word_length': 3.085946573751452, 'pattern_counts': {'":': 0, '<': 133, '<?xml version=': 0, '>': 133, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2720183', 'n_tokens_mistral': 3705, 'n_tokens_neox': 3538, 'n_words': 1086}