Fun with Total Array Ordering (TAO)

Slides:



Advertisements
Similar presentations
CC SQL Utilities.
Advertisements

Chapter 6 Structures By C. Shing ITEC Dept Radford University.
V14 New Features Dan Baronet. Many new features V14 is probably the release of Dyalog with the most new features.
Redundant Bit Vectors for the Audio Fingerprinting Server John Platt Jonathan Goldstein Chris Burges.
Introduction to ML - Part 2 Kenny Zhu. What is next? ML has a rich set of structured values Tuples: (17, true, “stuff”) Records: {name = “george”, age.
Compositional Development of Parallel Programs Nasim Mahmood, Guosheng Deng, and James C. Browne.
Microsoft ® Office Excel ® 2003 Training How to use lists KLDCS presents:
MATLAB Cell Arrays Greg Reese, Ph.D Research Computing Support Group Academic Technology Services Miami University.
CTS130 Spreadsheet Lesson 13 Working with Lists. Copying Data between Workbooks  Use the [Copy ]and [Paste] Buttons  Use the CTRL+[C] and CTRL + [V]
Introduction to Artificial Intelligence Lecture 2: Perception & Action
Parallel Programming with v14.0. Parallel Paths to Parallel Performance 1.Parallel Compiler Research –”Concurrent Dfns Compiler” targets fine-grained.
Fall CIS 764 Database Systems Engineering L6a: Usability - Part 1 (Part 2 … case studies) L6b. Review of Homeworks (next.
Mathcad Variable Names A string of characters (including numbers and some “special” characters (e.g. #, %, _, and a few more) Cannot start with a number.
Scheme & Functional Programming. ( ) >> 64 ( ) >> 666 (* ) >> 1200 (+ (* 3 5) (- 10 6)) >> 19.
Algorithm and Programming Array Dr. Ir. Riri Fitri Sari MM MSc International Class Electrical Engineering Dept University of Indonesia 15 March 2009.
Technical Road Map Morten Kromberg 0. 1 (Same Old) Focus Areas -Performance -(includes parallel computing) -Portability -(includes user interfaces) -Language.
Types in APL – The SimCorp Way Dyalog User Conference 2007 Lars Stampe Villadsen, SimCorp A/S (Denmark)
Chapter Fifteen: Functional Programming Languages Lesson 12.
Cliff Shaffer Computer Science Computational Complexity.
Microsoft ® Office Excel 2003 Training Using XML in Excel SynAppSys Educational Services presents:
DAT602 Database Application Development Lecture 2 Review of Relational Database.
1 CSE Computer Use: Fundamentals Week 5: Glade Manual Chapter 4 Gates and Circuits (Dale & Lewis Ch. 4)
CHAPTER 9 HASH TABLES, MAPS, AND SKIP LISTS ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++,
Chapter 7 What Can Computers Do For Me?. How important is the material in this chapter to understanding how a computer works? 4.
Fortran MATTHEW CARSON. History of FORTRAN FORTRAN ; First High Level Language FORTRAN I 1957; First Compiled Language FORTRAN II ; Independent.
Understand Tables and How to Create Them Database Administration Fundamentals LESSON 2.2.
Fall 2008Simple Parallel Algorithms1. Fall 2008Simple Parallel Algorithms2 Scalar Product of Two Vectors Let a = (a 1, a 2, …, a n ); b = (b 1, b 2, …,
New Language Features For Parallel and Asynchronous Execution Morten Kromberg Dyalog LTD Dyalog’13.
Fast VLSI Implementation of Sorting Algorithm for Standard Median Filters Hyeong-Seok Yu SungKyunKwan Univ. Dept. of ECE, Vada Lab.
Chapter 1: Preliminaries Lecture # 2. Chapter 1: Preliminaries Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation.
#DYNA16 vecdb The Dyalog Vector Database Workshop W2: Managing Data with Dyalog Morten Kromberg, CXO.
#DYNA16 Dyalog Version 15.0 Highlights Jay Foad, John Daintree Dan Baronet, Brian Becker Morten Kromberg.
Introduction to Programming Lecture 12. Today’s Lecture Includes Strings ( character arrays ) Strings ( character arrays ) Algorithms using arrays Algorithms.
Parallel Programming With Futures and Isolates Morten Kromberg, CXO.
A FIRST BOOK OF C++ CHAPTER 7 ARRAYS. OBJECTIVES In this chapter, you will learn about: One-Dimensional Arrays Array Initialization Arrays as Arguments.
9/27/2016IT 1791 Abstraction A tool (concept) to manage complexity Hide irrelevant details; focus on the features needed Primitive date types are already.
64 bit Dyalog APL A few bits of history Benefits Interoperability – Sockets – Component files – Workspaces – APs.
Logical Functions and Conditional Formatting in Excel
Dynamic Storage Allocation
Functional Programming Languages
Excel IF Function.
APPENDIX a WRITING SUBROUTINES IN C
Context-Sensitive Analysis
Arrays An array is a grouping of elements of the same type that share a common base name Can have any number of elements in the array Individual elements.
Documentation Need to have documentation in all programs
Abstraction A tool (concept) to manage complexity
Other Kinds of Arrays Chapter 11
Matrices Definition: A matrix is a rectangular array of numbers or symbolic elements In many applications, the rows of a matrix will represent individuals.
Chapter 6 - Arrays Outline 6.1 Introduction 6.2 Arrays
Sorting CSCE 121 J. Michael Moore
Bubble, Selection & Insertion sort
Jay Foad & Adám Brudzewsky
Hash Tables.
FP Foundations, Scheme In Text: Chapter 14.
Proposed Version 16.0 Language Features
Jupyter Notebooks in Dyalog APL
APL Code Golf Autumn Tournament
Data Structure and Algorithms
Arrays An array is a grouping of elements of the same type that share a common base name Can have any number of elements in the array Individual elements.
Insertion Sort Demo Sorting problem:
Elementary Linear Algebra
Transformation Operators
Matrix Addition
Arrays An array is a grouping of elements of the same type that share a common base name Can have any number of elements in the array Individual elements.
TransCAD Working with Matrices 2019/4/29.
More Variables and Data Types: references/matricies
CS210- Lecture 15 July 7, 2005 Agenda Median Heaps Adaptable PQ
Linked List Intro CSCE 121.
Types and Related Issues
Introduction to Matrices
Presentation transcript:

Fun with Total Array Ordering (TAO) Adám Brudzewsky (material by Jay Foad) 大道至簡 Fun with Total Array Ordering (TAO)   ⍒⍋

Grading ⍋'APL' 1 3 2

Grading ⍋'APL' 1 3 2

Grading [1,2,3] ⍋'APL' 1 3 2 'A' 'L' 'P' ⍨

Major Cells: Vector ┌→──┐ │APL│ └───┘

Major Cells: Matrix ┌→──┐ ↓AAA│ │PPP│ │LLL│ └───┘

Major Cells: Cube ┌→──┐ ↓AAA│ │AAA│──┐ │AAA│PP│ └───┘PP│──┐ │PPP│LL│ └───┘LL│ │LLL│ └───┘

Major Cells: mat ┌→─────┐ ↓John │ │Roger │ │Adam │ │Morten│ │Jay │ └──────┘

Major Cells: mat ⍋mat ┌→─────┐ 3 5 1 4 2 ↓John │ │Roger │ │Adam │ │Morten│ │Jay │ └──────┘

Major Cells: mat ⍋mat ┌→─────┐ 3 5 1 4 2 ↓John │ │Roger │ │Adam │ │Morten│ │Jay │ └──────┘

Major Cells: mat mat[⍋mat;] ┌→─────┐ ┌→─────┐ ↓John │ ↓Adam │ │Roger │ │Jay │ │Adam │ │John │ │Morten│ │Morten│ │Jay │ │Roger │ └──────┘ └──────┘

Sorting mat[⍋mat;] {(⊂⍋⍵)⌷⍵} mat

Sorting mat[⍋mat;] {(⊂⍋⍵)⌷⍵} mat

Sorting mat[⍋mat;] {(⊂⍒⍵)⌷⍵} mat

Sorting mat[⍋mat;] Sort ← {(⊂⍋⍵)⌷⍵} Sort mat Adam Jay John Morten Roger

Sorting n ← 'Roger' 'Adam' 'Jay' Sort n ⍝ 16.0 DOMAIN ERROR Sort n ⍝ 17.0 ┌────┬───┬─────┐ │Adam│Jay│Roger│ └────┴───┴─────┘

A bit of history 'Morten' 'Roger '

A bit of history 'Morten' 'Roger▉'

A bit of history A ← 'Morten' B ← 'Roger▉' ⍋ A ,[0.5] B 1 2 'Morten' ≺ 'Roger▉'

Total Array Ordering some other ≺ ? array array

Total Array Ordering How would you order: ⎕ ← 0 'Jay' (2 3⍴'DYALOG') (⍳9) ┌→──────────────────────────────────┐ │ ┌→──┐ ┌→──┐ ┌→────────────────┐ │ │ 0 │Jay│ ↓DYA│ │1 2 3 4 5 6 7 8 9│ │ │ └───┘ │LOG│ └~────────────────┘ │ │ └───┘ │ └∊──────────────────────────────────┘

Total Array Ordering How would you order: ⎕ ← 0 'Jay' (2 3⍴'DYALOG') (⍳9) ┌→──────────────────────────────────┐ │ ┌→──┐ ┌→──┐ ┌→────────────────┐ │ │ 0 │Jay│ ↓DYA│ │1 2 3 4 5 6 7 8 9│ │ │ └───┘ │LOG│ └~────────────────┘ │ │ └───┘ │ └∊──────────────────────────────────┘

Total Array Ordering

TAO

TAO Rules

TAO some other ≺ ? array array

TAO some other ≺ ? array array no refs no refs

TAO Rules Compatibility: simple arrays Consistency: (⍺≼⍵)∧(⍵≼⍺) ⇔ ⍺=⍵ ⍺≡⍵ ⍬≢''

TAO Rules: simple scalars character vs character: ✓ real number vs real number: ✓ complex: 1 ≺ 1J1 ≺ 2J¯1 ≺ 2 number vs character: 100 ≺ 'A' null: ⎕NULL ≺ ¯100

TAO Rules: simple scalars ⎕NULL ≺ ¯1 ≺ 0J¯2 ≺ 0 ≺ 0J2 ≺ 1 ≺ 'A'

TAO Rules: same shape ┌→───┐ ┌→───┐ │Jay▉│ │John│ └────┘ └────┘

TAO Rules: same shape ┌→───┐ ┌→───┐ │Jay▉│ │John│ └────┘ └────┘ ┌→─────────┐ ┌→─────────┐ │ ┌→─┐ │ │ ┌→─┐ │ │ │JF│ 3 1 │ │ │JD│ 2 7 │ │ └──┘ │ │ └──┘ │ └∊─────────┘ └∊─────────┘

TAO Rules: same shape ┌→───┐ ┌→───┐ │Jay▉│ │John│ └────┘ └────┘ ┌→─────────┐ ┌→─────────┐ │ ┌→─┐ │ │ ┌→─┐ │ │ │JF│ 3 1 │ │ │JD│ 2 7 │ │ └──┘ │ │ └──┘ │ └∊─────────┘ └∊─────────┘

TAO Rules: same shape ┌→───┐ ┌→───┐ │Jay▉│ │John│ └────┘ └────┘ ┌→─────────┐ ┌→─────────┐ │ ┌→─┐ │ │ ┌→─┐ │ │ │JF│ 3 1 │ │ │JD│ 2 7 │ │ └──┘ │ │ └──┘ │ └∊─────────┘ └∊─────────┘

TAO Rules: different shape CAN CAR CARPENTER CARPET CAT

TAO Rules: different shape CAR CARPENTER

TAO Rules: different shape CAR CARPENTER

TAO Rules: different shape CAR CARPENTER

TAO Rules: different shape CAN CAR CARPENTER CARPET CAT

TAO Rules: different shape CAN CAR CARPENTER CARPET CAT

TAO Rules: different shape ↑'CAR' 'CARPENTER' CAR▉▉▉▉▉▉ CARPENTER

TAO Rules: different shape ↑'CAR' 'CAR␀␀␀␀␀␀' CAR▉▉▉▉▉▉ CAR␀␀␀␀␀␀

TAO Rules: different shape ⍋↑'CAR' 'CAR␀␀␀␀␀␀' 2 1

TAO Rules: different shape 1 2 3 1 2 3 4

TAO Rules: different shape ¯1 ¯2 ¯3 ¯1 ¯2 ¯3 ¯4

TAO Rules: different shape ¯1 ¯2 ¯3 ¯1 ¯2 ¯3 ¯4

TAO Rules: different shape ↑(¯1 ¯2 ¯3) (¯1 ¯2 ¯3 ¯4) ¯1 ¯2 ¯3 0 ¯1 ¯2 ¯3 ¯4

TAO Rules: different shape ⍋↑(¯1 ¯2 ¯3) (¯1 ¯2 ¯3 ¯4) 2 1

TAO Rules: different shape ¯∞

TAO Rules: different shape ¯∞ ≺ ⎕NULL ≺ ¯1 ≺ 0J¯2 ≺ 0 ≺ 0J2 ≺ 1 ≺ 'A'

TAO Rules: different shape CAR¯∞¯∞¯∞¯∞¯∞¯∞ CARPENTER

TAO Rules: different shape CAR¯∞¯∞¯∞¯∞¯∞¯∞ CARPENTER

TAO Rules: different shape 1 2 1 2 3 1 2

TAO Rules: different shape 1 2 ¯∞ 1 2 3 1 2 ¯∞ ¯∞ ¯∞ ¯∞

TAO Rules: different shape 1 2 ¯∞ 1 2 3 1 2 ¯∞ ¯∞ ¯∞ ¯∞ ≺

TAO Rules: different rank ┌→──┐ ┌→────┐ │APL│ ↓Adam │ └───┘ │Jay │ │Roger│ └─────┘

TAO Rules: different rank ┌→──┐ ┌→────┐ ↓APL│ ↓Adam │ └───┘ │Jay │ │Roger│ └─────┘

TAO Rules: different rank ┌→────┐ ┌→────┐ ↓APL¯∞¯∞│ ↓Adam │ │¯∞¯∞¯∞¯∞¯∞│ │Jay │ │¯∞¯∞¯∞¯∞¯∞│ │Roger│ └─────┘ └─────┘

TAO Rules: different rank ┌→────┐ ┌→────┐ ↓APL¯∞¯∞│ ↓Adam │ │¯∞¯∞¯∞¯∞¯∞│ │Jay │ │¯∞¯∞¯∞¯∞¯∞│ │Roger│ └─────┘ └─────┘

TAO Rules: different rank ┌→──┐ ┌→──┐ │APL│ ↓APL│ └───┘ └───┘

TAO Rules: different rank ┌→──┐ ┌→──┐ ↓APL│ ↓APL│ └───┘ └───┘

TAO Rules: different rank ┌→──┐ ┌→──┐ │APL│ ↓APL│ └───┘ └───┘ 1 2

TAO Rules: different rank scalar vector 'A' ,'A' A A vector 1-row matrix 3⍴'APL' 1 3⍴'APL' APL APL

TAO Rules: recap simple scalars ⎕NULL ≺ nums ≺ chars same shape item-by-item in ravel order unequal shape pad with ¯∞ unequal rank prefix shape with 1s

TAO Rules: empty arrays 2 0 0⍴⍬ 0 0 3⍴''

TAO Rules: empty arrays 2 0 0⍴⍬ 0 0 3⍴'' 2 0 3⍴⍬ 2 0 3⍴''

TAO Rules: empty arrays 2 0 0⍴⍬ 0 0 3⍴'' ⍬ prototypical items '' or 2 0 0 original shapes 0 0 3 ?

TAO Rules: empty arrays 2 0 0⍴⍬ 0 0 3⍴'' ⍬ prototypical items '' 2 0 0 original shapes 0 0 3

TAO Rules: empty arrays 2 0 0⍴⍬ 0 0 3⍴⍬ ⍬ prototypical items ⍬ 2 0 0 original shapes 0 0 3

TAO Rules simple scalars ⎕NULL ≺ nums ≺ chars same shape item-by-item in ravel order unequal shape pad with ¯∞ unequal rank prefix shape with 1s both empty type then shape

TAO Scope ⍋⍵ ⍒⍵ ⍺⍸⍵

Demo Features coming in version 17.0…

Demo ISO 8601 yyyy-mm-ddThh:mm:ss.mmm Turing Awards ]load /tao/turing Sort ← {(⊂⍋⍵)⌷⍵} Sort turing vol ← ⊣/5 5⍴⎕A Cat ← {vol⍸⍵} Chop ← {(Cat ⍵){⊂⍵}⌸ ⍵} Chop turing Sort Chop turing Stock Tickers ]load /tao/stocks Sort stocks Under←{⍺←⊢ ⋄ (⍵⍵⍣¯1) ⍺ ⍺⍺ ⍵⍵ ⍵} Sort Under(1⌽⊢) stocks 2⌷Under⍉ stocks ⍋ 2⌷Under⍉ stocks Puncts ← {~⍵∊⎕D} Nums ← ⍎' '@Puncts Nums¨ 2⌷Under⍉ stocks ⍋ Nums¨ 2⌷Under⍉ stocks Nums¨@2 Under⍉ stocks ⍋ Nums¨@2 Under⍉ stocks ⍋ stocks ISO 8601 yyyy-mm-ddThh:mm:ss.mmm

Demo Phonebook Record Insertion ]load /tao/pb Sort ← {(⊂⍋⍵)⌷⍵} Sort pb pb ← Sort pb new ← 'Kromberg' 'Morten' 584 pb ⍸ new (2↑pb)⍪new⍪(2↓pb) 2(↑⍪new⍪↓)pb Into ← {(⍵⍸⍺)(↑⍪⍺⍪↓)⍵} new Into pb new2←'Becker' 'Brian' 563 ⊃Into/new new2 pb Spreadsheet Data Types ss ← (⎕NEW⊂'Clipboard').Array Sort ss ss[⍋ss[;1 3];] Natural Sorting )clear ]load /tao/names2 num←'((¯?\d+\.?\d*|¯?\d*\.\d+)(E¯?\d+)?)(J(?1))?' ExecNums ← {⍵.PatternNum:⍵.Match ⋄ ⍎⍵.Match} Order ← {⍋(∊num'.'⎕S ExecNums⍠1)¨⍵} Order names SuperNatSort ← {(⊂Order ⍵)⌷⍵} SuperNatSort names ]defs –topdown

TAO: a true team effort Arthur Whitney initial suggestion Roger Hui TAO of J John Scholes model: dfns.dyalog.com/n_le.htm Roger Hui Dyalog implementation Adám Brudzewsky, Roger Hui, Jay Foad, John Scholes, Morten Kromberg

Features coming in version 17.0 Grade and Sort anyno refs Array {(⊂⍋⍵}⌷⍵} for all ranks – fast! ⍋⍵ ⍒⍵ ⍺⍸⍵