Giacomo Mulas on Fri, 28 Mar 2014 14:35:33 +0100


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

Unidentified subject!


Hi Bill. Thanks for replying, did you cc your reply to me? I only saw it now
browsing the list archives (I am not subscribed).

Then I create the extended matrix with

  GEN coeffs2 = cgetg(cols+2, t_MAT);
  for (j=1; j<=cols; j++) {
    gel(coeffs2,j) = gel(coeffs1,j);
  }

This is where the bug lies: you need to copy gel(coeffs1,j):
gel(coeffs2,j) = gcopy(gel(coeffs1,j));
or even simply
GEN coeffs2 = gcopy(coeffs1);
otherwise the columns of coeffs2 and coeffs1 are sharing the same memory.

Indeed that's what I intended: coeffs2 is a matrix with one more column than
coeffs1, and apart from the additional one it is (and remains throughout the
calculation) identical to coeffs1. So I saw nothing wrong with them sharing
the same memory.

GEN coeffs2 = gcopy(coeffs1);

would not work though, since coeffs2 has one column more than coeffs1.

In any case, since memory is not an issue in this case, I will just copy
identical columns with gcopy, instead of copying pointers.

Bye
Giacomo

--
_________________________________________________________________

Giacomo Mulas <gmulas@oa-cagliari.inaf.it>
_________________________________________________________________

INAF - Osservatorio Astronomico di Cagliari
via della scienza 5 - 09047 Selargius (CA)

tel.   +39 070 71180244
mob. : +39 329  6603810
_________________________________________________________________

"When the storms are raging around you, stay right where you are"
                         (Freddy Mercury)
_________________________________________________________________