X-Git-Url: https://ginac.de/CLN/cln.git//cln.git?a=blobdiff_plain;f=src%2Fmodinteger%2Fcl_MI_fix16.h;h=e6fee67493733cae46d4efdba02a8a1f91829486;hb=da9fbcea6c2458ecac3c295ee56f1d002ffc2b17;hp=b5225e6d4b35706b219952ebfd347a348c22aa2d;hpb=dd9e0f894eec7e2a8cf85078330ddc0a6639090b;p=cln.git diff --git a/src/modinteger/cl_MI_fix16.h b/src/modinteger/cl_MI_fix16.h index b5225e6..e6fee67 100644 --- a/src/modinteger/cl_MI_fix16.h +++ b/src/modinteger/cl_MI_fix16.h @@ -1,42 +1,44 @@ // 1 < m < 2^16, standard representation +namespace cln { + static const _cl_MI fix16_plus (cl_heap_modint_ring* R, const _cl_MI& x, const _cl_MI& y) { - var uint32 zr = FN_to_UL(x.rep) + FN_to_UL(y.rep); - if (zr >= FN_to_UL(R->modulus)) { zr = zr - FN_to_UL(R->modulus); } + var uint32 zr = FN_to_UV(x.rep) + FN_to_UV(y.rep); + if (zr >= FN_to_UV(R->modulus)) { zr = zr - FN_to_UV(R->modulus); } return _cl_MI(R, L_to_FN(zr)); } static const _cl_MI fix16_minus (cl_heap_modint_ring* R, const _cl_MI& x, const _cl_MI& y) { - var uint32 xr = FN_to_UL(x.rep); - var uint32 yr = FN_to_UL(y.rep); + var uint32 xr = FN_to_UV(x.rep); + var uint32 yr = FN_to_UV(y.rep); var sint32 zr = xr - yr; - if (zr < 0) { zr = zr + FN_to_UL(R->modulus); } + if (zr < 0) { zr = zr + FN_to_UV(R->modulus); } return _cl_MI(R, L_to_FN(zr)); } static const _cl_MI fix16_uminus (cl_heap_modint_ring* R, const _cl_MI& x) { - var uint32 xr = FN_to_UL(x.rep); - var uint32 zr = (xr==0 ? 0 : FN_to_UL(R->modulus)-xr); + var uint32 xr = FN_to_UV(x.rep); + var uint32 zr = (xr==0 ? 0 : FN_to_UV(R->modulus)-xr); return _cl_MI(R, L_to_FN(zr)); } static const _cl_MI fix16_mul (cl_heap_modint_ring* R, const _cl_MI& x, const _cl_MI& y) { - var uint32 xr = FN_to_UL(x.rep); - var uint32 yr = FN_to_UL(y.rep); + var uint32 xr = FN_to_UV(x.rep); + var uint32 yr = FN_to_UV(y.rep); var uint32 zr = mulu16(xr,yr); - divu_3216_1616(zr,FN_to_UL(R->modulus),,zr=); + divu_3216_1616(zr,FN_to_UV(R->modulus),,zr=); return _cl_MI(R, L_to_FN(zr)); } static const _cl_MI fix16_square (cl_heap_modint_ring* R, const _cl_MI& x) { - var uint32 xr = FN_to_UL(x.rep); + var uint32 xr = FN_to_UV(x.rep); var uint32 zr = mulu16(xr,xr); - divu_3216_1616(zr,FN_to_UL(R->modulus),,zr=); + divu_3216_1616(zr,FN_to_UV(R->modulus),,zr=); return _cl_MI(R, L_to_FN(zr)); } @@ -64,8 +66,26 @@ class cl_heap_modint_ring_fix16 : public cl_heap_modint_ring { SUBCLASS_cl_heap_modint_ring() public: // Constructor. - cl_heap_modint_ring_fix16 (const cl_I& m) - : cl_heap_modint_ring (m, &std_setops, &fix16_addops, &fix16_mulops) {} - // Virtual destructor. + cl_heap_modint_ring_fix16 (const cl_I& m); + // Destructor. ~cl_heap_modint_ring_fix16 () {} }; + +static void cl_modint_ring_fix16_destructor (cl_heap* pointer) +{ + (*(cl_heap_modint_ring_fix16*)pointer).~cl_heap_modint_ring_fix16(); +} + +cl_class cl_class_modint_ring_fix16 = { + cl_modint_ring_fix16_destructor, + cl_class_flags_modint_ring +}; + +// Constructor. +inline cl_heap_modint_ring_fix16::cl_heap_modint_ring_fix16(const cl_I& m) + : cl_heap_modint_ring (m, &std_setops, &fix16_addops, &fix16_mulops) +{ + type = &cl_class_modint_ring_fix16; +} + +} // namespace cln