ramare on Wed, 29 Mar 2006 16:52:17 +0200


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

matrix and reference copies


This one works : (use matDelta(3,3))
{
matDelta(n, r)=
  local(mymat = matrix(r-1,r-1,a,b,a+b), too, j, res, s);
  for(j = 1, r-1,
     for(t = 1, r-1,
        if(j <= t, res = 1, res = 0);
        print(mymat);
        for(s = t+1, r, res += 2^s);
        print(res,"/",mymat[j, t],":",j,"-",t);
        mymat[j, t] = res;));
  return(mymat)
}

This one doesn't::
{
matDelta(n, r)=
  local(mymat = matrix(r-1,r-1), too, j, res, s);
  for(j = 1, r-1,
     for(t = 1, r-1,
        if(j <= t, res = 1, res = 0);
        print(mymat);
        for(s = t+1, r, res += 2^s);
        print(res,"/",mymat[j, t],":",j,"-",t);
        mymat[j, t] = res;));
  return(mymat)
}
In C, I guess the pointer corresponding to the entries of
matrix(r-1,r-1) haven't been initialized separately (same 0 is used
in each line).In the first case, they are.
Cheers !
Amities,
             Olivier