Skip to content
Draft
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
133 changes: 132 additions & 1 deletion lib/node_modules/@stdlib/blas/base/drotg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@license Apache-2.0

Copyright (c) 2023 The Stdlib Authors.
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.
Expand Down Expand Up @@ -76,6 +76,8 @@ var bool = ( y === out );

<section class="examples">

## Examples

```javascript
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
var drotg = require( '@stdlib/blas/base/drotg' );
Expand All @@ -93,6 +95,135 @@ for ( i = 0; i < 100; i++ ) {

<!-- /.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/drotg.h"
```

#### c_drotg( a, b, \*Out, strideOut )

Constructs a Givens plane rotation provided two double-precision floating-point values `a` and `b`.

```c
double Out[ 4 ];
c_drotg( 0.0, 2.0, Out, 1 );
// Out => [ 2.0, 1.0, 0.0, 1.0 ]
```

The function accepts the following arguments:

- **a**: `[in] double` rotational elimination parameter.
- **b**: `[in] double` rotational elimination parameter.
- **Out**: `[out] double*` output array.
- **strideOut**: `[in] CBLAS_INT` stride length for `Out`.

```c
void c_drotg( const double a, const double b, double *Out, const CBLAS_INT strideOut );
```

#### c_drotg_assign( a, b, \*Out, strideOut, offsetOut )

Constructs a Givens plane rotation provided two double-precision floating-point values `a` and `b` using alternative indexing semantics.

```c
double Out[ 4 ];
c_drotg_assign( 0.0, 2.0, Out, 1, 0 );
// Out => [ 2.0, 1.0, 0.0, 1.0 ]
```

The function accepts the following arguments:

- **a**: `[in] double` rotational elimination parameter.
- **b**: `[in] double` rotational elimination parameter.
- **Out**: `[out] double*` output array.
- **strideOut**: `[in] CBLAS_INT` stride length for `Out`.
- **offsetOut**: `[in] CBLAS_INT` starting index for `Out`.

```c
void c_drotg_assign( const double a, const double b, double *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut );
```

</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/drotg.h"
#include <stdio.h>

int main( void ) {
// Specify rotational elimination parameters:
const double a = 0.0;
const double b = 2.0;
int i;

// Create strided arrays:
double Out[ 4 ];

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

// Apply plane rotation:
c_drotg( a, b, Out, strideOut );

// Print the result:
for ( i = 0; i < 4; i++ ) {
printf( "Out[%d] = %lf\n", i, Out[ i ] );
}

// Apply plane rotation using alternative indexing semantics:
c_drotg_assign( a, b, Out, strideOut, 0 );

// Print the result:
for ( i = 0; i < 4; i++ ) {
printf( "Out[%d] = %lf\n", i, Out[ 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
108 changes: 108 additions & 0 deletions lib/node_modules/@stdlib/blas/base/drotg/benchmark/benchmark.assign.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/**
* @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 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 format = require( '@stdlib/string/format' );
var Float64Array = require( '@stdlib/array/float64' );
var pkg = require( './../package.json' ).name;
var drotg = require( './../lib/assign.js' );


// VARIABLES //

var options = {
'dtype': 'float32'
};


// FUNCTIONS //

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

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

out = new Float64Array(4);

b.tic();
for (i = 0; i < b.iterations; i++) {
z = drotg(va[i % len], vb[i % len], out, 1, 0);
if (isnanf(z[i % 4])) {
b.fail('should not return NaN');
}
}
b.toc();
if (isnanf(z[i % 4])) {
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(format('%s:assign:len=%d', pkg, len), f);
}
}

main();
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/**
* @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 format = require( '@stdlib/string/format' );
var tryRequire = require( '@stdlib/utils/try-require' );
var Float64Array = require( '@stdlib/array/float64' );
var pkg = require( './../package.json' ).name;


// VARIABLES //

var drotg = tryRequire(resolve(__dirname, './../lib/assign.native.js'));
var opts = {
'skip': (drotg 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 va = uniform(len, -100.0, 100.0, options);
var vb = uniform(len, -100.0, 100.0, options);
return benchmark;

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

out = new Float64Array(4);

b.tic();
for (i = 0; i < b.iterations; i++) {
z = drotg(va[i % len], vb[i % len], out, 1, 0);
if (isnanf(z[i % 4])) {
b.fail('should not return NaN');
}
}
b.toc();
if (isnanf(z[i % 4])) {
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(format('%s::native:len=%d', pkg, len), opts, f);
}
}

main();
Loading