Post Reply 
Help: Port prg to Home Mode( Minor linear_algebra)
02-03-2014, 05:38 AM
Post: #2
RE: Help HOME PRG (Minor linear_algebra)
Why are you defining j and ii as strings? Also, the help for DELCOL() and DELROW() suggest that they modify the matrix itself, so that subsequent references to the matrix are actually references to the the modified version.

To see this for yourself:

Code:

M1:=[[1,2],[3,4]];
DELCOL(M1,1);
M1;

My guess is that in CAS mode the dummy variable somehow protects its contents to prevent DELCOL() and DELROW() from modifying the matrix. Either that, or it is a bug.

The commands you should probably be using instead: delcols() and delrows() -- these do not alter the matrix.

Code:

EXPORT MINOR(m)
BEGIN
  LOCAL n:=dim(m),s;
  s:=n(1)*n(2);
  n:=n(1);
  MAKELIST(det(delcols(delrows(m,((I-1) MOD n)+1),IP((I-1)/n)+1)),I,1,s);
END;

You can easily change this to use seq() if you prefer. Just don't confuse a sequence with a matrix even if they both use the same delimiters.

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Help HOME PRG (Minor linear_algebra) - Han - 02-03-2014 05:38 AM



User(s) browsing this thread: 1 Guest(s)