! Copyright (C) 2005, 2010, 2018 Slava Pestov, Joe Groff, and Cat Stevens.
! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays combinators formatting fry kernel locals
-math math.bits math.functions math.matrices
-math.matrices.private math.order math.statistics math.text.english
-math.vectors random sequences sequences.deep summary ;
+USING: accessors arrays combinators formatting kernel math
+math.bits math.functions math.matrices math.order
+math.statistics math.text.english math.vectors random sequences
+sequences.deep summary ;
IN: math.matrices.extras
! this is a questionable implementation
! TODO: use the faster algorithm: [ determinant zero? ]
: invertible-matrix? ( matrix -- ? )
[ dimension first2 max <identity-matrix> ] keep
- dup recip m. = ;
+ dup recip mdot = ;
: linearly-independent-matrix? ( matrix -- ? ) ;
! this is the original definition of m^n as committed in 2012; it has not been lost
: (m^n) ( m n -- n )
make-bits over first length <identity-matrix>
- [ [ dupd m. ] when [ dup m. ] dip ] reduce nip ;
+ [ [ dupd mdot ] when [ dup mdot ] dip ] reduce nip ;
PRIVATE>
! A^-1 is the inverse but other negative powers are nonsense