/* enoki/array.h -- Main header file for the Enoki array class and various template specializations Enoki is a C++ template library that enables transparent vectorization of numerical kernels using SIMD instruction sets available on current processor architectures. Copyright (c) 2019 Wenzel Jakob All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. */ #pragma once #if defined(_MSC_VER) # pragma warning(push) # pragma warning(disable: 4146) // warning C4146: unary minus operator applied to unsigned type, result still unsigned # pragma warning(disable: 4554) // warning C4554: '>>': check operator precedence for possible error; use parentheses to clarify precedence # pragma warning(disable: 4702) // warning C4702: unreachable code # pragma warning(disable: 4522) // warning C4522: multiple assignment operators specified # pragma warning(disable: 4310) // warning C4310: cast truncates constant value # pragma warning(disable: 4127) // warning C4127: conditional expression is constant #elif defined(__GNUC__) && !defined(__clang__) # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wclass-memaccess" #endif #include #include #if defined(ENOKI_ARM_NEON) || defined(ENOKI_X86_SSE42) # include #endif #if defined(ENOKI_X86_AVX512F) # include #endif #if defined(ENOKI_X86_SSE42) # include #endif #if defined(ENOKI_X86_AVX) # include #endif #if defined(ENOKI_X86_AVX2) # include #endif #if defined(ENOKI_X86_AVX512F) # include #endif #if defined(ENOKI_ARM_NEON) # include #endif #include #include #include #include #include #include NAMESPACE_BEGIN(enoki) template struct Array : StaticArrayImpl> { using Base = StaticArrayImpl>; using ArrayType = Array; using MaskType = Mask; /// Type alias for creating a similar-shaped array over a different type template using ReplaceValue = Array; ENOKI_ARRAY_IMPORT(Base, Array) }; template struct Mask : StaticArrayImpl> { using Base = StaticArrayImpl>; using ArrayType = Array; using MaskType = Mask; /// Type alias for creating a similar-shaped array over a different type template using ReplaceValue = Mask; Mask() = default; template Mask(T &&value) : Base(std::forward(value), detail::reinterpret_flag()) { } template Mask(T &&value, detail::reinterpret_flag) : Base(std::forward(value), detail::reinterpret_flag()) { } /// Construct from sub-arrays template == array_depth_v && array_size_v == Base::Size1 && array_depth_v == array_depth_v && array_size_v == Base::Size2 && Base::Size2 != 0> = 0> Mask(const T1 &a1, const T2 &a2) : Base(a1, a2) { } template ...>> = 0> Mask(Ts&&... ts) : Base(std::forward(ts)...) { } ENOKI_ARRAY_IMPORT_BASIC(Base, Mask) using Base::operator=; }; template struct Packet : StaticArrayImpl> { using Base = StaticArrayImpl>; using ArrayType = Packet; using MaskType = PacketMask; static constexpr bool BroadcastPreferOuter = false; /// Type alias for creating a similar-shaped array over a different type template using ReplaceValue = Packet; ENOKI_ARRAY_IMPORT(Base, Packet) }; template struct PacketMask : StaticArrayImpl> { using Base = StaticArrayImpl>; static constexpr bool BroadcastPreferOuter = false; using ArrayType = Packet; using MaskType = PacketMask; /// Type alias for creating a similar-shaped array over a different type template using ReplaceValue = PacketMask; PacketMask() = default; template PacketMask(T &&value) : Base(std::forward(value), detail::reinterpret_flag()) { } template PacketMask(T &&value, detail::reinterpret_flag) : Base(std::forward(value), detail::reinterpret_flag()) { } /// Construct from sub-arrays template == array_depth_v && array_size_v == Base::Size1 && array_depth_v == array_depth_v && array_size_v == Base::Size2 && Base::Size2 != 0> = 0> PacketMask(const T1 &a1, const T2 &a2) : Base(a1, a2) { } template ...>> = 0> PacketMask(Ts&&... ts) : Base(std::forward(ts)...) { } ENOKI_ARRAY_IMPORT_BASIC(Base, PacketMask) using Base::operator=; }; NAMESPACE_END(enoki) #if defined(_MSC_VER) # pragma warning(pop) #elif defined(__GNUC__) && !defined(__clang__) # pragma GCC diagnostic pop #endif