Skip to content

Commit 28ee850

Browse files
authored
Merge branch 'stdlib-js:develop' into math-strided-real-typed-unary
2 parents ce2e22b + 93560b9 commit 28ee850

File tree

334 files changed

+33747
-661
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

334 files changed

+33747
-661
lines changed

CONTRIBUTORS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ EuniceSim142 <[email protected]>
2828
Frank Kovacs <[email protected]>
2929
Golden Kumar <[email protected]>
3030
Gunj Joshi <[email protected]>
31+
Gururaj Gurram <[email protected]>
3132
3233
Harshita Kalani <[email protected]>
3334
Hridyanshu <[email protected]>
@@ -44,6 +45,7 @@ Justin Dennison <[email protected]>
4445
Kaif Mohd <[email protected]>
4546
Karthik Prakash <[email protected]>
4647
48+
Kohantika Nath <[email protected]>
4749
Krishnendu Das <[email protected]>
4850
4951
Manik Sharma <[email protected]>
@@ -94,6 +96,7 @@ Tudor Pagu <[email protected]>
9496
Tufailahmed Bargir <[email protected]>
9597
Utkarsh <http://[email protected]>
9698
Utkarsh Raj <[email protected]>
99+
UtkershBasnet <[email protected]>
97100
Vaibhav Patel <[email protected]>
98101
Varad Gupta <[email protected]>
99102
Xiaochuan Ye <[email protected]>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
98bcc40ac8062635b492fb096d7815376a176ae26749d6c708083f4637f7c0bb
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
44f661e138065b7001afd544bffbe0e028a20e4c1de05d27daa658c99df2026b

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

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,74 @@ The namespace exports the following:
8383
<!-- eslint no-undef: "error" -->
8484

8585
```javascript
86-
var objectKeys = require( '@stdlib/utils/keys' );
8786
var ns = require( '@stdlib/array/base/assert' );
87+
var dtype = require( '@stdlib/array/dtype' );
88+
var Float64Array = require( '@stdlib/array/float64' );
89+
var Int32Array = require( '@stdlib/array/int32' );
90+
var Uint8Array = require( '@stdlib/array/uint8' );
91+
var Complex128Array = require( '@stdlib/array/complex128' );
8892

89-
console.log( objectKeys( ns ) );
93+
// Create various arrays:
94+
var arr1 = new Float64Array( [ 1.1, 2.2, 3.3 ] );
95+
var arr2 = new Int32Array( [ 1, 2, 3 ] );
96+
var arr3 = new Uint8Array( [ 1, 2, 3 ] );
97+
var arr4 = new Complex128Array( [ 1.0, 1.0, 2.0, 2.0 ] ); // two complex numbers: 1+1i, 2+2i
98+
99+
// Get data types:
100+
var dt1 = dtype( arr1 );
101+
var dt2 = dtype( arr2 );
102+
var dt3 = dtype( arr3 );
103+
var dt4 = dtype( arr4 );
104+
105+
// Check data types:
106+
console.log( dt1 + ' is floating-point data type: ' + ns.isFloatingPointDataType( dt1 ) );
107+
// => 'float64 is floating-point data type: true'
108+
109+
console.log( dt2 + ' is integer data type: ' + ns.isIntegerDataType( dt2 ) );
110+
// => 'int32 is integer data type: true'
111+
112+
console.log( dt3 + ' is unsigned integer data type: ' + ns.isUnsignedIntegerDataType( dt3 ) );
113+
// => 'uint8 is unsigned integer data type: true'
114+
115+
console.log( dt4 + ' is complex floating-point data type: ' + ns.isComplexFloatingPointDataType( dt4 ) );
116+
// => 'complex128 is complex floating-point data type: true'
117+
118+
// Check if arrays have the same values:
119+
console.log( 'arr2 and arr3 have same values: ' + ns.hasSameValues( arr2, arr3 ) );
120+
// => 'arr2 and arr3 have same values: true'
121+
122+
console.log( 'arr1 and arr2 have same values: ' + ns.hasSameValues( arr1, arr2 ) );
123+
// => 'arr1 and arr2 have same values: false'
124+
125+
// Check safe data type casts:
126+
console.log( 'Can safely cast from ' + dt2 + ' to ' + dt1 + ': ' + ns.isSafeDataTypeCast( dt2, dt1 ) );
127+
// => 'Can safely cast from int32 to float64: true'
128+
129+
console.log( 'Can safely cast from ' + dt1 + ' to ' + dt2 + ': ' + ns.isSafeDataTypeCast( dt1, dt2 ) );
130+
// => 'Can safely cast from float64 to int32: false'
131+
132+
console.log( 'Can safely cast from ' + dt3 + ' to ' + dt2 + ': ' + ns.isSafeDataTypeCast( dt3, dt2 ) );
133+
// => 'Can safely cast from uint8 to int32: true'
134+
135+
console.log( 'Can safely cast from ' + dt4 + ' to ' + dt1 + ': ' + ns.isSafeDataTypeCast( dt4, dt1 ) );
136+
// => 'Can safely cast from complex128 to float64: false'
137+
138+
// Check if arrays contain specific values:
139+
console.log( 'arr1 contains 2.2: ' + ns.contains( arr1, 2.2 ) );
140+
// => 'arr1 contains 2.2: true'
141+
142+
console.log( 'arr2 contains 2: ' + ns.contains( arr2, 2 ) );
143+
// => 'arr2 contains 2: true'
144+
145+
console.log( 'arr2 contains 2.2: ' + ns.contains( arr2, 2.2 ) );
146+
// => 'arr2 contains 2.2: false'
147+
148+
// Check complex array types:
149+
console.log( 'arr4 is Complex128Array: ' + ns.isComplex128Array( arr4 ) );
150+
// => 'arr4 is Complex128Array: true'
151+
152+
console.log( 'arr4 is complex typed array: ' + ns.isComplexTypedArray( arr4 ) );
153+
// => 'arr4 is complex typed array: true'
90154
```
91155

92156
</section>

lib/node_modules/@stdlib/array/base/assert/examples/index.js

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,71 @@
1818

1919
'use strict';
2020

21-
var objectKeys = require( '@stdlib/utils/keys' );
21+
var dtype = require( '@stdlib/array/dtype' );
22+
var Float64Array = require( '@stdlib/array/float64' );
23+
var Int32Array = require( '@stdlib/array/int32' );
24+
var Uint8Array = require( '@stdlib/array/uint8' );
25+
var Complex128Array = require( '@stdlib/array/complex128' );
2226
var ns = require( './../lib' );
2327

24-
console.log( objectKeys( ns ) );
28+
// Create various arrays:
29+
var arr1 = new Float64Array( [ 1.1, 2.2, 3.3 ] );
30+
var arr2 = new Int32Array( [ 1, 2, 3 ] );
31+
var arr3 = new Uint8Array( [ 1, 2, 3 ] );
32+
var arr4 = new Complex128Array( [ 1.0, 1.0, 2.0, 2.0 ] ); // two complex numbers: 1+1i, 2+2i
33+
34+
// Get data types:
35+
var dt1 = dtype( arr1 );
36+
var dt2 = dtype( arr2 );
37+
var dt3 = dtype( arr3 );
38+
var dt4 = dtype( arr4 );
39+
40+
// Check data types:
41+
console.log( dt1 + ' is floating-point data type: ' + ns.isFloatingPointDataType( dt1 ) );
42+
// => 'float64 is floating-point data type: true'
43+
44+
console.log( dt2 + ' is integer data type: ' + ns.isIntegerDataType( dt2 ) );
45+
// => 'int32 is integer data type: true'
46+
47+
console.log( dt3 + ' is unsigned integer data type: ' + ns.isUnsignedIntegerDataType( dt3 ) );
48+
// => 'uint8 is unsigned integer data type: true'
49+
50+
console.log( dt4 + ' is complex floating-point data type: ' + ns.isComplexFloatingPointDataType( dt4 ) );
51+
// => 'complex128 is complex floating-point data type: true'
52+
53+
// Check if arrays have the same values:
54+
console.log( 'arr2 and arr3 have same values: ' + ns.hasSameValues( arr2, arr3 ) );
55+
// => 'arr2 and arr3 have same values: true'
56+
57+
console.log( 'arr1 and arr2 have same values: ' + ns.hasSameValues( arr1, arr2 ) );
58+
// => 'arr1 and arr2 have same values: false'
59+
60+
// Check safe data type casts:
61+
console.log( 'Can safely cast from ' + dt2 + ' to ' + dt1 + ': ' + ns.isSafeDataTypeCast( dt2, dt1 ) );
62+
// => 'Can safely cast from int32 to float64: true'
63+
64+
console.log( 'Can safely cast from ' + dt1 + ' to ' + dt2 + ': ' + ns.isSafeDataTypeCast( dt1, dt2 ) );
65+
// => 'Can safely cast from float64 to int32: false'
66+
67+
console.log( 'Can safely cast from ' + dt3 + ' to ' + dt2 + ': ' + ns.isSafeDataTypeCast( dt3, dt2 ) );
68+
// => 'Can safely cast from uint8 to int32: true'
69+
70+
console.log( 'Can safely cast from ' + dt4 + ' to ' + dt1 + ': ' + ns.isSafeDataTypeCast( dt4, dt1 ) );
71+
// => 'Can safely cast from complex128 to float64: false'
72+
73+
// Check if arrays contain specific values:
74+
console.log( 'arr1 contains 2.2: ' + ns.contains( arr1, 2.2 ) );
75+
// => 'arr1 contains 2.2: true'
76+
77+
console.log( 'arr2 contains 2: ' + ns.contains( arr2, 2 ) );
78+
// => 'arr2 contains 2: true'
79+
80+
console.log( 'arr2 contains 2.2: ' + ns.contains( arr2, 2.2 ) );
81+
// => 'arr2 contains 2.2: false'
82+
83+
// Check complex array types:
84+
console.log( 'arr4 is Complex128Array: ' + ns.isComplex128Array( arr4 ) );
85+
// => 'arr4 is Complex128Array: true'
86+
87+
console.log( 'arr4 is complex typed array: ' + ns.isComplexTypedArray( arr4 ) );
88+
// => 'arr4 is complex typed array: true'
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2024 The Stdlib Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
21+
# isSameTypedArrayLike
22+
23+
> Test if two arguments are both typed-array-like objects and have the [same values][@stdlib/assert/is-same-value].
24+
25+
<section class="usage">
26+
27+
## Usage
28+
29+
```javascript
30+
var isSameTypedArrayLike = require( '@stdlib/assert/is-same-typed-array-like' );
31+
```
32+
33+
#### isSameTypedArrayLike( v1, v2 )
34+
35+
Tests if two arguments are both typed-array-like objects and have the [same values][@stdlib/assert/is-same-value].
36+
37+
```javascript
38+
var Int8Array = require( '@stdlib/array/int8' );
39+
var Int16Array = require( '@stdlib/array/int16' );
40+
41+
var x = new Int8Array( [ 1.0, 2.0 ] );
42+
var y = new Int16Array( [ 1.0, 2.0 ] );
43+
var bool = isSameTypedArrayLike( x, y );
44+
// returns true
45+
46+
bool = isSameTypedArrayLike( x, new Int8Array( [ -1.0, 2.0 ] ) );
47+
// returns false
48+
```
49+
50+
</section>
51+
52+
<!-- /.usage -->
53+
54+
<section class="examples">
55+
56+
## Examples
57+
58+
<!-- eslint no-undef: "error" -->
59+
60+
```javascript
61+
var Int8Array = require( '@stdlib/array/int8' );
62+
var Int16Array = require( '@stdlib/array/int16' );
63+
var isSameTypedArrayLike = require( '@stdlib/assert/is-same-typed-array-like' );
64+
65+
var x = new Int8Array( [ 1.0, 2.0, 3.0 ] );
66+
var y = new Int16Array( [ 1.0, 2.0, 3.0 ] );
67+
var out = isSameTypedArrayLike( x, y );
68+
// returns true
69+
70+
x = new Int8Array( [ 1.0, 2.0, 3.0 ] );
71+
y = new Int16Array( [ 1.0, 2.0, 4.0 ] );
72+
out = isSameTypedArrayLike( x, y );
73+
// returns false
74+
```
75+
76+
</section>
77+
78+
<!-- /.examples -->
79+
80+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
81+
82+
<section class="related">
83+
84+
</section>
85+
86+
<!-- /.related -->
87+
88+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
89+
90+
<section class="links">
91+
92+
[@stdlib/assert/is-same-value]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-same-value
93+
94+
<!-- <related-links> -->
95+
96+
<!-- </related-links> -->
97+
98+
</section>
99+
100+
<!-- /.links -->
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive;
25+
var pow = require( '@stdlib/math/base/special/pow' );
26+
var Int8Array = require( '@stdlib/array/int8' );
27+
var pkg = require( './../package.json' ).name;
28+
var isSameTypedArrayLike = require( './../lib' );
29+
30+
31+
// FUNCTIONS //
32+
33+
/**
34+
* Creates a benchmark function.
35+
*
36+
* @private
37+
* @param {PositiveInteger} len - array length
38+
* @returns {Function} benchmark function
39+
*/
40+
function createBenchmark( len ) {
41+
var x = new Int8Array( len );
42+
var y = new Int8Array( len );
43+
return benchmark;
44+
45+
/**
46+
* Benchmark function.
47+
*
48+
* @private
49+
* @param {Benchmark} b - benchmark instance
50+
*/
51+
function benchmark( b ) {
52+
var bool;
53+
var i;
54+
55+
b.tic();
56+
for ( i = 0; i < b.iterations; i++ ) {
57+
bool = isSameTypedArrayLike( x, y );
58+
if ( typeof bool !== 'boolean' ) {
59+
b.fail( 'should return a boolean' );
60+
}
61+
}
62+
b.toc();
63+
if ( !isBoolean( bool ) ) {
64+
b.fail( 'should return a boolean' );
65+
}
66+
b.pass( 'benchmark finished' );
67+
b.end();
68+
}
69+
}
70+
71+
72+
// MAIN //
73+
74+
/**
75+
* Main execution sequence.
76+
*
77+
* @private
78+
*/
79+
function main() {
80+
var len;
81+
var min;
82+
var max;
83+
var f;
84+
var i;
85+
86+
min = 1; // 10^min
87+
max = 6; // 10^max
88+
89+
for ( i = min; i <= max; i++ ) {
90+
len = pow( 10, i );
91+
f = createBenchmark( len );
92+
bench( pkg+':len='+len, f );
93+
}
94+
}
95+
96+
main();

0 commit comments

Comments
 (0)