3 * Trivial interface to PARI's integer factoring machinery
5 * (c) 2017 Mark Wooding
8 /*----- Licensing notice --------------------------------------------------*
10 * This file is part of Rhodes, a distributed discrete-log finder.
12 * Rhodes is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * Rhodes is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with Rhodes; if not, write to the Free Software Foundation,
24 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 #include <pari/pari.h>
34 static const char *prog;
36 __attribute__((noreturn))
37 static void barf(const char *msg, ...)
42 fprintf(stderr, "%s: ", prog);
43 vfprintf(stderr, msg, ap);
49 int main(int argc, char *argv[])
55 if (argc != 2) { fprintf(stderr, "usage: %s N\n", prog); exit(2); }
56 pari_init(16ul*1024ul*1024ul, 0);
57 n = gp_read_str(argv[1]);
58 if (typ(n) != t_INT || signe(n) <= 0) barf("expected a positive integer");
59 sd_factor_proven("1", d_SILENT);
61 assert(typ(ff) == t_MAT);
63 pp = gel(ff, 1); ee = gel(ff, 2);
64 assert(typ(pp) == t_COL);
65 assert(typ(ee) == t_COL);
66 nf = lg(pp); assert(nf == lg(ee));
70 pari_printf("%Ps %Ps\n", *pp, *ee);