1 ! Copyright (C) 2006 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: arrays hashtables hopf kernel math matrices namespaces
7 : ((i)) ( x y -- i_y[x] )
8 1 swap associate boundaries set d ;
10 : (i) ( x y -- i_y[x] )
11 [ <reversed> [ ((i)) ] each ] with-scope ;
14 #! Adjoint of left multiplication by y
15 [ >h ] 2apply [ dupd concat (i) ] linear-op nip ;
19 : set-generators ( seq -- )
22 1 [ h* ] reduce top-class set ;
25 #! Hodge star involution
26 top-class get swap i ;
29 #! Hodge inner product
33 [ length 1+ generators get length * 1+ -1^ ] keep
37 #! Adjoint of the differential
38 >h [ concat (d*) ] linear-op ;
46 [ d d* ] keep d* d l+ ;
48 : L-matrix ( basis -- matrix )
49 dup [ concat L ] op-matrix ;
51 : cohomology ( -- seq )
52 generators get basis [ L-matrix null/rank drop ] map ;