Skip to content

feat: add blas/base/zrotg #6697

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
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
191 changes: 191 additions & 0 deletions lib/node_modules/@stdlib/blas/base/zrotg/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
<!--

@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.

-->

# zrotg

> Constructs a Givens plane rotation.

<section class="usage">

## Usage

```javascript
var zrotg = require( '@stdlib/blas/base/zrotg' );
```

#### zrotg( za, zb )

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

```javascript
var Complex128 = require( '@stdlib/complex/float64/ctor' );

var za = new Complex128( 4.0, 3.0 );
// returns <Complex128>

var zb = new Complex128( 0.0, 0.0 );
// returns <Complex128>

var out = zrotg( za, zb );
// out => <Float64Array>[ 4.0, 3.0, 1.0, 0.0, 0.0 ]
```

The function has the following parameters:

- **za**: rotational elimination parameter.
- **za**: rotational elimination parameter.

Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views.

<!-- eslint-disable stdlib/capitalized-comments -->

</section>

<!-- /.usage -->

<section class="notes">

## Notes

- `zrotg()` corresponds to the [BLAS][blas] level 1 function [`zrotg`][zrotg].

</section>

<!-- /.notes -->

<section class="examples">

## Examples

<!-- eslint no-undef: "error" -->

```javascript
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
var Complex128 = require( '@stdlib/complex/float64/ctor' );
var zrotg = require( '@stdlib/blas/base/zrotg' );

var out;
var i;

function rand() {
return new Complex128( discreteUniform( -5, 5 ), discreteUniform( -5, 5 ) );
}

for ( i = 0; i < 100; i++ ) {
out = zrotg( rand(), rand() );
console.log( out );
}
```

</section>

<!-- /.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
TODO
```

#### TODO

TODO.

```c
TODO
```

TODO

```c
TODO
```

</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
TODO
```

</section>

<!-- /.examples -->

</section>

<!-- /.c -->

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

<section class="related">

</section>

<!-- /.related -->

<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="links">

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

[zrotg]: https://www.netlib.org/lapack/explore-html/d7/dc5/group__rotg_ga97ce56a6808661b36ab62269393ac10e.html

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

</section>

<!-- /.links -->
55 changes: 55 additions & 0 deletions lib/node_modules/@stdlib/blas/base/zrotg/benchmark/benchmark.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* @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 bench = require( '@stdlib/bench' );
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var Complex128 = require( '@stdlib/complex/float64/ctor' );
var pkg = require( './../package.json' ).name;
var zrotg = require( './../lib' );


// MAIN //

bench( pkg, function benchmark( b ) {
var za;
var zb;
var z;
var i;

za = new Complex128( discreteUniform( -5, 5 ), discreteUniform( -5, 5 ) );
zb = new Complex128( discreteUniform( -5, 5 ), discreteUniform( -5, 5 ) );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
z = zrotg( za, zb );
if ( isnan( z[ i%4 ] ) ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnan( z[ i%4 ] ) ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
b.end();
});
28 changes: 28 additions & 0 deletions lib/node_modules/@stdlib/blas/base/zrotg/docs/repl.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

{{alias}}( za, zb )
Constructs a Givens plane rotation from two double-precision complex
floating-point numbers.

Parameters
----------
za: Complex128
Rotational elimination parameter.

zb: Complex128
Rotational elimination parameter.

Returns
-------
out: Float64Array
Computed values.

Examples
--------
// Standard usage:
> var za = new {{alias:@stdlib/complex/float64/ctor}}( 4.0, 3.0 );
> var zb = new {{alias:@stdlib/complex/float64/ctor}}( 0.0, 0.0 );
> var out = {{alias}}( za, zb )
out => <Float64Array>[ 4.0, 3.0, 1.0, 0.0, 0.0 ]

See Also
--------
53 changes: 53 additions & 0 deletions lib/node_modules/@stdlib/blas/base/zrotg/docs/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* @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.
*/

// TypeScript Version: 4.1

/// <reference types="@stdlib/types"/>

import { Complex128 } from '@stdlib/types/complex';

/**
* Constructs a Givens plane rotation.
*
* @param za - rotational elimination parameter
* @param zb - rotational elimination parameter
* @returns output array
*
* @example
* var Complex128 = require( '@stdlib/complex/float64/ctor' );
*
* var za = new Complex128( 4.0, 3.0 );
* var zb = new Complex128( 0.0, 0.0 );
*
* var out = zrotg( za, zb );
* // returns <Float64Array>[ 4.0, 3.0, 1.0, 0.0, 0.0 ]
*
* @example
* var za = new Complex128( 1.0, 2.0 );
* var zb = new Complex128( 3.0, 4.0 );
*
* var out = zrotg( za, zb );
* // returns <Float64Array>[ ~1.732, ~5.1961, ~0.5773, ~0.8082, ~0.1154 ]
*/
declare function zrotg( za: Complex128, zb: Complex128 ): Float64Array;


// EXPORTS //

export = zrotg;
63 changes: 63 additions & 0 deletions lib/node_modules/@stdlib/blas/base/zrotg/docs/types/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* @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.
*/

import Complex128 = require( '@stdlib/complex/float64/ctor' );
import zrotg = require( './index' );


// TESTS //

// The function returns a Float64Array...
{
const za = new Complex128( 1.0, 1.0 );
const zb = new Complex128( 2.0, 2.0 );

zrotg( za, zb ); // $ExpectType Float64Array
}

// The compiler throws an error if the function is provided an argument which is not a number...
{
const za = new Complex128( 1.0, 1.0 );
const zb = new Complex128( 2.0, 2.0 );

zrotg( true, zb ); // $ExpectError
zrotg( false, zb ); // $ExpectError
zrotg( null, zb ); // $ExpectError
zrotg( undefined, zb ); // $ExpectError
zrotg( '5', zb ); // $ExpectError
zrotg( [], zb ); // $ExpectError
zrotg( {}, zb ); // $ExpectError

zrotg( za, true ); // $ExpectError
zrotg( za, false ); // $ExpectError
zrotg( za, null ); // $ExpectError
zrotg( za, undefined ); // $ExpectError
zrotg( za, '5' ); // $ExpectError
zrotg( za, [] ); // $ExpectError
zrotg( za, {} ); // $ExpectError
}

// The compiler throws an error if the function is provided an unsupported number of arguments...
{
const za = new Complex128( 1.0, 1.0 );
const zb = new Complex128( 2.0, 2.0 );

zrotg(); // $ExpectError
zrotg( za ); // $ExpectError
zrotg( za, zb, 3.0 ); // $ExpectError
}
Loading