Skip to content

Commit 134d5a7

Browse files
committed
docs: add files
--- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: passed - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: passed - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: passed - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: passed - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na ---
1 parent 24c63df commit 134d5a7

File tree

9 files changed

+566
-75
lines changed

9 files changed

+566
-75
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2023 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
25+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
26+
var Complex128Array = require( '@stdlib/array/complex128' );
27+
var Complex128 = require( '@stdlib/complex/float64/ctor' );
28+
var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' );
29+
var pkg = require( './../package.json' ).name;
30+
var zrotg = require( './../lib' );
31+
32+
33+
// VARIABLES //
34+
35+
var OPTS = {
36+
'dtype': 'float64'
37+
};
38+
39+
40+
// MAIN //
41+
42+
bench( pkg, function benchmark( b ) {
43+
var viewY;
44+
var za;
45+
var zb;
46+
var z;
47+
var i;
48+
49+
za = new Complex128( discreteUniform( -5, 5 ), discreteUniform( -5, 5 ) );
50+
zb = new Complex128( discreteUniform( -5, 5 ), discreteUniform( -5, 5 ) );
51+
52+
b.tic();
53+
for ( i = 0; i < b.iterations; i++ ) {
54+
z = zrotg( za, zb );
55+
56+
viewY = reinterpret( z, 0 );
57+
if ( isnan( viewY[ i%4 ] ) ) {
58+
b.fail( 'should not return NaN' );
59+
}
60+
}
61+
b.toc();
62+
if ( isnan( viewY[ i%4 ] ) ) {
63+
b.fail( 'should not return NaN' );
64+
}
65+
b.pass( 'benchmark finished' );
66+
b.end();
67+
});
68+
69+
bench( pkg+':assign', function benchmark( b ) {
70+
var viewY;
71+
var out;
72+
var za;
73+
var zb;
74+
var z;
75+
var i;
76+
77+
za = new Complex128( discreteUniform( -5, 5 ), discreteUniform( -5, 5 ) );
78+
zb = new Complex128( discreteUniform( -5, 5 ), discreteUniform( -5, 5 ) );
79+
out = new Complex128Array( 4 );
80+
81+
b.tic();
82+
for ( i = 0; i < b.iterations; i++ ) {
83+
z = zrotg.assign( za, zb, out, 1, 0 );
84+
85+
viewY = reinterpret( z, 0 );
86+
if ( typeof z !=='object' ) {
87+
b.fail( 'should return an array' );
88+
}
89+
}
90+
b.toc();
91+
if ( isnan( viewY[ i%4 ] ) ) {
92+
b.fail( 'should return the output array' );
93+
}
94+
b.pass( 'benchmark finished' );
95+
b.end();
96+
});
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
2+
{{alias}}( za, zb )
3+
Constructs a Givens plane rotation from two double-precision complex
4+
floating-point numbers.
5+
6+
Parameters
7+
----------
8+
za: Complex128
9+
Rotational elimination parameter.
10+
11+
zb: Complex128
12+
Rotational elimination parameter.
13+
14+
Returns
15+
-------
16+
out: Complex128Array
17+
Computed values.
18+
19+
Examples
20+
--------
21+
// Standard usage:
22+
> var za = new {{alias:@stdlib/complex/float64/ctor}}( 4.0, 3.0 );
23+
> var zb = new {{alias:@stdlib/complex/float64/ctor}}( 0.0, 0.0 );
24+
> var out = {{alias}}( za, zb )
25+
out => <Complex128Array>[ 4.0, 3.0, 0.0, 0.0, 1.0, 0.0, 0.0 ]
26+
27+
28+
{{alias}}.assign( za, zb, out, stride, offset )
29+
Constructs a Givens plane rotation from two double-precision complex
30+
floating-point numbers and assigns the results to an output array.
31+
32+
Parameters
33+
----------
34+
za: Complex128
35+
Rotational elimination parameter.
36+
37+
zb: Complex128
38+
Rotational elimination parameter.
39+
40+
out: Complex128Array
41+
Output array.
42+
43+
stride: integer
44+
Output array stride.
45+
46+
offset: integer
47+
Output array index offset.
48+
49+
Returns
50+
-------
51+
out: Complex128Array
52+
Output array.
53+
54+
Examples
55+
--------
56+
> var za = new {{alias:@stdlib/complex/float64/ctor}}( 4.0, 3.0 );
57+
> var zb = new {{alias:@stdlib/complex/float64/ctor}}( 0.0, 0.0 );
58+
> var out = new {{alias:@stdlib/array/complex128}}( 4 );
59+
> var y = {{alias}}.assign( za, zb, out, 1, 0 )
60+
<Complex128Array>[ 4.0, 3.0, 0.0, 0.0, 1.0, 0.0, 0.0 ]
61+
> var bool = ( y === out )
62+
true
63+
64+
See Also
65+
--------
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2023 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
// TypeScript Version: 4.1
20+
21+
/// <reference types="@stdlib/types"/>
22+
23+
import { Complex128Array } from '@stdlib/types/array';
24+
import { Complex128 } from '@stdlib/types/complex';
25+
26+
/**
27+
* Interface describing `zrotg`.
28+
*/
29+
interface Routine {
30+
/**
31+
* Constructs a Givens plane rotation.
32+
*
33+
* @param za - rotational elimination parameter
34+
* @param zb - rotational elimination parameter
35+
* @returns output array
36+
*
37+
* @example
38+
* var Complex128 = require( '@stdlib/complex/float64/ctor' );
39+
*
40+
* var za = new Complex128( 4.0, 3.0 );
41+
* var zb = new Complex128( 0.0, 0.0 );
42+
*
43+
* var out = zrotg( za, zb );
44+
* // <Complex128Array>[ 4.0, 3.0, 0.0, 0.0, 1.0, 0.0, 0.0 ]
45+
*
46+
* @example
47+
* var za = new Complex128( 1.0, 2.0 );
48+
* var zb = new Complex128( 3.0, 4.0 );
49+
*
50+
* var out = zrotg( za, zb );
51+
* // returns <Complex128Array>[ ~1.732, ~5.1961, 2.0, 4.0, ~0.5773, ~0.8082, ~0.1154 ]
52+
*/
53+
( za: Complex128, zb: Complex128 ): Complex128Array;
54+
55+
/**
56+
* Constructs a Givens plane rotation.
57+
*
58+
* @param za - rotational elimination parameter
59+
* @param zb - rotational elimination parameter
60+
* @param out - output array
61+
* @param stride - index increment
62+
* @param offset - starting index
63+
* @returns output array
64+
*
65+
* @example
66+
* var Complex128Array = require( '@stdlib/array/complex128' );
67+
*
68+
* var Complex128 = require( '@stdlib/complex/float64/ctor' );
69+
*
70+
* var za = new Complex128( 4.0, 3.0 );
71+
* var zb = new Complex128( 0.0, 0.0 );
72+
* var out = new Complex128Array( 4 );
73+
*
74+
* var y = zrotg.assign( za, zb, out, 1, 0 );
75+
* // returns <Complex128Array>[ 4.0, 3.0, 0.0, 0.0, 1.0, 0.0, 0.0 ]
76+
*
77+
* var bool = ( y === out );
78+
* // returns true
79+
*/
80+
assign( za: Complex128, zb: Complex128, out: Complex128Array, stride: number, offset: number ): Complex128Array;
81+
}
82+
83+
/**
84+
* Constructs a Givens plane rotation.
85+
*
86+
* @param za - rotational elimination parameter
87+
* @param zb - rotational elimination parameter
88+
* @returns output array
89+
*
90+
* @example
91+
* var Complex128 = require( '@stdlib/complex/float64/ctor' );
92+
*
93+
* var za = new Complex128( 4.0, 3.0 );
94+
* var zb = new Complex128( 0.0, 0.0 );
95+
*
96+
* var out = zrotg( za, zb );
97+
* // returns <Complex128Array>[ 4.0, 3.0, 0.0, 0.0, 1.0, 0.0, 0.0 ]
98+
*
99+
* @example
100+
* var Complex128Array = require( '@stdlib/array/complex128' );
101+
*
102+
* var za = new Complex128( 4.0, 3.0 );
103+
* var zb = new Complex128( 0.0, 0.0 );
104+
* var out = new Complex128Array( 4 );
105+
*
106+
* var y = zrotg.assign( za, zb, out, 1, 0 );
107+
* // returns <Complex128Array>[ 4.0, 3.0, 0.0, 0.0, 1.0, 0.0, 0.0 ]
108+
*
109+
* var bool = ( y === out );
110+
* // returns true
111+
*/
112+
declare var zrotg: Routine;
113+
114+
115+
// EXPORTS //
116+
117+
export = zrotg;

0 commit comments

Comments
 (0)