Differences between revisions 6 and 7
 ⇤ ← Revision 6 as of 2007-09-05 21:07:48 → Size: 3518 Editor: RogerHui Comment: ← Revision 7 as of 2008-12-08 10:45:39 → ⇥ Size: 3522 Editor: anonymous Comment: converted to 1.6 markup Deletions are marked like this. Additions are marked like this. Line 114: Line 114: [[Anchor(cross_product)]] <> Line 161: Line 161: [[Anchor(determinant)]] <> Line 220: Line 220: [[BR]] <
> Line 224: Line 224: [http://www.jsoftware.com/help/dictionary/dccapdot.htm dictionary entry] [[http://www.jsoftware.com/help/dictionary/dccapdot.htm|dictionary entry]] Line 226: Line 226: [http://www.jsoftware.com/help/phrases/parity_symmetry.htm Parity & Symmetry] [[http://www.jsoftware.com/help/phrases/parity_symmetry.htm|Parity & Symmetry]]

The complete tensor (or complete skew tensor) of order n  is the array C with shape n\$n such that for row i in (#:i.)n\$n , the atom (<i){C is

•  0 if i is not a permutation

•  1 if i is an even permutation

•  _1 if i is an odd permutation

Since the monad C.!.2  computes the parity of a permutation, the complete tensor of order n obtains by applying C.!.2 to (#:i.)n\$n .

For example, for n=:3

```   C.!.2 ] 0 0 1
0
C.!.2 ] 0 1 2
1
C.!.2 ] 0 2 1
_1

] i=: (#: i.) 3\$3
0 0 0
0 0 1
0 0 2

0 1 0
0 1 1
0 1 2

0 2 0
0 2 1
0 2 2

1 0 0
1 0 1
1 0 2

1 1 0
1 1 1
1 1 2

1 2 0
1 2 1
1 2 2

2 0 0
2 0 1
2 0 2

2 1 0
2 1 1
2 1 2

2 2 0
2 2 1
2 2 2
t=: ,"2 ] 2 1 1": i  NB. a more compact display
(C.!.2 i) ; t
┌────────┬────────────┐
│ 0  0  0│ 000 001 002│
│ 0  0  1│ 010 011 012│
│ 0 _1  0│ 020 021 022│
│        │            │
│ 0  0 _1│ 100 101 102│
│ 0  0  0│ 110 111 112│
│ 1  0  0│ 120 121 122│
│        │            │
│ 0  1  0│ 200 201 202│
│_1  0  0│ 210 211 212│
│ 0  0  0│ 220 221 222│
└────────┴────────────┘

CT=: C.!.2 @ (#:i.) @ \$~

CT 3
0  0  0
0  0  1
0 _1  0

0  0 _1
0  0  0
1  0  0

0  1  0
_1  0  0
0  0  0```

The complete tensor can be also be represented as a sparse array.

```   perm=: i.@! A. i.  NB. all permutations of i.n
CT1=: 3 : '(C.!.2 p) (<"1 p=. perm y)} 1\$.\$~y'

CT1 3
0 1 2 │  1
0 2 1 │ _1
1 0 2 │ _1
1 2 0 │  1
2 0 1 │  1
2 1 0 │ _1

(CT -: CT1)"0 >: i.6
1 1 1 1 1 1```

## Cross Product

The complete tensor is used in the generalized cross product:

```   ip   =: +/ .*
cross=: [ ip CT@#@[ ip ]

'x y'=: _40 + 2 3 ?.@\$ 100
x
6 15 39
y
12 14 _1
] c=. x cross y
561 _474 96

x ip c
0
c ip x
0
y ip c
0
c ip y
0

'x y'=: _40 + 2 4 ?.@\$ 100
x
6 15 39 12
y
14 _1 20 17
] c=. x cross y
0  423 _267  339
_423    0  _66  426
267   66    0 _216
_339 _426  216    0

x ip c
0 0 0 0
c ip x
0 0 0 0
y ip c
0 0 0 0
c ip y
0 0 0 0```

## Determinant

```   ] m=: _40 + 3 3 ?@\$ 100
15 _35 15
33  18 10
0 _35 29

*// m
0 _17325  14355
0  _9450   7830
0  _5250   4350

0  40425 _33495
0  22050 _18270
0  12250 _10150

0 _17325  14355
0  _9450   7830
0  _5250   4350

(CT 3) * *// m
0      0     0
0      0  7830
0   5250     0

0      0 33495
0      0     0
0      0     0

0 _17325     0
0      0     0
0      0     0

+/ , (CT 3) * *// m
29250
-/ .* m
29250

det=: +/ @ , @ (CT@# * *//)
det m
29250```

## Collected Definitions

```CT   =: C.!.2 @ (#:i.) @ \$~

perm =: i.@! A. i.
CT1  =: 3 : '(C.!.2 p) (<"1 p=. perm y)} 1\$.\$~y'

ip   =: +/ .*
cross=: [ ip CT@#@[ ip ]

det  =: +/ @ , @ (CT@# * *//)```

Contributed by RogerHui. The complete tensor and its applications are described in the dictionary entry for C. and in the Parity & Symmetry section of J Phrases.

Essays/Complete Tensor (last edited 2008-12-08 10:45:39 by anonymous)