Commit 73a28ac5 authored by Mohab Safey El Din's avatar Mohab Safey El Din
Browse files

some more bug fixes + removes dbg msgs

parent 5ea68ebb
......@@ -224,6 +224,7 @@ static inline fglm_bms_data_t *allocate_fglm_bms_data(long dim, mp_limb_t prime)
nmod_poly_init(data_bms->B, prime);
nmod_poly_init(data_bms->Z1, prime);
nmod_poly_init2(data_bms->rZ1, prime, dim+1);
nmod_poly_init(data_bms->Z2, prime);
......@@ -231,6 +232,14 @@ static inline fglm_bms_data_t *allocate_fglm_bms_data(long dim, mp_limb_t prime)
nmod_poly_init2(data_bms->V, prime, dim+1);
nmod_poly_init2(data_bms->param, prime, dim+1);
for(long i = 0; i < dim + 1; i++){
data_bms->rZ1->coeffs[i] = 0;
data_bms->rZ2->coeffs[i] = 0;
data_bms->V->coeffs[i] = 0;
data_bms->param->coeffs[i] = 0;
}
nmod_berlekamp_massey_init(data_bms->BMS, (mp_limb_t)prime);
nmod_poly_factor_init(data_bms->sqf);
......
......@@ -84,7 +84,7 @@ void display_fglm_param_maple(FILE * file, param_t *param){
display_nmod_poly(file, param->denom);
fprintf(file, ", \n");
for(int c = param->nvars-2; c >= 0; c--){
for(int c = param->nvars-2; c > 0; c--){
display_nmod_poly(file, param->coords[c]);
fprintf(file, ", \n");
}
......@@ -768,6 +768,12 @@ static void set_param_linear_vars(param_t *param,
if(linvars[nc] != 0){
/* int64_t lc = lineqs[nc +(nvars+1)*(nr-1 - (cnt-1))]; */
nmod_poly_fit_length(param->coords[ind], param->elim->length);
param->coords[ind]->coeffs[param->coords[ind]->length-1] = 0;
param->coords[ind]->length = param->elim->length;
for(long i = 0; i < param->coords[ind]->length; i++){
param->coords[ind]->coeffs[i] = 0;
}
int64_t lc = lineqs[nr - 1 - (cnt-1) +(nvars+1)*(nr-1 - (cnt-1))];
......@@ -776,13 +782,14 @@ static void set_param_linear_vars(param_t *param,
/* exit(1); */
/* } */
/* for(int k = nc + 1; k < nvars - 1 ; k++){ */
for(int k = 1; k < nvars-1 ; k++){
for(int k = 1; k < nvars - 1 ; k++){
int32_t c = lineqs[k+(nvars+1)*(nr-(cnt-1)-1)];
if(c){
/* one multiplies param->coords[k] by fc -c */
/* and adds this to param->coords[ind] */
uint32_t cc = (fc - c);
for(int i = 0; i < param->coords[k]->length; i++){
int64_t tmp = cc * param->coords[k]->coeffs[i];
tmp = tmp % fc;
......@@ -793,16 +800,14 @@ static void set_param_linear_vars(param_t *param,
}
}
nmod_poly_fit_length(param->coords[ind], param->elim->length);
param->coords[ind]->coeffs[param->coords[ind]->length-1] = 0;
param->coords[ind]->length = param->elim->length;
int32_t c1 = lineqs[nvars-1+(nvars+1)*(nr-(cnt-1)-1)];
int32_t c1 = lineqs[nvars - 1 +(nvars+1)*(nr-(cnt-1)-1)];
param->coords[ind]->coeffs[1] = ((int64_t)(param->coords[ind]->coeffs[1] + c1)) % fc;
int32_t c0 = lineqs[nvars+(nvars+1)*(nr-(cnt-1)-1)];
int32_t c0 = lineqs[nvars +(nvars+1)*(nr-(cnt-1)-1)];
param->coords[ind]->coeffs[0] = ((int64_t)(param->coords[ind]->coeffs[0] + c0)) % fc;
for(long k = param->coords[ind]->length - 1; k >= 0; k--){
if(param->coords[ind]->coeffs[k] == 0){
param->coords[ind]->length--;
......@@ -1266,8 +1271,6 @@ param_t *nmod_fglm_compute_trace_data(sp_matfglm_t *matrix, mod_t prime,
return NULL;
}
fprintf(stderr, "In nmod_fglm_compute_trace_data\n");
fprintf(stderr, "nvars = %ld\n", nvars);
/* to store the terms we need */
*bdata = allocate_fglm_data(matrix->nrows, matrix->ncols, nvars);
......
......@@ -58,6 +58,7 @@ static void mpz_upoly_init2(mpz_upoly_t poly, long alloc, long nbits){
}
for(long i = 0; i < alloc; i++){
mpz_init2(tmp[i], nbits);
mpz_set_ui(tmp[i], 0);
}
}
poly->coeffs = tmp;
......@@ -1534,6 +1535,7 @@ static inline void set_mpz_param_nmod(mpz_param_t mpz_param, param_t *nmod_param
}
mpz_param->denom->length = nmod_param->denom->length;
for(int j = 0; j < mpz_param->nvars - 1; j++){
for(long i = 0 ; i < nmod_param->coords[j]->length; i++){
mpz_set_ui(mpz_param->coords[j]->coeffs[i],
nmod_param->coords[j]->coeffs[i]);
......@@ -1570,6 +1572,7 @@ static inline void crt_lift_mpz_param(mpz_param_t mpz_param, param_t *nmod_param
/*assumes prod_crt = modulus * prime */
crt_lift_mpz_upoly(mpz_param->elim, nmod_param->elim, modulus, prime,
prod_crt, nthrds);
for(long i = 0; i < mpz_param->nvars - 1; i++){
crt_lift_mpz_upoly(mpz_param->coords[i], nmod_param->coords[i],
modulus, prime, prod_crt, nthrds);
......@@ -2084,8 +2087,6 @@ static inline int new_rational_reconstruction(mpz_param_t mpz_param,
}
}
exit(1);
long nsols = mpz_param->nsols;
mpz_t lc;
mpz_init(lc);
......@@ -2109,21 +2110,21 @@ static inline int new_rational_reconstruction(mpz_param_t mpz_param,
if(is_lifted[0]>0 && is_lifted[i+1]==0){
b = rational_reconstruction_upoly_with_denom(mpz_param->coords[i],
denominator,
tmp_mpz_param->coords[i],
nmod_param->coords[i]->length,
*modulus,
maxrec,
coef,
rnum,
rden,
numer,
denom,
lcm,
*guessed_num,
*guessed_den,
recdata,
info_level);
denominator,
tmp_mpz_param->coords[i],
nmod_param->coords[i]->length,
*modulus,
maxrec,
coef,
rnum,
rden,
numer,
denom,
lcm,
*guessed_num,
*guessed_den,
recdata,
info_level);
if(b == 0){
mpz_set_ui(recdata->D, 1);
......@@ -3250,7 +3251,6 @@ int msolve_trace_qq(mpz_param_t mpz_param,
btht[i] = copy_hash_table(tht, st);
}
normalize_nmod_param(nmod_params[0]);
if(info_level){
......@@ -4413,9 +4413,7 @@ int real_msolve_qq(mpz_param_t mp_param,
}
double st = realtime();
pts = malloc(sizeof(real_point_t) * nb);
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);
}
......
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