Skip to content

Latest commit

 

History

History
245 lines (154 loc) · 5.33 KB

File metadata and controls

245 lines (154 loc) · 5.33 KB

drotg

Construct a Givens plane rotation.

Usage

var drotg = require( '@stdlib/blas/base/drotg' );

drotg( a, b )

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

var out = drotg( 0.0, 2.0 );
// returns <Float64Array>[ 2.0, 1.0, 0.0, 1.0 ]

The function has the following parameters:

  • a: rotational elimination parameter.
  • b: rotational elimination parameter.

drotg.assign( a, b, out, stride, offset )

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

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

var out = new Float64Array( 4 );

var y = drotg.assign( 0.0, 2.0, out, 1, 0 );
// returns <Float64Array>[ 2.0, 1.0, 0.0, 1.0 ]

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

Notes

  • drotg() corresponds to the BLAS level 1 function drotg.

Examples

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

var out;
var i;

for ( i = 0; i < 100; i++ ) {
    out = drotg( discreteUniform( -5, 5 ), discreteUniform( -5, 5 ) );
    console.log( out );
}

C APIs

Usage

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

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

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.
void c_drotg_assign( const double a, const double b, double *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut );

Examples

#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 ] );
    }
}