Commit 21cecf2b authored by Charles Bouillaguet's avatar Charles Bouillaguet
Browse files

actual fix

parent 9c74d2ac
......@@ -478,6 +478,9 @@ int *jlog;
/* nrows and ncols have been setup */
void matrix_setup()
{
assert(nrows > 0);
assert(ncols > 0);
skipped = 0;
/* warning, scratch should be per-thread */
rw = alloc_array(nrows, sizeof(*rw), "row weights");
cw = alloc_array(ncols, sizeof(*cw), "col weights");
......@@ -489,6 +492,14 @@ void matrix_setup()
rw[i] = -1;
}
void matrix_clean()
{
free(rw);
free(cw);
free(ilog);
free(jlog);
}
/* Store m_j * f_i in the sparse matrix, and update metadata.
Eliminate duplicates and good monomials, renumbers columns.
Scratch should be a zero-filled array. This destroys row. */
......@@ -737,13 +748,20 @@ int main(int argc, char **argv)
int ncols_before = ncols;
ncols = 0;
u64 nnz_check = 0;
/* check empty columns ; enumerate all monomials again */
for (int j = 0; j < Nd[D + 1]; j++) {
int jj = bad_renumbering[j];
assert(jj < 0 || ncols <= jj);
if (jj < 0)
continue;
bad_renumbering[j] = ncols;
nnz_check += cw[jj];
if (cw[jj] != 0)
ncols += 1;
}
assert(nnz == nnz_check);
assert(ncols <= ncols_before);
log(1, " - %d empty columns\n", ncols_before - ncols);
if (out_basename == NULL) {
......@@ -771,16 +789,14 @@ int main(int argc, char **argv)
buffer_stream = fopen(matrix_filename, "w");
if (buffer_stream == NULL)
errx(1, "cannot open %s", matrix_filename);
matrix_clean();
log(0, "Matrix production (pass 2/2)\n");
for (int j = 0; j < ncols; j++)
cw[j] = 0;
for (int i = 0; i < nrows; i++)
rw[i] = -1;
/* output pass 2/2 */
matrix_setup();
output_setup();
for (int d = 2; d <= D; d++) {
log(1, " - Expanding to degree %d\n", d);
......
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