Skip to content

Commit 37e904e

Browse files
committed
Merge branch 'develop' of https://github.com/stdlib-js/stdlib into develop
2 parents a2c3eb0 + a6eb07f commit 37e904e

File tree

9 files changed

+336
-0
lines changed

9 files changed

+336
-0
lines changed

lib/node_modules/@stdlib/array/base/README.md

+9
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ The namespace exports the following:
5151
- <span class="signature">[`accessors( x )`][@stdlib/array/base/accessors]</span><span class="delimiter">: </span><span class="description">return element accessors for a provided array-like object.</span>
5252
- <span class="signature">[`arraylike2object( x )`][@stdlib/array/base/arraylike2object]</span><span class="delimiter">: </span><span class="description">convert an array-like object to an object likely to have the same "shape".</span>
5353
- <span class="signature">[`assert`][@stdlib/array/base/assert]</span><span class="delimiter">: </span><span class="description">base array assertion utilities.</span>
54+
- <span class="signature">[`bifurcateEntries( x, filter )`][@stdlib/array/base/bifurcate-entries]</span><span class="delimiter">: </span><span class="description">split array element entries into two groups.</span>
55+
- <span class="signature">[`bifurcateIndices( x, filter )`][@stdlib/array/base/bifurcate-indices]</span><span class="delimiter">: </span><span class="description">split array element indices into two groups.</span>
56+
- <span class="signature">[`bifurcateValues( x, filter )`][@stdlib/array/base/bifurcate-values]</span><span class="delimiter">: </span><span class="description">split array element values into two groups.</span>
5457
- <span class="signature">[`binary2d( arrays, shape, fcn )`][@stdlib/array/base/binary2d]</span><span class="delimiter">: </span><span class="description">apply a binary callback to elements in two two-dimensional nested input arrays and assign results to elements in a two-dimensional nested output array.</span>
5558
- <span class="signature">[`binary3d( arrays, shape, fcn )`][@stdlib/array/base/binary3d]</span><span class="delimiter">: </span><span class="description">apply a binary callback to elements in two three-dimensional nested input arrays and assign results to elements in a three-dimensional nested output array.</span>
5659
- <span class="signature">[`binary4d( arrays, shape, fcn )`][@stdlib/array/base/binary4d]</span><span class="delimiter">: </span><span class="description">apply a binary callback to elements in two four-dimensional nested input arrays and assign results to elements in a four-dimensional nested output array.</span>
@@ -224,6 +227,12 @@ console.log( objectKeys( ns ) );
224227

225228
[@stdlib/array/base/assert]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/assert
226229

230+
[@stdlib/array/base/bifurcate-entries]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/bifurcate-entries
231+
232+
[@stdlib/array/base/bifurcate-indices]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/bifurcate-indices
233+
234+
[@stdlib/array/base/bifurcate-values]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/bifurcate-values
235+
227236
[@stdlib/array/base/binary2d]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/binary2d
228237

229238
[@stdlib/array/base/binary3d]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/binary3d

lib/node_modules/@stdlib/array/complex128/README.md

+17
Original file line numberDiff line numberDiff line change
@@ -1769,6 +1769,23 @@ im = imag( z );
17691769
// returns 6.0
17701770
```
17711771

1772+
<a name="method-to-string"></a>
1773+
1774+
#### Complex128Array.prototype.toString()
1775+
1776+
Serializes an array as a string.
1777+
1778+
```javascript
1779+
var arr = new Complex128Array( 3 );
1780+
1781+
arr.set( [ 1.0, 1.0 ], 0 );
1782+
arr.set( [ 2.0, -2.0 ], 1 );
1783+
arr.set( [ 3.0, 3.0 ], 2 );
1784+
1785+
var str = arr.toString();
1786+
// returns '1 + 1i,2 - 2i,3 + 3i'
1787+
```
1788+
17721789
</section>
17731790

17741791
<!-- /.usage -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2023 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var pkg = require( './../package.json' ).name;
25+
var Complex128Array = require( './../lib' );
26+
27+
28+
// MAIN //
29+
30+
bench( pkg+':toString', function benchmark( b ) {
31+
var out;
32+
var arr;
33+
var i;
34+
35+
arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] );
36+
37+
b.tic();
38+
for ( i = 0; i < b.iterations; i++ ) {
39+
out = arr.toString();
40+
if ( typeof out !== 'string' ) {
41+
b.fail( 'should return a string' );
42+
}
43+
}
44+
b.toc();
45+
if ( typeof out !== 'string' ) {
46+
b.fail( 'should return a string' );
47+
}
48+
b.pass( 'benchmark finished' );
49+
b.end();
50+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2023 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var pow = require( '@stdlib/math/base/special/pow' );
25+
var Complex128 = require( '@stdlib/complex/float64' );
26+
var pkg = require( './../package.json' ).name;
27+
var Complex128Array = require( './../lib' );
28+
29+
30+
// FUNCTIONS //
31+
32+
/**
33+
* Creates a benchmark function.
34+
*
35+
* @private
36+
* @param {PositiveInteger} len - array length
37+
* @returns {Function} benchmark function
38+
*/
39+
function createBenchmark( len ) {
40+
var arr;
41+
var i;
42+
43+
arr = [];
44+
for ( i = 0; i < len; i++ ) {
45+
arr.push( new Complex128( i, i ) );
46+
}
47+
arr = new Complex128Array( arr );
48+
49+
return benchmark;
50+
51+
/**
52+
* Benchmark function.
53+
*
54+
* @private
55+
* @param {Benchmark} b - benchmark instance
56+
*/
57+
function benchmark( b ) {
58+
var out;
59+
var i;
60+
61+
b.tic();
62+
for ( i = 0; i < b.iterations; i++ ) {
63+
out = arr.toString();
64+
if ( typeof out !== 'string' ) {
65+
b.fail( 'should return a string' );
66+
}
67+
}
68+
b.toc();
69+
if ( typeof out !== 'string' ) {
70+
b.fail( 'should return a string' );
71+
}
72+
b.pass( 'benchmark finished' );
73+
b.end();
74+
}
75+
}
76+
77+
78+
// MAIN //
79+
80+
/**
81+
* Main execution sequence.
82+
*
83+
* @private
84+
*/
85+
function main() {
86+
var len;
87+
var min;
88+
var max;
89+
var f;
90+
var i;
91+
92+
min = 1; // 10^min
93+
max = 6; // 10^max
94+
95+
for ( i = min; i <= max; i++ ) {
96+
len = pow( 10, i );
97+
f = createBenchmark( len );
98+
bench( pkg+':toString:len='+len, f );
99+
}
100+
}
101+
102+
main();

lib/node_modules/@stdlib/array/complex128/docs/types/index.d.ts

+16
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,22 @@ declare class Complex128Array implements Complex128ArrayInterface {
909909
* // returns -3.0
910910
*/
911911
subarray( begin?: number, end?: number ): Complex64Array;
912+
913+
/**
914+
* Serializes an array as a string.
915+
*
916+
* @returns string
917+
*
918+
* @example
919+
* var arr = new Complex128Array( 2 );
920+
*
921+
* arr.set( [ 1.0, 1.0 ], 0 );
922+
* arr.set( [ 2.0, 2.0 ], 1 );
923+
*
924+
* var str = arr.toString();
925+
* // returns '1 + 1i,2 + 2i'
926+
*/
927+
toString(): string;
912928
}
913929

914930
/**

lib/node_modules/@stdlib/array/complex128/lib/main.js

+33
Original file line numberDiff line numberDiff line change
@@ -1945,6 +1945,39 @@ setReadOnly( Complex128Array.prototype, 'subarray', function subarray( begin, en
19451945
return new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len );
19461946
});
19471947

1948+
/**
1949+
* Serializes an array as a string.
1950+
*
1951+
* @name toString
1952+
* @memberof Complex128Array.prototype
1953+
* @type {Function}
1954+
* @throws {TypeError} `this` must be a complex number array
1955+
* @returns {string} string representation
1956+
*
1957+
* @example
1958+
* var arr = new Complex128Array( 2 );
1959+
*
1960+
* arr.set( [ 1.0, 1.0 ], 0 );
1961+
* arr.set( [ 2.0, 2.0 ], 1 );
1962+
*
1963+
* var str = arr.toString();
1964+
* // returns '1 + 1i,2 + 2i'
1965+
*/
1966+
setReadOnly( Complex128Array.prototype, 'toString', function toString() {
1967+
var out;
1968+
var buf;
1969+
var i;
1970+
if ( !isComplexArray( this ) ) {
1971+
throw new TypeError( 'invalid invocation. `this` is not a complex number array.' );
1972+
}
1973+
out = [];
1974+
buf = this._buffer;
1975+
for ( i = 0; i < this._length; i++ ) {
1976+
out.push( getComplex128( buf, i ).toString() );
1977+
}
1978+
return out.join( ',' );
1979+
});
1980+
19481981

19491982
// EXPORTS //
19501983

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2023 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var tape = require( 'tape' );
24+
var hasOwnProp = require( '@stdlib/assert/has-own-property' );
25+
var isFunction = require( '@stdlib/assert/is-function' );
26+
var Complex128Array = require( './../lib' );
27+
28+
29+
// TESTS //
30+
31+
tape( 'main export is a function', function test( t ) {
32+
t.ok( true, __filename );
33+
t.strictEqual( typeof Complex128Array, 'function', 'main export is a function' );
34+
t.end();
35+
});
36+
37+
tape( 'attached to the prototype of the main export is a `toString` method', function test( t ) {
38+
t.strictEqual( hasOwnProp( Complex128Array.prototype, 'toString' ), true, 'has property' );
39+
t.strictEqual( isFunction( Complex128Array.prototype.toString ), true, 'has method' );
40+
t.end();
41+
});
42+
43+
tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) {
44+
var values;
45+
var arr;
46+
var i;
47+
48+
arr = new Complex128Array( 5 );
49+
50+
values = [
51+
'5',
52+
5,
53+
NaN,
54+
true,
55+
false,
56+
null,
57+
void 0,
58+
{},
59+
[],
60+
function noop() {}
61+
];
62+
for ( i = 0; i < values.length; i++ ) {
63+
t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );
64+
}
65+
t.end();
66+
67+
function badValue( value ) {
68+
return function badValue() {
69+
return arr.toString.call( value );
70+
};
71+
}
72+
});
73+
74+
tape( 'the method returns an empty string if invoked on an empty array', function test( t ) {
75+
var str;
76+
var arr;
77+
78+
arr = new Complex128Array();
79+
str = arr.toString();
80+
81+
t.strictEqual( str, '', 'returns expected value' );
82+
t.end();
83+
});
84+
85+
tape( 'the method returns a string representation of a complex number array', function test( t ) {
86+
var expected;
87+
var str;
88+
var arr;
89+
90+
arr = new Complex128Array( [ 1, 2, -3, -4 ] );
91+
expected = '1 + 2i,-3 - 4i';
92+
93+
str = arr.toString();
94+
95+
t.strictEqual( str, expected, 'returns expected value' );
96+
t.end();
97+
});

lib/node_modules/@stdlib/ndarray/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ In addition, the namespace contains the following multidimensional array utility
8383
- <span class="signature">[`ndemptyLike( x[, options] )`][@stdlib/ndarray/empty-like]</span><span class="delimiter">: </span><span class="description">create an uninitialized ndarray having the same shape and data type as a provided ndarray.</span>
8484
- <span class="signature">[`ndempty( shape[, options] )`][@stdlib/ndarray/empty]</span><span class="delimiter">: </span><span class="description">create an uninitialized ndarray having a specified shape and data type.</span>
8585
- <span class="signature">[`FancyArray( dtype, buffer, shape, strides, offset, order[, options] )`][@stdlib/ndarray/fancy]</span><span class="delimiter">: </span><span class="description">fancy multidimensional array constructor.</span>
86+
- <span class="signature">[`ndarrayFlag( x, name )`][@stdlib/ndarray/flag]</span><span class="delimiter">: </span><span class="description">return a specified flag for a provided ndarray.</span>
87+
- <span class="signature">[`ndarrayFlags( x )`][@stdlib/ndarray/flags]</span><span class="delimiter">: </span><span class="description">return the flags of a provided ndarray.</span>
8688
- <span class="signature">[`scalar2ndarray( value[, options] )`][@stdlib/ndarray/from-scalar]</span><span class="delimiter">: </span><span class="description">convert a scalar value to a zero-dimensional ndarray.</span>
8789
- <span class="signature">[`ind2sub( shape, idx[, options] )`][@stdlib/ndarray/ind2sub]</span><span class="delimiter">: </span><span class="description">convert a linear index to an array of subscripts.</span>
8890
- <span class="signature">[`ndarrayIndexModes()`][@stdlib/ndarray/index-modes]</span><span class="delimiter">: </span><span class="description">list of ndarray index modes.</span>
@@ -180,6 +182,10 @@ console.log( objectKeys( ns ) );
180182

181183
[@stdlib/ndarray/fancy]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/fancy
182184

185+
[@stdlib/ndarray/flag]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/flag
186+
187+
[@stdlib/ndarray/flags]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/flags
188+
183189
[@stdlib/ndarray/from-scalar]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/from-scalar
184190

185191
[@stdlib/ndarray/ind2sub]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/ind2sub

0 commit comments

Comments
 (0)