1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// Copyright (C) 2011 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include "main.h"
float *ptr;
const float *const_ptr;
template<typename PlainObjectType,
bool IsDynamicSize = PlainObjectType::SizeAtCompileTime == Dynamic,
bool IsVector = PlainObjectType::IsVectorAtCompileTime
>
struct mapstaticmethods_impl {};
template<typename PlainObjectType, bool IsVector>
struct mapstaticmethods_impl<PlainObjectType, false, IsVector>
{
static void run(const PlainObjectType& m)
{
mapstaticmethods_impl<PlainObjectType, true, IsVector>::run(m);
int i = internal::random<int>(2,5), j = internal::random<int>(2,5);
PlainObjectType::Map(ptr).setZero();
PlainObjectType::MapAligned(ptr).setZero();
PlainObjectType::Map(const_ptr).sum();
PlainObjectType::MapAligned(const_ptr).sum();
PlainObjectType::Map(ptr, InnerStride<>(i)).setZero();
PlainObjectType::MapAligned(ptr, InnerStride<>(i)).setZero();
PlainObjectType::Map(const_ptr, InnerStride<>(i)).sum();
PlainObjectType::MapAligned(const_ptr, InnerStride<>(i)).sum();
PlainObjectType::Map(ptr, InnerStride<2>()).setZero();
PlainObjectType::MapAligned(ptr, InnerStride<3>()).setZero();
PlainObjectType::Map(const_ptr, InnerStride<4>()).sum();
PlainObjectType::MapAligned(const_ptr, InnerStride<5>()).sum();
PlainObjectType::Map(ptr, OuterStride<>(i)).setZero();
PlainObjectType::MapAligned(ptr, OuterStride<>(i)).setZero();
PlainObjectType::Map(const_ptr, OuterStride<>(i)).sum();
PlainObjectType::MapAligned(const_ptr, OuterStride<>(i)).sum();
PlainObjectType::Map(ptr, OuterStride<2>()).setZero();
PlainObjectType::MapAligned(ptr, OuterStride<3>()).setZero();
PlainObjectType::Map(const_ptr, OuterStride<4>()).sum();
PlainObjectType::MapAligned(const_ptr, OuterStride<5>()).sum();
PlainObjectType::Map(ptr, Stride<Dynamic, Dynamic>(i,j)).setZero();
PlainObjectType::MapAligned(ptr, Stride<2,Dynamic>(2,i)).setZero();
PlainObjectType::Map(const_ptr, Stride<Dynamic,3>(i,3)).sum();
PlainObjectType::MapAligned(const_ptr, Stride<Dynamic, Dynamic>(i,j)).sum();
PlainObjectType::Map(ptr, Stride<2,3>()).setZero();
PlainObjectType::MapAligned(ptr, Stride<3,4>()).setZero();
PlainObjectType::Map(const_ptr, Stride<2,4>()).sum();
PlainObjectType::MapAligned(const_ptr, Stride<5,3>()).sum();
}
};
template<typename PlainObjectType>
struct mapstaticmethods_impl<PlainObjectType, true, false>
{
static void run(const PlainObjectType& m)
{
typedef typename PlainObjectType::Index Index;
Index rows = m.rows(), cols = m.cols();
int i = internal::random<int>(2,5), j = internal::random<int>(2,5);
PlainObjectType::Map(ptr, rows, cols).setZero();
PlainObjectType::MapAligned(ptr, rows, cols).setZero();
PlainObjectType::Map(const_ptr, rows, cols).sum();
PlainObjectType::MapAligned(const_ptr, rows, cols).sum();
PlainObjectType::Map(ptr, rows, cols, InnerStride<>(i)).setZero();
PlainObjectType::MapAligned(ptr, rows, cols, InnerStride<>(i)).setZero();
PlainObjectType::Map(const_ptr, rows, cols, InnerStride<>(i)).sum();
PlainObjectType::MapAligned(const_ptr, rows, cols, InnerStride<>(i)).sum();
PlainObjectType::Map(ptr, rows, cols, InnerStride<2>()).setZero();
PlainObjectType::MapAligned(ptr, rows, cols, InnerStride<3>()).setZero();
PlainObjectType::Map(const_ptr, rows, cols, InnerStride<4>()).sum();
PlainObjectType::MapAligned(const_ptr, rows, cols, InnerStride<5>()).sum();
PlainObjectType::Map(ptr, rows, cols, OuterStride<>(i)).setZero();
PlainObjectType::MapAligned(ptr, rows, cols, OuterStride<>(i)).setZero();
PlainObjectType::Map(const_ptr, rows, cols, OuterStride<>(i)).sum();
PlainObjectType::MapAligned(const_ptr, rows, cols, OuterStride<>(i)).sum();
PlainObjectType::Map(ptr, rows, cols, OuterStride<2>()).setZero();
PlainObjectType::MapAligned(ptr, rows, cols, OuterStride<3>()).setZero();
PlainObjectType::Map(const_ptr, rows, cols, OuterStride<4>()).sum();
PlainObjectType::MapAligned(const_ptr, rows, cols, OuterStride<5>()).sum();
PlainObjectType::Map(ptr, rows, cols, Stride<Dynamic, Dynamic>(i,j)).setZero();
PlainObjectType::MapAligned(ptr, rows, cols, Stride<2,Dynamic>(2,i)).setZero();
PlainObjectType::Map(const_ptr, rows, cols, Stride<Dynamic,3>(i,3)).sum();
PlainObjectType::MapAligned(const_ptr, rows, cols, Stride<Dynamic, Dynamic>(i,j)).sum();
PlainObjectType::Map(ptr, rows, cols, Stride<2,3>()).setZero();
PlainObjectType::MapAligned(ptr, rows, cols, Stride<3,4>()).setZero();
PlainObjectType::Map(const_ptr, rows, cols, Stride<2,4>()).sum();
PlainObjectType::MapAligned(const_ptr, rows, cols, Stride<5,3>()).sum();
}
};
template<typename PlainObjectType>
struct mapstaticmethods_impl<PlainObjectType, true, true>
{
static void run(const PlainObjectType& v)
{
typedef typename PlainObjectType::Index Index;
Index size = v.size();
int i = internal::random<int>(2,5);
PlainObjectType::Map(ptr, size).setZero();
PlainObjectType::MapAligned(ptr, size).setZero();
PlainObjectType::Map(const_ptr, size).sum();
PlainObjectType::MapAligned(const_ptr, size).sum();
PlainObjectType::Map(ptr, size, InnerStride<>(i)).setZero();
PlainObjectType::MapAligned(ptr, size, InnerStride<>(i)).setZero();
PlainObjectType::Map(const_ptr, size, InnerStride<>(i)).sum();
PlainObjectType::MapAligned(const_ptr, size, InnerStride<>(i)).sum();
PlainObjectType::Map(ptr, size, InnerStride<2>()).setZero();
PlainObjectType::MapAligned(ptr, size, InnerStride<3>()).setZero();
PlainObjectType::Map(const_ptr, size, InnerStride<4>()).sum();
PlainObjectType::MapAligned(const_ptr, size, InnerStride<5>()).sum();
}
};
template<typename PlainObjectType>
void mapstaticmethods(const PlainObjectType& m)
{
mapstaticmethods_impl<PlainObjectType>::run(m);
VERIFY(true); // just to avoid 'unused function' warning
}
void test_mapstaticmethods()
{
ptr = internal::aligned_new<float>(1000);
for(int i = 0; i < 1000; i++) ptr[i] = float(i);
const_ptr = ptr;
CALL_SUBTEST_1(( mapstaticmethods(Matrix<float, 1, 1>()) ));
CALL_SUBTEST_1(( mapstaticmethods(Vector2f()) ));
CALL_SUBTEST_2(( mapstaticmethods(Vector3f()) ));
CALL_SUBTEST_2(( mapstaticmethods(Matrix2f()) ));
CALL_SUBTEST_3(( mapstaticmethods(Matrix4f()) ));
CALL_SUBTEST_3(( mapstaticmethods(Array4f()) ));
CALL_SUBTEST_4(( mapstaticmethods(Array3f()) ));
CALL_SUBTEST_4(( mapstaticmethods(Array33f()) ));
CALL_SUBTEST_5(( mapstaticmethods(Array44f()) ));
CALL_SUBTEST_5(( mapstaticmethods(VectorXf(1)) ));
CALL_SUBTEST_5(( mapstaticmethods(VectorXf(8)) ));
CALL_SUBTEST_6(( mapstaticmethods(MatrixXf(1,1)) ));
CALL_SUBTEST_6(( mapstaticmethods(MatrixXf(5,7)) ));
CALL_SUBTEST_7(( mapstaticmethods(ArrayXf(1)) ));
CALL_SUBTEST_7(( mapstaticmethods(ArrayXf(5)) ));
CALL_SUBTEST_8(( mapstaticmethods(ArrayXXf(1,1)) ));
CALL_SUBTEST_8(( mapstaticmethods(ArrayXXf(8,6)) ));
internal::aligned_delete(ptr, 1000);
}
|