! Copyright (C) 2010 Jeffrey Drake. ! See http://factorcode.org/license.txt for BSD license. USING: arrays kernel sequences locals compiler.tree.propagation.constraints math ; IN: opengl1 ! a b c 0 1 2 ! d e f 3 4 5 ! g h i 6 7 8 ! det (A) = aei + bfg + cdh − afh − bdi − ceg. : 33matrix? ( seq -- ? ) 8 swap bounds-check? ; ERROR: not-33matrix seq ; :: det ( matrix -- x ) matrix 33matrix? =f [ not-33matrix ] [ ( -- aei ) matrix 0 4 8 nths * * ( -- bfg ) matrix 1 5 6 nths * * ( -- cdh ) matrix 2 3 7 nths * * ( aei bfg cdh -- sum ) + + ( -- afh ) matrix 0 5 7 nths * * ( -- bdi ) matrix 1 3 8 nths * * ( -- ceg ) matrix 2 4 6 nths * * ( afh bdi ceg -- sum ) + + ( sum sum -- det ) - ] if ;