Commit 9cf8665e authored by Christian Eder's avatar Christian Eder
Browse files

Merge branch 'julia_interface' into 'master'

Julia interface

See merge request eder/msolve!28
parents 821c2a8e 417a8948
......@@ -180,7 +180,9 @@ static void print_msolve_polynomials_ff_32(
hm_t *hm = NULL;
cf32_t *cf = NULL;
const len_t nv = ht->nv;
const len_t nv = ht->nv;
const len_t ebl = ht->ebl;
const len_t evl = ht->evl;
/* state context if full basis is printed */
if (from == 0 && to == bs->lml) {
......@@ -212,22 +214,42 @@ static void print_msolve_polynomials_ff_32(
cf = bs->cf_32[bs->hm[idx][COEFFS]];
ctr = 0;
k = 1;
while (ctr == 0 && k <= nv) {
if (ht->ev[hm[0]][k] > 0) {
fprintf(file, "%s^%u",vnames[k], ht->ev[hm[0]][k]);
ctr++;
if (ebl > 0) {
while (ctr == 1 && k < ebl) {
if (ht->ev[hm[0]][k] > 0) {
fprintf(file, "%s^%u",vnames[k-1], ht->ev[hm[0]][k]);
ctr++;
}
k++;
}
k++;
}
for (;k <= nv; ++k) {
if (ht->ev[hm[0]][k] > 0) {
fprintf(file, "*%s^%u",vnames[k], ht->ev[hm[0]][k]);
for (k=ebl+1;k <= nv; ++k) {
if (ht->ev[hm[0]][k] > 0) {
fprintf(file, "*%s^%u",vnames[k-2], ht->ev[hm[0]][k]);
}
}
if (i < to-1) {
fprintf(file, ",\n");
} else {
fprintf(file, "\n");
}
}
if (i < to-1) {
fprintf(file, ",\n");
} else {
fprintf(file, "\n");
while (ctr == 1 && k < evl) {
if (ht->ev[hm[0]][k] > 0) {
fprintf(file, "%s^%u",vnames[k-1], ht->ev[hm[0]][k]);
ctr++;
}
k++;
}
for (;k < evl; ++k) {
if (ht->ev[hm[0]][k] > 0) {
fprintf(file, "*%s^%u",vnames[k-1], ht->ev[hm[0]][k]);
}
}
if (i < to-1) {
fprintf(file, ",\n");
} else {
fprintf(file, "\n");
}
}
}
}
......
......@@ -801,7 +801,7 @@ int msolve_ff(param_t **bparam,
uint64_t *linvars = calloc(gens->nvars, sizeof(uint64_t));
uint32_t **lineqs_ptr = malloc(sizeof(uint32_t *));
int64_t nb = f4_julia(bld, blen, bexp, bcf,
int64_t nb = f4_julia(&malloc, bld, blen, bexp, bcf,
gens->lens, gens->exps, (void *)gens->cfs, gens->field_char,
0, //mon_order,
elim_block_len,
......@@ -1109,7 +1109,7 @@ int msolve_ff_alloc(param_t **bparam,
exit(1);
}
int64_t nb = export_results_from_f4(bld, blen, bexp,
bcf, &bs, &bht, &st);
bcf, &malloc, &bs, &bht, &st);
/* timings */
ct1 = cputime();
......@@ -4750,7 +4750,7 @@ restart:
exit(1);
}
int64_t nb = export_results_from_f4(bld, blen, bexp,
bcf, &bs, &bht, &st);
bcf, &malloc, &bs, &bht, &st);
/* timings */
ct1 = cputime();
......@@ -5492,6 +5492,7 @@ restart:
}
static void export_julia_rational_parametrization_qq(
void *(*mallocp) (size_t),
int32_t *load,
int32_t *dim,
int32_t *dim_quot,
......@@ -5516,7 +5517,7 @@ static void export_julia_rational_parametrization_qq(
*lens = NULL;
*cfs = NULL;
} else {
int32_t *len = (int32_t *)malloc(
int32_t *len = (int32_t *)(*mallocp)(
(unsigned long)(param->nvars+1) * sizeof(int32_t));
/* precompute number of all terms of all polynomials */
......@@ -5533,7 +5534,7 @@ static void export_julia_rational_parametrization_qq(
len[i+2] = param->coords[i]->length+1;
}
mpz_t *cf = (mpz_t *)malloc(
mpz_t *cf = (mpz_t *)(*mallocp)(
(unsigned long)(nterms) * sizeof(mpz_t));
/* store elim */
......@@ -5558,10 +5559,10 @@ static void export_julia_rational_parametrization_qq(
*lens = len;
*cfs = (void *)cf;
mpz_t *sols_num = (mpz_t *)malloc(
mpz_t *sols_num = (mpz_t *)(*mallocp)(
(unsigned long)nb_real_roots * real_pts[0]->nvars * sizeof(mpz_t));
int32_t *sols_den = (int32_t *)malloc(
int32_t *sols_den = (int32_t *)(*mallocp)(
(unsigned long)nb_real_roots * real_pts[0]->nvars * sizeof(int32_t));
......@@ -5586,6 +5587,7 @@ static void export_julia_rational_parametrization_qq(
}
void msolve_julia(
void *(*mallocp) (size_t),
int32_t *rp_ld,
int32_t *rp_dim,
int32_t *rp_dquot,
......@@ -5689,9 +5691,9 @@ void msolve_julia(
if (mpz_param->dim != -1) {
export_julia_rational_parametrization_qq(
rp_ld, rp_dim, rp_dquot, rp_lens, rp_cfs,
real_sols_num, real_sols_den, mpz_param,
nb_real_roots, real_pts);
mallocp, rp_ld, rp_dim, rp_dquot, rp_lens,
rp_cfs, real_sols_num, real_sols_den,
mpz_param, nb_real_roots, real_pts);
} else {
*rp_ld = -1;
}
......
......@@ -164,6 +164,7 @@ int core_msolve(
);
void msolve_julia(
void *(*mallocp) (size_t),
int32_t *rp_ld,
int32_t *rp_dim,
int32_t *rp_dquot,
......
......@@ -82,6 +82,7 @@ int64_t (*export_julia_data)(
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
......
......@@ -381,6 +381,7 @@ extern int64_t (*export_julia_data)(
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
......
......@@ -420,6 +420,7 @@ int64_t export_results_from_f4(
int32_t **blen, /* length of each poly in basis */
int32_t **bexp, /* basis exponent vectors */
void **bcf, /* coefficients of basis elements */
void *(*mallocp) (size_t),
bs_t **bsp,
ht_t **bhtp,
stat_t **stp
......@@ -431,7 +432,7 @@ int64_t export_results_from_f4(
stat_t *st = *stp;
st->nterms_basis = export_julia_data(
bld, blen, bexp, bcf, bs, bht, st->fc);
bld, blen, bexp, bcf, mallocp, bs, bht, st->fc);
st->size_basis = *bld;
return st->nterms_basis;
......@@ -447,6 +448,7 @@ int64_t export_results_from_f4(
*
* RETURNs the length of the jl_basis array */
int64_t f4_julia(
void *(*mallocp) (size_t),
/* return values */
int32_t *bld, /* basis load */
int32_t **blen, /* length of each poly in basis */
......@@ -501,7 +503,7 @@ int64_t f4_julia(
}
int64_t nterms = export_results_from_f4(bld, blen, bexp,
bcf, &bs, &bht, &st);
bcf, mallocp, &bs, &bht, &st);
/* timings */
ct1 = cputime();
......
......@@ -56,6 +56,7 @@ int initialize_f4_input_data(
);
int64_t f4_julia(
void *(*mallocp) (size_t),
int32_t *bld, /* basis load */
int32_t **blen, /* length of each poly in basis */
int32_t **bexp, /* basis exponent vectors */
......@@ -84,6 +85,7 @@ int64_t export_results_from_f4(
int32_t **blen, /* length of each poly in basis */
int32_t **bexp, /* basis exponent vectors */
void **bcf, /* coefficients of basis elements */
void *(*mallocp) (size_t),
bs_t **bsp,
ht_t **bhtp,
stat_t **stp
......
......@@ -696,6 +696,7 @@ static int64_t export_julia_data_ff_8(
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
......@@ -722,11 +723,11 @@ static int64_t export_julia_data_ff_8(
return 0;
}
int32_t *len = (int32_t *)malloc(
int32_t *len = (int32_t *)(*mallocp)(
(unsigned long)(nelts) * sizeof(int32_t));
int32_t *exp = (int32_t *)malloc(
int32_t *exp = (int32_t *)(*mallocp)(
(unsigned long)(nterms) * (unsigned long)(nv) * sizeof(int32_t));
int32_t *cf = (int32_t *)malloc(
int32_t *cf = (int32_t *)(*mallocp)(
(unsigned long)(nterms) * sizeof(int32_t));
/* counters for lengths, exponents and coefficients */
......@@ -764,6 +765,7 @@ static int64_t export_julia_data_ff_16(
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
......@@ -790,11 +792,11 @@ static int64_t export_julia_data_ff_16(
return 0;
}
int32_t *len = (int32_t *)malloc(
int32_t *len = (int32_t *)(*mallocp)(
(unsigned long)(nelts) * sizeof(int32_t));
int32_t *exp = (int32_t *)malloc(
int32_t *exp = (int32_t *)(*mallocp)(
(unsigned long)(nterms) * (unsigned long)(nv) * sizeof(int32_t));
int32_t *cf = (int32_t *)malloc(
int32_t *cf = (int32_t *)(*mallocp)(
(unsigned long)(nterms) * sizeof(int32_t));
/* counters for lengths, exponents and coefficients */
......@@ -832,6 +834,7 @@ static int64_t export_julia_data_ff_32(
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
......@@ -858,11 +861,11 @@ static int64_t export_julia_data_ff_32(
return 0;
}
int32_t *len = (int32_t *)malloc(
int32_t *len = (int32_t *)(*mallocp)(
(unsigned long)(nelts) * sizeof(int32_t));
int32_t *exp = (int32_t *)malloc(
int32_t *exp = (int32_t *)(*mallocp)(
(unsigned long)(nterms) * (unsigned long)(nv) * sizeof(int32_t));
int32_t *cf = (int32_t *)malloc(
int32_t *cf = (int32_t *)(*mallocp)(
(unsigned long)(nterms) * sizeof(int32_t));
/* counters for lengths, exponents and coefficients */
......@@ -907,6 +910,7 @@ static int64_t export_julia_data_qq(
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
......@@ -933,11 +937,11 @@ static int64_t export_julia_data_qq(
return 0;
}
int32_t *len = (int32_t *)malloc(
int32_t *len = (int32_t *)(*mallocp)(
(unsigned long)(nelts) * sizeof(int32_t));
int32_t *exp = (int32_t *)malloc(
int32_t *exp = (int32_t *)(*mallocp)(
(unsigned long)(nterms) * (unsigned long)(nv) * sizeof(int32_t));
mpz_t *cf = (mpz_t *)malloc(
mpz_t *cf = (mpz_t *)(*mallocp)(
(unsigned long)(nterms) * sizeof(mpz_t));
/* counters for lengths, exponents and coefficients */
......@@ -1031,8 +1035,6 @@ int32_t check_and_set_meta_data(
printf("error: Too large elimination block.\n");
exit(1);
}
printf("ebl = %d\n", st->nev);
/* set hash table size */
st->init_hts = ht_size;
if (st->init_hts <= 0) {
......
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