Bill Allombert on Thu, 21 Nov 2013 21:57:28 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re : Function vs list of instructions executed separately


Hello Ewan,

GP2C has found a problem in insert_constraint0:

insert_constraint0(extr_constraints,extr_vectors,new_cstr,list_of_vars)=
                                                 ^^^^^^^^
{
 my(temp_vecs,temp_cstr,new_vecs,new_cstr);
                                 ^^^^^^^^
This redefines new_cstr to be 0.

Some comment on your code, and the full GP2C messages:

> eb_variables_array=['eb1,'eb2,'eb3,'eb4,'eb5,'eb6,'eb7,'eb8,'eb9,'eb10,'eb11,'eb12,'eb13,'eb14,'eb15,'eb16,'eb17,'eb18,'eb19,'eb20,'eb21,'eb22,'eb23,'eb24,'eb25,'eb26,'eb27,'eb28,'eb29,'eb30,'eb31,'eb32,'eb33,'eb34,'eb35,'eb36,'eb37,'eb38,'eb39,'eb40,'eb41,'eb42,'eb43,'eb44,'eb45,'eb46,'eb47,'eb48,'eb49,'eb50,'eb51,'eb52,'eb53,'eb54,'eb55,'eb56,'eb57,'eb58,'eb59,'eb60,'eb61,'eb62,'eb63,'eb64,'eb65,'eb66,'eb67,'eb68,'eb69,'eb70,'eb71,'eb72,'eb73,'eb74,'eb75,'eb76,'eb77,'eb78,'eb79,'eb80,'eb81,'eb82,'eb83,'eb84,'eb85,'eb86,'eb87,'eb88,'eb89,'eb90,'eb91,'eb92,'eb93,'eb94,'eb95,'eb96,'eb97,'eb98,'eb99,'eb100]

you can do
eb_variables_array=vector(100,i,eval(Str("'eb",i)));

> ryan_degree(expr,l_var)=
> {
>  my(n,k,answer);
>  n=length(l_var);
>  answer=0;
>  k=n;
>  while((answer<1)*(k>0),if(polcoeff(expr,1,l_var[k])!=0,answer=k;);k--;);
>  return(answer);

You can use && instead of *: answer<1 && k>0

> compute_kernel(l_expr,l_var)=
> {
>  my(variable_l,watcher,answer,part1,part2,expr,var1,form1,\
>  new_l_var,unchanged_indices,unchanged_variables,n,k0,k1);

Do not use \ at end of line inside {}, because \ is an operator in 
GP , so a \ b is legal.

Instead indent your code

>  for(k=1,n,\
>  current_expr=rewritings[k][2];\
>  d=ryan_degree(current_expr,l_var);\

  for(k=1,n,
    current_expr=rewritings[k][2];
    d=ryan_degree(current_expr,l_var);

> big_concat(l)={\
> my(answer,k);
> answer=l[1];
> for(k=2,length(l),answer=concat(answer,l[k]));
> return(answer);
> }

You can just do 
big_concat(l)=concat(l)

gp2c reported the following warning:
Warning:../ewan.gp:60: variable undeclared
annulators
Warning:../ewan.gp:67: variable undeclared
dual_version
Warning:../ewan.gp:51: function prototype is unknown
make_zero(expr,var1)
Warning:../ewan.gp:57: function prototype is unknown
big_subst(l_var,part1,part2)

gp2c-run reported the following
 In function ‘compute_kernel’:
282:208: warning: variable ‘n’ set but not used [-Wunused-but-set-variable]
282:44: warning: unused variable ‘answer’ [-Wunused-variable]
 In function ‘extract_basis’:
377:145: warning: unused variable ‘k’ [-Wunused-variable]
 In function ‘big_concat’:
451:23: warning: unused variable ‘k’ [-Wunused-variable]
 In function ‘cartesian_big_product’:
529:18: warning: unused variable ‘k’ [-Wunused-variable]
 In function ‘test_individual_for_extremality’:
626:7: warning: unused variable ‘k’ [-Wunused-variable]
 In function ‘test_individuals_for_extremality’:
652:18: warning: unused variable ‘r’ [-Wunused-variable]
652:7: warning: unused variable ‘k’ [-Wunused-variable]
 In function ‘untested_new_vectors’:
677:7: warning: unused variable ‘k’ [-Wunused-variable]
 In function ‘insert_constraint0’:
751:63: error: ‘new_cstr’ redeclared as different kind of symbol
748:64: note: previous definition of ‘new_cstr’ was here

Cheers,
Bill.