Project

General

Profile

Bug #350

problem with "matrix" argument in functions

Added by Anna Maria Bigatti almost 11 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Immediate
Assignee:
Category:
Safety
Target version:
Start date:
21 May 2013
Due date:
% Done:

100%

Estimated time:
Spent time:

Description

If a function has argument "matrix M" (instead of MatrixView or ConstMatrixView) it is passed as a "pointer", i.e. if M is modified inside the function, the outside matrix is modified.

I think there is no cure for this: they are pointers.
Should we write it in the documentation?

I'll post an explicit example when I have time to try


Related issues

Related to CoCoALib - Design #592: Review design of ConstMatrixViewClosed2014-07-17

History

#1 Updated by Anna Maria Bigatti over 10 years ago

  • Target version changed from CoCoALib-0.99534 Seoul14 to CoCoALib-0.99532

#2 Updated by Anna Maria Bigatti almost 10 years ago

  • Target version changed from CoCoALib-0.99532 to CoCoALib-0.99533 Easter14

#3 Updated by John Abbott almost 10 years ago

  • Target version changed from CoCoALib-0.99533 Easter14 to CoCoALib-0.99534 Seoul14

#4 Updated by John Abbott over 9 years ago

  • Target version changed from CoCoALib-0.99534 Seoul14 to CoCoALib-1.0

#5 Updated by John Abbott over 9 years ago

  • Status changed from New to In Progress
  • Assignee set to John Abbott
  • Priority changed from Normal to Immediate

I've just been burned by this bug. It definitely falls into the category nasty surprise. I'll try to fix ASAP.

#6 Updated by John Abbott over 9 years ago

Here is an explicit example:

RingElem bareiss(matrix M)
{
  const int n = NumRows(M);
  CoCoA_ASSERT(NumCols(M) == n);
  ring R = RingOf(M);
  RingElem d = one(R);
  for (int k=0; k < n; ++k)
  {
    for (int i=k+1; i < n; ++i)
      for (int j=k+1; j < n; ++j)
      {
        SetEntry(M,i,j,(M(i,j)*M(k,k)-M(i,k)*M(k,j))/d );
      }
    d = M(k,k);
  }
  return d;
}

This fn should not trash M but it does currently.

#7 Updated by John Abbott over 9 years ago

  • % Done changed from 0 to 70

I have made a few changes. All CoCoALib tests pass, and the example I gave above produces the desired behaviour. Checking in.

#8 Updated by John Abbott over 9 years ago

CVS is working terribly: sometimes fails, otherwise VERY SLOW. No idea why :-(
I hope to succeed with checking in -- the technicians are away on holiday...

#9 Updated by John Abbott over 9 years ago

  • Status changed from In Progress to Closed
  • % Done changed from 70 to 100

Since all tests seems to work correctly, I'm closing this issue.
There are some design questions still to consider, but that can be done as part of #592.

#10 Updated by John Abbott over 9 years ago

  • Target version changed from CoCoALib-1.0 to CoCoALib-0.99536 June 2015

#11 Updated by John Abbott over 9 years ago

  • Target version changed from CoCoALib-0.99536 June 2015 to CoCoALib-0.99535 Sep14

Also available in: Atom PDF