Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normal form interface #88

Merged
merged 7 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/msolve/iofiles.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ static void print_msolve_polynomials_ff(
const ht_t * const ht,
const md_t *st,
char **vnames,
const int lead_ideal_only
const int lead_ideal_only,
const int is_nf
)
{
len_t i, j, k, idx;
Expand All @@ -175,7 +176,7 @@ static void print_msolve_polynomials_ff(
const len_t evl = ht->evl;

/* state context if full basis is printed */
if (from == 0 && to == bs->lml) {
if (is_nf == 0 && from == 0 && to == bs->lml) {
if (lead_ideal_only != 0) {
fprintf(file, "#Lead ideal for input in characteristic ");
} else {
Expand All @@ -191,7 +192,6 @@ static void print_msolve_polynomials_ff(
fprintf(file, "#consisting of %u elements:\n", bs->lml);
}


int *evi = (int *)malloc((unsigned long)ht->nv * sizeof(int));
if (ebl == 0) {
for (i = 1; i < evl; ++i) {
Expand Down Expand Up @@ -312,12 +312,12 @@ static void print_ff_nf_data(
if(fn != NULL){
FILE *ofile = fopen(fn, mode);
print_msolve_polynomials_ff(ofile, from, to, bs, ht,
st, gens->vnames, 2-print_gb);
st, gens->vnames, 2-print_gb, 1);
fclose(ofile);
}
else{
print_msolve_polynomials_ff(stdout, from, to, bs, ht,
st, gens->vnames, 2-print_gb);
st, gens->vnames, 2-print_gb, 1);
}
}
}
Expand All @@ -335,12 +335,12 @@ static void print_ff_basis_data(
if(fn != NULL){
FILE *ofile = fopen(fn, mode);
print_msolve_polynomials_ff(ofile, 0, bs->lml, bs, ht,
st, gens->vnames, 2-print_gb);
st, gens->vnames, 2-print_gb, 0);
fclose(ofile);
}
else{
print_msolve_polynomials_ff(stdout, 0, bs->lml, bs, ht,
st, gens->vnames, 2-print_gb);
st, gens->vnames, 2-print_gb, 0);
}
}
}
Expand Down
8 changes: 1 addition & 7 deletions src/msolve/msolve.c
Original file line number Diff line number Diff line change
Expand Up @@ -4895,11 +4895,6 @@ int core_msolve(
info_level);

st->gfc = gens->field_char;
if(info_level){
fprintf(stderr,
"NOTE: Field characteristic is now corrected to %u\n",
st->gfc);
}
if (!success) {
printf("Bad input data, stopped computation.\n");
exit(1);
Expand Down Expand Up @@ -4946,8 +4941,7 @@ int core_msolve(
}
/* print all reduced elements in tbr, first normal_form ones
* are the input elements */
print_ff_nf_data(files->out_file, "a", normal_form,
tbr->lml, tbr, bht, st, gens, 1);
print_ff_nf_data(files->out_file, "a", 0, normal_form, tbr, bht, st, gens, 1);
if (normal_form_matrix > 0) {
/* sht and hcm will store the union of the support
* of all normal forms in tbr. */
Expand Down
2 changes: 1 addition & 1 deletion src/neogb/basis.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static void free_basis_elements(
free(bs->si);
bs->si = NULL;

bs->ld = bs->lo = 0;
bs->ld = bs->lo = bs->lml = 0;
}

void free_basis(
Expand Down
2 changes: 2 additions & 0 deletions src/neogb/convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,8 @@ static void return_normal_forms_to_basis(
double ct = cputime();
double rt = realtime();

free_basis_elements(bs);

/* fix size of basis for entering new elements directly */
check_enlarge_basis(bs, mat->np, st);

Expand Down
11 changes: 0 additions & 11 deletions src/neogb/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,6 @@ int (*hcm_cmp)(
void *htp
);

int64_t (*export_julia_data)(
int32_t *bload,
int32_t **blen,
int32_t **bexp,
void **bcf,
void *(*mallocp) (size_t),
const bs_t * const bs,
const ht_t * const ht,
const uint32_t fc
);

/* linear algebra routines */
void (*sba_linear_algebra)(
smat_t *smat,
Expand Down
13 changes: 2 additions & 11 deletions src/neogb/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ struct md_t
double reduce_gb_ctime;
double tracer_ctime;
double rht_ctime;
double nf_ctime;

double round_rtime;
double select_rtime;
Expand All @@ -361,6 +362,7 @@ struct md_t
double reduce_gb_rtime;
double tracer_rtime;
double rht_rtime;
double nf_rtime;

int64_t num_pairsred;
int64_t num_gb_crit;
Expand Down Expand Up @@ -466,17 +468,6 @@ extern int (*hcm_cmp)(
void *htp
);

extern int64_t (*export_julia_data)(
int32_t *bload,
int32_t **blen,
int32_t **bexp,
void **bcf,
void *(*mallocp) (size_t),
const bs_t * const bs,
const ht_t * const ht,
const uint32_t fc
);

/* linear algebra routines */
extern void (*sba_linear_algebra)(
smat_t *smat,
Expand Down
19 changes: 8 additions & 11 deletions src/neogb/f4.c
Original file line number Diff line number Diff line change
Expand Up @@ -682,12 +682,12 @@ int64_t export_results_from_f4(
)
{

bs_t *bs = *bsp;
ht_t *bht = *bhtp;
bs_t *bs = *bsp;
ht_t *bht = *bhtp;
md_t *st = *stp;

st->nterms_basis = export_julia_data(
bld, blen, bexp, bcf, mallocp, bs, bht, st->fc);
st->nterms_basis = export_data(
bld, blen, bexp, bcf, mallocp, bs, bht, st);
st->size_basis = *bld;

return st->nterms_basis;
Expand All @@ -702,7 +702,7 @@ int64_t export_results_from_f4(
* first all exponents of generator 1, then all of generator 2, ...
*
* RETURNs the length of the jl_basis array */
int64_t f4_julia(
int64_t export_f4(
void *(*mallocp) (size_t),
/* return values */
int32_t *bld, /* basis load */
Expand Down Expand Up @@ -757,9 +757,10 @@ int64_t f4_julia(
exit(1);
}

bs = core_f4(bs, md, &success, field_char);
int err = 0;
bs = core_f4(bs, md, &err, field_char);

if (!success) {
if (err) {
printf("Problem with F4, stopped computation.\n");
exit(1);
}
Expand All @@ -777,10 +778,6 @@ int64_t f4_julia(

/* free and clean up */
free_shared_hash_data(bht);
if (bht != NULL) {
free_hash_table(&bht);
}

if (bs != NULL) {
free_basis(&bs);
}
Expand Down
2 changes: 1 addition & 1 deletion src/neogb/f4.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void free_f4_julia_result_data(
const int64_t field_char
);

int64_t f4_julia(
int64_t export_f4(
void *(*mallocp) (size_t),
int32_t *bld, /* basis load */
int32_t **blen, /* length of each poly in basis */
Expand Down
Loading