Initialize an array of arrays to a constant
Want to see pretty graphs? Log in now!
npm install dup
|3||downloads in the last day|
|14||downloads in the last week|
|51||downloads in the last month|
|Last Published By|
|Version||0.0.0 last updated a year ago|
|Keywords||dup, initialize, array, constant, numeric, rep, zeros, matlab, clear, ndarray, grid, matrix, vector, tensor|
|Dependents (13)||continuous-observer, cube-mesh, gl-shader-core, grid-mesh, least-common-ancestor, mikolalysenko-hoarders, ndarray-gaussian-filter, ndarray-stencil, ndarray-unpack, planar-dual, rectangle-decomposition, symmetric-tensor-to-string, typedarray-pool|
Initializes an n-dimensional array to a constant value.
npm install dup
var dup = require("dup") console.log(dup(5)) //Prints: // // [0, 0, 0, 0, 0] // console.log(dup([3,2], 1)) //Prints: // // [[1, 1], // [1, 1], // [1, 1]] //
Initializes an array to a constant value
shapeEither an array of dimensions or a scalar, representing the shape of the array to create.
valueThe value to initialize the array with. Default is 0
Returns An n-dimensional array with the given shape and value
I often find myself using numeric.js'
rep method in my projects. However, for many things pulling in all of numeric.js is total overkill, especially for code that ultimately needs to run on the browser. So I decided to make this library which just implements the
rep and nothing else in the spirit of promoting modularity by smaller and more numerous packages.
(c) 2013 Mikola Lysenko. MIT License