Skip to content

Instantly share code, notes, and snippets.

@singularitti
Created April 7, 2019 05:30
Show Gist options
  • Save singularitti/10f58924f9f8517d55a98c6a7d00c573 to your computer and use it in GitHub Desktop.
Save singularitti/10f58924f9f8517d55a98c6a7d00c573 to your computer and use it in GitHub Desktop.
Make an array with linear spacing #JavaScript #array
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