7 #include "cl_complex.h"
18 // Solange b gerade, setze a:=a*a, b:=b/2. [a^b bleibt invariant, = x^y.]
20 // Solange b:=floor(b/2) >0 ist,
21 // setze a:=a*a, und falls b ungerade, setze c:=a*c.
23 // Für y=0: Ergebnis 1.
24 // Für y<0: (/ (expt x (- y))).
27 inline const cl_N expt_pos (const cl_N& x, uintL y)
31 while (!(b % 2)) { a = square(a); b = b >> 1; }
36 if (b % 2) { c = a * c; }
41 const cl_N expt (const cl_N& x, sintL y)
45 // x reell -> schnellere Routine
48 if (y==0) { return 1; } // y=0 -> Ergebnis 1
49 var uintL abs_y = (y<0 ? (uintL)(-y) : y); // Betrag von y nehmen
50 var cl_N z = expt_pos(x,abs_y); // (expt x (abs y))
51 return (y<0 ? recip(z) : z); // evtl. noch Kehrwert nehmen