Skip to content

Commit f707070

Browse files
committed
Fix a bug in SIMDVector under scalar mode that was causing compilation failure for when actual primitive types were mixed in the arithmetics with SIMDVector types
1 parent 899c6c0 commit f707070

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

simd_vector/simd_vector_base.h

+24-24
Original file line numberDiff line numberDiff line change
@@ -216,18 +216,18 @@ FASTOR_INLINE SIMDVector<T,ABI> operator+(const SIMDVector<T,ABI> &a, const SIMD
216216
out.value[i] = a.value[i] + b.value[i];
217217
return out;
218218
}
219-
template<typename U, typename T, int ABI>
220-
FASTOR_INLINE SIMDVector<T,ABI> operator+(const SIMDVector<T,ABI> &a, U b) {
219+
template<typename T, int ABI>
220+
FASTOR_INLINE SIMDVector<T,ABI> operator+(const SIMDVector<T,ABI> &a, T b) {
221221
SIMDVector<T,ABI> out;
222222
for (FASTOR_INDEX i=0; i<SIMDVector<T,ABI>::Size; ++i)
223-
out.value[i] = a.value[i] + static_cast<T>(b);
223+
out.value[i] = a.value[i] + b;
224224
return out;
225225
}
226-
template<typename U, typename T, int ABI>
227-
FASTOR_INLINE SIMDVector<T,ABI> operator+(U a, const SIMDVector<T,ABI> &b) {
226+
template<typename T, int ABI>
227+
FASTOR_INLINE SIMDVector<T,ABI> operator+(T a, const SIMDVector<T,ABI> &b) {
228228
SIMDVector<T,ABI> out;
229229
for (FASTOR_INDEX i=0; i<SIMDVector<T,ABI>::Size; ++i)
230-
out.value[i] = static_cast<T>(a) + b.value[i];
230+
out.value[i] = a + b.value[i];
231231
return out;
232232
}
233233
template<typename T, int ABI>
@@ -242,18 +242,18 @@ FASTOR_INLINE SIMDVector<T,ABI> operator-(const SIMDVector<T,ABI> &a, const SIMD
242242
out.value[i] = a.value[i] - b.value[i];
243243
return out;
244244
}
245-
template<typename U, typename T, int ABI>
246-
FASTOR_INLINE SIMDVector<T,ABI> operator-(const SIMDVector<T,ABI> &a, U b) {
245+
template<typename T, int ABI>
246+
FASTOR_INLINE SIMDVector<T,ABI> operator-(const SIMDVector<T,ABI> &a, T b) {
247247
SIMDVector<T,ABI> out;
248248
for (FASTOR_INDEX i=0; i<SIMDVector<T,ABI>::Size; ++i)
249-
out.value[i] = a.value[i] - static_cast<T>(b);
249+
out.value[i] = a.value[i] - b;
250250
return out;
251251
}
252-
template<typename U, typename T, int ABI>
253-
FASTOR_INLINE SIMDVector<T,ABI> operator-(U a, const SIMDVector<T,ABI> &b) {
252+
template<typename T, int ABI>
253+
FASTOR_INLINE SIMDVector<T,ABI> operator-(T a, const SIMDVector<T,ABI> &b) {
254254
SIMDVector<T,ABI> out;
255255
for (FASTOR_INDEX i=0; i<SIMDVector<T,ABI>::Size; ++i)
256-
out.value[i] = static_cast<T>(a) - b.value[i];
256+
out.value[i] = a - b.value[i];
257257
return out;
258258
}
259259
template<typename T, int ABI>
@@ -271,18 +271,18 @@ FASTOR_INLINE SIMDVector<T,ABI> operator*(const SIMDVector<T,ABI> &a, const SIMD
271271
out.value[i] = a.value[i] * b.value[i];
272272
return out;
273273
}
274-
template<typename U, typename T, int ABI>
275-
FASTOR_INLINE SIMDVector<T,ABI> operator*(const SIMDVector<T,ABI> &a, U b) {
274+
template<typename T, int ABI>
275+
FASTOR_INLINE SIMDVector<T,ABI> operator*(const SIMDVector<T,ABI> &a, T b) {
276276
SIMDVector<T,ABI> out;
277277
for (FASTOR_INDEX i=0; i<SIMDVector<T,ABI>::Size; ++i)
278-
out.value[i] = a.value[i] * static_cast<T>(b);
278+
out.value[i] = a.value[i] * b;
279279
return out;
280280
}
281-
template<typename U, typename T, int ABI>
282-
FASTOR_INLINE SIMDVector<T,ABI> operator*(U a, const SIMDVector<T,ABI> &b) {
281+
template<typename T, int ABI>
282+
FASTOR_INLINE SIMDVector<T,ABI> operator*(T a, const SIMDVector<T,ABI> &b) {
283283
SIMDVector<T,ABI> out;
284284
for (FASTOR_INDEX i=0; i<SIMDVector<T,ABI>::Size; ++i)
285-
out.value[i] = static_cast<T>(a) * b.value[i];
285+
out.value[i] = a * b.value[i];
286286
return out;
287287
}
288288

@@ -293,18 +293,18 @@ FASTOR_INLINE SIMDVector<T,ABI> operator/(const SIMDVector<T,ABI> &a, const SIMD
293293
out.value[i] = a.value[i] / b.value[i];
294294
return out;
295295
}
296-
template<typename U, typename T, int ABI>
297-
FASTOR_INLINE SIMDVector<T,ABI> operator/(const SIMDVector<T,ABI> &a, U b) {
296+
template<typename T, int ABI>
297+
FASTOR_INLINE SIMDVector<T,ABI> operator/(const SIMDVector<T,ABI> &a, T b) {
298298
SIMDVector<T,ABI> out;
299299
for (FASTOR_INDEX i=0; i<SIMDVector<T,ABI>::Size; ++i)
300-
out.value[i] = a.value[i] / static_cast<T>(b);
300+
out.value[i] = a.value[i] / b;
301301
return out;
302302
}
303-
template<typename U, typename T, int ABI>
304-
FASTOR_INLINE SIMDVector<T,ABI> operator/(U a, const SIMDVector<T,ABI> &b) {
303+
template<typename T, int ABI>
304+
FASTOR_INLINE SIMDVector<T,ABI> operator/(T a, const SIMDVector<T,ABI> &b) {
305305
SIMDVector<T,ABI> out;
306306
for (FASTOR_INDEX i=0; i<SIMDVector<T,ABI>::Size; ++i)
307-
out.value[i] = static_cast<T>(a) / b.value[i];
307+
out.value[i] = a / b.value[i];
308308
return out;
309309
}
310310

0 commit comments

Comments
 (0)