Skip to content

Commit 2551826

Browse files
authored
Merge branch 'develop' into smskrev
2 parents 842c64e + af6a5d7 commit 2551826

25 files changed

Lines changed: 2662 additions & 7 deletions

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

Lines changed: 145 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,150 @@ console.log( x.toString() );
149149

150150
<!-- /.examples -->
151151

152+
<!-- C interface documentation. -->
153+
154+
* * *
155+
156+
<section class="c">
157+
158+
## C APIs
159+
160+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
161+
162+
<section class="intro">
163+
164+
</section>
165+
166+
<!-- /.intro -->
167+
168+
<!-- C usage documentation. -->
169+
170+
<section class="usage">
171+
172+
### Usage
173+
174+
```c
175+
#include "stdlib/blas/base/csscal.h"
176+
```
177+
178+
#### c_csscal( N, alpha, \*X, strideX )
179+
180+
Scales a single-precision complex floating-point vector by a single-precision floating-point constant.
181+
182+
```c
183+
#include "stdlib/complex/float32/ctor.h"
184+
185+
stdlib_complex64_t x[] = {
186+
stdlib_complex64( 1.0f, 2.0f ),
187+
stdlib_complex64( 3.0f, 4.0f ),
188+
stdlib_complex64( 5.0f, 6.0f )
189+
};
190+
191+
c_csscal( 3, 2.0f, x, 1 );
192+
```
193+
194+
The function accepts the following arguments:
195+
196+
- **N**: `[in] CBLAS_INT` number of indexed elements.
197+
- **alpha**: `[in] float` scalar constant.
198+
- **X**: `[inout] stdlib_complex64_t*` input array.
199+
- **strideX**: `[in] CBLAS_INT` index increment for `x`.
200+
201+
```c
202+
void c_csscal( const CBLAS_INT N, const float alpha, void *X, const CBLAS_INT strideX );
203+
```
204+
205+
#### c_csscal_ndarray( N, alpha, \*X, strideX, offsetX )
206+
207+
Scales a single-precision complex floating-point vector by a single-precision floating-point constant using alternative indexing semantics.
208+
209+
```c
210+
#include "stdlib/complex/float32/ctor.h"
211+
212+
stdlib_complex64_t x[] = {
213+
stdlib_complex64( 1.0f, 2.0f ),
214+
stdlib_complex64( 3.0f, 4.0f ),
215+
stdlib_complex64( 5.0f, 6.0f )
216+
};
217+
218+
c_csscal_ndarray( 3, 2.0f, x, 1, 0 );
219+
```
220+
221+
The function accepts the following arguments:
222+
223+
- **N**: `[in] CBLAS_INT` number of indexed elements.
224+
- **alpha**: `[in] float` scalar constant.
225+
- **X**: `[inout] void*` input array.
226+
- **strideX**: `[in] CBLAS_INT` index increment for `x`.
227+
- **offsetX**: `[in] CBLAS_INT` starting index for `x`.
228+
229+
```c
230+
void c_csscal_ndarray( const CBLAS_INT N, const float alpha, void *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
231+
```
232+
233+
</section>
234+
235+
<!-- /.usage -->
236+
237+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
238+
239+
<section class="notes">
240+
241+
</section>
242+
243+
<!-- /.notes -->
244+
245+
<!-- C API usage examples. -->
246+
247+
<section class="examples">
248+
249+
### Examples
250+
251+
```c
252+
#include "stdlib/blas/base/csscal.h"
253+
#include "stdlib/complex/float32/ctor.h"
254+
#include "stdlib/complex/float32/real.h"
255+
#include "stdlib/complex/float32/imag.h"
256+
#include <stdio.h>
257+
258+
int main( void ) {
259+
stdlib_complex64_t x[] = {
260+
stdlib_complex64( 1.0f, 2.0f ),
261+
stdlib_complex64( 3.0f, 4.0f ),
262+
stdlib_complex64( 5.0f, 6.0f ),
263+
stdlib_complex64( 7.0f, 8.0f )
264+
};
265+
266+
// Specify the number of elements:
267+
const int N = 4;
268+
269+
// Specify the stride length:
270+
const int strideX = 1;
271+
272+
c_csscal( N, 2.0f, (void *)x, strideX );
273+
274+
// Print the result:
275+
for ( int i = 0; i < N; i++ ) {
276+
printf( "x[ %i ] = %f + %fj\n", i, stdlib_complex64_real( x[ i ] ), stdlib_complex64_imag( x[ i ] ) );
277+
}
278+
279+
c_csscal_ndarray( N, 2.0f, (void *)x, strideX, 0 );
280+
281+
// Print the result:
282+
for ( int i = 0; i < N; i++ ) {
283+
printf( "x[ %i ] = %f + %fj\n", i, stdlib_complex64_real( x[ i ] ), stdlib_complex64_imag( x[ i ] ) );
284+
}
285+
}
286+
```
287+
288+
</section>
289+
290+
<!-- /.examples -->
291+
292+
</section>
293+
294+
<!-- /.c -->
295+
152296
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
153297
154298
<section class="related">
@@ -163,7 +307,7 @@ console.log( x.toString() );
163307
164308
[blas]: http://www.netlib.org/blas
165309
166-
[csscal]: https://www.netlib.org/lapack/explore-html/d2/de8/group__scal_ga40d50a435a5fcf16cf41fa80d746819f.html#ga40d50a435a5fcf16cf41fa80d746819f
310+
[csscal]: https://www.netlib.org/lapack/explore-html/d2/de8/group__scal_ga38234ecdfde7c9a45753af53d13b0187.html#ga38234ecdfde7c9a45753af53d13b0187
167311
168312
[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
169313
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
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 resolve = require( 'path' ).resolve;
24+
var bench = require( '@stdlib/bench' );
25+
var uniform = require( '@stdlib/random/array/uniform' );
26+
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
27+
var pow = require( '@stdlib/math/base/special/pow' );
28+
var Complex64Array = require( '@stdlib/array/complex64' );
29+
var tryRequire = require( '@stdlib/utils/try-require' );
30+
var format = require( '@stdlib/string/format' );
31+
var pkg = require( './../package.json' ).name;
32+
33+
34+
// VARIABLES //
35+
36+
var csscal = tryRequire( resolve( __dirname, './../lib/csscal.native.js' ) );
37+
var opts = {
38+
'skip': ( csscal instanceof Error )
39+
};
40+
var options = {
41+
'dtype': 'float32'
42+
};
43+
44+
45+
// FUNCTIONS //
46+
47+
/**
48+
* Creates a benchmark function.
49+
*
50+
* @private
51+
* @param {PositiveInteger} len - array length
52+
* @returns {Function} benchmark function
53+
*/
54+
function createBenchmark( len ) {
55+
var xbuf;
56+
var x;
57+
58+
xbuf = uniform( len*2, -100.0, 100.0, options );
59+
x = new Complex64Array( xbuf.buffer );
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 i;
71+
72+
b.tic();
73+
for ( i = 0; i < b.iterations; i++ ) {
74+
csscal( x.length, 2.0, x, 1 );
75+
if ( isnanf( xbuf[ i%(len*2) ] ) ) {
76+
b.fail( 'should not return NaN' );
77+
}
78+
}
79+
b.toc();
80+
if ( isnanf( xbuf[ i%(len*2) ] ) ) {
81+
b.fail( 'should not return NaN' );
82+
}
83+
b.pass( 'benchmark finished' );
84+
b.end();
85+
}
86+
}
87+
88+
89+
// MAIN //
90+
91+
/**
92+
* Main execution sequence.
93+
*
94+
* @private
95+
*/
96+
function main() {
97+
var len;
98+
var min;
99+
var max;
100+
var f;
101+
var i;
102+
103+
min = 1; // 10^min
104+
max = 6; // 10^max
105+
106+
for ( i = min; i <= max; i++ ) {
107+
len = pow( 10, i );
108+
f = createBenchmark( len );
109+
bench( format( '%s::native:len=%d', pkg, len ), opts, f );
110+
}
111+
}
112+
113+
main();
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
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 resolve = require( 'path' ).resolve;
24+
var bench = require( '@stdlib/bench' );
25+
var uniform = require( '@stdlib/random/array/uniform' );
26+
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
27+
var pow = require( '@stdlib/math/base/special/pow' );
28+
var Complex64Array = require( '@stdlib/array/complex64' );
29+
var tryRequire = require( '@stdlib/utils/try-require' );
30+
var format = require( '@stdlib/string/format' );
31+
var pkg = require( './../package.json' ).name;
32+
33+
34+
// VARIABLES //
35+
36+
var csscal = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) );
37+
var opts = {
38+
'skip': ( csscal instanceof Error )
39+
};
40+
var options = {
41+
'dtype': 'float32'
42+
};
43+
44+
45+
// FUNCTIONS //
46+
47+
/**
48+
* Creates a benchmark function.
49+
*
50+
* @private
51+
* @param {PositiveInteger} len - array length
52+
* @returns {Function} benchmark function
53+
*/
54+
function createBenchmark( len ) {
55+
var xbuf;
56+
var x;
57+
58+
xbuf = uniform( len*2, -100.0, 100.0, options );
59+
x = new Complex64Array( xbuf.buffer );
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 i;
71+
72+
b.tic();
73+
for ( i = 0; i < b.iterations; i++ ) {
74+
csscal( x.length, 2.0, x, 1, 0 );
75+
if ( isnanf( xbuf[ i%(len*2) ] ) ) {
76+
b.fail( 'should not return NaN' );
77+
}
78+
}
79+
b.toc();
80+
if ( isnanf( xbuf[ i%(len*2) ] ) ) {
81+
b.fail( 'should not return NaN' );
82+
}
83+
b.pass( 'benchmark finished' );
84+
b.end();
85+
}
86+
}
87+
88+
89+
// MAIN //
90+
91+
/**
92+
* Main execution sequence.
93+
*
94+
* @private
95+
*/
96+
function main() {
97+
var len;
98+
var min;
99+
var max;
100+
var f;
101+
var i;
102+
103+
min = 1; // 10^min
104+
max = 6; // 10^max
105+
106+
for ( i = min; i <= max; i++ ) {
107+
len = pow( 10, i );
108+
f = createBenchmark( len );
109+
bench( format( '%s::native:ndarray:len=%d', pkg, len ), opts, f );
110+
}
111+
}
112+
113+
main();

0 commit comments

Comments
 (0)