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

Function af_pow

src/api/c/binary.cpp:401–444  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

399}
400
401af_err af_pow(af_array *out, const af_array lhs, const af_array rhs,
402 const bool batchMode) {
403 try {
404 const ArrayInfo &linfo = getInfo(lhs);
405 const ArrayInfo &rinfo = getInfo(rhs);
406 if (rinfo.isComplex()) {
407 af_array log_lhs, log_res;
408 af_array res;
409 AF_CHECK(af_log(&log_lhs, lhs));
410 AF_CHECK(af_mul(&log_res, log_lhs, rhs, batchMode));
411 AF_CHECK(af_exp(&res, log_res));
412 AF_CHECK(af_release_array(log_lhs));
413 AF_CHECK(af_release_array(log_res));
414 std::swap(*out, res);
415 return AF_SUCCESS;
416 }
417 if (linfo.isComplex()) {
418 af_array mag, angle;
419 af_array mag_res, angle_res;
420 af_array real_res, imag_res, cplx_res;
421 af_array res;
422 AF_CHECK(af_abs(&mag, lhs));
423 AF_CHECK(af_arg(&angle, lhs));
424 AF_CHECK(af_pow(&mag_res, mag, rhs, batchMode));
425 AF_CHECK(af_mul(&angle_res, angle, rhs, batchMode));
426 AF_CHECK(af_cos(&real_res, angle_res));
427 AF_CHECK(af_sin(&imag_res, angle_res));
428 AF_CHECK(af_cplx2(&cplx_res, real_res, imag_res, batchMode));
429 AF_CHECK(af_mul(&res, mag_res, cplx_res, batchMode));
430 AF_CHECK(af_release_array(mag));
431 AF_CHECK(af_release_array(angle));
432 AF_CHECK(af_release_array(mag_res));
433 AF_CHECK(af_release_array(angle_res));
434 AF_CHECK(af_release_array(real_res));
435 AF_CHECK(af_release_array(imag_res));
436 AF_CHECK(af_release_array(cplx_res));
437 std::swap(*out, res);
438 return AF_SUCCESS;
439 }
440 }
441 CATCHALL;
442
443 return af_arith_real<af_pow_t>(out, lhs, rhs, batchMode);
444}
445
446af_err af_root(af_array *out, const af_array lhs, const af_array rhs,
447 const bool batchMode) {

Callers 1

af_pow2Function · 0.85

Calls 7

af_mulFunction · 0.85
swapFunction · 0.85
af_absFunction · 0.85
af_argFunction · 0.85
af_cplx2Function · 0.85
isComplexMethod · 0.80
af_release_arrayFunction · 0.70

Tested by

no test coverage detected