MCPcopy Create free account
hub / github.com/apache/arrow / Multiply

Class Multiply

cpp/src/arrow/compute/kernels/base_arithmetic_internal.h:291–340  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

289};
290
291struct Multiply {
292 static_assert(std::is_same<decltype(int8_t() * int8_t()), int32_t>::value, "");
293 static_assert(std::is_same<decltype(uint8_t() * uint8_t()), int32_t>::value, "");
294 static_assert(std::is_same<decltype(int16_t() * int16_t()), int32_t>::value, "");
295 static_assert(std::is_same<decltype(uint16_t() * uint16_t()), int32_t>::value, "");
296 static_assert(std::is_same<decltype(int32_t() * int32_t()), int32_t>::value, "");
297 static_assert(std::is_same<decltype(uint32_t() * uint32_t()), uint32_t>::value, "");
298 static_assert(std::is_same<decltype(int64_t() * int64_t()), int64_t>::value, "");
299 static_assert(std::is_same<decltype(uint64_t() * uint64_t()), uint64_t>::value, "");
300
301 template <typename T, typename Arg0, typename Arg1>
302 static constexpr enable_if_floating_value<T> Call(KernelContext*, T left, T right,
303 Status*) {
304 return left * right;
305 }
306
307 template <typename T, typename Arg0, typename Arg1>
308 static constexpr enable_if_t<
309 is_unsigned_integer_value<T>::value && !std::is_same<T, uint16_t>::value, T>
310 Call(KernelContext*, T left, T right, Status*) {
311 return left * right;
312 }
313
314 template <typename T, typename Arg0, typename Arg1>
315 static constexpr enable_if_t<
316 is_signed_integer_value<T>::value && !std::is_same<T, int16_t>::value, T>
317 Call(KernelContext*, T left, T right, Status*) {
318 return to_unsigned(left) * to_unsigned(right);
319 }
320
321 // Multiplication of 16 bit integer types implicitly promotes to signed 32 bit
322 // integer. However, some inputs may nevertheless overflow (which triggers undefined
323 // behaviour). Therefore we first cast to 32 bit unsigned integers where overflow is
324 // well defined.
325 template <typename T, typename Arg0, typename Arg1>
326 static constexpr enable_if_same<T, int16_t, T> Call(KernelContext*, int16_t left,
327 int16_t right, Status*) {
328 return static_cast<uint32_t>(left) * static_cast<uint32_t>(right);
329 }
330 template <typename T, typename Arg0, typename Arg1>
331 static constexpr enable_if_same<T, uint16_t, T> Call(KernelContext*, uint16_t left,
332 uint16_t right, Status*) {
333 return static_cast<uint32_t>(left) * static_cast<uint32_t>(right);
334 }
335
336 template <typename T, typename Arg0, typename Arg1>
337 static enable_if_decimal_value<T> Call(KernelContext*, Arg0 left, Arg1 right, Status*) {
338 return left * right;
339 }
340};
341
342struct MultiplyChecked {
343 template <typename T, typename Arg0, typename Arg1>

Callers 5

ConsumeMethod · 0.70
MergeFromMethod · 0.70
ReduceMethod · 0.70
MultiplyCheckedFunction · 0.70
TYPED_TESTFunction · 0.70

Calls

no outgoing calls

Tested by 1

TYPED_TESTFunction · 0.56