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
29 * Loads two vectors of values from an interleaved array.
31 * \param a, b The vectors to load the values from memory into.
32 * \param memory The memory location where to read the next 2 * V::Size values from
33 * \param align Either pass Vc::Aligned or Vc::Unaligned. It defaults to Vc::Aligned if nothing is
36 * If you store your data as
38 * struct { float x, y; } m[1000];
40 * then the deinterleave function allows you to read \p Size concurrent x and y values like this:
43 * Vc::deinterleave(&x, &y, &m[10], Vc::Unaligned);
45 * This code will load m[10], m[12], m[14], ... into \p x and m[11], m[13], m[15], ... into \p y.
47 * The deinterleave function supports the following type combinations:
49 V \ M | float | double | ushort | short | uint | int
50 =========|=======|========|========|=======|======|=====
51 float_v | X | | X | X | |
52 ---------|-------|--------|--------|-------|------|-----
53 sfloat_v | X | | X | X | |
54 ---------|-------|--------|--------|-------|------|-----
55 double_v | | X | | | |
56 ---------|-------|--------|--------|-------|------|-----
58 ---------|-------|--------|--------|-------|------|-----
59 uint_v | | | X | | X |
60 ---------|-------|--------|--------|-------|------|-----
62 ---------|-------|--------|--------|-------|------|-----
63 ushort_v | | | X | | |
66 template<typename V, typename M, typename A> inline void deinterleave(V *a, V *b,
67 const M *memory, A align)
69 Internal::Helper::deinterleave(*a, *b, memory, align);
72 // documented as default for align above
73 template<typename V, typename M> inline void deinterleave(V *a, V *b,
76 Internal::Helper::deinterleave(*a, *b, memory, Aligned);
80 #endif // VC_COMMON_DEINTERLEAVE_H