Skip to content

Commit 5b4ce26

Browse files
authored
Merge branch 'develop' into blas/scartesian-power
2 parents 175ab01 + 8238153 commit 5b4ce26

62 files changed

Lines changed: 7564 additions & 7 deletions

Some content is hidden

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

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ The namespace exposes the following APIs:
4747

4848
- <span class="signature">[`caxpy( arrays )`][@stdlib/blas/base/ndarray/caxpy]</span><span class="delimiter">: </span><span class="description">multiply a one-dimensional single-precision complex floating-point ndarray `x` by a constant `alpha` and add the result to a one-dimensional single-precision complex floating-point ndarray `y`.</span>
4949
- <span class="signature">[`ccopy( arrays )`][@stdlib/blas/base/ndarray/ccopy]</span><span class="delimiter">: </span><span class="description">copy values from a one-dimensional single-precision complex floating-point ndarray `x` into a one-dimensional single-precision complex floating-point ndarray `y`.</span>
50+
- <span class="signature">[`cswap( arrays )`][@stdlib/blas/base/ndarray/cswap]</span><span class="delimiter">: </span><span class="description">interchange two one-dimensional complex single-precision floating-point ndarrays.</span>
5051
- <span class="signature">[`dasum( arrays )`][@stdlib/blas/base/ndarray/dasum]</span><span class="delimiter">: </span><span class="description">calculate the sum of absolute values for all elements in a one-dimensional double-precision floating-point ndarray.</span>
5152
- <span class="signature">[`daxpy( arrays )`][@stdlib/blas/base/ndarray/daxpy]</span><span class="delimiter">: </span><span class="description">multiply a one-dimensional double-precision floating-point ndarray `x` by a constant `alpha` and add the result to a one-dimensional double-precision floating-point ndarray `y`.</span>
5253
- <span class="signature">[`dcopy( arrays )`][@stdlib/blas/base/ndarray/dcopy]</span><span class="delimiter">: </span><span class="description">copy values from a one-dimensional double-precision floating-point ndarray `x` into a one-dimensional double-precision floating-point ndarray `y`.</span>
@@ -64,6 +65,7 @@ The namespace exposes the following APIs:
6465
- <span class="signature">[`sswap( arrays )`][@stdlib/blas/base/ndarray/sswap]</span><span class="delimiter">: </span><span class="description">interchange two one-dimensional single-precision floating-point ndarrays.</span>
6566
- <span class="signature">[`zaxpy( arrays )`][@stdlib/blas/base/ndarray/zaxpy]</span><span class="delimiter">: </span><span class="description">multiply a one-dimensional double-precision complex floating-point ndarray `x` by a constant `alpha` and add the result to a one-dimensional double-precision complex floating-point ndarray `y`.</span>
6667
- <span class="signature">[`zcopy( arrays )`][@stdlib/blas/base/ndarray/zcopy]</span><span class="delimiter">: </span><span class="description">copy values from a one-dimensional double-precision complex floating-point ndarray `x` into a one-dimensional double-precision complex floating-point ndarray `y`.</span>
68+
- <span class="signature">[`zswap( arrays )`][@stdlib/blas/base/ndarray/zswap]</span><span class="delimiter">: </span><span class="description">interchange two one-dimensional complex double-precision floating-point ndarrays.</span>
6769

6870
</div>
6971

@@ -110,6 +112,8 @@ console.log( objectKeys( ns ) );
110112

111113
[@stdlib/blas/base/ndarray/ccopy]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/blas/base/ndarray/ccopy
112114

115+
[@stdlib/blas/base/ndarray/cswap]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/blas/base/ndarray/cswap
116+
113117
[@stdlib/blas/base/ndarray/dasum]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/blas/base/ndarray/dasum
114118

115119
[@stdlib/blas/base/ndarray/daxpy]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/blas/base/ndarray/daxpy
@@ -144,6 +148,8 @@ console.log( objectKeys( ns ) );
144148

145149
[@stdlib/blas/base/ndarray/zcopy]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/blas/base/ndarray/zcopy
146150

151+
[@stdlib/blas/base/ndarray/zswap]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/blas/base/ndarray/zswap
152+
147153
<!-- </toc-links> -->
148154

149155
</section>

lib/node_modules/@stdlib/blas/base/ndarray/docs/types/index.d.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import caxpy = require( '@stdlib/blas/base/ndarray/caxpy' );
2424
import ccopy = require( '@stdlib/blas/base/ndarray/ccopy' );
25+
import cswap = require( '@stdlib/blas/base/ndarray/cswap' );
2526
import dasum = require( '@stdlib/blas/base/ndarray/dasum' );
2627
import daxpy = require( '@stdlib/blas/base/ndarray/daxpy' );
2728
import dcopy = require( '@stdlib/blas/base/ndarray/dcopy' );
@@ -39,6 +40,7 @@ import sdot = require( '@stdlib/blas/base/ndarray/sdot' );
3940
import sswap = require( '@stdlib/blas/base/ndarray/sswap' );
4041
import zaxpy = require( '@stdlib/blas/base/ndarray/zaxpy' );
4142
import zcopy = require( '@stdlib/blas/base/ndarray/zcopy' );
43+
import zswap = require( '@stdlib/blas/base/ndarray/zswap' );
4244

4345
/**
4446
* Interface describing the `ndarray` namespace.
@@ -105,6 +107,34 @@ interface Namespace {
105107
*/
106108
ccopy: typeof ccopy;
107109

110+
/**
111+
* Interchanges two one-dimensional complex single-precision floating-point ndarrays.
112+
*
113+
* ## Notes
114+
*
115+
* - The function expects the following ndarrays:
116+
*
117+
* - first one-dimensional input ndarray.
118+
* - second one-dimensional input ndarray.
119+
*
120+
* @param arrays - array-like object containing ndarrays
121+
* @returns second input ndarray
122+
*
123+
* @example
124+
* var Complex64Vector = require( '@stdlib/ndarray/vector/complex64' );
125+
*
126+
* var x = new Complex64Vector( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
127+
* var y = new Complex64Vector( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
128+
*
129+
* var z = ns.cswap( [ x, y ] );
130+
* // x => <ndarray>[ <Complex64>[ 7.0, 8.0 ], <Complex64>[ 9.0, 10.0 ], <Complex64>[ 11.0, 12.0 ] ]
131+
* // y => <ndarray>[ <Complex64>[ 1.0, 2.0 ], <Complex64>[ 3.0, 4.0 ], <Complex64>[ 5.0, 6.0 ] ]
132+
*
133+
* var bool = ( z === y );
134+
* // returns true
135+
*/
136+
cswap: typeof cswap;
137+
108138
/**
109139
* Computes the sum of absolute values for all elements in a one-dimensional double-precision floating-point ndarray.
110140
*
@@ -567,6 +597,34 @@ interface Namespace {
567597
* // returns true
568598
*/
569599
zcopy: typeof zcopy;
600+
601+
/**
602+
* Interchanges two one-dimensional complex double-precision floating-point ndarrays.
603+
*
604+
* ## Notes
605+
*
606+
* - The function expects the following ndarrays:
607+
*
608+
* - first one-dimensional input ndarray.
609+
* - second one-dimensional input ndarray.
610+
*
611+
* @param arrays - array-like object containing ndarrays
612+
* @returns second input ndarray
613+
*
614+
* @example
615+
* var Complex128Vector = require( '@stdlib/ndarray/vector/complex128' );
616+
*
617+
* var x = new Complex128Vector( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
618+
* var y = new Complex128Vector( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
619+
*
620+
* var z = ns.zswap( [ x, y ] );
621+
* // x => <ndarray>[ <Complex128>[ 7.0, 8.0 ], <Complex128>[ 9.0, 10.0 ], <Complex128>[ 11.0, 12.0 ] ]
622+
* // y => <ndarray>[ <Complex128>[ 1.0, 2.0 ], <Complex128>[ 3.0, 4.0 ], <Complex128>[ 5.0, 6.0 ] ]
623+
*
624+
* var bool = ( z === y );
625+
* // returns true
626+
*/
627+
zswap: typeof zswap;
570628
}
571629

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

0 commit comments

Comments
 (0)