Skip to content

Commit 73042f5

Browse files
committed
feat: add blas/ext/base/zdiff
--- 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: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - 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: missing_dependencies - task: lint_c_examples status: missing_dependencies - task: lint_c_benchmarks status: missing_dependencies - 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 9188369 commit 73042f5

34 files changed

Lines changed: 7098 additions & 0 deletions

lib/node_modules/@stdlib/blas/ext/base/zdiff/README.md

Lines changed: 402 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2026 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 uniform = require( '@stdlib/random/array/uniform' );
25+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
26+
var pow = require( '@stdlib/math/base/special/pow' );
27+
var Complex128Array = require( '@stdlib/array/complex128' );
28+
var format = require( '@stdlib/string/format' );
29+
var pkg = require( './../package.json' ).name;
30+
var zdiff = require( './../lib/zdiff.js' );
31+
32+
33+
// VARIABLES //
34+
35+
var options = {
36+
'dtype': 'float64'
37+
};
38+
39+
40+
// FUNCTIONS //
41+
42+
/**
43+
* Creates a benchmark function.
44+
*
45+
* @private
46+
* @param {PositiveInteger} len - array length
47+
* @returns {Function} benchmark function
48+
*/
49+
function createBenchmark( len ) {
50+
var obuf;
51+
var wbuf;
52+
var xbuf;
53+
var pbuf;
54+
var abuf;
55+
var ol;
56+
var N1;
57+
var N2;
58+
var x;
59+
var p;
60+
var a;
61+
var w;
62+
var o;
63+
var k;
64+
var N;
65+
66+
N = len;
67+
N1 = 1;
68+
N2 = 1;
69+
k = 1;
70+
ol = N + N1 + N2 - k;
71+
72+
xbuf = uniform( N*2, -100.0, 100.0, options );
73+
pbuf = uniform( N1*2, -100.0, 100.0, options );
74+
abuf = uniform( N2*2, -100.0, 100.0, options );
75+
wbuf = uniform( (N+N1+N2-1)*2, -100.0, 100.0, options );
76+
obuf = uniform( ol*2, -100.0, 100.0, options );
77+
78+
x = new Complex128Array( xbuf.buffer );
79+
p = new Complex128Array( pbuf.buffer );
80+
a = new Complex128Array( abuf.buffer );
81+
w = new Complex128Array( wbuf.buffer );
82+
o = new Complex128Array( obuf.buffer );
83+
return benchmark;
84+
85+
/**
86+
* Benchmark function.
87+
*
88+
* @private
89+
* @param {Benchmark} b - benchmark instance
90+
*/
91+
function benchmark( b ) {
92+
var i;
93+
94+
b.tic();
95+
for ( i = 0; i < b.iterations; i++ ) {
96+
zdiff( N, k, x, 1, N1, p, 1, N2, a, 1, o, 1, w, 1 );
97+
if ( isnan( obuf[ i%(ol*2) ] ) ) {
98+
b.fail( 'should not return NaN' );
99+
}
100+
}
101+
b.toc();
102+
if ( isnan( obuf[ i%(ol*2) ] ) ) {
103+
b.fail( 'should not return NaN' );
104+
}
105+
b.pass( 'benchmark finished' );
106+
b.end();
107+
}
108+
}
109+
110+
111+
// MAIN //
112+
113+
/**
114+
* Main execution sequence.
115+
*
116+
* @private
117+
*/
118+
function main() {
119+
var len;
120+
var min;
121+
var max;
122+
var f;
123+
var i;
124+
125+
min = 1; // 10^min
126+
max = 6; // 10^max
127+
128+
for ( i = min; i <= max; i++ ) {
129+
len = pow( 10, i );
130+
f = createBenchmark( len );
131+
bench( format( '%s:len=%d', pkg, len ), f );
132+
}
133+
}
134+
135+
main();
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2026 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 resolve = require( 'path' ).resolve;
24+
var bench = require( '@stdlib/bench' );
25+
var uniform = require( '@stdlib/random/array/uniform' );
26+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
27+
var pow = require( '@stdlib/math/base/special/pow' );
28+
var Complex128Array = require( '@stdlib/array/complex128' );
29+
var format = require( '@stdlib/string/format' );
30+
var tryRequire = require( '@stdlib/utils/try-require' );
31+
var pkg = require( './../package.json' ).name;
32+
33+
34+
// VARIABLES //
35+
36+
var options = {
37+
'dtype': 'float64'
38+
};
39+
var zdiff = tryRequire( resolve( __dirname, './../lib/zdiff.native.js' ) );
40+
var opts = {
41+
'skip': ( zdiff instanceof Error )
42+
};
43+
44+
45+
// FUNCTIONS //
46+
47+
/**
48+
* Creates a benchmark function.
49+
*
50+
* @private
51+
* @param {PositiveInteger} len - array length
52+
* @returns {Function} benchmark function
53+
*/
54+
function createBenchmark( len ) {
55+
var obuf;
56+
var wbuf;
57+
var xbuf;
58+
var pbuf;
59+
var abuf;
60+
var ol;
61+
var N1;
62+
var N2;
63+
var x;
64+
var p;
65+
var a;
66+
var w;
67+
var o;
68+
var k;
69+
var N;
70+
71+
N = len;
72+
N1 = 1;
73+
N2 = 1;
74+
k = 1;
75+
ol = N + N1 + N2 - k;
76+
77+
xbuf = uniform( N*2, -100.0, 100.0, options );
78+
pbuf = uniform( N1*2, -100.0, 100.0, options );
79+
abuf = uniform( N2*2, -100.0, 100.0, options );
80+
wbuf = uniform( (N+N1+N2-1)*2, -100.0, 100.0, options );
81+
obuf = uniform( ol*2, -100.0, 100.0, options );
82+
83+
x = new Complex128Array( xbuf.buffer );
84+
p = new Complex128Array( pbuf.buffer );
85+
a = new Complex128Array( abuf.buffer );
86+
w = new Complex128Array( wbuf.buffer );
87+
o = new Complex128Array( obuf.buffer );
88+
return benchmark;
89+
90+
/**
91+
* Benchmark function.
92+
*
93+
* @private
94+
* @param {Benchmark} b - benchmark instance
95+
*/
96+
function benchmark( b ) {
97+
var i;
98+
99+
b.tic();
100+
for ( i = 0; i < b.iterations; i++ ) {
101+
zdiff( N, k, x, 1, N1, p, 1, N2, a, 1, o, 1, w, 1 );
102+
if ( isnan( obuf[ i%(ol*2) ] ) ) {
103+
b.fail( 'should not return NaN' );
104+
}
105+
}
106+
b.toc();
107+
if ( isnan( obuf[ i%(ol*2) ] ) ) {
108+
b.fail( 'should not return NaN' );
109+
}
110+
b.pass( 'benchmark finished' );
111+
b.end();
112+
}
113+
}
114+
115+
116+
// MAIN //
117+
118+
/**
119+
* Main execution sequence.
120+
*
121+
* @private
122+
*/
123+
function main() {
124+
var len;
125+
var min;
126+
var max;
127+
var f;
128+
var i;
129+
130+
min = 1; // 10^min
131+
max = 6; // 10^max
132+
133+
for ( i = min; i <= max; i++ ) {
134+
len = pow( 10, i );
135+
f = createBenchmark( len );
136+
bench( format( '%s::native:len=%d', pkg, len ), opts, f );
137+
}
138+
}
139+
140+
main();

0 commit comments

Comments
 (0)