Skip to content
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
0538961
feat: add C implementation for blas/base/zdscal
ShabiShett07 May 25, 2025
0dc7cda
chore: add implementation
ShabiShett07 May 25, 2025
586ab55
chore: add implementation
ShabiShett07 May 25, 2025
c5280c8
chore: update copyright years
stdlib-bot May 25, 2025
11629ec
chore: update implementation
ShabiShett07 May 27, 2025
be3bded
chore: update implementation
ShabiShett07 May 27, 2025
9a513b5
chore: update implementation
ShabiShett07 May 27, 2025
d485742
chore: add void datatype
ShabiShett07 May 27, 2025
f3bcc1c
chore: add void datatype
ShabiShett07 May 27, 2025
3128670
chore: update fortran
ShabiShett07 May 27, 2025
04a6ba8
chore: update pointer
ShabiShett07 May 27, 2025
48d6ebb
chore: update precision
ShabiShett07 May 27, 2025
6d81a32
chore: update implementation
ShabiShett07 May 28, 2025
5c0bf73
chore: update indentation
ShabiShett07 May 28, 2025
12d0109
chore: update implementation
ShabiShett07 May 28, 2025
e424d87
chore: update fortan wrapper
ShabiShett07 May 28, 2025
4c6be03
chore: update fortan wrapper
ShabiShett07 May 28, 2025
a2a37b8
remove: unused packages
ShabiShett07 May 28, 2025
a5f41d1
chore: clean-up
ShabiShett07 Jun 18, 2025
0102822
chore: minor clean-up
ShabiShett07 Jun 18, 2025
55e9205
chore: minor clean-up
ShabiShett07 Jun 18, 2025
22b44fc
Merge branch 'develop' into feature/c/zdscal
ShabiShett07 Jun 20, 2025
667dea7
chore: minor clean-up
ShabiShett07 Jun 20, 2025
dcedfd9
docs: fix param name
kgryte Sep 7, 2025
6e81a38
docs: fix parameter name
kgryte Sep 7, 2025
163905c
docs: fix signatures
kgryte Sep 7, 2025
6ff7063
docs: revert changes
kgryte Sep 7, 2025
85d428e
docs: fix type
kgryte Sep 7, 2025
784e08a
docs: fix signature
kgryte Sep 7, 2025
553f334
style: fix spacing
kgryte Sep 7, 2025
736d820
docs: fix spacing
kgryte Sep 7, 2025
e9d0c82
docs: remove comment
kgryte Sep 7, 2025
075da31
docs: fix comment
kgryte Sep 7, 2025
9cbecf0
bench: add cast
kgryte Sep 7, 2025
90c0dcd
bench: add cast
kgryte Sep 7, 2025
082d521
docs: update comments
kgryte Sep 7, 2025
967b40b
refactor: update include guards
kgryte Sep 7, 2025
56f9199
refactor: update include guards
kgryte Sep 7, 2025
a4f2ca6
refactor: update include guards and fix include
kgryte Sep 7, 2025
06b0a12
fix: use correct signature
kgryte Sep 7, 2025
3cc2649
refactor: remove include
kgryte Sep 7, 2025
1a62c94
refactor: remove include
kgryte Sep 7, 2025
8b63622
refactor: remove include
kgryte Sep 7, 2025
5da2233
style: add spaces
kgryte Sep 7, 2025
03664e1
refactor: remove unnecessary variable
kgryte Sep 7, 2025
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
142 changes: 142 additions & 0 deletions lib/node_modules/@stdlib/blas/base/zdscal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,148 @@ 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/zdscal.h"
```

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

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

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

stdlib_complex128_t x[] = {
stdlib_complex128( 1.0, 2.0 ),
stdlib_complex128( 3.0, 4.0 ),
stdlib_complex128( 5.0, 6.0 )
};

c_zdscal( 3, 2.0, x, 1 );
```

The function accepts the following arguments:

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

```c
void c_zdscal( const CBLAS_INT N, const double alpha, void *X, const CBLAS_INT strideX );
```

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

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

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

stdlib_complex128_t x[] = {
stdlib_complex128( 1.0, 2.0 ),
stdlib_complex128( 3.0, 4.0 ),
stdlib_complex128( 5.0, 6.0 )
};

c_zdscal_ndarray( 3, 2.0, x, 1, 0 );
```
The function accepts the following arguments:
- **N**: `[in] CBLAS_INT` number of indexed elements.
- **alpha**: `[in] double` 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_zdscal_ndarray( const CBLAS_INT N, const double 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/zdscal.h"
#include "stdlib/complex/float64/ctor.h"
#include "stdlib/complex/float64/real.h"
#include "stdlib/complex/float64/imag.h"
#include <stdio.h>

int main( void ) {
// Create strided arrays:
stdlib_complex128_t x[] = {
stdlib_complex128( 1.0, 2.0 ),
stdlib_complex128( 3.0, 4.0 ),
stdlib_complex128( 5.0, 6.0 ),
stdlib_complex128( 7.0, 8.0 )
};

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

// Specify stride lengths:
const int strideX = 1;

c_zdscal( N, 2.0, (void *)x, strideX );

// Print the result:
for ( int i = 0; i < N; i++ ) {
printf( "x[ %i ] = %lf + %lfj\n", i, stdlib_complex128_real( x[ i ] ), stdlib_complex128_imag( x[ i ] ) );
}

c_zdscal_ndarray( N, 2.0, (void *)x, strideX, 0 );

// Print the result:
for ( int i = 0; i < N; i++ ) {
printf( "x[ %i ] = %lf + %lfj\n", i, stdlib_complex128_real( x[ i ] ), stdlib_complex128_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 Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2025 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 isnan = require( '@stdlib/math/base/assert/is-nan' );
var pow = require( '@stdlib/math/base/special/pow' );
var Complex128Array = require( '@stdlib/array/complex128' );
var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' );
var tryRequire = require( '@stdlib/utils/try-require' );
var pkg = require( './../package.json' ).name;


// VARIABLES //

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


// FUNCTIONS //

/**
* Creates a benchmark function.
*
* @private
* @param {PositiveInteger} len - array length
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var x = new Complex128Array( 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++ ) {
zdscal( x.length, 2.0, x, 1 );
if ( isnan( viewX[ i%(len*2) ] ) ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnan( 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 );
}
}

main();
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2025 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 isnan = require( '@stdlib/math/base/assert/is-nan' );
var pow = require( '@stdlib/math/base/special/pow' );
var Complex128Array = require( '@stdlib/array/complex128' );
var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' );
var tryRequire = require( '@stdlib/utils/try-require' );
var pkg = require( './../package.json' ).name;


// VARIABLES //

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


// FUNCTIONS //

/**
* Creates a benchmark function.
*
* @private
* @param {PositiveInteger} len - array length
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var x = new Complex128Array( 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++ ) {
zdscal( x.length, 2.0, x, 1, 0 );
if ( isnan( viewX[ i%(len*2) ] ) ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnan( 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 );
}
}

main();
Loading
Loading