/* Copyright (C) 2011-2014 Povilas Kanapickas 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 LIBSIMDPP_SIMD_EXTRACT_H #define LIBSIMDPP_SIMD_EXTRACT_H #ifndef LIBSIMDPP_SIMD_H #error "This file must be included through simd.h" #endif #include #include namespace simdpp { namespace SIMDPP_ARCH_NAMESPACE { /** Extracts the @a id-th element from a vector. @code r = a[id] @endcode This function may have very high latency. */ template SIMDPP_INL uint8_t extract(const uint8& a) { static_assert(id < N, "index out of bounds"); return detail::insn::i_extract(a); } template SIMDPP_INL int8_t extract(const int8& a) { static_assert(id < N, "index out of bounds"); return detail::insn::i_extract(a); } template SIMDPP_INL uint16_t extract(const uint16& a) { static_assert(id < N, "index out of bounds"); return detail::insn::i_extract(a); } template SIMDPP_INL int16_t extract(const int16& a) { static_assert(id < N, "index out of bounds"); return detail::insn::i_extract(a); } template SIMDPP_INL uint32_t extract(const uint32& a) { static_assert(id < N, "index out of bounds"); return detail::insn::i_extract(a); } template SIMDPP_INL int32_t extract(const int32& a) { static_assert(id < N, "index out of bounds"); return detail::insn::i_extract(a); } template SIMDPP_INL uint64_t extract(const uint64& a) { static_assert(id < N, "index out of bounds"); return detail::insn::i_extract(a); } template SIMDPP_INL int64_t extract(const int64& a) { static_assert(id < N, "index out of bounds"); return detail::insn::i_extract(a); } template SIMDPP_INL float extract(const float32& a) { static_assert(id < N, "index out of bounds"); return detail::insn::i_extract(a); } template SIMDPP_INL double extract(const float64& a) { static_assert(id < N, "index out of bounds"); return detail::insn::i_extract(a); } } // namespace SIMDPP_ARCH_NAMESPACE } // namespace simdpp #endif