Add singleton dimensions to an ndarray
Introduction
This module takes an input ndarray and either appends a singleton dimension (a dimension of length one) or inserts it before a specific dimension.
Examples
var ndarray = var unsqueeze = // => ndarray([1, 2, 3, 4], [2, 2, 1]) // => ndarray([1, 2, 3, 4], [1, 2, 2])
Note that ndarrays have no concept of row or column vectors. If you need a matrix explicitly representing a row or column vector, you can use unsqueeze:
var show = // Create a 3 x 1 matrix by appending a singleton dimension:// => 1.000// 2.000// 3.000 // Create a 1 x 3 matrix by prepending a singleton dimension:// => 1.000 2.000 3.000
Installation
$ npm install ndarray-unsqueeze
API
require('ndarray-unsqueeze')(input[, axis])
Arguments:
input
: The input ndarray to be unsqueezeaxes
(optional): An integer index of the dimension at which to insert the singleton dimension. If unspecified, singleton dimension is appended to the shape.
Returns: A new array view of the unsqueezed ndarray (i.e. a new ndarray object with the same underlying data).
See Also
License
© 2016 Ricky Reusser. MIT License.