Skip to content

Commit 205ace8

Browse files
committed
Restore removed files
1 parent 08787a1 commit 205ace8

File tree

9 files changed

+1134
-0
lines changed

9 files changed

+1134
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2020 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 randu = require( '@stdlib/random/base/randu' );
26+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
27+
var pow = require( '@stdlib/math/base/special/pow' );
28+
var Float64Array = require( '@stdlib/array/float64' );
29+
var tryRequire = require( '@stdlib/utils/try-require' );
30+
var pkg = require( './../package.json' ).name;
31+
32+
33+
// VARIABLES //
34+
35+
var dcusum = tryRequire( resolve( __dirname, './../lib/dcusum.native.js' ) );
36+
var opts = {
37+
'skip': ( dcusum instanceof Error )
38+
};
39+
40+
41+
// FUNCTIONS //
42+
43+
/**
44+
* Creates a benchmark function.
45+
*
46+
* @private
47+
* @param {PositiveInteger} len - array length
48+
* @returns {Function} benchmark function
49+
*/
50+
function createBenchmark( len ) {
51+
var x;
52+
var y;
53+
var i;
54+
55+
x = new Float64Array( len );
56+
y = new Float64Array( len );
57+
for ( i = 0; i < x.length; i++ ) {
58+
x[ i ] = ( randu()*20.0 ) - 10.0;
59+
}
60+
return benchmark;
61+
62+
function benchmark( b ) {
63+
var v;
64+
var i;
65+
66+
for ( i = 0; i < len; i++ ) {
67+
y[ i ] = 0.0;
68+
}
69+
b.tic();
70+
for ( i = 0; i < b.iterations; i++ ) {
71+
x[ 0 ] += 1.0;
72+
v = dcusum( x.length, 0.0, x, 1, y, 1 );
73+
if ( isnan( v[ i%len ] ) ) {
74+
b.fail( 'should not return NaN' );
75+
}
76+
}
77+
b.toc();
78+
if ( isnan( v[ i%len ] ) ) {
79+
b.fail( 'should not return NaN' );
80+
}
81+
b.pass( 'benchmark finished' );
82+
b.end();
83+
}
84+
}
85+
86+
87+
// MAIN //
88+
89+
/**
90+
* Main execution sequence.
91+
*
92+
* @private
93+
*/
94+
function main() {
95+
var len;
96+
var min;
97+
var max;
98+
var f;
99+
var i;
100+
101+
min = 1; // 10^min
102+
max = 6; // 10^max
103+
104+
for ( i = min; i <= max; i++ ) {
105+
len = pow( 10, i );
106+
f = createBenchmark( len );
107+
bench( pkg+'::native:len='+len, opts, f );
108+
}
109+
}
110+
111+
main();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2020 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 randu = require( '@stdlib/random/base/randu' );
26+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
27+
var pow = require( '@stdlib/math/base/special/pow' );
28+
var Float64Array = require( '@stdlib/array/float64' );
29+
var tryRequire = require( '@stdlib/utils/try-require' );
30+
var pkg = require( './../package.json' ).name;
31+
32+
33+
// VARIABLES //
34+
35+
var dcusum = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) );
36+
var opts = {
37+
'skip': ( dcusum instanceof Error )
38+
};
39+
40+
41+
// FUNCTIONS //
42+
43+
/**
44+
* Creates a benchmark function.
45+
*
46+
* @private
47+
* @param {PositiveInteger} len - array length
48+
* @returns {Function} benchmark function
49+
*/
50+
function createBenchmark( len ) {
51+
var x;
52+
var y;
53+
var i;
54+
55+
x = new Float64Array( len );
56+
y = new Float64Array( len );
57+
for ( i = 0; i < x.length; i++ ) {
58+
x[ i ] = ( randu()*20.0 ) - 10.0;
59+
}
60+
return benchmark;
61+
62+
function benchmark( b ) {
63+
var v;
64+
var i;
65+
66+
for ( i = 0; i < len; i++ ) {
67+
y[ i ] = 0.0;
68+
}
69+
b.tic();
70+
for ( i = 0; i < b.iterations; i++ ) {
71+
x[ 0 ] += 1.0;
72+
v = dcusum( x.length, 0.0, x, 1, 0, y, 1, 0 );
73+
if ( isnan( v[ i%len ] ) ) {
74+
b.fail( 'should not return NaN' );
75+
}
76+
}
77+
b.toc();
78+
if ( isnan( v[ i%len ] ) ) {
79+
b.fail( 'should not return NaN' );
80+
}
81+
b.pass( 'benchmark finished' );
82+
b.end();
83+
}
84+
}
85+
86+
87+
// MAIN //
88+
89+
/**
90+
* Main execution sequence.
91+
*
92+
* @private
93+
*/
94+
function main() {
95+
var len;
96+
var min;
97+
var max;
98+
var f;
99+
var i;
100+
101+
min = 1; // 10^min
102+
max = 6; // 10^max
103+
104+
for ( i = min; i <= max; i++ ) {
105+
len = pow( 10, i );
106+
f = createBenchmark( len );
107+
bench( pkg+'::native:ndarray:len='+len, opts, f );
108+
}
109+
}
110+
111+
main();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2020 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 addon = require( './../src/addon.node' );
24+
25+
26+
// MAIN //
27+
28+
/**
29+
* Computes the cumulative sum of double-precision floating-point strided array elements.
30+
*
31+
* @param {PositiveInteger} N - number of indexed elements
32+
* @param {number} sum - initial sum
33+
* @param {Float64Array} x - input array
34+
* @param {integer} strideX - `x` stride length
35+
* @param {Float64Array} y - output array
36+
* @param {integer} strideY - `y` stride length
37+
* @returns {Float64Array} output array
38+
*
39+
* @example
40+
* var Float64Array = require( '@stdlib/array/float64' );
41+
*
42+
* var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
43+
* var y = new Float64Array( x.length );
44+
* var N = x.length;
45+
*
46+
* var v = dcusum( N, 0.0, x, 1, y, 1 );
47+
* // returns <Float64Array>[ 1.0, -1.0, 1.0 ]
48+
*/
49+
function dcusum( N, sum, x, strideX, y, strideY ) {
50+
addon( N, sum, x, strideX, y, strideY );
51+
return y;
52+
}
53+
54+
55+
// EXPORTS //
56+
57+
module.exports = dcusum;

lib/node_modules/@stdlib/blas/ext/base/dcusum/lib/index.js

+10
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,19 @@
4949

5050
// MODULES //
5151

52+
var join = require( 'path' ).join;
53+
var tryRequire = require( '@stdlib/utils/try-require' );
5254
var dcusum = require( './main.js' );
5355

5456

57+
// MAIN //
58+
59+
var tmp = tryRequire( join( __dirname, './native.js' ) );
60+
if ( !(tmp instanceof Error) ) {
61+
dcusum = tmp;
62+
}
63+
64+
5565
// EXPORTS //
5666

5767
module.exports = dcusum;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2020 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 setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
24+
var dcusum = require( './dcusum.native.js' );
25+
var ndarray = require( './ndarray.native.js' );
26+
27+
28+
// MAIN //
29+
30+
setReadOnly( dcusum, 'ndarray', ndarray );
31+
32+
33+
// EXPORTS //
34+
35+
module.exports = dcusum;

0 commit comments

Comments
 (0)