Last active
March 3, 2018 15:56
-
-
Save mratsim/c03fe1ce187f4b0cb23ad694c06fcfe4 to your computer and use it in GitHub Desktop.
slice demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import math, arraymancer | |
| const | |
| x = @[1, 2, 3, 4, 5] | |
| y = @[1, 2, 3, 4, 5] | |
| var | |
| vandermonde: seq[seq[int]] | |
| row: seq[int] | |
| vandermonde = newSeq[seq[int]]() | |
| for i, xx in x: | |
| row = newSeq[int]() | |
| vandermonde.add(row) | |
| for j, yy in y: | |
| vandermonde[i].add(xx^yy) | |
| let foo = vandermonde.toTensor() | |
| echo foo | |
| # Tensor of shape 5x5 of type "int" on backend "Cpu" | |
| # |1 1 1 1 1| | |
| # |2 4 8 16 32| | |
| # |3 9 27 81 243| | |
| # |4 16 64 256 1024| | |
| # |5 25 125 625 3125| | |
| let t = 2 | |
| echo foo[1..^2, t] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment