aboutsummaryrefslogtreecommitdiff
path: root/src/benchmarks/cfrac/pfactor.h
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2019-08-24 17:57:51 +0200
committerFlorian Fischer <florian.fl.fischer@fau.de>2019-08-24 17:57:51 +0200
commit77ac9ce0a5c55d4f79f8fb8f7daa59ddb53cb507 (patch)
tree93d4e30a207265af03394d347bfff76ba677f3ce /src/benchmarks/cfrac/pfactor.h
parent971adefadb94e8780b1a73f08ed11d76c2ead8a2 (diff)
downloadallocbench-77ac9ce0a5c55d4f79f8fb8f7daa59ddb53cb507.tar.gz
allocbench-77ac9ce0a5c55d4f79f8fb8f7daa59ddb53cb507.zip
add cfrac benchmark
Diffstat (limited to 'src/benchmarks/cfrac/pfactor.h')
-rw-r--r--src/benchmarks/cfrac/pfactor.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/benchmarks/cfrac/pfactor.h b/src/benchmarks/cfrac/pfactor.h
new file mode 100644
index 0000000..edd5686
--- /dev/null
+++ b/src/benchmarks/cfrac/pfactor.h
@@ -0,0 +1,62 @@
+typedef struct Pfs {
+ struct Pfs *next;
+ precision factor;
+ unsigned count;
+} Pfactor;
+
+typedef Pfactor *FactorPtr;
+typedef FactorPtr FactorList;
+typedef precision (*pfunc)(); /* pointer to func returning precision */
+
+#ifndef __STDC__
+
+extern int pprime(); /* test whether a number is prime */
+extern precision pnextprime(); /* next prime >= it's argument */
+
+extern precision pgcd(); /* greatest common divisor */
+extern precision plcm(); /* least common multiple */
+extern precision peuclid(); /* extended euclid's algorithm */
+
+extern precision prho(); /* find factor using rho method */
+extern precision pfermat(); /* find factor using Fermat's method */
+extern precision pcfrac(); /* factor w/continued fractions */
+
+extern int prhoInit(); /* alter parameters for rho method */
+extern int pcfracInit(); /* alter paramteres for cfrac method */
+
+extern precision ptrial(); /* find factors using trial division */
+extern precision prfactor(); /* recursively factor a number */
+
+extern void paddfactor(); /* add a factor to a factorlist */
+extern void pputfactors(); /* print a factorlist */
+extern void pfreefactors(); /* return a factorlist to memory */
+
+#else
+
+extern int pprime(precision, unsigned trialCount);
+extern precision pnextprime(precision, unsigned trialCount);
+
+extern precision pgcd(precision, precision);
+extern precision plcm(precision, precision);
+extern precision peuclid(precision, precision, precision *, precision *);
+
+extern precision prho(precision n, unsigned *maxCount);
+extern precision pfermat(precision n, unsigned *maxCount);
+extern precision pcfrac(precision n, unsigned *maxCount);
+
+extern int prhoInit(precision c, unsigned batchSize);
+extern int pcfracInit(unsigned m, unsigned k, unsigned aborts);
+
+extern precision ptrial(precision n, unsigned *maxCount, FactorList *);
+extern precision prfactor(precision, unsigned *maxCount, pfunc, FactorList *);
+
+extern void paddfactor(FactorList *, precision);
+extern void pfreefactors(FactorList *);
+
+#ifndef BUFSIZE
+#include <stdio.h>
+#endif
+
+extern void pputfactors(FILE *, FactorList);
+
+#endif