// Implementation.
#include "cl_low.h"
-#include "cl_malloc.h"
-#include "cl_abort.h"
+#include "cln/malloc.h"
+#include "cln/abort.h"
+
+namespace cln {
// Multiplikations-Doppelschleife:
// Multipliziert zwei UDS und legt das Ergebnis in einer dritten UDS ab.
}
// Karatsuba-multiplication: O(n^(log 3 / log 2))
- static void mulu_karatsuba (const uintD* sourceptr1, uintC len1,
- const uintD* sourceptr2, uintC len2,
- uintD* destptr);
static void mulu_karatsuba_square (const uintD* sourceptr, uintC len,
uintD* destptr);
#include "cl_DS_mul_kara.h"
const unsigned int cl_fftm_threshold2 = 2*cl_fftm_threshold;
// len1 > cl_fftm_threshold1 && len2 > cl_fftm_threshold2
// && len1 >= cl_fftm_threshold1 + cl_fftm_threshold/(len2-cl_fftm_threshold1)*(cl_fftm_threshold-cl_fftm_threshold1).
- static inline cl_boolean cl_fftm_suitable (uintL len1, uintL len2)
+ static inline cl_boolean cl_fftm_suitable (uintC len1, uintC len2)
{ if (len1 >= cl_fftm_threshold)
return cl_true;
if (len1 > cl_fftm_threshold1)
if (len2 > cl_fftm_threshold2)
- { var uint32 hi;
+ { const unsigned int prod_threshold = cl_fftm_threshold*(cl_fftm_threshold-cl_fftm_threshold1);
+ if (len1-cl_fftm_threshold1 >= prod_threshold)
+ return cl_true;
+ if (len2-cl_fftm_threshold1 >= prod_threshold)
+ return cl_true;
+ var uint32 hi;
var uint32 lo;
mulu32(len1-cl_fftm_threshold1,len2-cl_fftm_threshold1, hi=,lo=);
- if (hi > 0 || lo >= cl_fftm_threshold*(cl_fftm_threshold-cl_fftm_threshold1))
+ if (hi > 0 || lo >= prod_threshold)
return cl_true;
}
return cl_false;
mulu_fft_modm(sourceptr,len,sourceptr,len,destptr);
}
}
+
+} // namespace cln