Skip to content

Commit

Permalink
adds import_input_data_nf_ff_16
Browse files Browse the repository at this point in the history
  • Loading branch information
mohabsafey committed Jun 23, 2023
1 parent a0ba39c commit dad7468
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/msolve/msolve.c
Original file line number Diff line number Diff line change
Expand Up @@ -4645,7 +4645,7 @@ int core_msolve(
* to the correct field characteristic. */
success = initialize_gba_input_data(&bs, &bht, &st,
gens->lens, gens->exps, (void *)gens->cfs,
1073741827, 0 /* DRL order */, elim_block_len, gens->nvars,
gens->field_char/* 1073741827 */, 0 /* DRL order */, elim_block_len, gens->nvars,
/* gens->field_char, 0 [> DRL order <], gens->nvars, */
gens->ngens, saturate, initial_hts, nr_threads, max_pairs,
update_ht, la_option, use_signatures, 1 /* reduce_gb */, 0,
Expand All @@ -4670,9 +4670,19 @@ int core_msolve(
}
} else {
sat = initialize_basis(st);
import_input_data_nf_ff_32(
sat, bht, st, gens->ngens-saturate, gens->ngens,
gens->lens, gens->exps, (void *)gens->cfs);
if (st->fc > 0) {
normalize_initial_basis(bs, st->fc);
}
if(st->ff_bits == 16){
import_input_data_nf_ff_16(
sat, bht, st, gens->ngens-saturate, gens->ngens,
gens->lens, gens->exps, (void *)gens->cfs);
}
else{
import_input_data_nf_ff_32(
sat, bht, st, gens->ngens-saturate, gens->ngens,
gens->lens, gens->exps, (void *)gens->cfs);
}
sat->ld = sat->lml = saturate;
/* normalize_initial_basis(tbr, st->fc); */
for (int k = 0; k < saturate; ++k) {
Expand Down
81 changes: 81 additions & 0 deletions src/neogb/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,87 @@ void import_input_data_nf_ff_32(
}
}

void import_input_data_nf_ff_16(
bs_t *tbr,
ht_t *ht,
stat_t *st,
const int32_t start,
const int32_t stop,
const int32_t *lens,
const int32_t *exps,
const void *vcfs
)
{
int32_t i, j, k;
cf16_t *cf = NULL;
int64_t tmpcf = 0;
hm_t *hm = NULL;

int16_t *cfs = (int16_t *)vcfs;

int32_t off = 0; /* offset in arrays */
const len_t fc = st->fc;

for (i = 0; i < start; ++i) {
off += lens[i];
}

/* check basis size first */
check_enlarge_basis(tbr, stop-start, st);

exp_t *e = ht->ev[0]; /* use as temporary storage */

for (i = start; i < stop; ++i) {
while (lens[i] >= ht->esz-ht->eld) {
enlarge_hash_table(ht);
e = ht->ev[0]; /* reset e if enlarging */
}
hm = (hm_t *)malloc(((unsigned long)lens[i]+OFFSET) * sizeof(hm_t));
cf = (cf16_t *)malloc((unsigned long)(lens[i]) * sizeof(cf16_t));
tbr->hm[i-start] = hm;
tbr->cf_16[i-start] = cf;

hm[COEFFS] = i-start; /* link to matcf entry */
hm[PRELOOP] = (lens[i] % UNROLL); /* offset */
hm[LENGTH] = lens[i]; /* length */

tbr->red[i-start] = 0;

for (j = off; j < off+lens[i]; ++j) {
set_exponent_vector(e, exps, j, ht, st);
hm[j-off+OFFSET] = insert_in_hash_table(e, ht);
/* make coefficient positive */
tmpcf = (int64_t)cfs[j];
tmpcf += (tmpcf >> 63) & fc;
cf[j-off] = (cf16_t)tmpcf;
}
off += lens[i];
/* sort terms in polynomial w.r.t. given monomial order */
sort_terms_ff_16(&cf, &hm, ht);
}
/* set total degree of input polynomials */
deg_t deg = 0;
if (st->nev) {
for (i = 0; i < stop-start; ++i) {
hm = tbr->hm[i];
deg = ht->hd[hm[OFFSET]].deg;
k = hm[LENGTH] + OFFSET;
for (j = OFFSET+1; j < k; ++j) {
if (deg < ht->hd[hm[j]].deg) {
deg = ht->hd[hm[j]].deg;
st->homogeneous = 1;
}
}
tbr->hm[i][DEG] = deg;
}
} else {
for (i = 0; i < stop-start; ++i) {
hm = tbr->hm[i];
tbr->hm[i][DEG] = ht->hd[hm[OFFSET]].deg;
}
}
}



void import_input_data_nf_qq(
Expand Down
11 changes: 11 additions & 0 deletions src/neogb/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,17 @@ void import_input_data_nf_ff_32(
const void *vcfs
);

void import_input_data_nf_ff_16(
bs_t *tbr,
ht_t *ht,
stat_t *st,
const int32_t start,
const int32_t stop,
const int32_t *lens,
const int32_t *exps,
const void *vcfs
);

void import_input_data_nf_qq(
bs_t *tbr,
ht_t *ht,
Expand Down

0 comments on commit dad7468

Please sign in to comment.