-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathfns_scalar.cpp
189 lines (139 loc) · 4.24 KB
/
fns_scalar.cpp
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
//
// Copyright (c) 2005, 2006 by CodeSourcery
// Copyright (c) 2013 Stefan Seefeld
// All rights reserved.
//
// This file is part of OpenVSIP. It is made available under the
// license contained in the accompanying LICENSE.GPL file.
#include <iostream>
#include <cassert>
#include <vsip/initfin.hpp>
#include <vsip/support.hpp>
#include <vsip/vector.hpp>
#include <vsip/matrix.hpp>
#include <vsip/math.hpp>
#include <test.hpp>
#include <storage.hpp>
using namespace ovxx;
template <dimension_type Dim,
typename T1,
typename T2>
void
test_magsq()
{
Storage<Dim, T1> Z;
Storage<Dim, T2> A;
put_nth(A.view, 0, T2(-3));
Z.view = vsip::magsq(A.view);
test_assert(equal(get_nth(Z.view, 0), T1(3*3)));
}
template <dimension_type Dim,
typename T1,
typename T2>
void
test_mag()
{
Storage<Dim, T1> Z;
Storage<Dim, T2> A;
put_nth(A.view, 0, T2(-3));
Z.view = vsip::mag(A.view);
test_assert(equal(get_nth(Z.view, 0), T1(3)));
}
template <dimension_type Dim,
typename T1,
typename T2,
typename T3>
void
test_maxmgsq()
{
Storage<Dim, T1> Z;
Storage<Dim, T2> A;
Storage<Dim, T3> B;
put_nth(A.view, 0, T2(-3));
put_nth(B.view, 0, T3(-4));
Z.view = vsip::maxmgsq(A.view, B.view);
test_assert(equal(get_nth(Z.view, 0), T1(4*4)));
}
template <dimension_type Dim,
typename T1,
typename T2,
typename T3>
void
test_minmgsq()
{
Storage<Dim, T1> Z;
Storage<Dim, T2> A;
Storage<Dim, T3> B;
put_nth(A.view, 0, T2(-3));
put_nth(B.view, 0, T3(-4));
Z.view = vsip::minmgsq(A.view, B.view);
test_assert(equal(get_nth(Z.view, 0), T1(3*3)));
}
template <dimension_type Dim,
typename T1,
typename T2>
void
test_arg()
{
Storage<Dim, T1> Z;
Storage<Dim, T2> A;
T2 input(3., 6.);
put_nth(A.view, 0, input);
Z.view = vsip::arg(A.view);
test_assert(equal(get_nth(Z.view, 0), std::arg(input)));
}
int
main(int argc, char** argv)
{
vsipl init(argc, argv);
// magsq
test_magsq<0, float, complex<float> >();
test_magsq<1, float, complex<float> >();
test_magsq<2, float, complex<float> >();
test_magsq<0, float, float>();
test_magsq<1, float, float>();
test_magsq<2, float, float>();
// mag
test_mag<0, float, complex<float> >();
test_mag<1, float, complex<float> >();
test_mag<2, float, complex<float> >();
test_mag<0, float, float>();
test_mag<1, float, float>();
test_mag<2, float, float>();
// maxmgsq
test_maxmgsq<0, float, complex<float>, complex<float> >();
test_maxmgsq<1, float, complex<float>, complex<float> >();
test_maxmgsq<2, float, complex<float>, complex<float> >();
test_maxmgsq<0, double, complex<double>, complex<double> >();
test_maxmgsq<1, double, complex<double>, complex<double> >();
test_maxmgsq<2, double, complex<double>, complex<double> >();
test_maxmgsq<0, double, complex<float>, complex<double> >();
test_maxmgsq<1, double, complex<float>, complex<double> >();
test_maxmgsq<2, double, complex<float>, complex<double> >();
test_maxmgsq<0, float, float, float>();
test_maxmgsq<1, float, float, float>();
test_maxmgsq<2, float, float, float>();
test_maxmgsq<0, double, float, double>();
test_maxmgsq<1, double, float, double>();
test_maxmgsq<2, double, float, double>();
// minmgsq
test_minmgsq<0, float, complex<float>, complex<float> >();
test_minmgsq<1, float, complex<float>, complex<float> >();
test_minmgsq<2, float, complex<float>, complex<float> >();
test_minmgsq<0, double, complex<double>, complex<double> >();
test_minmgsq<1, double, complex<double>, complex<double> >();
test_minmgsq<2, double, complex<double>, complex<double> >();
test_minmgsq<0, double, complex<float>, complex<double> >();
test_minmgsq<1, double, complex<float>, complex<double> >();
test_minmgsq<2, double, complex<float>, complex<double> >();
test_minmgsq<0, float, float, float>();
test_minmgsq<1, float, float, float>();
test_minmgsq<2, float, float, float>();
test_minmgsq<0, double, float, double>();
test_minmgsq<1, double, float, double>();
test_minmgsq<2, double, float, double>();
// arg (float = arg(float) not allowed.)
test_arg<0, float, complex<float> >();
test_arg<1, float, complex<float> >();
test_arg<2, float, complex<float> >();
}