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
266 changes: 266 additions & 0 deletions lib/node_modules/@stdlib/blas/base/drotmg/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,266 @@
<!--

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

-->

# drotmg

> Construct a Given plane rotation.

<section class="usage">

## Usage

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

#### drotmg( d1, d2, x1, y1 )

Constructs a Given plane rotation provided four double-precision floating-point values `d1`, `d2`, `x1` and `y1`.

```javascript
var out = drotmg( 5.0, 4.0, 1.0, -2.0 );
// returns <Float64Array>[ 1.0, -0.625, 0.0, 0.0, -0.5 ]
```

The function has the following parameters:

- **d1**: scaling factor for the first vector component.
- **d2**: scaling factor for the second vector component.
- **x1**: first component of the first vector.
- **y1**: first component of the second vector.

#### drotmg.assign( d1, d2, x1, y1, out, stride, offset )

Constructs a Given plane rotation provided two double-precision floating-point values d1, d2, x1 and y1 and assigns results to an output array.

```javascript
var Float64Array = require( '@stdlib/array/float64' );

var out = new Float64Array( 5 );

var y = drotmg.assign( 5.0, 4.0, 1.0, -2.0, out, 1, 0 );
// returns <Float64Array>[ 1.0, -0.625, 0.0, 0.0, -0.5 ]

var bool = ( y === out );
// returns true
```

</section>

<!-- /.usage -->

<section class="notes">

## Notes

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

</section>

<!-- /.notes -->

## Examples

<section class="examples">

```javascript
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
var drotmg = require( '@stdlib/blas/base/drotmg' );

var out;
var y1;
var x1;
var d2;
var d1;
var i;
for ( i = 0; i < 100; i++ ) {
d1 = discreteUniform( -5, 5 );
d2 = discreteUniform( -5, 5 );
x1 = discreteUniform( -5, 5 );
y1 = discreteUniform( -5, 5 );
out = drotmg( d1, d2, x1, y1 );
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
#include "stdlib/blas/base/drotmg.h"
```

#### c_drotmg( d1, d2, x1, y1, \*Out, strideOut )

Constructs a Given plane rotation provided four double-precision floating-point values `d1`, `d2`, `x1` & `y1`and assigns results to an output array.


```c
double Out[5];

c_drotmg( 5.0, 4.0, 1.0, -2.0, Out, 1 );
// Out => <Float64Array>[ 1.0, -0.625, 0.0, 0.0, -0.5]
```

The function accepts the following arguments:

- **d1**: `[in] double` scaling factor for the first vector component.
- **d2**: `[in] double` scaling factor for the second vector component.
- **x1**: `[in] double` first component of the first vector.
- **y1**: `[in] double` first component of the second vector.
- **Out**: `[inout] double*` output array.
- **strideOut**: `[in] CBLAS_INT` stride length for `Out`.


```c
void c_drotmg( double d1, double d2, double x1, double y1, double* Out, const CBLAS_INT strideOut );
```

#### c_drotmg_assign( d1, d2, x1, y1, \*Out, strideOut, offsetOut )

Constructs a Given plane rotation provided four double-precision floating-point values `d1`, `d2`, `x1` & `y1`and assigns results to an output array using alternative indexing semantics..

```c
double Out[5];

c_drotmg( 5.0, 4.0, 1.0, -2.0, Out, 1, 0 );
// Out => <Float64Array>[ 1.0, -0.625, 0.0, 0.0, -0.5]
```

The function accepts the following arguments:

- **d1**: `[in] double` scaling factor for the first vector component.
- **d2**: `[in] double` scaling factor for the second vector component.
- **x1**: `[in] double` first component of the first vector.
- **y1**: `[in] double` first component of the second vector.
- **Out**: `[inout] double*` output array.
- **strideOut**: `[in] CBLAS_INT` stride length for `Out`.
- **offsetOut**: `[in] CBLAS_INT` starting index for `Out`.

Given transformation.

```c
void c_drotmg_assign( double d1, double d2, double x1, double y1, 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/drotmg.h"
#include <stdio.h>

int main( void ) {
const double d1 = 5.0;
const double d2 = 4.0;
const double x1 = 1.0;
const double y1 = -2.0;
int i;

// Create strided arrays:
double out[ 5 ];

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

// Apply plane rotation:
c_drotmg( d1, d2, x1, y1, out, strideOut );

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

// Apply plane rotation
c_drotmg_assign( d1, d2, x1, y1, out, strideOut, 0 );

// Print the result:
for ( i = 0; i < 5; 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">

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

[drotmg]: http://www.netlib.org/lapack/explore-html/df/d28/group__single__blas__level1.html

</section>

<!-- /.links -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/**
* @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 discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var Float64Array = require( '@stdlib/array/float64' );
var format = require( '@stdlib/string/format' );
var pkg = require( './../package.json' ).name;
var drotmg = require( './../lib/assign.js' );


// VARIABLES //

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


// MAIN //

bench( format( '%s:assign', pkg ), function benchmark( b ) {
var out;
var d1;
var d2;
var x1;
var y1;
var z;
var i;

d1 = discreteUniform( 100, -5, 5, options );
d2 = discreteUniform( 100, -5, 5, options );
x1 = discreteUniform( 100, -5, 5, options );
y1 = discreteUniform( 100, -5, 5, options );
out = new Float64Array( 5 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
z = drotmg( d1[ i%d1.length ], d2[ i%d2.length ], x1[ i%x1.length ], y1[ i%y1.length ], out, 1, 0 ); // eslint-disable-line max-len
if ( typeof z !=='object' ) {
b.fail( 'should return an array' );
}
}
b.toc();
if ( isnan( z[ i%5 ] ) ) {
b.fail( 'should return the output array' );
}
b.pass( 'benchmark finished' );
b.end();
});
Loading