aboutsummaryrefslogtreecommitdiffstats
path: root/zahl
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2016-05-06 13:48:43 +0200
committerMattias Andrée <maandree@kth.se>2016-05-06 13:48:43 +0200
commitb0e210a02b8576828ac64e8b97bd565fd28c8748 (patch)
tree02e74578d0543b40718ea9ae60a4b1295630a61d /zahl
parentzsqr is no longer slower than zmul, they are identical (diff)
downloadlibzahl-b0e210a02b8576828ac64e8b97bd565fd28c8748.tar.gz
libzahl-b0e210a02b8576828ac64e8b97bd565fd28c8748.tar.bz2
libzahl-b0e210a02b8576828ac64e8b97bd565fd28c8748.tar.xz
Make zmul and zsqr (calls low-level functions) inline
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'zahl')
-rw-r--r--zahl/inlines.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/zahl/inlines.h b/zahl/inlines.h
index 9e196f8..8f6b490 100644
--- a/zahl/inlines.h
+++ b/zahl/inlines.h
@@ -266,3 +266,28 @@ zsave(z_t a, void *buffer)
}
return sizeof(int) + sizeof(size_t) + (zzero(a) ? 0 : a->used * sizeof(zahl_char_t));
}
+
+
+ZAHL_INLINE void
+zmul(z_t a, z_t b, z_t c)
+{
+ int b_sign, c_sign;
+ b_sign = b->sign, b->sign *= b_sign;
+ c_sign = c->sign, c->sign *= c_sign;
+ zmul_ll(a, b, c);
+ c->sign = c_sign;
+ b->sign = b_sign;
+ ZAHL_SET_SIGNUM(a, zsignum(b) * zsignum(c));
+}
+
+
+ZAHL_INLINE void
+zsqr(z_t a, z_t b)
+{
+ if (ZAHL_UNLIKELY(zzero(b))) {
+ ZAHL_SET_SIGNUM(a, 0);
+ } else {
+ zsqr_ll(a, b);
+ ZAHL_SET_SIGNUM(a, 1);
+ }
+}