SYMBOL: matrix
: with-matrix ( matrix quot -- )
- [ swap matrix set call matrix get ] with-scope ; inline
+ matrix swap [ matrix get ] compose with-variable ; inline
: nth-row ( row# -- seq ) matrix get nth ;
-: change-row ( row# quot: ( seq -- seq ) -- )
+: change-row ( ..a row# quot: ( ..a seq -- ..b seq ) -- ..b )
matrix get swap change-nth ; inline
: exchange-rows ( row# row# -- ) matrix get exchange ;
[ 0 0 (echelon) ] with-matrix ;
: nonzero-rows ( matrix -- matrix' )
- [ [ zero? ] all? not ] filter ;
+ [ [ zero? ] all? ] reject ;
: null/rank ( matrix -- null rank )
echelon dup length swap nonzero-rows length [ - ] keep ;