Skip to content

Commit

Permalink
ivy: add tests for matrix indexing
Browse files Browse the repository at this point in the history
Change-Id: I09a4c98c9d21ae3686fcb76abe0c2ae0bd058269
  • Loading branch information
robpike committed Dec 3, 2014
1 parent f1e9c71 commit 5a78716
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
24 changes: 24 additions & 0 deletions testdata/binary_matrix.ivy
Original file line number Diff line number Diff line change
Expand Up @@ -507,3 +507,27 @@
(2 3 rho iota 10)[2 1]
4 5 6
1 2 3

x = 3 4 5 rho iota 100
x[2]
21 22 23 24 25
26 27 28 29 30
31 32 33 34 35
36 37 38 39 40

x = 3 4 5 rho iota 100
x[3 2 1]
41 42 43 44 45
46 47 48 49 50
51 52 53 54 55
56 57 58 59 60

21 22 23 24 25
26 27 28 29 30
31 32 33 34 35
36 37 38 39 40

1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
4 changes: 2 additions & 2 deletions value/matrix.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ func (m Matrix) String() string {
var b bytes.Buffer
switch len(m.shape) {
case 0:
return ""
Errorf("matrix is scalar")
case 1:
return m.data.String()
Errorf("matrix is vector")
case 2:
nrows := int(m.shape[0].(Int))
ncols := int(m.shape[1].(Int))
Expand Down

0 comments on commit 5a78716

Please sign in to comment.