The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
delcols bug
01-02-2024, 07:08 PM (This post was last modified: 01-02-2024 08:29 PM by Albert Chan.)
Post: #1
delcols bug
Below produce permanent of square matrix.

delcols does not work (tested on both HP emulators 2018/10/16, 2023/4/13)
I had to add mydelcols := delcols, and use mydelcols to make it work.

Code:
#cas
per(m) :=
BEGIN
 LOCAL r, mydelcols := delcols;
 IF len(m)<2 THEN RETURN m[1][1] END
 r := map(x->sum(!x),m);
 r := index(r,max(r)); /* most zeroes row */
 r, m := m[r], delrows(m,r);
 sum(when(r[k],r[k]*per(mydelcols(m,k)),0), k=1..len(r));
END;
#end

Lets debug with print(m); right after LOCAL r

> per([[0,1,2],[3,4,5],[6,7,8]])      → 144

Terminal:
m:[[0,1,2],[3,4,5],[6,7,8]]
m:[[3,5],[6,8]]
m:[[8]]
m:[[6]]
m:[[3,4],[6,7]]
m:[[7]]
m:[[6]]

This is using delcols directly inside sum:

Terminal:
m:[[0,1,2],[3,4,5],[6,7,8]]
m:[[4],[7]]
m:Error: Bad Argument Type
m:Error: Invalid Dimension
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
delcols bug - Albert Chan - 01-02-2024 07:08 PM
RE: delcols bug - jte - 01-02-2024, 09:20 PM
RE: delcols bug - jte - 01-05-2024, 09:49 PM
RE: delcols bug - parisse - 01-06-2024, 10:45 AM
RE: delcols bug - Albert Chan - 01-06-2024, 11:55 AM
RE: delcols bug - parisse - 01-08-2024, 04:24 PM



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