MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / gauss_pow

Function gauss_pow

benchmarks/audit/gen.py:126–136  ·  view source on GitHub ↗
(re, im, n)

Source from the content-addressed store, hash-verified

124# v = mant·10^exp, |mant| ∈ [1, 10). The reference is an exact Gaussian
125# integer/rational power (binary powering over Fraction).
126def gauss_pow(re, im, n):
127 from fractions import Fraction
128 r, i = Fraction(1), Fraction(0)
129 br, bi = Fraction(re), Fraction(im)
130 while n:
131 if n & 1:
132 r, i = r * br - i * bi, r * bi + i * br
133 n >>= 1
134 if n:
135 br, bi = br * br - bi * bi, 2 * br * bi
136 return r, i
137
138
139def mantexp(fr):

Callers 1

gen.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected