UNPKG

1.08 kBMarkdownView Raw
1<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
2
3# Function squeeze
4
5Squeeze a matrix, remove inner and outer singleton dimensions from a matrix.
6
7
8## Syntax
9
10```js
11math.squeeze(x)
12```
13
14### Parameters
15
16Parameter | Type | Description
17--------- | ---- | -----------
18`x` | Matrix &#124; Array | Matrix to be squeezed
19
20### Returns
21
22Type | Description
23---- | -----------
24Matrix &#124; Array | Squeezed matrix
25
26
27## Examples
28
29```js
30math.squeeze([3]) // returns 3
31math.squeeze([[3]]) // returns 3
32
33const A = math.zeros(3, 1) // returns [[0], [0], [0]] (size 3x1)
34math.squeeze(A) // returns [0, 0, 0] (size 3)
35
36const B = math.zeros(1, 3) // returns [[0, 0, 0]] (size 1x3)
37math.squeeze(B) // returns [0, 0, 0] (size 3)
38
39// only inner and outer dimensions are removed
40const C = math.zeros(2, 1, 3) // returns [[[0, 0, 0]], [[0, 0, 0]]] (size 2x1x3)
41math.squeeze(C) // returns [[[0, 0, 0]], [[0, 0, 0]]] (size 2x1x3)
42```
43
44
45## See also
46
47[subset](subset.md)