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

Function af_hypot

src/api/c/binary.cpp:510–541  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

508}
509
510af_err af_hypot(af_array *out, const af_array lhs, const af_array rhs,
511 const bool batchMode) {
512 try {
513 const af_dtype type = implicit(lhs, rhs);
514
515 if (type != f16 && type != f32 && type != f64) {
516 AF_ERROR("Only floating point arrays are supported for hypot ",
517 AF_ERR_NOT_SUPPORTED);
518 }
519
520 const ArrayInfo &linfo = getInfo(lhs);
521 const ArrayInfo &rinfo = getInfo(rhs);
522
523 dim4 odims = getOutDims(linfo.dims(), rinfo.dims(), batchMode);
524
525 if (odims.ndims() == 0) {
526 return af_create_handle(out, 0, nullptr, type);
527 }
528
529 af_array res;
530 switch (type) {
531 case f16: res = arithOp<half, af_hypot_t>(lhs, rhs, odims); break;
532 case f32: res = arithOp<float, af_hypot_t>(lhs, rhs, odims); break;
533 case f64: res = arithOp<double, af_hypot_t>(lhs, rhs, odims); break;
534 default: TYPE_ERROR(0, type);
535 }
536
537 std::swap(*out, res);
538 }
539 CATCHALL;
540 return AF_SUCCESS;
541}
542
543template<typename T, af_op_t op>
544static inline af_array logicOp(const af_array lhs, const af_array rhs,

Callers

nothing calls this directly

Calls 6

implicitFunction · 0.85
getOutDimsFunction · 0.85
swapFunction · 0.85
af_create_handleFunction · 0.70
dimsMethod · 0.45
ndimsMethod · 0.45

Tested by

no test coverage detected