aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJ08nY2017-04-10 00:39:07 +0200
committerJ08nY2017-04-10 00:39:07 +0200
commit08bff37e281d9ae1911611693e5cff71b50f8578 (patch)
tree4b1a9aa9059c22629d07ffeb7b2c7b51fa2289fb /src
parent3598e2d17837e480869e472e224140ad2643c58c (diff)
downloadecgen-08bff37e281d9ae1911611693e5cff71b50f8578.tar.gz
ecgen-08bff37e281d9ae1911611693e5cff71b50f8578.tar.zst
ecgen-08bff37e281d9ae1911611693e5cff71b50f8578.zip
Fixed exhaustive curve generation for params with no curve
- Added some debug prints - Fixed debug macro - Temporarily disabled obj_free in exhaustive_gen until roll_t arrives
Diffstat (limited to 'src')
-rw-r--r--src/cm/cm.c7
-rw-r--r--src/exhaustive/exhaustive.c4
-rw-r--r--src/invalid/invalid.c2
-rw-r--r--src/io/output.h4
-rw-r--r--src/math/curve.c15
5 files changed, 24 insertions, 8 deletions
diff --git a/src/cm/cm.c b/src/cm/cm.c
index c1e3393..71e720c 100644
--- a/src/cm/cm.c
+++ b/src/cm/cm.c
@@ -3,6 +3,9 @@
* Copyright (C) 2017 J08nY
*/
#include "cm.h"
-#include "io/config.h"
+#include "io/output.h"
-int cm_do(config_t *cfg) { return INT_MIN; }
+int cm_do(config_t *cfg) {
+ debug("# Starting Complex Multiplication method\n");
+ return INT_MIN;
+}
diff --git a/src/exhaustive/exhaustive.c b/src/exhaustive/exhaustive.c
index a4ce9aa..be3ab1c 100644
--- a/src/exhaustive/exhaustive.c
+++ b/src/exhaustive/exhaustive.c
@@ -132,7 +132,7 @@ int exhaustive_gen_retry(curve_t *curve, const config_t *cfg,
// rewind pari stack
int new_state = state + diff - start_offset;
if (new_state <= OFFSET_CURVE) {
- obj_free(curve->curve);
+ // obj_free(curve->curve);
}
avma = tops[new_state];
}
@@ -181,6 +181,8 @@ static void exhaustive_quit(arg_t *argss[]) {
}
int exhaustive_do(config_t *cfg) {
+ debug("# Starting Exhaustive method\n");
+
gen_t generators[OFFSET_END];
arg_t *argss[OFFSET_END];
exhaustive_ginit(generators, cfg);
diff --git a/src/invalid/invalid.c b/src/invalid/invalid.c
index 4a14ad1..e01a49c 100644
--- a/src/invalid/invalid.c
+++ b/src/invalid/invalid.c
@@ -265,6 +265,8 @@ static size_t invalid_curves_threaded(curve_t *curve, config_t *cfg,
}
int invalid_do(config_t *cfg) {
+ debug("# Starting Invalid curve method\n");
+
gen_t gen[OFFSET_END];
arg_t *argss[OFFSET_END];
invalid_original_ginit(gen, cfg);
diff --git a/src/io/output.h b/src/io/output.h
index 009e318..3560ab5 100644
--- a/src/io/output.h
+++ b/src/io/output.h
@@ -103,9 +103,9 @@ void output_init(const config_t *cfg);
void output_quit(void);
#ifdef DEBUG
-#define debug(fmt, ...) fprintf(out, fmt, ##__VA_ARGS__)
+#define debug(...) fprintf(out, ##__VA_ARGS__)
#else
-#define debug(fmt, ...)
+#define debug(...)
#endif
#endif // ECGEN_OUTPUT_H
diff --git a/src/math/curve.c b/src/math/curve.c
index 0d4cd12..ba21280 100644
--- a/src/math/curve.c
+++ b/src/math/curve.c
@@ -114,14 +114,23 @@ int curve_any(curve_t *curve, const config_t *cfg, arg_t *args) {
default:
pari_err_TYPE("curve_any", curve->field);
}
+ GEN crv = ellinit(v, curve->field, -1);
- curve->curve = gerepilecopy(ltop, ellinit(v, curve->field, -1));
- return 1;
+ if (glength(crv) == 0) {
+ avma = ltop;
+ return -3;
+ } else {
+ curve->curve = gerepilecopy(ltop, crv);
+ return 1;
+ }
}
int curve_nonzero(curve_t *curve, const config_t *cfg, arg_t *args) {
pari_sp ltop = avma;
- curve_any(curve, cfg, args);
+ int any = curve_any(curve, cfg, args);
+ if (any <= 0) {
+ return any;
+ }
if (gequal0(ell_get_disc(curve->curve))) {
avma = ltop;
return -3;