Commit 2c085f06 authored by Christian Eder's avatar Christian Eder
Browse files

Merge branch 'julia_interface' into 'master'

Updates Julia interface for correctly freeing returned data

See merge request eder/msolve!30
parents c98d90b2 107940e1
......@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT([msolve], [0.1.2], [ederc@mathematik.uni-kl.de])
AC_INIT([msolve], [0.1.7], [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])
......
......@@ -4776,7 +4776,9 @@ int real_msolve_qq(mpz_param_t mp_param,
}
double st = realtime();
pts = malloc(sizeof(real_point_t) * nb);
fprintf(stderr, "nbvars = %ld\n", mp_param->nvars);
if(info_level){
fprintf(stderr, "nbvars = %ld\n", mp_param->nvars);
}
for(long i = 0; i < nb; i++){
real_point_init(pts[i], mp_param->nvars);
}
......@@ -5965,3 +5967,60 @@ void msolve_julia(
-----------------------------------\n");
}
}
/* The parameters themselves are handled by julia, thus we only
* free what they are pointing to, julia's garbage collector then
* takes care of everything leftover. */
void free_msolve_julia_result_data(
void (*freep) (void *),
int32_t **res_len,
void **res_cf,
void **sols_num,
int32_t **sols_den,
const int64_t res_ld,
const int64_t nr_sols,
const int64_t field_char
)
{
int64_t i;
int64_t len = 0;
int32_t *lens = *res_len;
for (i = 0; i < res_ld; ++i) {
len += (int64_t)lens[i];
}
(*freep)(lens);
lens = NULL;
*res_len = lens;
if (field_char > 0) {
int32_t *numerators = *(int32_t **)sols_num;
(*freep)(numerators);
numerators = NULL;
int32_t *cfs= *(int32_t **)res_cf;
(*freep)(cfs);
cfs = NULL;
} else {
/* denominators only exist if char == 0 */
int32_t *denominators = *sols_den;
(*freep)(denominators);
denominators = NULL;
*sols_den = denominators;
/* mpz_t **numerators = (mpz_t **)sols_num;
* for (i = 0; i < nr_sols; ++i) {
* (*freep)((*numerators)[i]);
* }
* (*freep)(*numerators);
* *numerators = NULL;
* mpz_t **cfs = (mpz_t **)res_cf;
* for (i = 0; i < len; ++i) {
* (*freep)((*cfs)[i]);
* }
* (*freep)(*cfs);
* *cfs = NULL; */
}
*sols_num = NULL;
*res_cf = NULL;
}
......@@ -194,4 +194,15 @@ void msolve_julia(
const int32_t precision,
const int32_t info_level
);
void free_msolve_julia_result_data(
void (*freep) (void *),
int32_t **res_len,
void **res_cf,
void **sols_num,
int32_t **sols_den,
const int64_t res_ld,
const int64_t nr_sols,
const int64_t field_char
);
#endif
......@@ -21,7 +21,11 @@
#include "f4.h"
void free_julia_data(
/* The parameters themselves are handled by julia, thus we only
* free what they are pointing to, julia's garbage collector then
* takes care of everything leftover. */
void free_f4_julia_result_data(
void (*freep) (void *),
int32_t **blen, /* length of each poly in basis */
int32_t **bexp, /* basis exponent vectors */
void **bcf, /* coefficients of basis elements */
......@@ -38,34 +42,32 @@ void free_julia_data(
len += (int64_t)lens[i];
}
free(lens);
lens = NULL;
(*freep)(lens);
lens = NULL;
*blen = lens;
/* exponent vectors */
int32_t *exps = *bexp;
free(exps);
(*freep)(exps);
exps = NULL;
*bexp = exps;
bexp = NULL;
/* coefficients */
if (field_char == 0) {
mpz_t **cfs = (mpz_t **)bcf;
for (i = 0; i < len; ++i) {
mpz_clear((*cfs)[i]);
}
free(*cfs);
free(cfs);
cfs = NULL;
/* mpz_t **cfs = (mpz_t **)bcf;
* for (i = 0; i < len; ++i) {
* mpz_clear((*cfs)[i]);
* }
* (*freep)(*cfs);
* *cfs = NULL; */
} else {
if (field_char > 0) {
int32_t *cfs = *((int32_t **)bcf);
free(cfs);
(*freep)(cfs);
cfs = NULL;
}
}
bcf = NULL;
*bcf = NULL;
}
static void clear_matrix(
......
......@@ -24,7 +24,8 @@
#include "data.h"
void free_julia_data(
void free_f4_julia_result_data(
void (*freep) (void *),
int32_t **blen, /* length of each poly in basis */
int32_t **bexp, /* basis exponent vectors */
void **bcf, /* coefficients of basis elements */
......
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