MCPcopy Create free account
hub / github.com/pydata/numexpr / _inline_sqrt

Function _inline_sqrt

numexpr3/complex_functions.hpp:508–531  ·  view source on GitHub ↗

RAM: this function branches a lot. Search for a branchless sqrt?

Source from the content-addressed store, hash-verified

506
507// RAM: this function branches a lot. Search for a branchless sqrt?
508static inline void
509_inline_sqrt( npy_complex64 x, npy_complex64 &r )
510{
511 npy_float32 s, d;
512
513 if (x.real == 0. && x.imag == 0.)
514 r = x;
515 else {
516 s = sqrtf((fabsf(x.real) + hypotf(x.real,x.imag))/2);
517 d = x.imag/(2*s);
518 if (x.real > 0.) {
519 r.real = s;
520 r.imag = d;
521 }
522 else if (x.imag >= 0.) {
523 r.real = d;
524 r.imag = s;
525 }
526 else {
527 r.real = -d;
528 r.imag = -s;
529 }
530 }
531}
532
533static inline void
534_inline_sqrt( npy_complex128 x, npy_complex128 &r )

Callers 5

nc_sqrtFunction · 0.85
nc_acosFunction · 0.85
nc_acoshFunction · 0.85
nc_asinFunction · 0.85
nc_asinhFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…