Created
April 7, 2019 05:30
-
-
Save singularitti/10f58924f9f8517d55a98c6a7d00c573 to your computer and use it in GitHub Desktop.
Make an array with linear spacing #JavaScript #array
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
| function linspace(shape, start, end, options) { | |
| /* | |
| If we use ndarray-linspace package, | |
| it returns a ndarray with dtype='array', | |
| but this dtype cannot be used by ndarray-tile package, it needs 'float'. | |
| So we need to transform dtype manually. | |
| */ | |
| let tmp = linspace(ndarray([], shape), start, end, options); | |
| return reshape(ndarray(new Float64Array(tmp.data)), shape); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment