]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/math/matrices/laplace/laplace.factor
factor: trim using lists
[factor.git] / extra / math / matrices / laplace / laplace.factor
index dcc6f39a1a9486df902430272c419dda49e9bf23..306895e7d4151c39dc52559c8bd4ed3f6693e77e 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2013 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays assocs fry kernel locals math math.matrices
-math.vectors sequences sequences.private ;
+USING: accessors classes kernel math math.matrices math.vectors
+sequences sequences.private ;
 IN: math.matrices.laplace
 
 <PRIVATE
@@ -18,7 +18,7 @@ M: missing length seq>> length 1 - ;
 INSTANCE: missing immutable-sequence
 
 : first-sub-matrix ( matrix -- first-row seq )
-    [ unclip-slice swap ] [ length iota ] bi
+    [ unclip-slice swap ] [ length <iota> ] bi
     [ '[ _ <missing> ] map ] with map ;
 
 :: laplace-expansion ( row matrix -- x )
@@ -29,12 +29,7 @@ INSTANCE: missing immutable-sequence
         v* [ odd? [ neg ] when ] map-index sum
     ] if ;
 
-ERROR: not-a-square-matrix matrix ;
-
-: check-square-matrix ( matrix -- matrix )
-    dup square-matrix? [ not-a-square-matrix ] unless ; inline
-
 PRIVATE>
 
 : determinant ( matrix -- x )
-    check-square-matrix 0 swap laplace-expansion ;
+    square-matrix check-instance 0 swap laplace-expansion ;