Skip to content

Commit 426f2b4

Browse files
committed
bench: add benchmarks
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: passed - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed ---
1 parent 594abb7 commit 426f2b4

File tree

10 files changed

+458
-255
lines changed

10 files changed

+458
-255
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 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/array/discrete-uniform' );
25+
var Float64Array = require( '@stdlib/array/float64' );
26+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
27+
var pkg = require( './../package.json' ).name;
28+
var dlartg = require( './../lib/dlartg.js' );
29+
30+
31+
// VARIABLES //
32+
33+
var opts = {
34+
'dtype': 'float64'
35+
};
36+
37+
38+
// MAIN //
39+
40+
bench( pkg, function benchmark( b ) {
41+
var C;
42+
var S;
43+
var R;
44+
var F;
45+
var G;
46+
var i;
47+
48+
F = discreteUniform( 1, -50, 50, opts );
49+
G = discreteUniform( 1, -50, 50, opts );
50+
C = new Float64Array( 1 );
51+
S = new Float64Array( 1 );
52+
R = new Float64Array( 1 );
53+
54+
b.tic();
55+
for ( i = 0; i < b.iterations; i++ ) {
56+
dlartg( F, G, C, S, R );
57+
if ( isnan( C[ 0 ] ) ) {
58+
b.fail( 'should not return NaN' );
59+
}
60+
}
61+
b.toc();
62+
if ( isnan( S[ 0 ] ) ) {
63+
b.fail( 'should not return NaN' );
64+
}
65+
b.pass( 'benchmark finished' );
66+
b.end();
67+
});
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 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/array/discrete-uniform' );
25+
var Float64Array = require( '@stdlib/array/float64' );
26+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
27+
var pkg = require( './../package.json' ).name;
28+
var dlartg = require( './../lib/ndarray.js' );
29+
30+
31+
// VARIABLES //
32+
33+
var opts = {
34+
'dtype': 'float64'
35+
};
36+
37+
38+
// MAIN //
39+
40+
bench( pkg, function benchmark( b ) {
41+
var C;
42+
var S;
43+
var R;
44+
var F;
45+
var G;
46+
var i;
47+
48+
F = discreteUniform( 1, -50, 50, opts );
49+
G = discreteUniform( 1, -50, 50, opts );
50+
C = new Float64Array( 1 );
51+
S = new Float64Array( 1 );
52+
R = new Float64Array( 1 );
53+
54+
b.tic();
55+
for ( i = 0; i < b.iterations; i++ ) {
56+
dlartg( F, 0, G, 0, C, 0, S, 0, R, 0 );
57+
if ( isnan( C[ 0 ] ) ) {
58+
b.fail( 'should not return NaN' );
59+
}
60+
}
61+
b.toc();
62+
if ( isnan( S[ 0 ] ) ) {
63+
b.fail( 'should not return NaN' );
64+
}
65+
b.pass( 'benchmark finished' );
66+
b.end();
67+
});

lib/node_modules/@stdlib/lapack/base/dlartg/docs/types/index.d.ts

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ interface Routine {
3131
*
3232
* @param F - single element array representing the first component of the vector to be rotated
3333
* @param G - single element array representing the second component of the vector to be rotated
34-
* @param CS - single element array overwritten by the cosine of the rotation
35-
* @param SN - single element array overwritten by the sine of the rotation
34+
* @param C - single element array overwritten by the cosine of the rotation
35+
* @param S - single element array overwritten by the sine of the rotation
3636
* @param R - single element array overwritten by the non-zero component of the rotated vector
3737
* @returns {void}
3838
*
@@ -41,16 +41,16 @@ interface Routine {
4141
*
4242
* var F = new Float64Array( [ 3.0 ] );
4343
* var G = new Float64Array( [ 4.0 ] );
44-
* var CS = new Float64Array( 1 );
45-
* var SN = new Float64Array( 1 );
44+
* var C = new Float64Array( 1 );
45+
* var S = new Float64Array( 1 );
4646
* var R = new Float64Array( 1 );
4747
*
48-
* dlartg( F, G, CS, SN, R );
48+
* dlartg( F, G, C, S, R );
4949
* // R => <Float64Array>[ 5.0 ]
50-
* // CS => <Float64Array>[ 0.6 ]
51-
* // SN => <Float64Array>[ 0.8 ]
50+
* // C => <Float64Array>[ 0.6 ]
51+
* // S => <Float64Array>[ 0.8 ]
5252
*/
53-
( F: Float64Array, G: Float64Array, CS: Float64Array, SN: Float64Array, R: Float64Array ): void;
53+
( F: Float64Array, G: Float64Array, C: Float64Array, S: Float64Array, R: Float64Array ): void;
5454

5555
/**
5656
* Generates a plane rotation of a vector using alternative indexing semantics such that the following equation is satisfied.
@@ -63,10 +63,10 @@ interface Routine {
6363
* @param offsetF - starting index for `F`
6464
* @param G - single element array representing the second component of the vector to be rotated
6565
* @param offsetG - starting index for `G`
66-
* @param CS - single element array overwritten by the cosine of the rotation
67-
* @param offsetCS - starting index for `CS`
68-
* @param SN - single element array overwritten by the sine of the rotation
69-
* @param offsetSN - starting index for `SN`
66+
* @param C - single element array overwritten by the cosine of the rotation
67+
* @param offsetC - starting index for `C`
68+
* @param S - single element array overwritten by the sine of the rotation
69+
* @param offsetS - starting index for `S`
7070
* @param R - single element array overwritten by the non-zero component of the rotated vector
7171
* @param offsetR - starting index for `R`
7272
* @returns {void}
@@ -76,16 +76,16 @@ interface Routine {
7676
*
7777
* var F = new Float64Array( [ 3.0 ] );
7878
* var G = new Float64Array( [ 4.0 ] );
79-
* var CS = new Float64Array( 1 );
80-
* var SN = new Float64Array( 1 );
79+
* var C = new Float64Array( 1 );
80+
* var S = new Float64Array( 1 );
8181
* var R = new Float64Array( 1 );
8282
*
83-
* dlartg.ndarray( F, 0, G, 0, CS, 0, SN, 0, R, 0 );
83+
* dlartg.ndarray( F, 0, G, 0, C, 0, S, 0, R, 0 );
8484
* // R => <Float64Array>[ 5.0 ]
85-
* // CS => <Float64Array>[ 0.6 ]
86-
* // SN => <Float64Array>[ 0.8 ]
85+
* // C => <Float64Array>[ 0.6 ]
86+
* // S => <Float64Array>[ 0.8 ]
8787
*/
88-
ndarray( F: Float64Array, offsetF: number, G: Float64Array, offsetG: number, CS: Float64Array, offsetCS: number, SN: Float64Array, offsetSN: number, R: Float64Array, offsetR: number ): void;
88+
ndarray( F: Float64Array, offsetF: number, G: Float64Array, offsetG: number, C: Float64Array, offsetC: number, S: Float64Array, offsetS: number, R: Float64Array, offsetR: number ): void;
8989
}
9090

9191
/**
@@ -97,8 +97,8 @@ interface Routine {
9797
*
9898
* @param F - single element array representing the first component of the vector to be rotated
9999
* @param G - single element array representing the second component of the vector to be rotated
100-
* @param CS - single element array overwritten by the cosine of the rotation
101-
* @param SN - single element array overwritten by the sine of the rotation
100+
* @param C - single element array overwritten by the cosine of the rotation
101+
* @param S - single element array overwritten by the sine of the rotation
102102
* @param R - single element array overwritten by the non-zero component of the rotated vector
103103
* @returns {void}
104104
*
@@ -107,28 +107,28 @@ interface Routine {
107107
*
108108
* var F = new Float64Array( [ 3.0 ] );
109109
* var G = new Float64Array( [ 4.0 ] );
110-
* var CS = new Float64Array( 1 );
111-
* var SN = new Float64Array( 1 );
110+
* var C = new Float64Array( 1 );
111+
* var S = new Float64Array( 1 );
112112
* var R = new Float64Array( 1 );
113113
*
114-
* dlartg( F, G, CS, SN, R );
114+
* dlartg( F, G, C, S, R );
115115
* // R => <Float64Array>[ 5.0 ]
116-
* // CS => <Float64Array>[ 0.6 ]
117-
* // SN => <Float64Array>[ 0.8 ]
116+
* // C => <Float64Array>[ 0.6 ]
117+
* // S => <Float64Array>[ 0.8 ]
118118
*
119119
* @example
120120
* var Float64Array = require( '@stdlib/array/float64' );
121121
*
122122
* var F = new Float64Array( [ 3.0 ] );
123123
* var G = new Float64Array( [ 4.0 ] );
124-
* var CS = new Float64Array( 1 );
125-
* var SN = new Float64Array( 1 );
124+
* var C = new Float64Array( 1 );
125+
* var S = new Float64Array( 1 );
126126
* var R = new Float64Array( 1 );
127127
*
128-
* dlartg.ndarray( F, 0, G, 0, CS, 0, SN, 0, R, 0 );
128+
* dlartg.ndarray( F, 0, G, 0, C, 0, S, 0, R, 0 );
129129
* // R => <Float64Array>[ 5.0 ]
130-
* // CS => <Float64Array>[ 0.6 ]
131-
* // SN => <Float64Array>[ 0.8 ]
130+
* // C => <Float64Array>[ 0.6 ]
131+
* // S => <Float64Array>[ 0.8 ]
132132
*/
133133
declare var dlartg: Routine;
134134

0 commit comments

Comments
 (0)