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/srotg/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 @@ -92,6 +92,137 @@ 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/srotg.h"
```

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

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

```c
float Out[4];
c_srotg( 0.0, 2.0, Out, 1 );
// Out => <Float32Array>[ 2.0, 1.0, 0.0, 1.0 ]
```

The function accepts the following arguments:

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

```c
void c_srotg_assign( float a, float b, float* Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut );
```

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

Constructs a Givens plane rotation provided two single-precision floating-point values `a` and `b` and assigns results to an output array.

```c
float Out[4];
c_srotg_assign( 0.0, 2.0, Out, 1, 0 );
// Out => <Float32Array>[ 2.0, 1.0, 0.0, 1.0 ]
```

The function accepts the following arguments:

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

Givens transformation.

```c
void c_srotg_assign( float a, float b, float* 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/srotg.h"
#include <stdio.h>

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

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

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

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

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

// Apply plane rotation
c_srotg_assign( a, b, Out, strideOut, 0 );

// Print the result:
for ( i = 0; i < 4; i++ ) {
printf( "Out[%d] = %f\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/srotg/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 Float32Array = require( '@stdlib/array/float32' );
var pkg = require( './../package.json' ).name;
var srotg = 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 Float32Array(4);

b.tic();
for (i = 0; i < b.iterations; i++) {
z = srotg(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 Float32Array = require( '@stdlib/array/float32' );
var pkg = require( './../package.json' ).name;


// VARIABLES //

var srotg = tryRequire(resolve(__dirname, './../lib/assign.native.js'));
var opts = {
'skip': (srotg 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 Float32Array(4);

b.tic();
for (i = 0; i < b.iterations; i++) {
z = srotg(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