Skip to content

Commit 53d229f

Browse files
fix: improve benchmarks and other minor changes
--- 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: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - 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 f12a2af commit 53d229f

7 files changed

Lines changed: 91 additions & 73 deletions

File tree

lib/node_modules/@stdlib/lapack/base/dlasv2/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ limitations under the License.
2424
2525
<section class="intro">
2626

27-
The singular value decomposition of a 2x2 upper triangular matrix $ \begin{bmatrix} F & G \\ 0 & H \end{bmatrix}$ is given by -
27+
The singular value decomposition of a 2x2 upper triangular matrix $ \begin{bmatrix} F & G \\ 0 & H \end{bmatrix}$ is given by
2828

2929
<!-- <equation class="equation" label="eq:dlasv2_svd" align="center" raw="\left[\begin{array}{rr} \mathrm{CSL} & \mathrm{SNL} \\ -\mathrm{SNL} & \mathrm{CSL} \end{array}\right] \left[\begin{array}{rr} F & G \\ 0 & H \end{array}\right] \left[\begin{array}{rr} \mathrm{CSR} & -\mathrm{SNR} \\ \mathrm{SNR} & \mathrm{CSR} \end{array}\right] = \left[\begin{array}{rr} \mathrm{SSMAX} & 0 \\ 0 & \mathrm{SSMIN} \end{array}\right]" alt="Singular value decomposition of a 2x2 upper triangular matrix."> -->
3030

lib/node_modules/@stdlib/lapack/base/dlasv2/benchmark/benchmark.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,41 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24-
var uniform = require( '@stdlib/random/base/uniform' );
24+
var uniform = require( '@stdlib/random/array/uniform' );
2525
var Float64Array = require( '@stdlib/array/float64' );
2626
var format = require( '@stdlib/string/format' );
2727
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2828
var pkg = require( './../package.json' ).name;
2929
var dlasv2 = require( './../lib/dlasv2.js' );
3030

3131

32+
// VARIABLES //
33+
34+
var options = {
35+
'dtype': 'float64'
36+
};
37+
38+
3239
// MAIN //
3340

3441
bench( format( '%s', pkg ), function benchmark( b ) {
3542
var out;
43+
var N;
3644
var f;
3745
var g;
3846
var h;
3947
var i;
4048

49+
N = 100;
50+
f = uniform( N, -500.0, 500.0, options );
51+
g = uniform( N, -500.0, 500.0, options );
52+
h = uniform( N, -500.0, 500.0, options );
53+
4154
out = new Float64Array( 6 );
4255

4356
b.tic();
4457
for ( i = 0; i < b.iterations; i++ ) {
45-
f = uniform( -10.0, 10.0 );
46-
g = uniform( -10.0, 10.0 );
47-
h = uniform( -10.0, 10.0 );
48-
49-
dlasv2( f, g, h, out );
58+
dlasv2( f[ i%f.length ], g[ i%g.length ], h[ i%h.length ], out );
5059
if ( isnan( out[ i%out.length ] ) ) {
5160
b.fail( 'should not return NaN' );
5261
}

lib/node_modules/@stdlib/lapack/base/dlasv2/benchmark/benchmark.ndarray.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,41 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24-
var uniform = require( '@stdlib/random/base/uniform' );
24+
var uniform = require( '@stdlib/random/array/uniform' );
2525
var Float64Array = require( '@stdlib/array/float64' );
2626
var format = require( '@stdlib/string/format' );
2727
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2828
var pkg = require( './../package.json' ).name;
2929
var dlasv2 = require( './../lib/ndarray.js' );
3030

3131

32+
// VARIABLES //
33+
34+
var options = {
35+
'dtype': 'float64'
36+
};
37+
38+
3239
// MAIN //
3340

34-
bench( format( '%s', pkg ), function benchmark( b ) {
41+
bench( format( '%s:ndarray', pkg ), function benchmark( b ) {
3542
var out;
43+
var N;
3644
var f;
3745
var g;
3846
var h;
3947
var i;
4048

49+
N = 100;
50+
f = uniform( N, -500.0, 500.0, options );
51+
g = uniform( N, -500.0, 500.0, options );
52+
h = uniform( N, -500.0, 500.0, options );
53+
4154
out = new Float64Array( 6 );
4255

4356
b.tic();
4457
for ( i = 0; i < b.iterations; i++ ) {
45-
f = uniform( -10.0, 10.0 );
46-
g = uniform( -10.0, 10.0 );
47-
h = uniform( -10.0, 10.0 );
48-
49-
dlasv2( f, g, h, out, 1, 0 );
58+
dlasv2( f[ i%f.length ], g[ i%g.length ], h[ i%h.length ], out, 1, 0 );
5059
if ( isnan( out[ i%out.length ] ) ) {
5160
b.fail( 'should not return NaN' );
5261
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ interface Routine {
4545
* var out = new Float64Array( 6 );
4646
*
4747
* dlasv2( 2.0, 3.0, 4.0, out );
48-
* // out => <Float64Array>[ 1.5513263285176897, 5.1568776039816795, 0.9664996487646696, 0.25666793515702424, 0.7496781758158659, 0.6618025632357402 ]
48+
* // out => <Float64Array>[ ~1.5513, ~5.1569, ~0.9665, ~0.2567, ~0.7497, ~0.6618 ]
4949
*/
5050
( F: number, G: number, H: number, out: Float64Array ): Float64Array;
5151

@@ -72,7 +72,7 @@ interface Routine {
7272
* var out = new Float64Array( 6 );
7373
*
7474
* dlasv2.ndarray( 2.0, 3.0, 4.0, out, 1, 0 );
75-
* // out => <Float64Array>[ 1.5513263285176897, 5.1568776039816795, 0.9664996487646696, 0.25666793515702424, 0.7496781758158659, 0.6618025632357402 ]
75+
* // out => <Float64Array>[ ~1.5513, ~5.1569, ~0.9665, ~0.2567, ~0.7497, ~0.6618 ]
7676
*/
7777
ndarray( F: number, G: number, H: number, out: Float64Array, strideOut: number, offsetOut: number ): Float64Array;
7878
}

lib/node_modules/@stdlib/lapack/base/dlasv2/lib/base.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ function dlasv2( F, G, H, out, strideOut, offsetOut ) {
210210
snr = srt;
211211
}
212212

213-
// Correct signs 0f ssmax and ssmin
213+
// Correct signs of ssmax and ssmin
214214
if ( PMAX === 1 ) {
215215
tsign = copysign( 1.0, csr ) * copysign( 1.0, csl ) * copysign( 1.0, F );
216216
}

lib/node_modules/@stdlib/lapack/base/dlasv2/test/test.dlasv2.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,17 @@ var G_GT_F_AND_H = require( './fixtures/g_gt_f_and_h.json' );
4848
* @param {Object} t - test object
4949
* @param {Collection} actual - actual values
5050
* @param {Collection} expected - expected values
51-
* @param {number} rtol - relative tolerance
51+
* @param {number} maxULPs - maximum allowed ULP difference
5252
*/
53-
function isApprox( t, actual, expected, rtol ) {
53+
function isApprox( t, actual, expected, maxULPs ) {
5454
var i;
5555

5656
t.strictEqual( actual.length, expected.length, 'returns expected value' );
5757
for ( i = 0; i < expected.length; i++ ) {
5858
if ( actual[ i ] === expected[ i ] ) {
5959
t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' );
6060
} else {
61-
t.strictEqual( isAlmostSameValue( actual[ i ], expected[ i ], rtol ), true, 'returns expected value' );
61+
t.strictEqual( isAlmostSameValue( actual[ i ], expected[ i ], maxULPs ), true, 'returns expected value' );
6262
}
6363
}
6464
}
@@ -88,7 +88,7 @@ tape( 'the function computes the singular value decomposition of a triangular ma
8888

8989
dlasv2( data.F, data.G, data.H, out );
9090
expected = data.out;
91-
isApprox( t, out, expected, 1.0 );
91+
isApprox( t, out, expected, 1 );
9292
t.end();
9393
});
9494

@@ -103,7 +103,7 @@ tape( 'the function computes the singular value decomposition of a triangular ma
103103

104104
dlasv2( data.F, data.G, data.H, out );
105105
expected = data.out;
106-
isApprox( t, out, expected, 1.0 );
106+
isApprox( t, out, expected, 1 );
107107
t.end();
108108
});
109109

@@ -118,7 +118,7 @@ tape( 'the function computes the singular value decomposition of a triangular ma
118118

119119
dlasv2( data.F, data.G, data.H, out );
120120
expected = data.out;
121-
isApprox( t, out, expected, 1.0 );
121+
isApprox( t, out, expected, 1 );
122122
t.end();
123123
});
124124

@@ -133,7 +133,7 @@ tape( 'the function computes the singular value decomposition of a diagonal matr
133133

134134
dlasv2( data.F, data.G, data.H, out );
135135
expected = data.out;
136-
isApprox( t, out, expected, 1.0 );
136+
isApprox( t, out, expected, 1 );
137137
t.end();
138138
});
139139

@@ -148,7 +148,7 @@ tape( 'the function computes the singular value decomposition of a diagonal matr
148148

149149
dlasv2( data.F, data.G, data.H, out );
150150
expected = data.out;
151-
isApprox( t, out, expected, 1.0 );
151+
isApprox( t, out, expected, 1 );
152152
t.end();
153153
});
154154

@@ -163,7 +163,7 @@ tape( 'the function computes the singular value decomposition of a diagonal matr
163163

164164
dlasv2( data.F, data.G, data.H, out );
165165
expected = data.out;
166-
isApprox( t, out, expected, 1.0 );
166+
isApprox( t, out, expected, 1 );
167167
t.end();
168168
});
169169

@@ -174,7 +174,7 @@ tape( 'the function computes the singular value decomposition of a diagonal matr
174174
expected = new Float64Array( [ 1.0, PINF, 0.0, 1.0, 0.0, 1.0 ] );
175175
out = new Float64Array( 6 );
176176
out = dlasv2( PINF, 2.0, 1.0, out );
177-
isApprox( t, out, expected, 1.0 );
177+
isApprox( t, out, expected, 1 );
178178
t.end();
179179
});
180180

@@ -189,6 +189,6 @@ tape( 'the function computes the singular value decomposition of a diagonal matr
189189

190190
dlasv2( data.F, data.G, data.H, out );
191191
expected = data.out;
192-
isApprox( t, out, expected, 1.0 );
192+
isApprox( t, out, expected, 1 );
193193
t.end();
194194
});

0 commit comments

Comments
 (0)