Skip to content

Commit b2c2989

Browse files
committed
refactor: update javascript examples
1 parent 44bdad4 commit b2c2989

File tree

2 files changed

+15
-49
lines changed

2 files changed

+15
-49
lines changed

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

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -169,30 +169,15 @@ console.log( y );
169169
<!-- eslint no-undef: "error" -->
170170

171171
```javascript
172-
var round = require( '@stdlib/math/base/special/round' );
173-
var randu = require( '@stdlib/random/base/randu' );
174-
var Float64Array = require( '@stdlib/array/float64' );
172+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
175173
var dsort2hp = require( '@stdlib/blas/ext/base/dsort2hp' );
176174

177-
var rand;
178-
var sign;
179-
var x;
180-
var y;
181-
var i;
182-
183-
x = new Float64Array( 10 );
184-
y = new Float64Array( 10 ); // index array
185-
for ( i = 0; i < x.length; i++ ) {
186-
rand = round( randu()*100.0 );
187-
sign = randu();
188-
if ( sign < 0.5 ) {
189-
sign = -1.0;
190-
} else {
191-
sign = 1.0;
192-
}
193-
x[ i ] = sign * rand;
194-
y[ i ] = i;
195-
}
175+
var x = discreteUniform( 10, -100, 100, {
176+
'dtype': 'float64'
177+
});
178+
var y = discreteUniform( 10, -100, 100, {
179+
'dtype': 'float64'
180+
});
196181
console.log( x );
197182
console.log( y );
198183

lib/node_modules/@stdlib/blas/ext/base/dsort2hp/examples/index.js

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,15 @@
1818

1919
'use strict';
2020

21-
var round = require( '@stdlib/math/base/special/round' );
22-
var randu = require( '@stdlib/random/base/randu' );
23-
var Float64Array = require( '@stdlib/array/float64' );
24-
var dsort2hp = require( './../lib' );
21+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
22+
var dsort2hp = require( '@stdlib/blas/ext/base/dsort2hp' );
2523

26-
var rand;
27-
var sign;
28-
var x;
29-
var y;
30-
var i;
31-
32-
x = new Float64Array( 10 );
33-
y = new Float64Array( 10 ); // index array
34-
for ( i = 0; i < x.length; i++ ) {
35-
if ( randu() < 0.2 ) {
36-
x[ i ] = NaN;
37-
} else {
38-
rand = round( randu()*100.0 );
39-
sign = randu();
40-
if ( sign < 0.5 ) {
41-
sign = -1.0;
42-
} else {
43-
sign = 1.0;
44-
}
45-
x[ i ] = sign * rand;
46-
}
47-
y[ i ] = i;
48-
}
24+
var x = discreteUniform( 10, -100, 100, {
25+
'dtype': 'float64'
26+
});
27+
var y = discreteUniform( 10, -100, 100, {
28+
'dtype': 'float64'
29+
});
4930
console.log( x );
5031
console.log( y );
5132

0 commit comments

Comments
 (0)