Commit cfffd0f2 authored by Charles Bouillaguet's avatar Charles Bouillaguet
Browse files

prettier verbosity + ULTRAVERBOSE option

parent 9e482c41
......@@ -13,6 +13,8 @@
#include "parser.h"
// #define ULTRAVERBOSE
typedef __int128 u128;
typedef uint64_t u64;
typedef uint32_t u32;
......@@ -344,15 +346,16 @@ void monomial_setup_list()
double start = wtime();
vmask = mkvar(v) - 1;
log(1, "Counting monomials\n");
log(0, "Monomials setup\n");
log(1, " - Counting monomials\n");
Nd[0] = 0;
for (int d = 0; d <= D; d++) {
int binom_n_d = monomial_enumerate(d, NULL); /* not the smartest way to do the job... */
Nd[d + 1] = Nd[d] + binom_n_d;
log(2, "%d monomials of degree %d\n", binom_n_d, d);
log(2, " - %d monomials of degree %d\n", binom_n_d, d);
}
log(1, "Building monomial list\n");
log(1, " - Building monomial list\n");
monomials = malloc(Nd[D + 1] * sizeof(*monomials));
if (monomials == NULL)
err(1, "cannot allocate monomial list");
......@@ -361,7 +364,7 @@ void monomial_setup_list()
test_grlex_order();
test_ranking();
log(1, "Singling out bad monomials\n");
log(1, " - Singling out bad monomials\n");
bad_monomial = malloc(Nd[D + 1] * sizeof(*bad_monomial));
if (bad_monomial == NULL)
err(1, "cannot allocate list of bad monomials");
......@@ -371,13 +374,23 @@ void monomial_setup_list()
bad_monomial[j] = bad;
nbad += bad;
}
log(2, " - %d bad monomials\n", nbad);
test_bad_monomials();
log(0, "monomials setup [%.1fs]\n", wtime() - start);
log(1, " - Monomials setup: %.1fs\n", wtime() - start);
#ifdef ULTRAVERBOSE
printf("monomials: ");
for (int j = 0; j < Nd[D + 1]; j++) {
print_monomial(stdout, monomials[j]);
printf(", ");
}
printf("\n");
#endif
}
void monomial_setup_multiplication()
{
log(1, "Building monomial multiplication table\n");
log(0, "Building monomial multiplication table\n");
mul_table = malloc(Nd[3] * Nd[D - 1] * sizeof(*mul_table));
if (mul_table == NULL)
err(1, "cannot allocate monomial multiplication table");
......@@ -501,7 +514,7 @@ void macaulay_dense(int d)
if (d < 2)
return;
log(0, "Generating degree-%d (dense) Macaulay matrix \n", d);
log(1, "matrix size: %d x %d\n", m * Nd[d - 1], Nd[d + 1]);
log(1, " - matrix size: %d x %d\n", m * Nd[d - 1], Nd[d + 1]);
M = mzd_init(m * Nd[d - 1], Nd[d + 1]);
LM = malloc(Nd[d + 1] * sizeof(*LM));
if (M == NULL || LM == NULL)
......@@ -520,7 +533,7 @@ void macaulay_dense(int d)
}
}
assert(l == M->nrows);
log(1, "echelonization\n");
log(1, " - echelonization\n");
int rank = mzd_echelonize(M, 0);
if (rank < M->nrows)
errx(1, "Bizarre, rank defect!");
......@@ -541,6 +554,7 @@ void macaulay_dense(int d)
/* multiply by degree-d monomials */
void macaulay_sparse(int d)
{
int i = 0;
struct poly_t *head = poly_head->next;
for (struct poly_t * p = head; p != NULL; p = p->next) {
int row[9000];
......@@ -554,7 +568,17 @@ void macaulay_sparse(int d)
for (int k = 0; k < size; k++)
newrow[k] = mmul(j, row[k]);
matrix_store_row(newrow, size);
#ifdef ULTRAVERBOSE
if (d == 0) {
printf("--- f_%d\n", i);
} else {
printf("--- ");
print_monomial(stdout, monomials[j]);
printf(" * f_%d\n", i);
}
#endif
}
i++;
}
}
......@@ -623,15 +647,15 @@ int main(int argc, char **argv)
if (input_file == NULL)
err(1, "Cannot open %s", in_filename);
}
log(0, "Reading input system\n");
parser(input_file, NULL, &parser_setup, &parser_store_monomial, &parser_store_polynomial, NULL);
log(0, "Read %d polynomials in %d variables\n", m, n);
log(0, "Generating degree-%d Macaulay matrix\n", D);
log(0, "Truncating columns linear in the first %d variables\n", v);
log(1, " - Read %d polynomials in %d variables\n", m, n);
log(1, " - Generating degree-%d Macaulay matrix\n", D);
log(1, " - Truncating columns linear in the first %d variables\n", v);
monomial_setup_list();
log(1, "%d total monomials of degree <= %d\n", Nd[D+1], D);
log(1, "%d matrix columns\n", nbad);
log(1, " - %d total monomials of degree <= %d\n", Nd[D+1], D);
log(1, " - %d matrix columns\n", nbad);
int mac_rows = m * Nd[D - 1];
if (D >= 4)
......@@ -640,21 +664,22 @@ int main(int argc, char **argv)
char hncols[10];
human_format(mac_rows, hnrows);
human_format(nbad, hncols);
log(1, "Estimating matrix: %s rows, %s columns\n", hnrows, hncols);
log(1, " - Estimating sparse matrix: %s rows, %s columns\n", hnrows, hncols);
if (mac_rows < nbad)
errx(1, "matrix will have more columns than rows. Increase degree or reduce inner hybridation.");
monomial_setup_multiplication();
macaulay_dense(D - 2);
log(0, "Starting matrix production\n");
matrix_setup();
for (int d = 2; d <= D; d++) {
printf("Expanding to degree %d\n", d);
log(1, " - Expanding to degree %d\n", d);
macaulay_sparse(d - 2);
char hnnz[10];
human_format(nrows, hnrows);
human_format(nnz, hnnz);
log(1, "Matrix: %s rows, %s cols, %s nnz (%.0f per row), %d poly skipped\n",
log(2, " - %s rows, %s cols, %s nnz (%.0f per row), %d poly skipped\n",
hnrows, hncols, hnnz, (double) nnz / nrows, skipped);
}
......@@ -665,7 +690,7 @@ int main(int argc, char **argv)
int ntouched = 0;
for (int j = 0; j < ncols; j++)
ntouched += scratch[j];
log(1, "%d / %d columns non-empty\n", ntouched, ncols);
log(1, " - %d / %d columns non-empty\n", ntouched, ncols);
if (out_filename) {
log(1, "saving...\n");
......@@ -673,6 +698,8 @@ int main(int argc, char **argv)
if (out_file == NULL)
errx(1, "cannot open %s", out_filename);
cado_export(out_file);
} else {
log(1, "not saving matrix because no --out option given\n");
}
exit(EXIT_SUCCESS);
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment