Skip to content

Commit 0223c17

Browse files
committed
feat: add stats/strided/dcovmatmtk
--- 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: missing_dependencies - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: passed - task: lint_c_benchmarks status: passed - 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 40e9eaa commit 0223c17

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+7791
-0
lines changed

lib/node_modules/@stdlib/stats/strided/dcovmatmtk/README.md

Lines changed: 524 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
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 uniform = require( '@stdlib/random/array/uniform' );
25+
var zeros = require( '@stdlib/array/zeros' );
26+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
27+
var pow = require( '@stdlib/math/base/special/pow' );
28+
var floor = require( '@stdlib/math/base/special/floor' );
29+
var pkg = require( './../package.json' ).name;
30+
var dcovmatmtk = require( './../lib/dcovmatmtk.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} N - number of elements per dimension
47+
* @returns {Function} benchmark function
48+
*/
49+
function createBenchmark( N ) {
50+
var means = uniform( N, -10.0, 10.0, options );
51+
var A = uniform( N*N, -10.0, 10.0, options );
52+
var B = zeros( N*N, options.dtype );
53+
return benchmark;
54+
55+
function benchmark( b ) {
56+
var out;
57+
var i;
58+
59+
b.tic();
60+
for ( i = 0; i < b.iterations; i++ ) {
61+
out = dcovmatmtk( 'row-major', 'rows', 'full', N, N, 1, means, 1, A, N, B, N );
62+
if ( isnan( out[ i%(N*2) ] ) ) {
63+
b.fail( 'should not return NaN' );
64+
}
65+
}
66+
b.toc();
67+
if ( isnan( B[ i%(N*2) ] ) ) {
68+
b.fail( 'should not return NaN' );
69+
}
70+
b.pass( 'benchmark finished' );
71+
b.end();
72+
}
73+
}
74+
75+
76+
// MAIN //
77+
78+
/**
79+
* Main execution sequence.
80+
*
81+
* @private
82+
*/
83+
function main() {
84+
var min;
85+
var max;
86+
var N;
87+
var f;
88+
var i;
89+
90+
min = 1; // 10^min
91+
max = 6; // 10^max
92+
93+
for ( i = min; i <= max; i++ ) {
94+
N = floor( pow( pow( 10, i ), 1.0/2.0 ) );
95+
f = createBenchmark( N );
96+
bench( pkg+'::equidimensional:size='+(N*N), f );
97+
}
98+
}
99+
100+
main();
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
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 resolve = require( 'path' ).resolve;
24+
var bench = require( '@stdlib/bench' );
25+
var uniform = require( '@stdlib/random/array/uniform' );
26+
var zeros = require( '@stdlib/array/zeros' );
27+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
28+
var pow = require( '@stdlib/math/base/special/pow' );
29+
var floor = require( '@stdlib/math/base/special/floor' );
30+
var tryRequire = require( '@stdlib/utils/try-require' );
31+
var pkg = require( './../package.json' ).name;
32+
33+
34+
// VARIABLES //
35+
36+
var dcovmatmtk = tryRequire( resolve( __dirname, './../lib/dcovmatmtk.native.js' ) );
37+
var opts = {
38+
'skip': ( dcovmatmtk instanceof Error )
39+
};
40+
var options = {
41+
'dtype': 'float64'
42+
};
43+
44+
45+
// FUNCTIONS //
46+
47+
/**
48+
* Creates a benchmark function.
49+
*
50+
* @private
51+
* @param {PositiveInteger} N - number of elements per dimension
52+
* @returns {Function} benchmark function
53+
*/
54+
function createBenchmark( N ) {
55+
var means = uniform( N, -10.0, 10.0, options );
56+
var A = uniform( N*N, -10.0, 10.0, options );
57+
var B = zeros( N*N, options.dtype );
58+
return benchmark;
59+
60+
function benchmark( b ) {
61+
var out;
62+
var i;
63+
64+
b.tic();
65+
for ( i = 0; i < b.iterations; i++ ) {
66+
out = dcovmatmtk( 'row-major', 'rows', 'full', N, N, 1, means, 1, A, N, B, N );
67+
if ( isnan( out[ i%(N*2) ] ) ) {
68+
b.fail( 'should not return NaN' );
69+
}
70+
}
71+
b.toc();
72+
if ( isnan( B[ i%(N*2) ] ) ) {
73+
b.fail( 'should not return NaN' );
74+
}
75+
b.pass( 'benchmark finished' );
76+
b.end();
77+
}
78+
}
79+
80+
81+
// MAIN //
82+
83+
/**
84+
* Main execution sequence.
85+
*
86+
* @private
87+
*/
88+
function main() {
89+
var min;
90+
var max;
91+
var N;
92+
var f;
93+
var i;
94+
95+
min = 1; // 10^min
96+
max = 6; // 10^max
97+
98+
for ( i = min; i <= max; i++ ) {
99+
N = floor( pow( pow( 10, i ), 1.0/2.0 ) );
100+
f = createBenchmark( N );
101+
bench( pkg+'::equidimensional:size='+(N*N), opts, f );
102+
}
103+
}
104+
105+
main();
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
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 uniform = require( '@stdlib/random/array/uniform' );
25+
var zeros = require( '@stdlib/array/zeros' );
26+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
27+
var pow = require( '@stdlib/math/base/special/pow' );
28+
var floor = require( '@stdlib/math/base/special/floor' );
29+
var pkg = require( './../package.json' ).name;
30+
var dcovmatmtk = require( './../lib/ndarray.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} N - number of elements per dimension
47+
* @returns {Function} benchmark function
48+
*/
49+
function createBenchmark( N ) {
50+
var means = uniform( N, -10.0, 10.0, options );
51+
var A = uniform( N*N, -10.0, 10.0, options );
52+
var B = zeros( N*N, options.dtype );
53+
return benchmark;
54+
55+
function benchmark( b ) {
56+
var out;
57+
var i;
58+
59+
b.tic();
60+
for ( i = 0; i < b.iterations; i++ ) {
61+
out = dcovmatmtk( 'rows', 'full', N, N, 1, means, 1, 0, A, N, 1, 0, B, N, 1, 0 );
62+
if ( isnan( out[ i%(N*2) ] ) ) {
63+
b.fail( 'should not return NaN' );
64+
}
65+
}
66+
b.toc();
67+
if ( isnan( B[ i%(N*2) ] ) ) {
68+
b.fail( 'should not return NaN' );
69+
}
70+
b.pass( 'benchmark finished' );
71+
b.end();
72+
}
73+
}
74+
75+
76+
// MAIN //
77+
78+
/**
79+
* Main execution sequence.
80+
*
81+
* @private
82+
*/
83+
function main() {
84+
var min;
85+
var max;
86+
var N;
87+
var f;
88+
var i;
89+
90+
min = 1; // 10^min
91+
max = 6; // 10^max
92+
93+
for ( i = min; i <= max; i++ ) {
94+
N = floor( pow( pow( 10, i ), 1.0/2.0 ) );
95+
f = createBenchmark( N );
96+
bench( pkg+'::equidimensional:ndarray:size='+(N*N), f );
97+
}
98+
}
99+
100+
main();

0 commit comments

Comments
 (0)