]> git.uio.no Git - u/mrichter/AliRoot.git/blob - Vc/include/Vc/common/deinterleave.h
update to Vc 0.7.3-dev
[u/mrichter/AliRoot.git] / Vc / include / Vc / common / deinterleave.h
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
23 #include "macros.h"
24
25 namespace AliRoot {
26 namespace Vc
27 {
28
29 /**
30  * \ingroup Vectors
31  *
32  * Loads two vectors of values from an interleaved array.
33  *
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
37  * specified.
38  *
39  * If you store your data as
40  * \code
41  * struct { float x, y; } m[1000];
42  * \endcode
43  * then the deinterleave function allows you to read \p Size concurrent x and y values like this:
44  * \code
45  * Vc::float_v x, y;
46  * Vc::deinterleave(&x, &y, &m[10], Vc::Unaligned);
47  * \endcode
48  * This code will load m[10], m[12], m[14], ... into \p x and m[11], m[13], m[15], ... into \p y.
49  *
50  * The deinterleave function supports the following type combinations:
51 \verbatim
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 ---------|-------|--------|--------|-------|------|-----
60    int_v |       |        |        |   X   |      |  X
61 ---------|-------|--------|--------|-------|------|-----
62   uint_v |       |        |    X   |       |   X  |
63 ---------|-------|--------|--------|-------|------|-----
64  short_v |       |        |        |   X   |      |
65 ---------|-------|--------|--------|-------|------|-----
66 ushort_v |       |        |    X   |       |      |
67 \endverbatim
68  */
69 template<typename V, typename M, typename A> Vc_ALWAYS_INLINE void deinterleave(V *a, V *b,
70         const M *memory, A align)
71 {
72     Internal::Helper::deinterleave(*a, *b, memory, align);
73 }
74
75 // documented as default for align above
76 template<typename V, typename M> Vc_ALWAYS_INLINE void deinterleave(V *a, V *b,
77         const M *memory)
78 {
79     Internal::Helper::deinterleave(*a, *b, memory, Aligned);
80 }
81
82 } // namespace Vc
83 } // namespace AliRoot
84
85 #include "undomacros.h"
86
87 #endif // VC_COMMON_DEINTERLEAVE_H