Skip to content

Commit 8e9ce7e

Browse files
feat: adds C and fortran implementation
--- 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: 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: missing_dependencies - task: lint_c_examples status: missing_dependencies - 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: na - task: lint_license_headers status: passed ---
1 parent 1be9bb6 commit 8e9ce7e

26 files changed

+2346
-49
lines changed

lib/node_modules/@stdlib/blas/base/cdotu/benchmark/benchmark.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ function createBenchmark( N ) {
9191
* @private
9292
*/
9393
function main() {
94-
var N;
9594
var min;
9695
var max;
96+
var N;
9797
var f;
9898
var i;
9999

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
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 Complex64Array = require( '@stdlib/array/complex64' );
29+
var tryRequire = require( '@stdlib/utils/try-require' );
30+
var real = require( '@stdlib/complex/float32/real' );
31+
var imag = require( '@stdlib/complex/float32/imag' );
32+
var format = require( '@stdlib/string/format' );
33+
var pkg = require( './../package.json' ).name;
34+
35+
36+
// VARIABLES //
37+
38+
var cdotu = tryRequire( resolve( __dirname, './../lib/cdotu.native.js' ) );
39+
var opts = {
40+
'skip': ( cdotu instanceof Error )
41+
};
42+
var options = {
43+
'dtype': 'float32'
44+
};
45+
46+
47+
// FUNCTIONS //
48+
49+
/**
50+
* Creates a benchmark function.
51+
*
52+
* @private
53+
* @param {PositiveInteger} N - array length
54+
* @returns {Function} benchmark function
55+
*/
56+
function createBenchmark( N ) {
57+
var x;
58+
var y;
59+
60+
x = new Complex64Array( uniform( N*2, -100.0, 100.0, options ) );
61+
y = new Complex64Array( uniform( N*2, -100.0, 100.0, options ) );
62+
return benchmark;
63+
64+
/**
65+
* Benchmark function.
66+
*
67+
* @private
68+
* @param {Benchmark} b - benchmark instance
69+
*/
70+
function benchmark( b ) {
71+
var d;
72+
var i;
73+
74+
b.tic();
75+
for ( i = 0; i < b.iterations; i++ ) {
76+
d = cdotu( x.length, x, 1, y, 1 );
77+
if ( isnan( real( d ) ) ) {
78+
b.fail( 'should not return NaN' );
79+
}
80+
}
81+
b.toc();
82+
if ( isnan( imag( d ) ) ) {
83+
b.fail( 'should not return NaN' );
84+
}
85+
b.pass( 'benchmark finished' );
86+
b.end();
87+
}
88+
}
89+
90+
91+
// MAIN //
92+
93+
/**
94+
* Main execution sequence.
95+
*
96+
* @private
97+
*/
98+
function main() {
99+
var min;
100+
var max;
101+
var N;
102+
var f;
103+
var i;
104+
105+
min = 1; // 10^min
106+
max = 5; // 10^max
107+
108+
for ( i = min; i <= max; i++ ) {
109+
N = pow( 10, i );
110+
f = createBenchmark( N );
111+
bench( format( '%s::native:len=%d', pkg, N ), opts, f );
112+
}
113+
}
114+
115+
main();

lib/node_modules/@stdlib/blas/base/cdotu/benchmark/benchmark.ndarray.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ function createBenchmark( N ) {
9191
* @private
9292
*/
9393
function main() {
94-
var N;
9594
var min;
9695
var max;
96+
var N;
9797
var f;
9898
var i;
9999

@@ -103,7 +103,7 @@ function main() {
103103
for ( i = min; i <= max; i++ ) {
104104
N = pow( 10, i );
105105
f = createBenchmark( N );
106-
bench( format( '%s:ndarray:len=%d', pkg, N ), f );
106+
bench( format( '%s::native:ndarray:len=%d', pkg, N ), f );
107107
}
108108
}
109109

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
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 Complex64Array = require( '@stdlib/array/complex64' );
29+
var tryRequire = require( '@stdlib/utils/try-require' );
30+
var real = require( '@stdlib/complex/float32/real' );
31+
var imag = require( '@stdlib/complex/float32/imag' );
32+
var format = require( '@stdlib/string/format' );
33+
var pkg = require( './../package.json' ).name;
34+
35+
36+
// VARIABLES //
37+
38+
var cdotu = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) );
39+
var opts = {
40+
'skip': ( cdotu instanceof Error )
41+
};
42+
var options = {
43+
'dtype': 'float32'
44+
};
45+
46+
47+
// FUNCTIONS //
48+
49+
/**
50+
* Creates a benchmark function.
51+
*
52+
* @private
53+
* @param {PositiveInteger} N - array length
54+
* @returns {Function} benchmark function
55+
*/
56+
function createBenchmark( N ) {
57+
var x;
58+
var y;
59+
60+
x = new Complex64Array( uniform( N*2, -100.0, 100.0, options ) );
61+
y = new Complex64Array( uniform( N*2, -100.0, 100.0, options ) );
62+
return benchmark;
63+
64+
/**
65+
* Benchmark function.
66+
*
67+
* @private
68+
* @param {Benchmark} b - benchmark instance
69+
*/
70+
function benchmark( b ) {
71+
var d;
72+
var i;
73+
74+
b.tic();
75+
for ( i = 0; i < b.iterations; i++ ) {
76+
d = cdotu( x.length, x, 1, 0, y, 1, 0 );
77+
if ( isnan( real( d ) ) ) {
78+
b.fail( 'should not return NaN' );
79+
}
80+
}
81+
b.toc();
82+
if ( isnan( imag( d ) ) ) {
83+
b.fail( 'should not return NaN' );
84+
}
85+
b.pass( 'benchmark finished' );
86+
b.end();
87+
}
88+
}
89+
90+
91+
// MAIN //
92+
93+
/**
94+
* Main execution sequence.
95+
*
96+
* @private
97+
*/
98+
function main() {
99+
var min;
100+
var max;
101+
var N;
102+
var f;
103+
var i;
104+
105+
min = 1; // 10^min
106+
max = 5; // 10^max
107+
108+
for ( i = min; i <= max; i++ ) {
109+
N = pow( 10, i );
110+
f = createBenchmark( N );
111+
bench( format( '%s::native:ndarray:len=%d', pkg, N ), opts, f );
112+
}
113+
}
114+
115+
main();

0 commit comments

Comments
 (0)