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

Function ireduce_all_common

src/api/c/reduce.cpp:1081–1138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1079
1080template<af_op_t op>
1081static af_err ireduce_all_common(double *real_val, double *imag_val,
1082 unsigned *loc, const af_array in) {
1083 try {
1084 const ArrayInfo &in_info = getInfo(in);
1085 af_dtype type = in_info.getType();
1086
1087 ARG_ASSERT(3, in_info.ndims() > 0);
1088 ARG_ASSERT(0, real_val != nullptr);
1089 *real_val = 0;
1090 if (imag_val) { *imag_val = 0; }
1091
1092 cfloat cfval;
1093 cdouble cdval;
1094
1095 switch (type) {
1096 case f32:
1097 *real_val = ireduce_all<op, float, double>(loc, in);
1098 break;
1099 case f64:
1100 *real_val = ireduce_all<op, double, double>(loc, in);
1101 break;
1102 case u32: *real_val = ireduce_all<op, uint, double>(loc, in); break;
1103 case s32: *real_val = ireduce_all<op, int, double>(loc, in); break;
1104 case u64:
1105 *real_val = ireduce_all<op, uintl, double>(loc, in);
1106 break;
1107 case s64: *real_val = ireduce_all<op, intl, double>(loc, in); break;
1108 case u16:
1109 *real_val = ireduce_all<op, ushort, double>(loc, in);
1110 break;
1111 case s16:
1112 *real_val = ireduce_all<op, short, double>(loc, in);
1113 break;
1114 case b8: *real_val = ireduce_all<op, char, double>(loc, in); break;
1115 case u8: *real_val = ireduce_all<op, uchar, double>(loc, in); break;
1116 case s8: *real_val = ireduce_all<op, schar, double>(loc, in); break;
1117
1118 case c32:
1119 cfval = ireduce_all<op, cfloat>(loc, in);
1120 ARG_ASSERT(1, imag_val != nullptr);
1121 *real_val = real(cfval);
1122 *imag_val = imag(cfval);
1123 break;
1124
1125 case c64:
1126 cdval = ireduce_all<op, cdouble>(loc, in);
1127 ARG_ASSERT(1, imag_val != nullptr);
1128 *real_val = real(cdval);
1129 *imag_val = imag(cdval);
1130 break;
1131
1132 default: TYPE_ERROR(1, type);
1133 }
1134 }
1135 CATCHALL;
1136
1137 return AF_SUCCESS;
1138}

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