define words for min/max element, norm, equality of matrices in contrib/math

darcs
erg 2006-11-15 19:14:17 +00:00
parent 9def7af3f5
commit 722a9b82ce
1 changed files with 7 additions and 0 deletions

View File

@ -27,3 +27,10 @@ USING: arrays generic kernel sequences math ;
: v.m ( v m -- v ) flip [ v. ] map-with ;
: m.v ( m v -- v ) swap [ v. ] map-with ;
: m. ( m m -- m ) flip swap [ m.v ] map-with ;
: mmin ( m -- n ) >r 1/0. r> [ [ min ] each ] each ;
: mmax ( m -- n ) >r -1/0. r> [ [ max ] each ] each ;
: mnorm ( m -- n ) dup mmax abs m/n ;
: m-almost= ( m n -- ? )
t -rot [ [ almost= and ] 2each ] 2each ;