DMA32
  9   ˆl—ß=¿J•4Ÿº‚ „ \¸Ó×yLZ7ÿ�þBP<ÒÍ”�³ßÍ¼çÊ„™ EÉÈÇÆ ?÷     //
// SPDX-License-Identifier: BSD-3-Clause
// Copyright Contributors to the OpenEXR Project.
//

// clang-format off


#ifndef _PyImathAutovectorize_h_
#define _PyImathAutovectorize_h_

#include <Python.h>
#include <boost/python.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/pop_front.hpp>
#include <boost/mpl/push_front.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/transform.hpp>
#include <boost/mpl/remove_if.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/for_each.hpp>
#include <boost/mpl/not.hpp>
#include <boost/mpl/count.hpp>
#include <boost/mpl/or.hpp>
#include <boost/type_traits/is_base_of.hpp>
#include <boost/type_traits/function_traits.hpp>
#include <boost/static_assert.hpp>
#include <boost/python/args.hpp>
#include <iostream>
#include "PyImathFixedArray.h"
#include "PyImathTask.h"
#include "PyImathUtil.h"

namespace PyImath {

struct op_with_precomputation {};

namespace detail {

using boost::is_base_of;
using boost::is_same;
using boost::is_const;
using boost::remove_const;
using boost::remove_reference;
using boost::function_traits;

using boost::mpl::at;
using boost::mpl::at_c;
using boost::mpl::push_front;
using boost::mpl::vector;
using boost::mpl::push_back;
using boost::mpl::transform;
using boost::mpl::fold;
using boost::mpl::_;
using boost::mpl::_1;
using boost::mpl::_2;
using boost::mpl::long_;
using boost::mpl::false_;
using boost::mpl::true_;
using boost::mpl::not_;
using boost::mpl::or_;
using boost::mpl::and_;
using boost::mpl::size;
using boost::mpl::remove_if;
using boost::mpl::if_;
using boost::mpl::for_each;


struct null_precomputation {
    static void precompute(size_t len) { return; }
};

template <class T> struct op_precompute
{
    static void
    apply(size_t len)
    {
        if_<is_base_of<op_with_precomputation,T>,
            T,
            null_precomputation>::type::precompute(len);
    }
};

template <int N>
struct possible_vectorizations
{
    typedef typename fold<
        typename possible_vectorizations<N-1>::type,
        vector<>,
        push_back<push_back<_1,push_back<_2,false_> >,push_back<_2,true_> >
    >::type type;
};

template <>
struct possible_vectorizations<0>
{
    typedef vector<vector<> > type;    
};

template <class Vectorizable>
struct disallow_vectorization
{
    template <class Vectorize>
    struct apply
    {
        // Valid = !Vectorize || Vectorizable
        typedef typename transform<Vectorize,not_<_> >::type DontVectorize;
        typedef typename transform<DontVectorize,Vectorizable,or_<_,_> >::type Valid;
        typedef typename not_<fold<Valid,true_,and_<_,_> > >::type type;
    };
};

template <class Vectorizable>
struct allowable_vectorizations
{
    typedef typename possible_vectorizations<size<Vectorizable>::value>::type possible;
    typedef typename remove_if<possible,disallow_vectorization<Vectorizable> >::type type;
};

template <class T>
bool any_masked(const T &value)
{
    return false;
};

template <class T>
bool any_masked(const PyImath::FixedArray<T> &value)
{
    return value.isMaskedReference();
};

template <class T1, class T2>
bool any_masked(const T1 &a, const T2 &b)
{
    return any_masked(a) || any_masked(b);
}

template <class T1, class T2, class T3>
bool any_masked(const T1 &a, const T2 &b, const T3 &c)
{
    return any_masked(a,b) || any_masked(c);
}

template <class T1, class T2, class T3, class T4>
bool any_masked(const T1 &a, const T2 &b, const T3 &c, const T4 &d)
{
    return any_masked(a,b) || any_masked(c,d);
}

//-----------------------------------------------------------------------------------------

//
// measure_argument returns a pair indicating the integral length of the argument
// (scalar arguments have implicit length 1), and a bool indicating whether the argument
// is a vectorized argument.
//
template <class T>
struct measure_argument
{
    static inline std::pair<size_t,bool> apply(T arg) { return st