MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / reduce_all_common

Function reduce_all_common

src/api/c/reduce.cpp:640–689  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

638
639template<af_op_t op>
640static af_err reduce_all_common(double *real_val, double *imag_val,
641 const af_array in) {
642 try {
643 const ArrayInfo &in_info = getInfo(in);
644 af_dtype type = in_info.getType();
645
646 ARG_ASSERT(2, in_info.ndims() > 0);
647 ARG_ASSERT(0, real_val != nullptr);
648 *real_val = 0;
649 if (imag_val != nullptr) { *imag_val = 0; }
650
651 cfloat cfval;
652 cdouble cdval;
653
654 switch (type) {
655 // clang-format off
656 case f32: *real_val = reduce_all<op, float, float>(in); break;
657 case f64: *real_val = reduce_all<op, double, double>(in); break;
658 case u32: *real_val = reduce_all<op, uint, uint>(in); break;
659 case s32: *real_val = reduce_all<op, int, int>(in); break;
660 case u64: *real_val = reduce_all<op, uintl, uintl>(in); break;
661 case s64: *real_val = reduce_all<op, intl, intl>(in); break;
662 case u16: *real_val = reduce_all<op, ushort, ushort>(in); break;
663 case s16: *real_val = reduce_all<op, short, short>(in); break;
664 case b8: *real_val = reduce_all<op, char, char>(in); break;
665 case u8: *real_val = reduce_all<op, uchar, uchar>(in); break;
666 case s8: *real_val = reduce_all<op, schar, schar>(in); break;
667 case f16: *real_val = reduce_all<op, half, half>(in); break;
668 // clang-format on
669 case c32:
670 cfval = reduce_all<op, cfloat, cfloat, cfloat>(in);
671 ARG_ASSERT(1, imag_val != nullptr);
672 *real_val = real(cfval);
673 *imag_val = imag(cfval);
674 break;
675
676 case c64:
677 cdval = reduce_all<op, cdouble, cdouble, cdouble>(in);
678 ARG_ASSERT(1, imag_val != nullptr);
679 *real_val = real(cdval);
680 *imag_val = imag(cdval);
681 break;
682
683 default: TYPE_ERROR(1, type);
684 }
685 }
686 CATCHALL;
687
688 return AF_SUCCESS;
689}
690
691template<af_op_t op>
692static af_err reduce_all_common_array(af_array *out, const af_array in) {

Callers

nothing calls this directly

Calls 4

realFunction · 0.50
imagFunction · 0.50
getTypeMethod · 0.45
ndimsMethod · 0.45

Tested by

no test coverage detected