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

Function nc_pow

numexpr3/complex_functions.hpp:833–877  ·  view source on GitHub ↗

RAM: algorithm branches, and is really not designed for a modern CPU... TODO: we should be able to branch the exp>-100 && exp<100 test before the for loop.

Source from the content-addressed store, hash-verified

831// TODO: we should be able to branch the exp>-100 && exp<100 test before the
832// for loop.
833static void
834nc_pow( npy_intp n, npy_complex64 *a, npy_intp sb1, npy_complex64 *b, npy_intp sb2, npy_complex64 *r)
835{
836 npy_intp exp, mask;
837 npy_complex64 p, aa;
838 sb1 /= sizeof(npy_complex64);
839 sb2 /= sizeof(npy_complex64);
840
841 for( int I = 0; I < n; I++ ) {
842 if (b[I*sb2].real == 0. && b[I*sb2].imag == 0.) {
843 r[I].real = 1.;
844 r[I].imag = 0.;
845 continue;
846 }
847 if (a[I*sb1].real == 0. && a[I*sb1].imag == 0.) {
848 r[I].real = 0.;
849 r[I].imag = 0.;
850 continue;
851 }
852 if (b[I*sb2].imag == 0 && (exp=(npy_intp)b[I*sb2].real) == b[I*sb2].real) {
853 if (exp > -100 && exp < 100) {
854 mask = 1;
855 exp = (exp < 0) ? -exp : exp;
856
857 aa = Z_1;
858 p.real = a[I*sb1].real; p.imag = a[I*sb1].imag;
859 while (1) {
860 aa = (exp & mask) ? _return_mul( aa, p ) : aa;
861
862 mask <<= 1;
863 if (n < mask || mask <= 0) break;
864 p = _return_mul( p, p );
865 }
866 r[I].real = aa.real;
867 r[I].imag = aa.imag;
868 r[I] = (b[I*sb2].real < 0) ? _return_div( Z_1, r[I] ) : r[I];
869 continue;
870 }
871 }
872
873 _inline_log( a[I*sb1], r[I] );
874 _inline_mul(r[I], b[I*sb2], r[I] );
875 _inline_exp(r[I], r[I] );
876 }
877}
878
879static void
880nc_pow( npy_intp n, npy_complex128 *a, npy_intp sb1, npy_complex128 *b, npy_intp sb2, npy_complex128 *r)

Callers

nothing calls this directly

Calls 5

_return_mulFunction · 0.85
_return_divFunction · 0.85
_inline_logFunction · 0.85
_inline_mulFunction · 0.85
_inline_expFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…