]> git.uio.no Git - u/mrichter/AliRoot.git/blame - Vc/include/Vc/common/deinterleave.h
Vc package added (version 0.6.79-dev)
[u/mrichter/AliRoot.git] / Vc / include / Vc / common / deinterleave.h
CommitLineData
f22341db 1/* This file is part of the Vc library.
2
3 Copyright (C) 2010-2011 Matthias Kretz <kretz@kde.org>
4
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.
9
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.
14
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/>.
17
18*/
19
20#ifndef VC_COMMON_DEINTERLEAVE_H
21#define VC_COMMON_DEINTERLEAVE_H
22
23namespace Vc
24{
25
26/**
27 * \ingroup Utilities
28 *
29 * Loads two vectors of values from an interleaved array.
30 *
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
34 * specified.
35 *
36 * If you store your data as
37 * \code
38 * struct { float x, y; } m[1000];
39 * \endcode
40 * then the deinterleave function allows you to read \p Size concurrent x and y values like this:
41 * \code
42 * Vc::float_v x, y;
43 * Vc::deinterleave(&x, &y, &m[10], Vc::Unaligned);
44 * \endcode
45 * This code will load m[10], m[12], m[14], ... into \p x and m[11], m[13], m[15], ... into \p y.
46 *
47 * The deinterleave function supports the following type combinations:
48\verbatim
49 V \ M | float | double | ushort | short | uint | int
50=========|=======|========|========|=======|======|=====
51 float_v | X | | X | X | |
52---------|-------|--------|--------|-------|------|-----
53sfloat_v | X | | X | X | |
54---------|-------|--------|--------|-------|------|-----
55double_v | | X | | | |
56---------|-------|--------|--------|-------|------|-----
57 int_v | | | | X | | X
58---------|-------|--------|--------|-------|------|-----
59 uint_v | | | X | | X |
60---------|-------|--------|--------|-------|------|-----
61 short_v | | | | X | |
62---------|-------|--------|--------|-------|------|-----
63ushort_v | | | X | | |
64\endverbatim
65 */
66template<typename V, typename M, typename A> inline void deinterleave(V *a, V *b,
67 const M *memory, A align)
68{
69 Internal::Helper::deinterleave(*a, *b, memory, align);
70}
71
72// documented as default for align above
73template<typename V, typename M> inline void deinterleave(V *a, V *b,
74 const M *memory)
75{
76 Internal::Helper::deinterleave(*a, *b, memory, Aligned);
77}
78
79} // namespace Vc
80#endif // VC_COMMON_DEINTERLEAVE_H