Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 146 additions & 1 deletion lib/node_modules/@stdlib/blas/base/csscal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,150 @@ console.log( x.toString() );

<!-- /.examples -->

<!-- C interface documentation. -->

* * *

<section class="c">

## C APIs

<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->

<section class="intro">

</section>

<!-- /.intro -->

<!-- C usage documentation. -->

<section class="usage">

### Usage

```c
#include "stdlib/blas/base/csscal.h"
```

#### c_csscal( N, alpha, \*X, strideX )

Scales a single-precision complex floating-point vector by a single-precision floating-point constant.

```c
#include "stdlib/complex/float32/ctor.h"

stdlib_complex64_t x[] = {
stdlib_complex64( 1.0f, 2.0f ),
stdlib_complex64( 3.0f, 4.0f ),
stdlib_complex64( 5.0f, 6.0f )
};

c_csscal( 3, 2.0f, x, 1 );
```

The function accepts the following arguments:

- **N**: `[in] CBLAS_INT` number of indexed elements.
- **alpha**: `[in] float` scalar constant.
- **X**: `[inout] stdlib_complex64_t*` input array.
- **strideX**: `[in] CBLAS_INT` index increment for `x`.

```c
void c_csscal( const CBLAS_INT N, const float alpha, void *X, const CBLAS_INT strideX );
```

#### c_csscal_ndarray( N, alpha, \*X, strideX, offsetX )

Scales a single-precision complex floating-point vector by a single-precision floating-point constant using alternative indexing semantics.

```c
#include "stdlib/complex/float32/ctor.h"

stdlib_complex64_t x[] = {
stdlib_complex64( 1.0f, 2.0f ),
stdlib_complex64( 3.0f, 4.0f ),
stdlib_complex64( 5.0f, 6.0f )
};

c_csscal_ndarray( 3, 2.0f, x, 1, 0 );
```

The function accepts the following arguments:

- **N**: `[in] CBLAS_INT` number of indexed elements.
- **alpha**: `[in] float` scalar constant.
- **X**: `[inout] void*` input array.
- **strideX**: `[in] CBLAS_INT` index increment for `x`.
- **offsetX**: `[in] CBLAS_INT` starting index for `x`.

```c
void c_csscal_ndarray( const CBLAS_INT N, const float alpha, void *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
```

</section>

<!-- /.usage -->

<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="notes">

</section>

<!-- /.notes -->

<!-- C API usage examples. -->

<section class="examples">

### Examples

```c
#include "stdlib/blas/base/csscal.h"
#include "stdlib/complex/float32/ctor.h"
#include "stdlib/complex/float32/real.h"
#include "stdlib/complex/float32/imag.h"
#include <stdio.h>

int main( void ) {
stdlib_complex64_t x[] = {
stdlib_complex64( 1.0f, 2.0f ),
stdlib_complex64( 3.0f, 4.0f ),
stdlib_complex64( 5.0f, 6.0f ),
stdlib_complex64( 7.0f, 8.0f )
};

// Specify the number of elements:
const int N = 4;

// Specify the stride length:
const int strideX = 1;

c_csscal( N, 2.0f, (void *)x, strideX );

// Print the result:
for ( int i = 0; i < N; i++ ) {
printf( "x[ %i ] = %f + %fj\n", i, stdlib_complex64_real( x[ i ] ), stdlib_complex64_imag( x[ i ] ) );
}

c_csscal_ndarray( N, 2.0f, (void *)x, strideX, 0 );

// Print the result:
for ( int i = 0; i < N; i++ ) {
printf( "x[ %i ] = %f + %fj\n", i, stdlib_complex64_real( x[ i ] ), stdlib_complex64_imag( x[ i ] ) );
}
}
```

</section>

<!-- /.examples -->

</section>

<!-- /.c -->

<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->

<section class="related">
Expand All @@ -163,7 +307,7 @@ console.log( x.toString() );

[blas]: http://www.netlib.org/blas

[csscal]: https://www.netlib.org/lapack/explore-html/d2/de8/group__scal_ga40d50a435a5fcf16cf41fa80d746819f.html#ga40d50a435a5fcf16cf41fa80d746819f
[csscal]: https://www.netlib.org/lapack/explore-html/d2/de8/group__scal_ga38234ecdfde7c9a45753af53d13b0187.html#ga38234ecdfde7c9a45753af53d13b0187

[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray

Expand All @@ -172,3 +316,4 @@ console.log( x.toString() );
</section>

<!-- /.links -->

Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2026 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench' );
var uniform = require( '@stdlib/random/array/uniform' );
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
var pow = require( '@stdlib/math/base/special/pow' );
var Complex64Array = require( '@stdlib/array/complex64' );
var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' );
var tryRequire = require( '@stdlib/utils/try-require' );
var pkg = require( './../package.json' ).name;


// VARIABLES //

var csscal = tryRequire( resolve( __dirname, './../lib/csscal.native.js' ) );
var opts = {
'skip': ( csscal instanceof Error )
};
var options = {
'dtype': 'float32'
};


// FUNCTIONS //

/**
* Creates a benchmark function.
*
* @private
* @param {PositiveInteger} len - array length
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var x = new Complex64Array( uniform( len*2, -100.0, 100.0, options ) );

return benchmark;

/**
* Benchmark function.
*
* @private
* @param {Benchmark} b - benchmark instance
*/
function benchmark( b ) {
var viewX;
var i;

viewX = reinterpret( x, 0 );
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
csscal( x.length, 2.0, x, 1 );
if ( isnanf( viewX[ i%(len*2) ] ) ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnanf( viewX[ i%(len*2) ] ) ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
b.end();
}
}


// MAIN //

/**
* Main execution sequence.
*
* @private
*/
function main() {
var len;
var min;
var max;
var f;
var i;

min = 1; // 10^min
max = 6; // 10^max

for ( i = min; i <= max; i++ ) {
len = pow( 10, i );
f = createBenchmark( len );
bench( pkg+'::native:len='+len, opts, f );

Check warning on line 107 in lib/node_modules/@stdlib/blas/base/csscal/benchmark/benchmark.native.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Use `@stdlib/string/format` instead of string concatenation for benchmark descriptions
}
}

main();
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2026 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench' );
var uniform = require( '@stdlib/random/array/uniform' );
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
var pow = require( '@stdlib/math/base/special/pow' );
var Complex64Array = require( '@stdlib/array/complex64' );
var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' );
var tryRequire = require( '@stdlib/utils/try-require' );
var pkg = require( './../package.json' ).name;


// VARIABLES //

var csscal = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) );
var opts = {
'skip': ( csscal instanceof Error )
};
var options = {
'dtype': 'float32'
};


// FUNCTIONS //

/**
* Creates a benchmark function.
*
* @private
* @param {PositiveInteger} len - array length
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var x = new Complex64Array( uniform( len*2, -100.0, 100.0, options ) );

return benchmark;

/**
* Benchmark function.
*
* @private
* @param {Benchmark} b - benchmark instance
*/
function benchmark( b ) {
var viewX;
var i;

viewX = reinterpret( x, 0 );
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
csscal( x.length, 2.0, x, 1, 0 );
if ( isnanf( viewX[ i%(len*2) ] ) ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnanf( viewX[ i%(len*2) ] ) ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
b.end();
}
}


// MAIN //

/**
* Main execution sequence.
*
* @private
*/
function main() {
var len;
var min;
var max;
var f;
var i;

min = 1; // 10^min
max = 6; // 10^max

for ( i = min; i <= max; i++ ) {
len = pow( 10, i );
f = createBenchmark( len );
bench( pkg+'::native:ndarray:len='+len, opts, f );

Check warning on line 107 in lib/node_modules/@stdlib/blas/base/csscal/benchmark/benchmark.ndarray.native.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Use `@stdlib/string/format` instead of string concatenation for benchmark descriptions
}
}

main();
Loading