You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...
Copy file name to clipboardExpand all lines: any/lib/main.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -127,7 +127,7 @@ function any( x, options ) {
127
127
128
128
// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...
Copy file name to clipboardExpand all lines: base/binary-reduce-strided1d-dispatch/lib/main.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -364,7 +364,7 @@ setReadOnly( BinaryStrided1dDispatch.prototype, 'apply', function apply( x, y )
364
364
365
365
// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...
Copy file name to clipboardExpand all lines: base/spread-dimensions/README.md
+13-5Lines changed: 13 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,7 +40,7 @@ limitations under the License.
40
40
var spreadDimensions =require( '@stdlib/ndarray/base/spread-dimensions' );
41
41
```
42
42
43
-
#### spreadDimensions( ndims, x, dims )
43
+
#### spreadDimensions( ndims, x, dims, writable )
44
44
45
45
Expands the shape of an array to a specified dimensionality by spreading its dimensions to specified dimension indices and inserting dimensions of size one for the remaining dimensions.
46
46
@@ -53,7 +53,7 @@ var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );
53
53
// returns <ndarray>
54
54
55
55
// Prepend a singleton dimension:
56
-
var y =spreadDimensions( 3, x, [ 1, 2 ] );
56
+
var y =spreadDimensions( 3, x, [ 1, 2 ], false );
57
57
// returns <ndarray>
58
58
59
59
var sh =y.shape;
@@ -63,7 +63,7 @@ var a = ndarray2array( y );
63
63
// returns [ [ [ 1, 2 ], [ 3, 4 ] ] ]
64
64
65
65
// Append a singleton dimension:
66
-
y =spreadDimensions( 3, x, [ 0, 1 ] );
66
+
y =spreadDimensions( 3, x, [ 0, 1 ], false );
67
67
// returns <ndarray>
68
68
69
69
sh =y.shape;
@@ -73,7 +73,7 @@ a = ndarray2array( y );
73
73
// returns [ [ [ 1 ], [ 2 ] ], [ [ 3 ], [ 4 ] ] ]
74
74
75
75
// Insert a singleton dimension:
76
-
y =spreadDimensions( 3, x, [ 0, 2 ] );
76
+
y =spreadDimensions( 3, x, [ 0, 2 ], false );
77
77
// returns <ndarray>
78
78
79
79
sh =y.shape;
@@ -83,6 +83,13 @@ a = ndarray2array( y );
83
83
// returns [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]
84
84
```
85
85
86
+
The function accepts the following arguments:
87
+
88
+
-**ndims**: number of dimensions in the output ndarray. Must be greater than or equal to the number of dimensions in the input ndarray.
89
+
-**x**: input ndarray.
90
+
-**dims**: dimension indices specifying where to place the dimensions of the input ndarray. Must resolve to normalized indices arranged in ascending order.
91
+
-**writable**: boolean indicating whether a returned ndarray should be writable.
92
+
86
93
</section>
87
94
88
95
<!-- /.usage -->
@@ -95,6 +102,7 @@ a = ndarray2array( y );
95
102
96
103
- Each provided dimension index must reside on the interval `[-ndims, ndims-1]`. If provided a negative dimension index, the position at which to place a respective dimension is computed as `ndims + index`.
97
104
- Provided dimension indices must resolve to normalized dimension indices arranged in ascending order.
105
+
- The `writable` parameter **only** applies to ndarray constructors supporting **read-only** instances.
98
106
99
107
</section>
100
108
@@ -121,7 +129,7 @@ var x = array( [ [ 1, 2 ], [ 3, 4 ] ], {
0 commit comments