Commit 0c65a79e authored by Christian Eder's avatar Christian Eder
Browse files

Merge branch 'julia-interface' into 'master'

Julia interface changes

See merge request eder/msolve!78
parents 8d55764f 3a652342
......@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT([msolve], [0.3.0], [ederc@mathematik.uni-kl.de])
AC_INIT([msolve], [0.4.0], [ederc@mathematik.uni-kl.de])
AM_INIT_AUTOMAKE([-Wall -Werror foreign silent-rules subdir-objects color-tests parallel-tests])
AC_CONFIG_SRCDIR([config.h.in])
AC_CONFIG_MACRO_DIR([m4])
......
......@@ -715,8 +715,8 @@ static int add_random_linear_form_to_input_system(
gens->random_linear_form[j] = ((int8_t)(rand()));
while(gens->random_linear_form[j] == 0){
gens->random_linear_form[j] = ((int8_t)(rand()) % gens->field_char);
}
mpz_set_ui(*(gens->mpz_cfs[i]), gens->random_linear_form[j]);
}
mpz_set_ui(*(gens->mpz_cfs[i]), gens->random_linear_form[j]);
k++;
j++;
}
......@@ -5432,12 +5432,16 @@ restart:
static void export_julia_rational_parametrization_qq(
void *(*mallocp) (size_t),
int32_t *load,
int32_t *nvars,
int32_t *dim,
int32_t *dim_quot,
int32_t **lens,
char ***var_namesp,
void **cfs_linear_form,
void **cfs,
void **real_sols_num,
int32_t **real_sols_den,
data_gens_ff_t *gens, /* might change vnames, thus not const */
const mpz_param_t param,
const long nb_real_roots,
const real_point_t *real_pts
......@@ -5449,6 +5453,26 @@ static void export_julia_rational_parametrization_qq(
*load = (int32_t)param->nvars+1;
*dim = (int32_t)param->dim;
*dim_quot = (int32_t)param->dquot;
*nvars = (int32_t)gens->nvars;
/* keep variable names for returning rational parametrization */
*var_namesp = gens->vnames;
gens->vnames = NULL;
mpz_t *cf_lf = NULL;
/* check existence of linear form */
if (gens->linear_form_base_coef > 0) {
cf_lf = (mpz_t *)(*mallocp)(
(unsigned long)(gens->nvars) * sizeof(mpz_t));
int64_t len = 0;
for (i = 0; i < gens->ngens-1; ++i) {
len += 2*gens->lens[i]; /* numerator plus denominator, thus "2*" */
}
j = 0;
for (i = 0; i < 2*gens->nvars; i += 2) {
mpz_init_set(cf_lf[j++], *(gens->mpz_cfs[i+len]));
}
}
if ((param->dim > 0) || (param->dim == 0 && param->dquot == 0)) {
*lens = NULL;
......@@ -5493,8 +5517,9 @@ static void export_julia_rational_parametrization_qq(
mpz_init_set((cf+ctr)[j], param->cfs[i]);
ctr += param->coords[i]->length+1;
}
*lens = len;
*cfs = (void *)cf;
*lens = len;
*cfs = (void *)cf;
*cfs_linear_form = (void *)cf_lf;
/* if there are no real solutions return the parametrization at least */
if (nb_real_roots <= 0) {
......@@ -5533,9 +5558,12 @@ static void export_julia_rational_parametrization_qq(
void msolve_julia(
void *(*mallocp) (size_t),
int32_t *rp_ld,
int32_t *rp_nr_vars,
int32_t *rp_dim,
int32_t *rp_dquot,
int32_t **rp_lens,
char ***rp_var_namesp,
void **rp_cfs_linear_form,
void **rp_cfs,
int32_t *n_real_sols,
void **real_sols_num,
......@@ -5587,7 +5615,10 @@ void msolve_julia(
gens->linear_form_base_coef = 0;
/* gens->vnames = var_names; */
gens->vnames = (char **)malloc((unsigned long)nr_vars * sizeof(char *));
memcpy(gens->vnames, var_names, (unsigned long)nr_vars * sizeof(char *));
for (i = 0; i < nr_vars; ++i) {
gens->vnames[i] = calloc((unsigned long)strlen(var_names[i]), sizeof(char));
memcpy(gens->vnames[i], var_names[i], (unsigned long)strlen(var_names[i]) * sizeof(char));
}
/* gens->lens = lens; */
gens->lens = (int32_t *)malloc((unsigned long)nr_gens * sizeof(int32_t));
memcpy(gens->lens, lens, (unsigned long)nr_gens * sizeof(int32_t));
......@@ -5630,20 +5661,25 @@ void msolve_julia(
if (ret == -1) {
exit(1);
}
/* clean up data storage, but do not free data handled by julia */
free(gens);
gens = NULL;
*rp_dim = mpz_param->dim;
char **rp_var_names = NULL;
if (mpz_param->dim != -1) {
export_julia_rational_parametrization_qq(
mallocp, 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_nr_vars, rp_dim, rp_dquot, rp_lens,
&rp_var_names, rp_cfs_linear_form, rp_cfs, real_sols_num,
real_sols_den, gens, mpz_param, nb_real_roots, real_pts);
} else {
*rp_ld = -1;
}
/* clean up data storage, but do not free data handled by julia */
free(gens);
gens = NULL;
*rp_var_namesp = rp_var_names;
/* free parametrization */
free(param);
mpz_param_clear(mpz_param);
......
......@@ -173,9 +173,12 @@ int core_msolve(
void msolve_julia(
void *(*mallocp) (size_t),
int32_t *rp_ld,
int32_t *rp_nr_vars,
int32_t *rp_dim,
int32_t *rp_dquot,
int32_t **rp_lens,
char ***rp_var_namesp,
void **rp_cfs_linear_form,
void **rp_cfs,
int32_t *n_real_sols,
void **real_sols_num,
......
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