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
Copy file name to clipboardExpand all lines: lib/node_modules/@stdlib/blas/ext/join-between/README.md
+49-34Lines changed: 49 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,60 +30,56 @@ limitations under the License.
30
30
var joinBetween =require( '@stdlib/blas/ext/join-between' );
31
31
```
32
32
33
-
#### joinBetween( x\[, options] )
33
+
#### joinBetween( x, separators\[, options] )
34
34
35
35
Returns an [ndarray][@stdlib/ndarray/ctor] created by joining elements using specified separators for each pair of consecutive elements along one or more [ndarray][@stdlib/ndarray/ctor] dimensions.
36
36
37
37
```javascript
38
38
var array =require( '@stdlib/ndarray/array' );
39
+
var scalar2ndarray =require( '@stdlib/ndarray/from-scalar' );
-**separators**: separators [ndarray][@stdlib/ndarray/ctor]. Must be [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the shape consisting of the complement of the shape defined by `options.dims` followed by `N-1` where `N` is the number of elements along the reduced dimensions.
52
59
-**options**: function options (_optional_).
53
60
54
61
The function accepts the following options:
55
62
56
-
-**prefix**: prefix to prepend to each joined string. Default: `''`.
57
-
-**suffix**: suffix to append to each joined string. Default: `''`.
58
-
-**separators**: separators. Must be an array-like object. When provided an array containing a single element, the same separator is used between all consecutive pairs of elements. When containing multiple elements, each element specifies the separator to use between consecutive pairs, and the number of elements must equal one less than the number of elements along the reduced dimensions. Default: `[ ',' ]`.
63
+
-**prefix**: prefix to prepend to each joined string. May be a scalar value or an [ndarray][@stdlib/ndarray/ctor] which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the complement of the shape defined by `options.dims`. Default: `''`.
64
+
-**suffix**: suffix to append to each joined string. May be a scalar value or an [ndarray][@stdlib/ndarray/ctor] which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the complement of the shape defined by `options.dims`. Default: `''`.
59
65
-**dims**: list of dimensions over which to perform operation. If not provided, the function performs the operation over all elements in a provided input [ndarray][@stdlib/ndarray/ctor].
60
66
-**keepdims**: boolean indicating whether the reduced dimensions should be included in the returned [ndarray][@stdlib/ndarray/ctor] as singleton dimensions. Default: `false`.
61
67
62
-
By default, the function joins [ndarray][@stdlib/ndarray/ctor] elements by using `,` as a separator between all consecutive pairs of elements. To perform the operation with a different separator, provide a `separators` option.
68
+
To specify a prefix and suffix to prepend and append to each joined string, provide `prefix` and `suffix` options.
63
69
64
70
```javascript
65
71
var array =require( '@stdlib/ndarray/array' );
72
+
var scalar2ndarray =require( '@stdlib/ndarray/from-scalar' );
66
73
67
74
var x =array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
68
75
69
-
varout=joinBetween( x, {
70
-
'separators':[ '|' ]
76
+
varsep=scalar2ndarray( ', ', {
77
+
'dtype':'generic'
71
78
});
72
-
// returns <ndarray>[ '1|2|3|4|5|6' ]
73
-
```
74
79
75
-
To specify a prefix and suffix to prepend and append to each joined string, provide `prefix` and `suffix` options.
76
-
77
-
```javascript
78
-
var array =require( '@stdlib/ndarray/array' );
79
-
80
-
var x =array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
81
-
// returns <ndarray>[ 1, 2, 3, 4, 5, 6 ]
82
-
83
-
var out =joinBetween( x, {
80
+
var out =joinBetween( x, sep, {
84
81
'prefix':'[ ',
85
-
'suffix':' ]',
86
-
'separators': [ ', ' ]
82
+
'suffix':' ]'
87
83
});
88
84
// returns <ndarray>[ '[ 1, 2, 3, 4, 5, 6 ]' ]
89
85
```
@@ -92,32 +88,45 @@ By default, the function performs the operation over all elements in a provided
92
88
93
89
```javascript
94
90
var array =require( '@stdlib/ndarray/array' );
91
+
var scalar2ndarray =require( '@stdlib/ndarray/from-scalar' );
By default, the function excludes reduced dimensions from the output [ndarray][@stdlib/ndarray/ctor]. To include the reduced dimensions as singleton dimensions, set the `keepdims` option to `true`.
106
111
107
112
```javascript
108
113
var array =require( '@stdlib/ndarray/array' );
114
+
var scalar2ndarray =require( '@stdlib/ndarray/from-scalar' );
Joins elements of an input [ndarray][@stdlib/ndarray/ctor] using specified separators for each pair of consecutive elements along one or more [ndarray][@stdlib/ndarray/ctor] dimensions and assigns results to a provided output [ndarray][@stdlib/ndarray/ctor].
123
132
@@ -126,11 +135,14 @@ var array = require( '@stdlib/ndarray/array' );
126
135
var scalar2ndarray =require( '@stdlib/ndarray/from-scalar' );
127
136
128
137
var x =array( [ 1.0, 2.0, 3.0, 4.0 ] );
138
+
var sep =scalar2ndarray( ',', {
139
+
'dtype':'generic'
140
+
});
129
141
var y =scalar2ndarray( '', {
130
142
'dtype':'generic'
131
143
});
132
144
133
-
var out =joinBetween.assign( x, y );
145
+
var out =joinBetween.assign( x, sep, y );
134
146
// returns <ndarray>[ '1,2,3,4' ]
135
147
136
148
var bool = ( out === y );
@@ -140,14 +152,14 @@ var bool = ( out === y );
140
152
The method has the following parameters:
141
153
142
154
-**x**: input [ndarray][@stdlib/ndarray/ctor].
155
+
-**separators**: separators [ndarray][@stdlib/ndarray/ctor]. Must be [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the shape consisting of the complement of the shape defined by `options.dims` followed by `N-1` where `N` is the number of elements along the reduced dimensions.
143
156
-**out**: output [ndarray][@stdlib/ndarray/ctor].
144
157
-**options**: function options (_optional_).
145
158
146
159
The method accepts the following options:
147
160
148
-
-**prefix**: prefix to prepend to each joined string. Default: `''`.
149
-
-**suffix**: suffix to append to each joined string. Default: `''`.
150
-
-**separators**: separators. Must be an array-like object. When provided an array containing a single element, the same separator is used between all consecutive pairs of elements. When containing multiple elements, each element specifies the separator to use between consecutive pairs, and the number of elements must equal one less than the number of elements along the reduced dimensions. Default: `[ ',' ]`.
161
+
-**prefix**: prefix to prepend to each joined string. May be a scalar value or an [ndarray][@stdlib/ndarray/ctor] which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the complement of the shape defined by `options.dims`. Default: `''`.
162
+
-**suffix**: suffix to append to each joined string. May be a scalar value or an [ndarray][@stdlib/ndarray/ctor] which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the complement of the shape defined by `options.dims`. Default: `''`.
151
163
-**dims**: list of dimensions over which to perform operation. If not provided, the function performs the operation over all elements in a provided input [ndarray][@stdlib/ndarray/ctor].
152
164
153
165
</section>
@@ -159,7 +171,6 @@ The method accepts the following options:
159
171
## Notes
160
172
161
173
- Setting the `keepdims` option to `true` can be useful when wanting to ensure that the output [ndarray][@stdlib/ndarray/ctor] is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with ndarrays having the same shape as the input [ndarray][@stdlib/ndarray/ctor].
162
-
- When providing an array containing multiple separators, each element specifies the separator to use between consecutive pairs. The same separators are used for every complement position when reducing specific dimensions.
163
174
164
175
</section>
165
176
@@ -172,18 +183,22 @@ The method accepts the following options:
172
183
<!-- eslint no-undef: "error" -->
173
184
174
185
```javascript
186
+
var scalar2ndarray =require( '@stdlib/ndarray/from-scalar' );
175
187
var uniform =require( '@stdlib/random/uniform' );
176
188
var ndarray2array =require( '@stdlib/ndarray/to-array' );
177
189
var joinBetween =require( '@stdlib/blas/ext/join-between' );
0 commit comments