Leading Axis Theory and Practice in Array Kingdom 2023

undefined
Leading Axis
Theory and Practice
Rich Park
Adám Brudzewsky
 
asst. Josh David
 
 
Rank and Dyadic Transpose
are the Keys to the
Array Kingdom
 
 
Rank and Dyadic Transpose
are the Keys to the
Array Kingdom™
 
 
Theory
The Rank Operator
Leading Axis Functions
Leading Axis Operators
Dyadic Transpose
Performance
 
Leading Axis Overview
 
Make Functions
apply to
Whole Arrays
 
 
Make Functions
apply to
Whole Arrays™
 
Array of rank 3
A ← 2 3 4
⍴⎕
A
 
Theory
U
V
W
X
Q
R
S
T
M
N
O
P
I
J
K
L
E
F
G
H
A
B
C
D
L
E
F
G
H
A
B
C
D
 
Array of rank 3
2-Cell: layer*
 
 
* Major cell
A ← 
2
 3 4
⍴⎕
A
 
Theory
U
V
W
X
Q
R
S
T
M
N
O
P
I
J
K
L
E
F
G
H
A
B
C
D
 
Array of rank 3
2-Cell: layer*
1-Cell: row
 
* Major cell
A ← 2 
3
 4
⍴⎕
A
 
Theory
U
V
W
X
Q
R
S
T
M
N
O
P
I
J
K
L
E
F
G
H
A
B
C
D
 
Array of rank 3
2-Cell: layer*
1-Cell: row
0-Cell: element
* Major cell
A ← 2 3 
4
⍴⎕
A
 
Theory
U
V
W
X
Q
R
S
T
M
N
O
P
I
J
K
L
E
F
G
H
A
B
C
D
 
Trailing axis
Array of rank 
N
K
-Cell
Major Cell
Leading axis
Trailing axis
collection of arrays of rank 
N
−1
sub-array of rank 
K
N
−1-Cell
first dimension; “list” of major cells
last dimension; “list” of scalar elements
 
Theory
 
Functions
X
Y  X
Y
X↑Y  X↓Y  X
Y
Y  X
Y
Y  X
Y  
Y  
Y
≠Y  
Y  X
Y  X
Y
 
Operators
  
@
 
Discussion: Leading-Axis Primitives
 
The Rank Operator
is just Blinkers
 
 
 
The Rank Operator
is just Blinkers™
 
 
f
 sees 
arg
 of 
max rank 
M
If necessary, 
f
 will be called multiple times
 
Pro tip 
to avoid stranding of 
M
 and 
Y
:
 
(
f
M)Y
 
or
      
f(
M)Y
 
or
      
f
M
Y
 
The Rank Operator (
f
M
)
Sub-Arrays
Elements/Scalars
Rows/Vectors
Layers/Matrices
Blocks
.
.
.
Rank
0
1
2
3
.
.
.
 
Rank Values
Consider 
'ABcdef' → 'BAcdef'
layers
rows of each layer
columns (elements of each row)
Bonus question: 
How would you do it without 
?
A←3 5 4
⍴⍳
60
 
Task: Exchange the First Two…
 
 
f
 sees 
left arg
 of 
max rank 
L
f
 sees 
right arg
 of 
max rank 
R
If necessary, sub-arrays will be used multiple times
 
Pro tips:
 
If 
L
 and 
R
 are the same then 
f
R
 is enough
  
If confused, try 
{
⍺⍵
}
L R
 
The Rank Operator (
f
L R
)
 
Functions
X≡Y
X
Y
Y
Y
↑Y
 
Operators
A
f
f
B
A
 
Discussion: Whole Array Primitives
 
names←↑(,'Hey' 'Jay'
.{↑
⍺⍵
}'ley' 'den')[?10
4]
Boolean vector indicating layers that are 
2 3
'Heyley'
Boolean matrix indicating rows that are 
'Hey'
Boolean rank-3 array indicating elements that are 
'e'
 
Bonus: 
Think about what the relationship is between 
 and 
=
 
Task: Using 
L R
   'ABC'(,
0 1)'xy'
Axy
Bxy
Cxy
Remember: 
L=R
   'ABC'((,
0)
0 1)'xy'
Ax
Ay
Bx
By
Cx
Cy
 
A←1 10 100
B←2 3 4
⍴⍳
24
Produce:
   1    2    3    4
  50   60   70   80
 900 1000 1100 1200
  13   14   15   16
 170  180  190  200
2100 2200 2300 2400
 
Task: Using 
L2 R2)
L1 R1 …
Dyadic Transpose reorders axes
Move axes to end, then use Rank on any function,
operating on only those trailing axes
 
Dyadic Transpose (
X
Y
): Why?
Reorders axes by the left argument:
Each number is the destination index where we 
send 
that axis.
3 1 2
A
│ │ └
3
rd
 
dimension will be the 2
nd
│ └──
2
nd
 
dimension will be the 1
st
└────
1
st
 
dimension will be the 3
rd
 
Dyadic Transpose (
X
Y
): How?
   2 3 4
⍴⎕
A
ABCD
EFGH
IJKL
MNOP
QRST
UVWX
1. 
horizontally:
ABCD
MNOP
EFGH
QRST
IJKL
UVWX
 
Tasks: Merging Layers…
2. 
vertically:
ABCD
EFGH
IJKL
MNOP
QRST
UVWX
 
Transpose,
Apply-with-Rank,
Transpose
 
 
Transpose,
Apply-with-Rank,
Transpose™
 
 
Keep Rank
Close to
the Primitives
+
÷
 
Keep Rank
Close to
the Primitives™
+
÷
n←?1 10 100 1000
10
a←'{+
⌿⍵⌿⍨
1 0
⍴⍨≢⍵
}
d
n'
b←'… your code here …'
d←1 
 cmpx a b
d←2 
 cmpx a b
d←3 
 cmpx a b
d←4 
 cmpx a b
 
Task: Speed it Up!
n←?1 10 100 1000
10
a←'{+
⌿⍵⌿⍨
1 0
⍴⍨≢⍵
}
d
n'
b←'… your code here …'
d←1 
 0 0 0 0.1 cmpx a b
d←2 
 0 0 0 0.1 cmpx a b
d←3 
 0 0 0 0.1 cmpx a b
d←4 
 0 0 0 0.1 cmpx a b
 
Task: Speed it Up!
 
'cmpx'
CY'dfns'
 
Rank and Dyadic Transpose are the Keys to the Array Kingdom
Make Functions apply to Whole Arrays
The Rank Operator is just Blinkers
Transpose, Rank-Apply-with-Rank, Transpose
Keep Rank Close to the Primitives
 
Lessons to Take Home
Slide Note
Embed
Share

Exploring the concept of Leading Axis Theory and Practice in the Array Kingdom of Elsinore 2023. The discussion covers essential keys like Rank and Dyadic Transpose, Make Functions apply to whole arrays, and Theory Arrays of various ranks. The images provide insights into major cells, leading axes, and more, forming a comprehensive guide to understanding and implementing this theory for efficient array operations.

  • Leading Axis Theory
  • Array Kingdom
  • Elsinore 2023
  • Rank Operator
  • Dyadic Transpose

Uploaded on Sep 12, 2024 | 1 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. Elsinore 2023 Leading Axis Theory and Practice Rich Park Ad m Brudzewsky asst. Josh David

  2. Rank and Dyadic Transpose are the Keys to the Array Kingdom Leading Axis Theory and Practice 1

  3. Rank and Dyadic Transpose are the Keys to the Array Kingdom Leading Axis Theory and Practice 2

  4. Leading Axis Overview Theory The Rank Operator Leading Axis Functions Leading Axis Operators Dyadic Transpose Performance Leading Axis Theory and Practice 3

  5. Make Functions apply to Whole Arrays 1 1 1 2 1 3 ~ ~ ~ 2 1 2 2 2 3 ~ ~ ~ Leading Axis Theory and Practice 4

  6. Make Functions apply to Whole Arrays 1 1 1 2 1 3 ~ ~ ~ 2 1 2 2 2 3 ~ ~ ~ Leading Axis Theory and Practice 5

  7. Theory Array of rank 3 M N O P A A B B C C D D Q R S T E E F F G G H H U V W X L L I J K A 2 3 4 A Leading Axis Theory and Practice 6

  8. Theory Array of rank 3 2-Cell: layer* M N O P A B C D Q R S T E F G H U V W X I J K L * Major cell A 2 3 4 A Leading Axis Theory and Practice 7

  9. Theory Array of rank 3 2-Cell: layer* 1-Cell: row M N O P A B C D Q R S T E F G H U V W X I J K L * Major cell A 2 3 4 A Leading Axis Theory and Practice 8

  10. Theory Array of rank 3 2-Cell: layer* 1-Cell: row 0-Cell: element M N O P A B C D Q R S T E F G H U V W X I J K L * Major cell Trailing axis A 2 3 4 A Leading Axis Theory and Practice 9

  11. Theory Array of rank N K-Cell Major Cell Leading axis Trailing axis collection of arrays of rank N 1 sub-array of rank K N 1-Cell first dimension; list of major cells last dimension; list of scalar elements Leading Axis Theory and Practice 10

  12. Discussion: Leading-Axis Primitives Functions Operators X Y X Y X Y X Y X Y @ Y X Y Y X Y Y Y Y Y X Y X Y Leading Axis Theory and Practice 11

  13. The Rank Operator is just Blinkers Leading Axis Theory and Practice 12

  14. The Rank Operator is just Blinkers Leading Axis Theory and Practice 13

  15. The Rank Operator (fM) f sees arg of max rank M If necessary, f will be called multiple times Pro tip to avoid stranding of M and Y: (f M)Y or f( M)Y or f M Y Leading Axis Theory and Practice 14

  16. Rank Values Sub-Arrays Elements/Scalars Rows/Vectors Layers/Matrices Blocks ... Rank 0 1 2 3 ... Leading Axis Theory and Practice 15

  17. Task: Exchange the First Two Consider 'ABcdef' 'BAcdef' layers A 3 5 4 60 rows of each layer columns (elements of each row) Bonus question: How would you do it without ? Leading Axis Theory and Practice 16

  18. The Rank Operator (fL R) f sees left arg of max rank L f sees right arg of max rank R If necessary, sub-arrays will be used multiple times Pro tips: If L and R are the same then f R is enough If confused, try { } L R Leading Axis Theory and Practice 17

  19. Discussion: Whole Array Primitives Functions Operators A f X Y X Y f B Y A Y Y Leading Axis Theory and Practice 18

  20. Task: Using L R names (,'Hey' 'Jay' .{ }'ley' 'den')[?10 4] Boolean vector indicating layers that are 2 3 'Heyley' Boolean matrix indicating rows that are 'Hey' Boolean rank-3 array indicating elements that are 'e' Bonus: Think about what the relationship is between and = Leading Axis Theory and Practice 19

  21. Double-Rank ((fL2 R2)L1 R1) 'ABC'(, 0 1)'xy' Axy Bxy Cxy 'ABC'((, 0) 0 1)'xy' Ax Ay Bx By Cx Cy Remember: L=R Leading Axis Theory and Practice 20

  22. Task: Using (L2 R2)L1 R1 A 1 10 100 B 2 3 4 24 Produce: 1 2 3 4 50 60 70 80 900 1000 1100 1200 13 14 15 16 170 180 190 200 2100 2200 2300 2400 Leading Axis Theory and Practice 21

  23. Dyadic Transpose (XY): Why? Dyadic Transpose reorders axes Move axes to end, then use Rank on any function, operating on only those trailing axes Leading Axis Theory and Practice 22

  24. Dyadic Transpose (XY): How? Reorders axes by the left argument: Each number is the destination index where we send that axis. 3 1 2 A 3rd 2nd dimension will be the 1st 1st dimension will be the 3rd dimension will be the 2nd Leading Axis Theory and Practice 23

  25. Tasks: Merging Layers 1. horizontally: 2. vertically: 2 3 4 A ABCD EFGH IJKL ABCD EFGH IJKL MNOP QRST UVWX ABCDMNOP EFGHQRST IJKLUVWX MNOP QRST UVWX Leading Axis Theory and Practice 24

  26. Transpose, Apply-with-Rank, Transpose Leading Axis Theory and Practice 25

  27. Transpose, Apply-with-Rank, Transpose Leading Axis Theory and Practice 26

  28. Keep Rank Close to the Primitives + Leading Axis Theory and Practice 27

  29. Keep Rank Close to the Primitives + Leading Axis Theory and Practice 28

  30. Task: Speed it Up! n ?1 10 100 1000 10 a '{+ 1 0 } d n' b ' your code here ' d 1 cmpx a b d 2 cmpx a b d 3 cmpx a b d 4 cmpx a b Leading Axis Theory and Practice 29

  31. Task: Speed it Up! n ?1 10 100 1000 10 a '{+ 1 0 } d n' b ' your code here ' 'cmpx' CY'dfns' d 1 0 0 0 0.1 cmpx a b d 2 0 0 0 0.1 cmpx a b d 3 0 0 0 0.1 cmpx a b d 4 0 0 0 0.1 cmpx a b Leading Axis Theory and Practice 30

  32. Lessons to Take Home Rank and Dyadic Transpose are the Keys to the Array Kingdom Make Functions apply to Whole Arrays The Rank Operator is just Blinkers Transpose, Rank-Apply-with-Rank, Transpose Keep Rank Close to the Primitives Leading Axis Theory and Practice 31

More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#