1 /* This file is part of the Vc library.
3 Copyright (C) 2010-2011 Matthias Kretz <kretz@kde.org>
5 Vc is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation, either version 3 of
8 the License, or (at your option) any later version.
10 Vc is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with Vc. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef VC_COMMON_DEINTERLEAVE_H
21 #define VC_COMMON_DEINTERLEAVE_H
32 * Loads two vectors of values from an interleaved array.
34 * \param a, b The vectors to load the values from memory into.
35 * \param memory The memory location where to read the next 2 * V::Size values from
36 * \param align Either pass Vc::Aligned or Vc::Unaligned. It defaults to Vc::Aligned if nothing is
39 * If you store your data as
41 * struct { float x, y; } m[1000];
43 * then the deinterleave function allows you to read \p Size concurrent x and y values like this:
46 * Vc::deinterleave(&x, &y, &m[10], Vc::Unaligned);
48 * This code will load m[10], m[12], m[14], ... into \p x and m[11], m[13], m[15], ... into \p y.
50 * The deinterleave function supports the following type combinations:
52 V \ M | float | double | ushort | short | uint | int
53 =========|=======|========|========|=======|======|=====
54 float_v | X | | X | X | |
55 ---------|-------|--------|--------|-------|------|-----
56 sfloat_v | X | | X | X | |
57 ---------|-------|--------|--------|-------|------|-----
58 double_v | | X | | | |
59 ---------|-------|--------|--------|-------|------|-----
61 ---------|-------|--------|--------|-------|------|-----
62 uint_v | | | X | | X |
63 ---------|-------|--------|--------|-------|------|-----
65 ---------|-------|--------|--------|-------|------|-----
66 ushort_v | | | X | | |
69 template<typename V, typename M, typename A> Vc_ALWAYS_INLINE void deinterleave(V *a, V *b,
70 const M *memory, A align)
72 Internal::Helper::deinterleave(*a, *b, memory, align);
75 // documented as default for align above
76 template<typename V, typename M> Vc_ALWAYS_INLINE void deinterleave(V *a, V *b,
79 Internal::Helper::deinterleave(*a, *b, memory, Aligned);
83 } // namespace AliRoot
85 #include "undomacros.h"
87 #endif // VC_COMMON_DEINTERLEAVE_H