rsc

rsc

Go Hacker. Mistake maker. (he/him)

Member Since 12 years ago

Google, Cambridge, MA

Experience Points
6.7k
follower
Lessons Completed
0
follow
Lessons Completed
3
stars
Best Reply Awards
126
repos

935 contributions in the last year

Pinned
⚡ The Go programming language
⚡ Fast, indexed regexp search over large file trees
⚡ Plan 9 from User Space
⚡ Packages and commands for using Plan 9 from Go
⚡ Two-factor authentication on the command line
Activity
Dec
7
1 day ago
Activity icon
issue

rsc issue comment golang/go

rsc
rsc

build: GOEXPERIMENT=unified fails using Go 1.17 as bootstrap toolchain

% GOROOT_BOOTSTRAP=$HOME/sdk/go1.17 GOEXPERIMENT=unified ./make.bash
go: unknown GOEXPERIMENT unified
Building Go cmd/dist using /Users/rsc/sdk/go1.17. ()
go: unknown GOEXPERIMENT unified
% 

I'm not sure what's going on here. It looks like maybe GOEXPERIMENT should be cleared during the use of the bootstrap toolchain in make.bash?

rsc
rsc

Looks like maybe CL 344512 is the fix.

pull request

rsc merge to google/go-cmp

rsc
rsc

Update minimum supported version to go1.11.

Activity icon
issue

rsc issue comment golang/go

rsc
rsc

build: GOEXPERIMENT=unified fails using Go 1.17 as bootstrap toolchain

% GOROOT_BOOTSTRAP=$HOME/sdk/go1.17 GOEXPERIMENT=unified ./make.bash
go: unknown GOEXPERIMENT unified
Building Go cmd/dist using /Users/rsc/sdk/go1.17. ()
go: unknown GOEXPERIMENT unified
% 

I'm not sure what's going on here. It looks like maybe GOEXPERIMENT should be cleared during the use of the bootstrap toolchain in make.bash?

Activity icon
issue

rsc issue golang/go

rsc
rsc

build: GOEXPERIMENT=unified fails using Go 1.17 as bootstrap toolchain

% GOROOT_BOOTSTRAP=$HOME/sdk/go1.17 GOEXPERIMENT=unified ./make.bash
go: unknown GOEXPERIMENT unified
Building Go cmd/dist using /Users/rsc/sdk/go1.17. ()
go: unknown GOEXPERIMENT unified
% 

I'm not sure what's going on here. It looks like maybe GOEXPERIMENT should be cleared during the use of the bootstrap toolchain in make.bash?

Activity icon
issue

rsc issue comment golang/go

rsc
rsc

all: rewrite `interface{}` to `any`

Reminder issue.

rsc
rsc

This is not the issue, nor the time, to debate allowing any. This issue is about tracking certain work. Regarding allowing any at all, we had the proposal discussion, and the proposal was accepted. See https://github.com/golang/go/issues/33232#issuecomment-915333205 for the rationale. No one is raising any new information that would warrant reopening the decision.

Activity icon
issue

rsc issue comment robpike/ivy

rsc
rsc

ivy: various matrix-related improvements

Seven commits. Probably easiest to read the commits individually.

  • Add dyadic transpose, like 1 3 2 transp 3 4 5 rho 24:

    1 3 2 transp 2 3 4 rho iota 24
     1  5  9
     2  6 10
     3  7 11
     4  8 12
    
    13 17 21
    14 18 22
    15 19 23
    16 20 24
    
  • Generalize catenate on matrices to handle existing vector generalizations, following APL semantics. Vectors have always handled combinations of scalars and vectors:

     1, 2 3 4 5
     1 2 3 4, 1
     1 2, 3 4 4
    

    But matrices have had shape (n ...), (...) -> (n+1 ...) only (single element append). Added:

     (n ...), (...) -> (n+1 ...)  # list, elem
     (...), (n ...) -> (n+1 ...)  # elem, list
     (n ...), (m ...) -> (n+m ...)  # list, list
     (1), (n ...) -> (n+1 ...)  # scalar (extended), list
     (n ...), (1) -> (n+1 ...)  # list, scalar (extended)
    
  • Preserve shape of left argument in 'in'. Now these two have the same result:

     (3 4 rho iota 12) == 4
     (3 4 rho iota 12) in 4
    

    Before the second result was a plain vector, not a (3 4).

  • Add context in conversion failures.

     (2 2 rho 1) transp (2 2 rho 1)
     transp: cannot convert matrix to vector
    

    (The "transp: " is new.)

  • Implement sel on matrices. Formerly only worked on vectors.

    2 0 1 sel (2 3 rho iota 6)
        1 1 3
        4 4 6
    

    Following APL X/Y, sel applies to last axis. Can get first (X⌿Y) easily using transpose.

  • Implement take and drop on matrices. Formerly only worked on vectors.

     -1 2 take 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
     2 -2 drop 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
  • Don't overparenthesize x[1] in )op display.

     op f x = x[1] + x[2]
     )op f
         op f x = x[1] + x[2]
    

    Used to print (x[1]).

rsc
rsc

I pushed a new sequence with the changes applied except for the suggested use of shrink. Long comment above about that.

open pull request

rsc wants to merge robpike/ivy

rsc
rsc

ivy: various matrix-related improvements

Seven commits. Probably easiest to read the commits individually.

  • Add dyadic transpose, like 1 3 2 transp 3 4 5 rho 24:

    1 3 2 transp 2 3 4 rho iota 24
     1  5  9
     2  6 10
     3  7 11
     4  8 12
    
    13 17 21
    14 18 22
    15 19 23
    16 20 24
    
  • Generalize catenate on matrices to handle existing vector generalizations, following APL semantics. Vectors have always handled combinations of scalars and vectors:

     1, 2 3 4 5
     1 2 3 4, 1
     1 2, 3 4 4
    

    But matrices have had shape (n ...), (...) -> (n+1 ...) only (single element append). Added:

     (n ...), (...) -> (n+1 ...)  # list, elem
     (...), (n ...) -> (n+1 ...)  # elem, list
     (n ...), (m ...) -> (n+m ...)  # list, list
     (1), (n ...) -> (n+1 ...)  # scalar (extended), list
     (n ...), (1) -> (n+1 ...)  # list, scalar (extended)
    
  • Preserve shape of left argument in 'in'. Now these two have the same result:

     (3 4 rho iota 12) == 4
     (3 4 rho iota 12) in 4
    

    Before the second result was a plain vector, not a (3 4).

  • Add context in conversion failures.

     (2 2 rho 1) transp (2 2 rho 1)
     transp: cannot convert matrix to vector
    

    (The "transp: " is new.)

  • Implement sel on matrices. Formerly only worked on vectors.

    2 0 1 sel (2 3 rho iota 6)
        1 1 3
        4 4 6
    

    Following APL X/Y, sel applies to last axis. Can get first (X⌿Y) easily using transpose.

  • Implement take and drop on matrices. Formerly only worked on vectors.

     -1 2 take 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
     2 -2 drop 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
  • Don't overparenthesize x[1] in )op display.

     op f x = x[1] + x[2]
     )op f
         op f x = x[1] + x[2]
    

    Used to print (x[1]).

rsc
rsc

APL seems not to do the shrinking. Over on tryapl.org:

      ⍴1↑3 4⍴⍳12
1 4
      ⍴1 1↑3 4⍴⍳12
1 1

And with Ivy with these changes:

rho 1 take 3 4 rho iota 12
1 4

rho 1 1 take 3 4 rho iota 12
1 1

If shrink were applied, these would disagree.

Without appealing to APL, I've found that it's very difficult to write programs when you can't predict the rank of an expression. If you have

rho n take 3 4 rho iota 12

and that's usually an (n 4) except it ends up a (4) when n == 1, that's quite difficult to handle in code.

Or with vectors, suppose you are splitting a list into pieces and trying to process two halves, like you know (rho u) >= 2 and process v = ((rho u) div 2) take u and w = ((rho u) div 2) drop u. Today, thankfully, Ivy treats even 1-element results as vectors, not scalars. That means that v[1] and w[1] are always valid. If these vectors devolved into scalars, they'd stop being valid.

I ran into this with indexing too. If you have a vector v of indexes and you use x[v], you really want to get back a vector of results, no matter the length of v. The use of shrink means that if v happens to have length 1, then you get a scalar. That means x[v][1] fails, but only in the case when v has length 1. I definitely have had to resort to using take instead of indexing in Ivy to avoid this problem.

Back over to tryapl.org, indexing by a vector always returns a vector, presumably to avoid this kind of problem:

      x ← 1 2 3
      x[1]
1
      x[1⍴1]
1
      ⍴x[1]

      ⍴x[1⍴1]
1

(In APL ⍴ always returns a vector, with zero length for a scalar.)

There's a bigger conversation here about figuring out what the right rules are for when, if ever, shrink should be applied, but take and drop on vectors don't shrink today, which in practice works well, and I don't think they should shrink on matrices either. That is, the rule they follow is that they are rank-preserving operators, as are the others I added.

pull request

rsc merge to robpike/ivy

rsc
rsc

ivy: various matrix-related improvements

Seven commits. Probably easiest to read the commits individually.

  • Add dyadic transpose, like 1 3 2 transp 3 4 5 rho 24:

    1 3 2 transp 2 3 4 rho iota 24
     1  5  9
     2  6 10
     3  7 11
     4  8 12
    
    13 17 21
    14 18 22
    15 19 23
    16 20 24
    
  • Generalize catenate on matrices to handle existing vector generalizations, following APL semantics. Vectors have always handled combinations of scalars and vectors:

     1, 2 3 4 5
     1 2 3 4, 1
     1 2, 3 4 4
    

    But matrices have had shape (n ...), (...) -> (n+1 ...) only (single element append). Added:

     (n ...), (...) -> (n+1 ...)  # list, elem
     (...), (n ...) -> (n+1 ...)  # elem, list
     (n ...), (m ...) -> (n+m ...)  # list, list
     (1), (n ...) -> (n+1 ...)  # scalar (extended), list
     (n ...), (1) -> (n+1 ...)  # list, scalar (extended)
    
  • Preserve shape of left argument in 'in'. Now these two have the same result:

     (3 4 rho iota 12) == 4
     (3 4 rho iota 12) in 4
    

    Before the second result was a plain vector, not a (3 4).

  • Add context in conversion failures.

     (2 2 rho 1) transp (2 2 rho 1)
     transp: cannot convert matrix to vector
    

    (The "transp: " is new.)

  • Implement sel on matrices. Formerly only worked on vectors.

    2 0 1 sel (2 3 rho iota 6)
        1 1 3
        4 4 6
    

    Following APL X/Y, sel applies to last axis. Can get first (X⌿Y) easily using transpose.

  • Implement take and drop on matrices. Formerly only worked on vectors.

     -1 2 take 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
     2 -2 drop 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
  • Don't overparenthesize x[1] in )op display.

     op f x = x[1] + x[2]
     )op f
         op f x = x[1] + x[2]
    

    Used to print (x[1]).

pull request

rsc merge to robpike/ivy

rsc
rsc

ivy: various matrix-related improvements

Seven commits. Probably easiest to read the commits individually.

  • Add dyadic transpose, like 1 3 2 transp 3 4 5 rho 24:

    1 3 2 transp 2 3 4 rho iota 24
     1  5  9
     2  6 10
     3  7 11
     4  8 12
    
    13 17 21
    14 18 22
    15 19 23
    16 20 24
    
  • Generalize catenate on matrices to handle existing vector generalizations, following APL semantics. Vectors have always handled combinations of scalars and vectors:

     1, 2 3 4 5
     1 2 3 4, 1
     1 2, 3 4 4
    

    But matrices have had shape (n ...), (...) -> (n+1 ...) only (single element append). Added:

     (n ...), (...) -> (n+1 ...)  # list, elem
     (...), (n ...) -> (n+1 ...)  # elem, list
     (n ...), (m ...) -> (n+m ...)  # list, list
     (1), (n ...) -> (n+1 ...)  # scalar (extended), list
     (n ...), (1) -> (n+1 ...)  # list, scalar (extended)
    
  • Preserve shape of left argument in 'in'. Now these two have the same result:

     (3 4 rho iota 12) == 4
     (3 4 rho iota 12) in 4
    

    Before the second result was a plain vector, not a (3 4).

  • Add context in conversion failures.

     (2 2 rho 1) transp (2 2 rho 1)
     transp: cannot convert matrix to vector
    

    (The "transp: " is new.)

  • Implement sel on matrices. Formerly only worked on vectors.

    2 0 1 sel (2 3 rho iota 6)
        1 1 3
        4 4 6
    

    Following APL X/Y, sel applies to last axis. Can get first (X⌿Y) easily using transpose.

  • Implement take and drop on matrices. Formerly only worked on vectors.

     -1 2 take 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
     2 -2 drop 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
  • Don't overparenthesize x[1] in )op display.

     op f x = x[1] + x[2]
     )op f
         op f x = x[1] + x[2]
    

    Used to print (x[1]).

open pull request

rsc wants to merge robpike/ivy

rsc
rsc

ivy: various matrix-related improvements

Seven commits. Probably easiest to read the commits individually.

  • Add dyadic transpose, like 1 3 2 transp 3 4 5 rho 24:

    1 3 2 transp 2 3 4 rho iota 24
     1  5  9
     2  6 10
     3  7 11
     4  8 12
    
    13 17 21
    14 18 22
    15 19 23
    16 20 24
    
  • Generalize catenate on matrices to handle existing vector generalizations, following APL semantics. Vectors have always handled combinations of scalars and vectors:

     1, 2 3 4 5
     1 2 3 4, 1
     1 2, 3 4 4
    

    But matrices have had shape (n ...), (...) -> (n+1 ...) only (single element append). Added:

     (n ...), (...) -> (n+1 ...)  # list, elem
     (...), (n ...) -> (n+1 ...)  # elem, list
     (n ...), (m ...) -> (n+m ...)  # list, list
     (1), (n ...) -> (n+1 ...)  # scalar (extended), list
     (n ...), (1) -> (n+1 ...)  # list, scalar (extended)
    
  • Preserve shape of left argument in 'in'. Now these two have the same result:

     (3 4 rho iota 12) == 4
     (3 4 rho iota 12) in 4
    

    Before the second result was a plain vector, not a (3 4).

  • Add context in conversion failures.

     (2 2 rho 1) transp (2 2 rho 1)
     transp: cannot convert matrix to vector
    

    (The "transp: " is new.)

  • Implement sel on matrices. Formerly only worked on vectors.

    2 0 1 sel (2 3 rho iota 6)
        1 1 3
        4 4 6
    

    Following APL X/Y, sel applies to last axis. Can get first (X⌿Y) easily using transpose.

  • Implement take and drop on matrices. Formerly only worked on vectors.

     -1 2 take 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
     2 -2 drop 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
  • Don't overparenthesize x[1] in )op display.

     op f x = x[1] + x[2]
     )op f
         op f x = x[1] + x[2]
    

    Used to print (x[1]).

open pull request

rsc wants to merge robpike/ivy

rsc
rsc

ivy: various matrix-related improvements

Seven commits. Probably easiest to read the commits individually.

  • Add dyadic transpose, like 1 3 2 transp 3 4 5 rho 24:

    1 3 2 transp 2 3 4 rho iota 24
     1  5  9
     2  6 10
     3  7 11
     4  8 12
    
    13 17 21
    14 18 22
    15 19 23
    16 20 24
    
  • Generalize catenate on matrices to handle existing vector generalizations, following APL semantics. Vectors have always handled combinations of scalars and vectors:

     1, 2 3 4 5
     1 2 3 4, 1
     1 2, 3 4 4
    

    But matrices have had shape (n ...), (...) -> (n+1 ...) only (single element append). Added:

     (n ...), (...) -> (n+1 ...)  # list, elem
     (...), (n ...) -> (n+1 ...)  # elem, list
     (n ...), (m ...) -> (n+m ...)  # list, list
     (1), (n ...) -> (n+1 ...)  # scalar (extended), list
     (n ...), (1) -> (n+1 ...)  # list, scalar (extended)
    
  • Preserve shape of left argument in 'in'. Now these two have the same result:

     (3 4 rho iota 12) == 4
     (3 4 rho iota 12) in 4
    

    Before the second result was a plain vector, not a (3 4).

  • Add context in conversion failures.

     (2 2 rho 1) transp (2 2 rho 1)
     transp: cannot convert matrix to vector
    

    (The "transp: " is new.)

  • Implement sel on matrices. Formerly only worked on vectors.

    2 0 1 sel (2 3 rho iota 6)
        1 1 3
        4 4 6
    

    Following APL X/Y, sel applies to last axis. Can get first (X⌿Y) easily using transpose.

  • Implement take and drop on matrices. Formerly only worked on vectors.

     -1 2 take 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
     2 -2 drop 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
  • Don't overparenthesize x[1] in )op display.

     op f x = x[1] + x[2]
     )op f
         op f x = x[1] + x[2]
    

    Used to print (x[1]).

pull request

rsc merge to robpike/ivy

rsc
rsc

ivy: various matrix-related improvements

Seven commits. Probably easiest to read the commits individually.

  • Add dyadic transpose, like 1 3 2 transp 3 4 5 rho 24:

    1 3 2 transp 2 3 4 rho iota 24
     1  5  9
     2  6 10
     3  7 11
     4  8 12
    
    13 17 21
    14 18 22
    15 19 23
    16 20 24
    
  • Generalize catenate on matrices to handle existing vector generalizations, following APL semantics. Vectors have always handled combinations of scalars and vectors:

     1, 2 3 4 5
     1 2 3 4, 1
     1 2, 3 4 4
    

    But matrices have had shape (n ...), (...) -> (n+1 ...) only (single element append). Added:

     (n ...), (...) -> (n+1 ...)  # list, elem
     (...), (n ...) -> (n+1 ...)  # elem, list
     (n ...), (m ...) -> (n+m ...)  # list, list
     (1), (n ...) -> (n+1 ...)  # scalar (extended), list
     (n ...), (1) -> (n+1 ...)  # list, scalar (extended)
    
  • Preserve shape of left argument in 'in'. Now these two have the same result:

     (3 4 rho iota 12) == 4
     (3 4 rho iota 12) in 4
    

    Before the second result was a plain vector, not a (3 4).

  • Add context in conversion failures.

     (2 2 rho 1) transp (2 2 rho 1)
     transp: cannot convert matrix to vector
    

    (The "transp: " is new.)

  • Implement sel on matrices. Formerly only worked on vectors.

    2 0 1 sel (2 3 rho iota 6)
        1 1 3
        4 4 6
    

    Following APL X/Y, sel applies to last axis. Can get first (X⌿Y) easily using transpose.

  • Implement take and drop on matrices. Formerly only worked on vectors.

     -1 2 take 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
     2 -2 drop 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
  • Don't overparenthesize x[1] in )op display.

     op f x = x[1] + x[2]
     )op f
         op f x = x[1] + x[2]
    

    Used to print (x[1]).

open pull request

rsc wants to merge robpike/ivy

rsc
rsc

ivy: various matrix-related improvements

Seven commits. Probably easiest to read the commits individually.

  • Add dyadic transpose, like 1 3 2 transp 3 4 5 rho 24:

    1 3 2 transp 2 3 4 rho iota 24
     1  5  9
     2  6 10
     3  7 11
     4  8 12
    
    13 17 21
    14 18 22
    15 19 23
    16 20 24
    
  • Generalize catenate on matrices to handle existing vector generalizations, following APL semantics. Vectors have always handled combinations of scalars and vectors:

     1, 2 3 4 5
     1 2 3 4, 1
     1 2, 3 4 4
    

    But matrices have had shape (n ...), (...) -> (n+1 ...) only (single element append). Added:

     (n ...), (...) -> (n+1 ...)  # list, elem
     (...), (n ...) -> (n+1 ...)  # elem, list
     (n ...), (m ...) -> (n+m ...)  # list, list
     (1), (n ...) -> (n+1 ...)  # scalar (extended), list
     (n ...), (1) -> (n+1 ...)  # list, scalar (extended)
    
  • Preserve shape of left argument in 'in'. Now these two have the same result:

     (3 4 rho iota 12) == 4
     (3 4 rho iota 12) in 4
    

    Before the second result was a plain vector, not a (3 4).

  • Add context in conversion failures.

     (2 2 rho 1) transp (2 2 rho 1)
     transp: cannot convert matrix to vector
    

    (The "transp: " is new.)

  • Implement sel on matrices. Formerly only worked on vectors.

    2 0 1 sel (2 3 rho iota 6)
        1 1 3
        4 4 6
    

    Following APL X/Y, sel applies to last axis. Can get first (X⌿Y) easily using transpose.

  • Implement take and drop on matrices. Formerly only worked on vectors.

     -1 2 take 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
     2 -2 drop 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
  • Don't overparenthesize x[1] in )op display.

     op f x = x[1] + x[2]
     )op f
         op f x = x[1] + x[2]
    

    Used to print (x[1]).

pull request

rsc merge to robpike/ivy

rsc
rsc

ivy: various matrix-related improvements

Seven commits. Probably easiest to read the commits individually.

  • Add dyadic transpose, like 1 3 2 transp 3 4 5 rho 24:

    1 3 2 transp 2 3 4 rho iota 24
     1  5  9
     2  6 10
     3  7 11
     4  8 12
    
    13 17 21
    14 18 22
    15 19 23
    16 20 24
    
  • Generalize catenate on matrices to handle existing vector generalizations, following APL semantics. Vectors have always handled combinations of scalars and vectors:

     1, 2 3 4 5
     1 2 3 4, 1
     1 2, 3 4 4
    

    But matrices have had shape (n ...), (...) -> (n+1 ...) only (single element append). Added:

     (n ...), (...) -> (n+1 ...)  # list, elem
     (...), (n ...) -> (n+1 ...)  # elem, list
     (n ...), (m ...) -> (n+m ...)  # list, list
     (1), (n ...) -> (n+1 ...)  # scalar (extended), list
     (n ...), (1) -> (n+1 ...)  # list, scalar (extended)
    
  • Preserve shape of left argument in 'in'. Now these two have the same result:

     (3 4 rho iota 12) == 4
     (3 4 rho iota 12) in 4
    

    Before the second result was a plain vector, not a (3 4).

  • Add context in conversion failures.

     (2 2 rho 1) transp (2 2 rho 1)
     transp: cannot convert matrix to vector
    

    (The "transp: " is new.)

  • Implement sel on matrices. Formerly only worked on vectors.

    2 0 1 sel (2 3 rho iota 6)
        1 1 3
        4 4 6
    

    Following APL X/Y, sel applies to last axis. Can get first (X⌿Y) easily using transpose.

  • Implement take and drop on matrices. Formerly only worked on vectors.

     -1 2 take 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
     2 -2 drop 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
  • Don't overparenthesize x[1] in )op display.

     op f x = x[1] + x[2]
     )op f
         op f x = x[1] + x[2]
    

    Used to print (x[1]).

open pull request

rsc wants to merge robpike/ivy

rsc
rsc

ivy: various matrix-related improvements

Seven commits. Probably easiest to read the commits individually.

  • Add dyadic transpose, like 1 3 2 transp 3 4 5 rho 24:

    1 3 2 transp 2 3 4 rho iota 24
     1  5  9
     2  6 10
     3  7 11
     4  8 12
    
    13 17 21
    14 18 22
    15 19 23
    16 20 24
    
  • Generalize catenate on matrices to handle existing vector generalizations, following APL semantics. Vectors have always handled combinations of scalars and vectors:

     1, 2 3 4 5
     1 2 3 4, 1
     1 2, 3 4 4
    

    But matrices have had shape (n ...), (...) -> (n+1 ...) only (single element append). Added:

     (n ...), (...) -> (n+1 ...)  # list, elem
     (...), (n ...) -> (n+1 ...)  # elem, list
     (n ...), (m ...) -> (n+m ...)  # list, list
     (1), (n ...) -> (n+1 ...)  # scalar (extended), list
     (n ...), (1) -> (n+1 ...)  # list, scalar (extended)
    
  • Preserve shape of left argument in 'in'. Now these two have the same result:

     (3 4 rho iota 12) == 4
     (3 4 rho iota 12) in 4
    

    Before the second result was a plain vector, not a (3 4).

  • Add context in conversion failures.

     (2 2 rho 1) transp (2 2 rho 1)
     transp: cannot convert matrix to vector
    

    (The "transp: " is new.)

  • Implement sel on matrices. Formerly only worked on vectors.

    2 0 1 sel (2 3 rho iota 6)
        1 1 3
        4 4 6
    

    Following APL X/Y, sel applies to last axis. Can get first (X⌿Y) easily using transpose.

  • Implement take and drop on matrices. Formerly only worked on vectors.

     -1 2 take 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
     2 -2 drop 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
  • Don't overparenthesize x[1] in )op display.

     op f x = x[1] + x[2]
     )op f
         op f x = x[1] + x[2]
    

    Used to print (x[1]).

rsc
rsc

Done as AllInts. The general one would be

func VectorAll[T any](v Vector) bool {
    for _, c := range v {
        if _, ok := c.Inner().(T); !ok {
            return false
        }
    }
    return true
}

if !VectorAll[Int](v) { ... }

(It can't be a method on Vector because there are no parameterized methods, because then interface satisfaction is either inconsistent or incomplete.)

pull request

rsc merge to robpike/ivy

rsc
rsc

ivy: various matrix-related improvements

Seven commits. Probably easiest to read the commits individually.

  • Add dyadic transpose, like 1 3 2 transp 3 4 5 rho 24:

    1 3 2 transp 2 3 4 rho iota 24
     1  5  9
     2  6 10
     3  7 11
     4  8 12
    
    13 17 21
    14 18 22
    15 19 23
    16 20 24
    
  • Generalize catenate on matrices to handle existing vector generalizations, following APL semantics. Vectors have always handled combinations of scalars and vectors:

     1, 2 3 4 5
     1 2 3 4, 1
     1 2, 3 4 4
    

    But matrices have had shape (n ...), (...) -> (n+1 ...) only (single element append). Added:

     (n ...), (...) -> (n+1 ...)  # list, elem
     (...), (n ...) -> (n+1 ...)  # elem, list
     (n ...), (m ...) -> (n+m ...)  # list, list
     (1), (n ...) -> (n+1 ...)  # scalar (extended), list
     (n ...), (1) -> (n+1 ...)  # list, scalar (extended)
    
  • Preserve shape of left argument in 'in'. Now these two have the same result:

     (3 4 rho iota 12) == 4
     (3 4 rho iota 12) in 4
    

    Before the second result was a plain vector, not a (3 4).

  • Add context in conversion failures.

     (2 2 rho 1) transp (2 2 rho 1)
     transp: cannot convert matrix to vector
    

    (The "transp: " is new.)

  • Implement sel on matrices. Formerly only worked on vectors.

    2 0 1 sel (2 3 rho iota 6)
        1 1 3
        4 4 6
    

    Following APL X/Y, sel applies to last axis. Can get first (X⌿Y) easily using transpose.

  • Implement take and drop on matrices. Formerly only worked on vectors.

     -1 2 take 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
     2 -2 drop 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
  • Don't overparenthesize x[1] in )op display.

     op f x = x[1] + x[2]
     )op f
         op f x = x[1] + x[2]
    

    Used to print (x[1]).

open pull request

rsc wants to merge robpike/ivy

rsc
rsc

ivy: various matrix-related improvements

Seven commits. Probably easiest to read the commits individually.

  • Add dyadic transpose, like 1 3 2 transp 3 4 5 rho 24:

    1 3 2 transp 2 3 4 rho iota 24
     1  5  9
     2  6 10
     3  7 11
     4  8 12
    
    13 17 21
    14 18 22
    15 19 23
    16 20 24
    
  • Generalize catenate on matrices to handle existing vector generalizations, following APL semantics. Vectors have always handled combinations of scalars and vectors:

     1, 2 3 4 5
     1 2 3 4, 1
     1 2, 3 4 4
    

    But matrices have had shape (n ...), (...) -> (n+1 ...) only (single element append). Added:

     (n ...), (...) -> (n+1 ...)  # list, elem
     (...), (n ...) -> (n+1 ...)  # elem, list
     (n ...), (m ...) -> (n+m ...)  # list, list
     (1), (n ...) -> (n+1 ...)  # scalar (extended), list
     (n ...), (1) -> (n+1 ...)  # list, scalar (extended)
    
  • Preserve shape of left argument in 'in'. Now these two have the same result:

     (3 4 rho iota 12) == 4
     (3 4 rho iota 12) in 4
    

    Before the second result was a plain vector, not a (3 4).

  • Add context in conversion failures.

     (2 2 rho 1) transp (2 2 rho 1)
     transp: cannot convert matrix to vector
    

    (The "transp: " is new.)

  • Implement sel on matrices. Formerly only worked on vectors.

    2 0 1 sel (2 3 rho iota 6)
        1 1 3
        4 4 6
    

    Following APL X/Y, sel applies to last axis. Can get first (X⌿Y) easily using transpose.

  • Implement take and drop on matrices. Formerly only worked on vectors.

     -1 2 take 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
     2 -2 drop 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
  • Don't overparenthesize x[1] in )op display.

     op f x = x[1] + x[2]
     )op f
         op f x = x[1] + x[2]
    

    Used to print (x[1]).

pull request

rsc merge to robpike/ivy

rsc
rsc

ivy: various matrix-related improvements

Seven commits. Probably easiest to read the commits individually.

  • Add dyadic transpose, like 1 3 2 transp 3 4 5 rho 24:

    1 3 2 transp 2 3 4 rho iota 24
     1  5  9
     2  6 10
     3  7 11
     4  8 12
    
    13 17 21
    14 18 22
    15 19 23
    16 20 24
    
  • Generalize catenate on matrices to handle existing vector generalizations, following APL semantics. Vectors have always handled combinations of scalars and vectors:

     1, 2 3 4 5
     1 2 3 4, 1
     1 2, 3 4 4
    

    But matrices have had shape (n ...), (...) -> (n+1 ...) only (single element append). Added:

     (n ...), (...) -> (n+1 ...)  # list, elem
     (...), (n ...) -> (n+1 ...)  # elem, list
     (n ...), (m ...) -> (n+m ...)  # list, list
     (1), (n ...) -> (n+1 ...)  # scalar (extended), list
     (n ...), (1) -> (n+1 ...)  # list, scalar (extended)
    
  • Preserve shape of left argument in 'in'. Now these two have the same result:

     (3 4 rho iota 12) == 4
     (3 4 rho iota 12) in 4
    

    Before the second result was a plain vector, not a (3 4).

  • Add context in conversion failures.

     (2 2 rho 1) transp (2 2 rho 1)
     transp: cannot convert matrix to vector
    

    (The "transp: " is new.)

  • Implement sel on matrices. Formerly only worked on vectors.

    2 0 1 sel (2 3 rho iota 6)
        1 1 3
        4 4 6
    

    Following APL X/Y, sel applies to last axis. Can get first (X⌿Y) easily using transpose.

  • Implement take and drop on matrices. Formerly only worked on vectors.

     -1 2 take 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
     2 -2 drop 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
  • Don't overparenthesize x[1] in )op display.

     op f x = x[1] + x[2]
     )op f
         op f x = x[1] + x[2]
    

    Used to print (x[1]).

open pull request

rsc wants to merge robpike/ivy

rsc
rsc

ivy: various matrix-related improvements

Seven commits. Probably easiest to read the commits individually.

  • Add dyadic transpose, like 1 3 2 transp 3 4 5 rho 24:

    1 3 2 transp 2 3 4 rho iota 24
     1  5  9
     2  6 10
     3  7 11
     4  8 12
    
    13 17 21
    14 18 22
    15 19 23
    16 20 24
    
  • Generalize catenate on matrices to handle existing vector generalizations, following APL semantics. Vectors have always handled combinations of scalars and vectors:

     1, 2 3 4 5
     1 2 3 4, 1
     1 2, 3 4 4
    

    But matrices have had shape (n ...), (...) -> (n+1 ...) only (single element append). Added:

     (n ...), (...) -> (n+1 ...)  # list, elem
     (...), (n ...) -> (n+1 ...)  # elem, list
     (n ...), (m ...) -> (n+m ...)  # list, list
     (1), (n ...) -> (n+1 ...)  # scalar (extended), list
     (n ...), (1) -> (n+1 ...)  # list, scalar (extended)
    
  • Preserve shape of left argument in 'in'. Now these two have the same result:

     (3 4 rho iota 12) == 4
     (3 4 rho iota 12) in 4
    

    Before the second result was a plain vector, not a (3 4).

  • Add context in conversion failures.

     (2 2 rho 1) transp (2 2 rho 1)
     transp: cannot convert matrix to vector
    

    (The "transp: " is new.)

  • Implement sel on matrices. Formerly only worked on vectors.

    2 0 1 sel (2 3 rho iota 6)
        1 1 3
        4 4 6
    

    Following APL X/Y, sel applies to last axis. Can get first (X⌿Y) easily using transpose.

  • Implement take and drop on matrices. Formerly only worked on vectors.

     -1 2 take 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
     2 -2 drop 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
  • Don't overparenthesize x[1] in )op display.

     op f x = x[1] + x[2]
     )op f
         op f x = x[1] + x[2]
    

    Used to print (x[1]).

pull request

rsc merge to robpike/ivy

rsc
rsc

ivy: various matrix-related improvements

Seven commits. Probably easiest to read the commits individually.

  • Add dyadic transpose, like 1 3 2 transp 3 4 5 rho 24:

    1 3 2 transp 2 3 4 rho iota 24
     1  5  9
     2  6 10
     3  7 11
     4  8 12
    
    13 17 21
    14 18 22
    15 19 23
    16 20 24
    
  • Generalize catenate on matrices to handle existing vector generalizations, following APL semantics. Vectors have always handled combinations of scalars and vectors:

     1, 2 3 4 5
     1 2 3 4, 1
     1 2, 3 4 4
    

    But matrices have had shape (n ...), (...) -> (n+1 ...) only (single element append). Added:

     (n ...), (...) -> (n+1 ...)  # list, elem
     (...), (n ...) -> (n+1 ...)  # elem, list
     (n ...), (m ...) -> (n+m ...)  # list, list
     (1), (n ...) -> (n+1 ...)  # scalar (extended), list
     (n ...), (1) -> (n+1 ...)  # list, scalar (extended)
    
  • Preserve shape of left argument in 'in'. Now these two have the same result:

     (3 4 rho iota 12) == 4
     (3 4 rho iota 12) in 4
    

    Before the second result was a plain vector, not a (3 4).

  • Add context in conversion failures.

     (2 2 rho 1) transp (2 2 rho 1)
     transp: cannot convert matrix to vector
    

    (The "transp: " is new.)

  • Implement sel on matrices. Formerly only worked on vectors.

    2 0 1 sel (2 3 rho iota 6)
        1 1 3
        4 4 6
    

    Following APL X/Y, sel applies to last axis. Can get first (X⌿Y) easily using transpose.

  • Implement take and drop on matrices. Formerly only worked on vectors.

     -1 2 take 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
     2 -2 drop 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
  • Don't overparenthesize x[1] in )op display.

     op f x = x[1] + x[2]
     )op f
         op f x = x[1] + x[2]
    

    Used to print (x[1]).

open pull request

rsc wants to merge robpike/ivy

rsc
rsc

ivy: various matrix-related improvements

Seven commits. Probably easiest to read the commits individually.

  • Add dyadic transpose, like 1 3 2 transp 3 4 5 rho 24:

    1 3 2 transp 2 3 4 rho iota 24
     1  5  9
     2  6 10
     3  7 11
     4  8 12
    
    13 17 21
    14 18 22
    15 19 23
    16 20 24
    
  • Generalize catenate on matrices to handle existing vector generalizations, following APL semantics. Vectors have always handled combinations of scalars and vectors:

     1, 2 3 4 5
     1 2 3 4, 1
     1 2, 3 4 4
    

    But matrices have had shape (n ...), (...) -> (n+1 ...) only (single element append). Added:

     (n ...), (...) -> (n+1 ...)  # list, elem
     (...), (n ...) -> (n+1 ...)  # elem, list
     (n ...), (m ...) -> (n+m ...)  # list, list
     (1), (n ...) -> (n+1 ...)  # scalar (extended), list
     (n ...), (1) -> (n+1 ...)  # list, scalar (extended)
    
  • Preserve shape of left argument in 'in'. Now these two have the same result:

     (3 4 rho iota 12) == 4
     (3 4 rho iota 12) in 4
    

    Before the second result was a plain vector, not a (3 4).

  • Add context in conversion failures.

     (2 2 rho 1) transp (2 2 rho 1)
     transp: cannot convert matrix to vector
    

    (The "transp: " is new.)

  • Implement sel on matrices. Formerly only worked on vectors.

    2 0 1 sel (2 3 rho iota 6)
        1 1 3
        4 4 6
    

    Following APL X/Y, sel applies to last axis. Can get first (X⌿Y) easily using transpose.

  • Implement take and drop on matrices. Formerly only worked on vectors.

     -1 2 take 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
     2 -2 drop 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
  • Don't overparenthesize x[1] in )op display.

     op f x = x[1] + x[2]
     )op f
         op f x = x[1] + x[2]
    

    Used to print (x[1]).

pull request

rsc merge to robpike/ivy

rsc
rsc

ivy: various matrix-related improvements

Seven commits. Probably easiest to read the commits individually.

  • Add dyadic transpose, like 1 3 2 transp 3 4 5 rho 24:

    1 3 2 transp 2 3 4 rho iota 24
     1  5  9
     2  6 10
     3  7 11
     4  8 12
    
    13 17 21
    14 18 22
    15 19 23
    16 20 24
    
  • Generalize catenate on matrices to handle existing vector generalizations, following APL semantics. Vectors have always handled combinations of scalars and vectors:

     1, 2 3 4 5
     1 2 3 4, 1
     1 2, 3 4 4
    

    But matrices have had shape (n ...), (...) -> (n+1 ...) only (single element append). Added:

     (n ...), (...) -> (n+1 ...)  # list, elem
     (...), (n ...) -> (n+1 ...)  # elem, list
     (n ...), (m ...) -> (n+m ...)  # list, list
     (1), (n ...) -> (n+1 ...)  # scalar (extended), list
     (n ...), (1) -> (n+1 ...)  # list, scalar (extended)
    
  • Preserve shape of left argument in 'in'. Now these two have the same result:

     (3 4 rho iota 12) == 4
     (3 4 rho iota 12) in 4
    

    Before the second result was a plain vector, not a (3 4).

  • Add context in conversion failures.

     (2 2 rho 1) transp (2 2 rho 1)
     transp: cannot convert matrix to vector
    

    (The "transp: " is new.)

  • Implement sel on matrices. Formerly only worked on vectors.

    2 0 1 sel (2 3 rho iota 6)
        1 1 3
        4 4 6
    

    Following APL X/Y, sel applies to last axis. Can get first (X⌿Y) easily using transpose.

  • Implement take and drop on matrices. Formerly only worked on vectors.

     -1 2 take 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
     2 -2 drop 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
  • Don't overparenthesize x[1] in )op display.

     op f x = x[1] + x[2]
     )op f
         op f x = x[1] + x[2]
    

    Used to print (x[1]).

open pull request

rsc wants to merge robpike/ivy

rsc
rsc

ivy: various matrix-related improvements

Seven commits. Probably easiest to read the commits individually.

  • Add dyadic transpose, like 1 3 2 transp 3 4 5 rho 24:

    1 3 2 transp 2 3 4 rho iota 24
     1  5  9
     2  6 10
     3  7 11
     4  8 12
    
    13 17 21
    14 18 22
    15 19 23
    16 20 24
    
  • Generalize catenate on matrices to handle existing vector generalizations, following APL semantics. Vectors have always handled combinations of scalars and vectors:

     1, 2 3 4 5
     1 2 3 4, 1
     1 2, 3 4 4
    

    But matrices have had shape (n ...), (...) -> (n+1 ...) only (single element append). Added:

     (n ...), (...) -> (n+1 ...)  # list, elem
     (...), (n ...) -> (n+1 ...)  # elem, list
     (n ...), (m ...) -> (n+m ...)  # list, list
     (1), (n ...) -> (n+1 ...)  # scalar (extended), list
     (n ...), (1) -> (n+1 ...)  # list, scalar (extended)
    
  • Preserve shape of left argument in 'in'. Now these two have the same result:

     (3 4 rho iota 12) == 4
     (3 4 rho iota 12) in 4
    

    Before the second result was a plain vector, not a (3 4).

  • Add context in conversion failures.

     (2 2 rho 1) transp (2 2 rho 1)
     transp: cannot convert matrix to vector
    

    (The "transp: " is new.)

  • Implement sel on matrices. Formerly only worked on vectors.

    2 0 1 sel (2 3 rho iota 6)
        1 1 3
        4 4 6
    

    Following APL X/Y, sel applies to last axis. Can get first (X⌿Y) easily using transpose.

  • Implement take and drop on matrices. Formerly only worked on vectors.

     -1 2 take 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
     2 -2 drop 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
  • Don't overparenthesize x[1] in )op display.

     op f x = x[1] + x[2]
     )op f
         op f x = x[1] + x[2]
    

    Used to print (x[1]).

pull request

rsc merge to robpike/ivy

rsc
rsc

ivy: various matrix-related improvements

Seven commits. Probably easiest to read the commits individually.

  • Add dyadic transpose, like 1 3 2 transp 3 4 5 rho 24:

    1 3 2 transp 2 3 4 rho iota 24
     1  5  9
     2  6 10
     3  7 11
     4  8 12
    
    13 17 21
    14 18 22
    15 19 23
    16 20 24
    
  • Generalize catenate on matrices to handle existing vector generalizations, following APL semantics. Vectors have always handled combinations of scalars and vectors:

     1, 2 3 4 5
     1 2 3 4, 1
     1 2, 3 4 4
    

    But matrices have had shape (n ...), (...) -> (n+1 ...) only (single element append). Added:

     (n ...), (...) -> (n+1 ...)  # list, elem
     (...), (n ...) -> (n+1 ...)  # elem, list
     (n ...), (m ...) -> (n+m ...)  # list, list
     (1), (n ...) -> (n+1 ...)  # scalar (extended), list
     (n ...), (1) -> (n+1 ...)  # list, scalar (extended)
    
  • Preserve shape of left argument in 'in'. Now these two have the same result:

     (3 4 rho iota 12) == 4
     (3 4 rho iota 12) in 4
    

    Before the second result was a plain vector, not a (3 4).

  • Add context in conversion failures.

     (2 2 rho 1) transp (2 2 rho 1)
     transp: cannot convert matrix to vector
    

    (The "transp: " is new.)

  • Implement sel on matrices. Formerly only worked on vectors.

    2 0 1 sel (2 3 rho iota 6)
        1 1 3
        4 4 6
    

    Following APL X/Y, sel applies to last axis. Can get first (X⌿Y) easily using transpose.

  • Implement take and drop on matrices. Formerly only worked on vectors.

     -1 2 take 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
     2 -2 drop 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
  • Don't overparenthesize x[1] in )op display.

     op f x = x[1] + x[2]
     )op f
         op f x = x[1] + x[2]
    

    Used to print (x[1]).

open pull request

rsc wants to merge robpike/ivy

rsc
rsc

ivy: various matrix-related improvements

Seven commits. Probably easiest to read the commits individually.

  • Add dyadic transpose, like 1 3 2 transp 3 4 5 rho 24:

    1 3 2 transp 2 3 4 rho iota 24
     1  5  9
     2  6 10
     3  7 11
     4  8 12
    
    13 17 21
    14 18 22
    15 19 23
    16 20 24
    
  • Generalize catenate on matrices to handle existing vector generalizations, following APL semantics. Vectors have always handled combinations of scalars and vectors:

     1, 2 3 4 5
     1 2 3 4, 1
     1 2, 3 4 4
    

    But matrices have had shape (n ...), (...) -> (n+1 ...) only (single element append). Added:

     (n ...), (...) -> (n+1 ...)  # list, elem
     (...), (n ...) -> (n+1 ...)  # elem, list
     (n ...), (m ...) -> (n+m ...)  # list, list
     (1), (n ...) -> (n+1 ...)  # scalar (extended), list
     (n ...), (1) -> (n+1 ...)  # list, scalar (extended)
    
  • Preserve shape of left argument in 'in'. Now these two have the same result:

     (3 4 rho iota 12) == 4
     (3 4 rho iota 12) in 4
    

    Before the second result was a plain vector, not a (3 4).

  • Add context in conversion failures.

     (2 2 rho 1) transp (2 2 rho 1)
     transp: cannot convert matrix to vector
    

    (The "transp: " is new.)

  • Implement sel on matrices. Formerly only worked on vectors.

    2 0 1 sel (2 3 rho iota 6)
        1 1 3
        4 4 6
    

    Following APL X/Y, sel applies to last axis. Can get first (X⌿Y) easily using transpose.

  • Implement take and drop on matrices. Formerly only worked on vectors.

     -1 2 take 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
     2 -2 drop 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
  • Don't overparenthesize x[1] in )op display.

     op f x = x[1] + x[2]
     )op f
         op f x = x[1] + x[2]
    

    Used to print (x[1]).

rsc
rsc

Done. I did leave one note here saying 'APL calls this operator the dyadic transpose', because that's important for finding documentation about it with a web search.

pull request

rsc merge to robpike/ivy

rsc
rsc

ivy: various matrix-related improvements

Seven commits. Probably easiest to read the commits individually.

  • Add dyadic transpose, like 1 3 2 transp 3 4 5 rho 24:

    1 3 2 transp 2 3 4 rho iota 24
     1  5  9
     2  6 10
     3  7 11
     4  8 12
    
    13 17 21
    14 18 22
    15 19 23
    16 20 24
    
  • Generalize catenate on matrices to handle existing vector generalizations, following APL semantics. Vectors have always handled combinations of scalars and vectors:

     1, 2 3 4 5
     1 2 3 4, 1
     1 2, 3 4 4
    

    But matrices have had shape (n ...), (...) -> (n+1 ...) only (single element append). Added:

     (n ...), (...) -> (n+1 ...)  # list, elem
     (...), (n ...) -> (n+1 ...)  # elem, list
     (n ...), (m ...) -> (n+m ...)  # list, list
     (1), (n ...) -> (n+1 ...)  # scalar (extended), list
     (n ...), (1) -> (n+1 ...)  # list, scalar (extended)
    
  • Preserve shape of left argument in 'in'. Now these two have the same result:

     (3 4 rho iota 12) == 4
     (3 4 rho iota 12) in 4
    

    Before the second result was a plain vector, not a (3 4).

  • Add context in conversion failures.

     (2 2 rho 1) transp (2 2 rho 1)
     transp: cannot convert matrix to vector
    

    (The "transp: " is new.)

  • Implement sel on matrices. Formerly only worked on vectors.

    2 0 1 sel (2 3 rho iota 6)
        1 1 3
        4 4 6
    

    Following APL X/Y, sel applies to last axis. Can get first (X⌿Y) easily using transpose.

  • Implement take and drop on matrices. Formerly only worked on vectors.

     -1 2 take 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
     2 -2 drop 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
  • Don't overparenthesize x[1] in )op display.

     op f x = x[1] + x[2]
     )op f
         op f x = x[1] + x[2]
    

    Used to print (x[1]).

push

rsc push rsc/ivy

rsc
rsc

ivy: generalize catenate for matrix

Catenate on vector has always handled all combinations of vectors and scalars, like:

1, 2 3 4 5
1 2 3 4, 1
1 2, 3 4 4

because scalars are implicit promoted to vector.

Matrix catenation has only allowed a specific shape combination, namely a matrix adding a single element. In terms of shapes:

(n ...), (...) -> (n+1 ...)

Per [1], APL's catenate generalizes to allow other combinations too. Implement those rules:

(n ...), (...) -> (n+1 ...)  # list, elem
(...), (n ...) -> (n+1 ...)  # elem, list
(n ...), (m ...) -> (n+m ...)  # list, list
(1), (n ...) -> (n+1 ...)  # scalar (extended), list
(n ...), (1) -> (n+1 ...)  # list, scalar (extended)

See testdata/binary_matrix.ivy for examples.

[1] https://help.dyalog.com/17.1/index.htm#Language/Primitive%20Functions/Catenate%20Laminate.htm

rsc
rsc

ivy: preserve shape of left argument of 'in'

Per https://aplwiki.com/wiki/Membership, in preserves the shape of the left argument, so that these both produce a 3x4 matrix:

(3 4 rho iota 12) == 4 (3 4 rho iota 12) in 4

Before this change, the latter was producing a vector of length 12.

rsc
rsc

ivy: give context in conversion failures

For example, transp requires a vector on the left:

(2 2 rho 1) transp (2 2 rho 1)
transp: cannot convert matrix to vector

is better than (deep in some expression):

(2 2 rho 1) transp (2 2 rho 1)
cannot convert matrix to vector
rsc
rsc

ivy: implement multidimensional sel

Made sel match APL X/Y, applying to last axis. (The APL X⌿Y can be had with transp X sel transp Y.)

rsc
rsc

ivy: implement multidimensional take, drop

-1 2 take 3 4 5 rho iota 60
	41 42 43 44 45
	46 47 48 49 50

2 -2 drop 3 4 5 rho iota 60
	41 42 43 44 45
	46 47 48 49 50
rsc
rsc

ivy: do not overparenthesize x[1] nested in larger expressions

op f x = x[1] + x[2]
)op f
	op f x = x[1] + x[2]

Used to print (x[1]) + x[2].

commit sha: 883733b84c3c0d25e60f5ddae6f93c6f962add35

push time in 1 day ago
Dec
6
2 days ago
Activity icon
wiki
created time in 1 day ago
pull request

rsc pull request robpike/ivy

rsc
rsc

ivy: various matrix-related improvements

Seven commits. Probably easiest to read the commits individually.

  • Add dyadic transpose, like 1 3 2 (3 4 5 rho 24):

    1 3 2 transp 2 3 4 rho iota 24
     1  5  9
     2  6 10
     3  7 11
     4  8 12
    
    13 17 21
    14 18 22
    15 19 23
    16 20 24
    
  • Generalize catenate on matrices to handle existing vector generalizations, following APL semantics. Vectors have always handled combinations of scalars and vectors:

     1, 2 3 4 5
     1 2 3 4, 1
     1 2, 3 4 4
    

    But matrices have had shape (n ...), (...) -> (n+1 ...) only (single element append). Added:

     (n ...), (...) -> (n+1 ...)  # list, elem
     (...), (n ...) -> (n+1 ...)  # elem, list
     (n ...), (m ...) -> (n+m ...)  # list, list
     (1), (n ...) -> (n+1 ...)  # scalar (extended), list
     (n ...), (1) -> (n+1 ...)  # list, scalar (extended)
    
  • Preserve shape of left argument in 'in'. Now these two have the same result:

     (3 4 rho iota 12) == 4
     (3 4 rho iota 12) in 4
    

    Before the second result was a plain vector, not a (3 4).

  • Add context in conversion failures.

     (2 2 rho 1) transp (2 2 rho 1)
     transp: cannot convert matrix to vector
    

    (The "transp: " is new.)

  • Implement sel on matrices. Formerly only worked on vectors.

    2 0 1 sel (2 3 rho iota 6)
        1 1 3
        4 4 6
    

    Following APL X/Y, sel applies to last axis. Can get first (X⌿Y) easily using transpose.

  • Implement take and drop on matrices. Formerly only worked on vectors.

     -1 2 take 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
     2 -2 drop 3 4 5 rho iota 60
             41 42 43 44 45
             46 47 48 49 50
    
  • Don't overparenthesize x[1] in )op display.

     op f x = x[1] + x[2]
     )op f
         op f x = x[1] + x[2]
    

    Used to print (x[1]).

push

rsc push rsc/ivy

rsc
rsc

Merge pull request #67 from rsc/master

ivy: fix buggy interaction between take and comma

rsc
rsc

ivy: generalize catenate for matrix

Catenate on vector has always handled all combinations of vectors and scalars, like:

1, 2 3 4 5
1 2 3 4, 1
1 2, 3 4 4

because scalars are implicit promoted to vector.

Matrix catenation has only allowed a specific shape combination, namely a matrix adding a single element. In terms of shapes:

(n ...), (...) -> (n+1 ...)

Per [1], APL's catenate generalizes to allow other combinations too. Implement those rules:

(n ...), (...) -> (n+1 ...)  # list, elem
(...), (n ...) -> (n+1 ...)  # elem, list
(n ...), (m ...) -> (n+m ...)  # list, list
(1), (n ...) -> (n+1 ...)  # scalar (extended), list
(n ...), (1) -> (n+1 ...)  # list, scalar (extended)

See testdata/binary_matrix.ivy for examples.

[1] https://help.dyalog.com/17.1/index.htm#Language/Primitive%20Functions/Catenate%20Laminate.htm

rsc
rsc

ivy: preserve shape of left argument of 'in'

Per https://aplwiki.com/wiki/Membership, in preserves the shape of the left argument, so that these both produce a 3x4 matrix:

(3 4 rho iota 12) == 4 (3 4 rho iota 12) in 4

Before this change, the latter was producing a vector of length 12.

rsc
rsc

ivy: give context in conversion failures

For example, transp requires a vector on the left:

(2 2 rho 1) transp (2 2 rho 1)
transp: cannot convert matrix to vector

is better than (deep in some expression):

(2 2 rho 1) transp (2 2 rho 1)
cannot convert matrix to vector
rsc
rsc

ivy: implement multidimensional sel

Made sel match APL X/Y, applying to last axis. (The APL X⌿Y can be had with transp X sel transp Y.)

rsc
rsc

ivy: implement multidimensional take, drop

-1 2 take 3 4 5 rho iota 60
	41 42 43 44 45
	46 47 48 49 50

2 -2 drop 3 4 5 rho iota 60
	41 42 43 44 45
	46 47 48 49 50
rsc
rsc

ivy: do not overparenthesize x[1] nested in larger expressions

op f x = x[1] + x[2]
)op f
	op f x = x[1] + x[2]

Used to print (x[1]) + x[2].

commit sha: 6b81af641b23b304dfdad49dda2febf09c290b58

push time in 1 day ago
Previous