@@ -144,7 +144,14 @@ template<typename T, size_t N>
144144struct dot_impl {
145145 KERNEL_FLOAT_INLINE
146146 static T call (const vector_storage<T, N>& left, const vector_storage<T, N>& right) {
147- return sum (zip (ops::multiply<T> {}, left, right));
147+ vector_storage<T, N> intermediate;
148+ detail::apply_impl<ops::multiply<T>, N, T, T, T>::call (
149+ ops::multiply<T>(),
150+ intermediate.data (),
151+ left.data (),
152+ right.data ());
153+
154+ return detail::reduce_impl<ops::add<T>, N, T>::call (ops::add<T>(), intermediate.data ());
148155 }
149156};
150157} // namespace detail
@@ -197,25 +204,25 @@ template<typename T>
197204struct magnitude_impl <T, 2 > {
198205 KERNEL_FLOAT_INLINE
199206 static T call (const vector_storage<T, 2 >& input) {
200- return ops::hypot<T> {} (input.data ()[0 ], input.data ()[1 ]);
207+ return ops::hypot<T>() (input.data ()[0 ], input.data ()[1 ]);
201208 }
202209};
203210
204- // The 3-argument overload of hypot is only available from C++17
205- #ifdef __cpp_lib_hypot
211+ // The 3-argument overload of hypot is only available on host from C++17
212+ #if defined( __cpp_lib_hypot) && KERNEL_FLOAT_IS_HOST
206213template <>
207214struct magnitude_impl <float , 3 > {
208215 KERNEL_FLOAT_INLINE
209216 static float call (const vector_storage<float , 3 >& input) {
210- return std ::hypot (input.data ()[0 ], input.data ()[1 ], input.data ()[2 ]);
217+ return ::hypot (input.data ()[0 ], input.data ()[1 ], input.data ()[2 ]);
211218 }
212219};
213220
214221template <>
215222struct magnitude_impl <double , 3 > {
216223 KERNEL_FLOAT_INLINE
217224 static float call (const vector_storage<double , 3 >& input) {
218- return std ::hypot (input.data ()[0 ], input.data ()[1 ], input.data ()[2 ]);
225+ return ::hypot (input.data ()[0 ], input.data ()[1 ], input.data ()[2 ]);
219226 }
220227};
221228#endif
0 commit comments