Socket
Book a DemoInstallSign in
Socket

ndarray-unsqueeze

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ndarray-unsqueeze

Add singleton dimensions to an ndarray

latest
Source
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

ndarray-unsqueeze Build Status npm version js-standard-style

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 = require('ndarray')
var unsqueeze = require('ndarray-unsqueeze')

unsqueeze(ndarray([1, 2, 3, 4], [2, 2]))
// => ndarray([1, 2, 3, 4], [2, 2, 1])

unsqueeze(ndarray([1, 2, 3, 4], [2, 2]), 0)
// => 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 = require('ndarray-show')

// Create a 3 x 1 matrix by appending a singleton dimension:
show(unsqueeze(ndarray([1,2,3])))
// => 1.000
//    2.000
//    3.000

// Create a 1 x 3 matrix by prepending a singleton dimension:
show(unsqueeze(ndarray([1,2,3]), 0))
// => 1.000  2.000  3.000

Installation

$ npm install ndarray-unsqueeze

API

require('ndarray-unsqueeze')(input[, axis])

Arguments:

  • input: The input ndarray to be unsqueeze
  • axes (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.

Keywords

ndarray

FAQs

Package last updated on 04 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts