Skip to content

Commit 4b47bc0

Browse files
committed
Auto-generated commit
1 parent 107bbe9 commit 4b47bc0

11 files changed

Lines changed: 860 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
### Features
1212

13+
- [`68ef817`](https://github.com/stdlib-js/stdlib/commit/68ef81746517bdba3d02ea39e564034a9d999194) - add `blas/base/ndarray/dswap` [(#11715)](https://github.com/stdlib-js/stdlib/pull/11715)
1314
- [`538ced0`](https://github.com/stdlib-js/stdlib/commit/538ced061007046094f1786c6d3fda9a113130b3) - update `blas/ext/base` TypeScript declarations [(#11737)](https://github.com/stdlib-js/stdlib/pull/11737)
1415
- [`5d7de9d`](https://github.com/stdlib-js/stdlib/commit/5d7de9dc58abb2a9b049a17b87f988d9d52ed56e) - add `cunitspace` to namespace
1516
- [`ae4bc4f`](https://github.com/stdlib-js/stdlib/commit/ae4bc4f7d737d97ac8e404e86402a41baa851952) - add `zunitspace` to namespace
@@ -916,6 +917,7 @@ A total of 57 issues were closed in this release:
916917

917918
<details>
918919

920+
- [`68ef817`](https://github.com/stdlib-js/stdlib/commit/68ef81746517bdba3d02ea39e564034a9d999194) - **feat:** add `blas/base/ndarray/dswap` [(#11715)](https://github.com/stdlib-js/stdlib/pull/11715) _(by Kaustubh Patange)_
919921
- [`40db61d`](https://github.com/stdlib-js/stdlib/commit/40db61db7ca352e3a55a699a010d984fc05f6144) - **chore:** follow-up fixes [(#11721)](https://github.com/stdlib-js/stdlib/pull/11721) _(by Philipp Burckhardt)_
920922
- [`20303f7`](https://github.com/stdlib-js/stdlib/commit/20303f76bbd7bb77a4d612c86632f2f876a99110) - **chore:** modernize examples and benchmarks _(by Athan Reines)_
921923
- [`e2618f8`](https://github.com/stdlib-js/stdlib/commit/e2618f884bbcbbb72692813c76971c92b34c908c) - **chore:** modernize examples and benchmarks _(by Athan Reines)_

base/ndarray/dswap/README.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2026 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+
# dswap
22+
23+
> Interchange two one-dimensional double-precision floating-point ndarrays.
24+
25+
<section class="intro">
26+
27+
</section>
28+
29+
<!-- /.intro -->
30+
31+
<section class="usage">
32+
33+
## Usage
34+
35+
```javascript
36+
var dswap = require( '@stdlib/blas/base/ndarray/dswap' );
37+
```
38+
39+
#### dswap( arrays )
40+
41+
Interchanges two one-dimensional double-precision floating-point ndarrays.
42+
43+
```javascript
44+
var Float64Array = require( '@stdlib/array/float64' );
45+
var ndarray = require( '@stdlib/ndarray/base/ctor' );
46+
47+
var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
48+
var x = new ndarray( 'float64', xbuf, [ 5 ], [ 1 ], 0, 'row-major' );
49+
50+
var ybuf = new Float64Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] );
51+
var y = new ndarray( 'float64', ybuf, [ 5 ], [ 1 ], 0, 'row-major' );
52+
53+
var z = dswap( [ x, y ] );
54+
// x => <ndarray>[ 6.0, 7.0, 8.0, 9.0, 10.0 ]
55+
// y => <ndarray>[ 1.0, 2.0, 3.0, 4.0, 5.0 ]
56+
57+
var bool = ( y === z );
58+
// returns true
59+
```
60+
61+
The function has the following parameters:
62+
63+
- **arrays**: array-like object containing two input ndarrays.
64+
65+
</section>
66+
67+
<!-- /.usage -->
68+
69+
<section class="notes">
70+
71+
</section>
72+
73+
<!-- /.notes -->
74+
75+
<section class="examples">
76+
77+
## Examples
78+
79+
<!-- eslint no-undef: "error" -->
80+
81+
```javascript
82+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
83+
var ndarray = require( '@stdlib/ndarray/base/ctor' );
84+
var ndarray2array = require( '@stdlib/ndarray/to-array' );
85+
var dswap = require( '@stdlib/blas/base/ndarray/dswap' );
86+
87+
var opts = {
88+
'dtype': 'float64'
89+
};
90+
91+
var xbuf = discreteUniform( 10, 0, 100, opts );
92+
var x = new ndarray( opts.dtype, xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
93+
console.log( ndarray2array( x ) );
94+
95+
var ybuf = discreteUniform( 10, 0, 100, opts );
96+
var y = new ndarray( opts.dtype, ybuf, [ ybuf.length ], [ 1 ], 0, 'row-major' );
97+
console.log( ndarray2array( y ) );
98+
99+
var out = dswap( [ x, y ] );
100+
console.log( ndarray2array( x ) );
101+
console.log( ndarray2array( out ) );
102+
```
103+
104+
</section>
105+
106+
<!-- /.examples -->
107+
108+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
109+
110+
<section class="related">
111+
112+
</section>
113+
114+
<!-- /.related -->
115+
116+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
117+
118+
<section class="links">
119+
120+
</section>
121+
122+
<!-- /.links -->
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2026 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 uniform = require( '@stdlib/random/array/uniform' );
25+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
26+
var pow = require( '@stdlib/math/base/special/pow' );
27+
var ndarray = require( '@stdlib/ndarray/base/ctor' );
28+
var format = require( '@stdlib/string/format' );
29+
var pkg = require( './../package.json' ).name;
30+
var dswap = require( './../lib' );
31+
32+
33+
// VARIABLES //
34+
35+
var options = {
36+
'dtype': 'float64'
37+
};
38+
39+
40+
// FUNCTIONS //
41+
42+
/**
43+
* Creates a benchmark function.
44+
*
45+
* @private
46+
* @param {PositiveInteger} len - array length
47+
* @returns {Function} benchmark function
48+
*/
49+
function createBenchmark( len ) {
50+
var xbuf;
51+
var ybuf;
52+
var x;
53+
var y;
54+
55+
xbuf = uniform( len, -100.0, 100.0, options );
56+
x = new ndarray( options.dtype, xbuf, [ len ], [ 1 ], 0, 'row-major' );
57+
58+
ybuf = uniform( len, -100.0, 100.0, options );
59+
y = new ndarray( options.dtype, ybuf, [ len ], [ 1 ], 0, 'row-major' );
60+
61+
return benchmark;
62+
63+
/**
64+
* Benchmark function.
65+
*
66+
* @private
67+
* @param {Benchmark} b - benchmark instance
68+
*/
69+
function benchmark( b ) {
70+
var z;
71+
var i;
72+
73+
b.tic();
74+
for ( i = 0; i < b.iterations; i++ ) {
75+
z = dswap( [ x, y ] );
76+
if ( typeof z !== 'object' ) {
77+
b.fail( 'should return an ndarray' );
78+
}
79+
}
80+
b.toc();
81+
if ( isnan( z.get( i%len ) ) ) {
82+
b.fail( 'should not return NaN' );
83+
}
84+
b.pass( 'benchmark finished' );
85+
b.end();
86+
}
87+
}
88+
89+
90+
// MAIN //
91+
92+
/**
93+
* Main execution sequence.
94+
*
95+
* @private
96+
*/
97+
function main() {
98+
var len;
99+
var min;
100+
var max;
101+
var f;
102+
var i;
103+
104+
min = 1; // 10^min
105+
max = 6; // 10^max
106+
107+
for ( i = min; i <= max; i++ ) {
108+
len = pow( 10, i );
109+
f = createBenchmark( len );
110+
bench( format( '%s:len=%d', pkg, len ), f );
111+
}
112+
}
113+
114+
main();

base/ndarray/dswap/docs/repl.txt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
{{alias}}( arrays )
3+
Interchanges two one-dimensional double-precision floating-point ndarrays.
4+
5+
If provided an empty input ndarray, the function returns the output ndarray
6+
unchanged.
7+
8+
Parameters
9+
----------
10+
arrays: ArrayLikeObject<ndarray>
11+
Array-like object containing two input ndarrays.
12+
13+
Returns
14+
-------
15+
out: ndarray
16+
The second input ndarray.
17+
18+
Examples
19+
--------
20+
> var xbuf = new {{alias:@stdlib/array/float64}}( [ 4.0, 2.0, -3.0 ] );
21+
> var ybuf = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 0.0 ] );
22+
> var dt = 'float64';
23+
> var sh = [ xbuf.length ];
24+
> var st = [ 1 ];
25+
> var oo = 0;
26+
> var ord = 'row-major';
27+
> var x = new {{alias:@stdlib/ndarray/ctor}}( dt, xbuf, sh, st, oo, ord );
28+
> var y = new {{alias:@stdlib/ndarray/ctor}}( dt, ybuf, sh, st, oo, ord );
29+
30+
> {{alias}}( [ x, y ] );
31+
> x
32+
<ndarray>[ 0.0, 0.0, 0.0 ]
33+
> y
34+
<ndarray>[ 4.0, 2.0, -3.0 ]
35+
36+
See Also
37+
--------
38+
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2026 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+
// TypeScript Version: 4.1
20+
21+
/// <reference types="@stdlib/types"/>
22+
23+
import { float64ndarray } from '@stdlib/types/ndarray';
24+
25+
/**
26+
* Interchanges two one-dimensional double-precision floating-point ndarrays.
27+
*
28+
* @param arrays - array-like object containing two input ndarrays
29+
* @returns second input ndarray
30+
*
31+
* @example
32+
* var Float64Array = require( '@stdlib/array/float64' );
33+
* var ndarray = require( '@stdlib/ndarray/base/ctor' );
34+
*
35+
* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
36+
* var x = new ndarray( 'float64', xbuf, [ 5 ], [ 1 ], 0, 'row-major' );
37+
*
38+
* var ybuf = new Float64Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] );
39+
* var y = new ndarray( 'float64', ybuf, [ 5 ], [ 1 ], 0, 'row-major' );
40+
*
41+
* var z = dswap( [ x, y ] );
42+
* // x => <ndarray>[ 6.0, 7.0, 8.0, 9.0, 10.0 ]
43+
* // y => <ndarray>[ 1.0, 2.0, 3.0, 4.0, 5.0 ]
44+
*
45+
* var bool = ( z === y );
46+
* // returns true
47+
*/
48+
declare function dswap( arrays: [ float64ndarray, float64ndarray ] ): float64ndarray;
49+
50+
51+
// EXPORTS //
52+
53+
export = dswap;

0 commit comments

Comments
 (0)