2006-07-27 18:57:44 -04:00
|
|
|
! Copyright (C) 2006 Slava Pestov.
|
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2006-08-18 16:15:08 -04:00
|
|
|
USING: arrays hashtables hopf kernel math matrices namespaces
|
|
|
|
|
sequences topology ;
|
2006-07-27 18:57:44 -04:00
|
|
|
IN: laplacian
|
|
|
|
|
|
2006-08-18 16:15:08 -04:00
|
|
|
: ((i)) ( x y -- i_y[x] )
|
|
|
|
|
1 swap associate boundaries set d ;
|
2006-07-27 18:57:44 -04:00
|
|
|
|
2006-08-18 16:15:08 -04:00
|
|
|
: (i) ( x y -- i_y[x] )
|
2006-08-20 14:39:45 -04:00
|
|
|
[ <reversed> [ ((i)) ] each ] with-scope ;
|
2006-08-18 16:15:08 -04:00
|
|
|
|
|
|
|
|
: i ( x y -- i_y[x] )
|
|
|
|
|
#! Adjoint of left multiplication by y
|
|
|
|
|
[ >h ] 2apply [ dupd concat (i) ] linear-op nip ;
|
|
|
|
|
|
|
|
|
|
SYMBOL: top-class
|
|
|
|
|
|
|
|
|
|
: set-generators ( seq -- )
|
2006-08-27 16:51:27 -04:00
|
|
|
natural-sort
|
2006-08-18 16:15:08 -04:00
|
|
|
dup generators set
|
|
|
|
|
1 [ h* ] reduce top-class set ;
|
2006-07-27 18:57:44 -04:00
|
|
|
|
|
|
|
|
: star ( x -- *x )
|
2006-08-18 16:15:08 -04:00
|
|
|
#! Hodge star involution
|
|
|
|
|
top-class get swap i ;
|
|
|
|
|
|
|
|
|
|
: <,>* ( a b -- n )
|
|
|
|
|
#! Hodge inner product
|
|
|
|
|
star h* star co1 ;
|
|
|
|
|
|
|
|
|
|
: (d*) ( x -- d*[x] )
|
|
|
|
|
[ length 1+ generators get length * 1+ -1^ ] keep
|
|
|
|
|
star d star h* ;
|
|
|
|
|
|
|
|
|
|
: d* ( x -- d*[x] )
|
|
|
|
|
#! Adjoint of the differential
|
|
|
|
|
>h [ concat (d*) ] linear-op ;
|
|
|
|
|
|
|
|
|
|
: [,] ( x y -- z )
|
|
|
|
|
#! Lie bracket
|
|
|
|
|
h* d* ;
|
|
|
|
|
|
|
|
|
|
: L ( z -- Lz )
|
|
|
|
|
#! Laplacian.
|
|
|
|
|
[ d d* ] keep d* d l+ ;
|
|
|
|
|
|
|
|
|
|
: L-matrix ( basis -- matrix )
|
|
|
|
|
dup [ concat L ] op-matrix ;
|
|
|
|
|
|
2006-08-27 16:51:27 -04:00
|
|
|
: cohomology ( -- seq )
|
|
|
|
|
generators get basis [ L-matrix null/rank drop ] map ;
|