aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2016-03-07 07:36:29 +0100
committerMattias Andrée <maandree@kth.se>2016-03-07 07:36:29 +0100
commitc1b7101b0f33b07c98b971b2dd075c068f319299 (patch)
tree9ed364acb42ad8920c25a63ff123af44a5c0187b
parentFix another typo (diff)
downloadlibzahl-c1b7101b0f33b07c98b971b2dd075c068f319299.tar.gz
libzahl-c1b7101b0f33b07c98b971b2dd075c068f319299.tar.bz2
libzahl-c1b7101b0f33b07c98b971b2dd075c068f319299.tar.xz
A brief description of exponentiation by squaring
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rw-r--r--src/zpow.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/zpow.c b/src/zpow.c
index 7388bde..f709ff9 100644
--- a/src/zpow.c
+++ b/src/zpow.c
@@ -8,6 +8,12 @@
void
zpow(z_t a, z_t b, z_t c)
{
+ /*
+ * Exponentiation by squaring.
+ *
+ * 7↑19 = 7↑10011₂ = 7↑2⁰ ⋅ 7↑2¹ ⋅ 7↑2⁴ where a↑2↑(n + 1) = (a↑2↑n)².
+ */
+
size_t i, j, n, bits;
zahl_char_t x;