ROOT  6.06/09
Reference Guide
expandandmerge.cpp
Go to the documentation of this file.
1 /* This file is part of the Vc library.
2 
3  Copyright (C) 2009-2012 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 #include "unittest.h"
21 #include <iostream>
22 
23 using namespace Vc;
24 
25 enum {
27 };
28 
29 void testSigned()
30 {
31  for (int start = -32000; start < 32000; start += 5) {
33  for (int i = 0; i < VectorSizeFactor; ++i) {
34  a[i] = int_v(IndexesFromZero) + int_v::Size * i + start;
35  }
36  short_v b(a);
37  COMPARE(b, short_v(IndexesFromZero) + start);
38 
39  // false positive: warning: ‘c’ is used uninitialized in this function
41  b.expand(c);
42  for (int i = 0; i < VectorSizeFactor; ++i) {
43  COMPARE(c[i], int_v(IndexesFromZero) + int_v::Size * i + start);
44  }
45  }
46 }
47 
49 {
50 #if defined(VC_IMPL_SSE4_1) || defined(VC_IMPL_AVX)
51  for (unsigned int start = 0; start < 64000; start += 5) {
52 #else
53  for (unsigned int start = 0; start < 32000; start += 5) {
54 #endif
56  for (unsigned int i = 0; i < VectorSizeFactor; ++i) {
57  a[i] = uint_v(IndexesFromZero) + uint_v::Size * i + start;
58  }
59  ushort_v b(a);
60  COMPARE(b, ushort_v(IndexesFromZero) + start);
61 
62  // false positive: warning: ‘c’ is used uninitialized in this function
64  b.expand(c);
65  for (unsigned int i = 0; i < VectorSizeFactor; ++i) {
66  COMPARE(c[i], uint_v(IndexesFromZero) + uint_v::Size * i + start);
67  }
68  }
69  for (unsigned int start = 32000; start < 64000; start += 5) {
71  b += start;
72  COMPARE(b, ushort_v(IndexesFromZero) + start);
73 
74  // false positive: warning: ‘c’ may be used uninitialized in this function
76  b.expand(c);
77  for (unsigned int i = 0; i < VectorSizeFactor; ++i) {
78  COMPARE(c[i], uint_v(IndexesFromZero) + uint_v::Size * i + start);
79  }
80  }
81 }
82 
83 int main()
84 {
87  return 0;
88 }
VECTOR_NAMESPACE::uint_v uint_v
Definition: vector.h:88
const char * Size
Definition: TXMLSetup.cxx:56
Vector< unsigned short > ushort_v
Definition: vector.h:422
Vector< short > short_v
Definition: vector.h:421
TArc * a
Definition: textangle.C:12
VECTOR_NAMESPACE::short_v short_v
Definition: vector.h:90
#define COMPARE(a, b)
Definition: unittest.h:509
VECTOR_NAMESPACE::ushort_v ushort_v
Definition: vector.h:92
VECTOR_NAMESPACE::int_v int_v
Definition: vector.h:86
void testUnsigned()
Vector< unsigned int > uint_v
Definition: vector.h:420
int main()
void testSigned()
Vector< int > int_v
Definition: vector.h:419
Definition: casts.h:28
#define runTest(name)
Definition: unittest.h:42