JPhrases/Transformations

From J Wiki
Jump to navigation Jump to search

11C. Transformations

m0=: ] i."1&.|: 1 _1"_ Column node table from connection table columns (inverse to m3)
m1=: ] (i."1) 1 _1"_ Node table from connection table rows (inverse to m4)
m2=: [:-/ ] =/ [:i. [:>: [:>./ , Row connection table from node table columns
m3=: [: |: m2 Column connection table from node table columns (inverse to m0)
m4=: [:-/"2 ] =/ [:i. [:>: [:>./ , Row connection table from node table rows (inverse to m1)
   y
 1  1  0  0  0
 0 _1  0  1  1
_1  0  1 _1  0
 0  0 _1  0 _1

   m0 y
0 0 2 1 1
2 1 3 2 3

   m3 m0 y
 1  1  0  0  0
 0 _1  0  1  1
_1  0  1 _1  0
 0  0 _1  0 _1