-
-
Notifications
You must be signed in to change notification settings - Fork 586
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: update
blas/ext/base/dsnannsumors
PR-URL: #2804 Closes: #1491 Ref: #1152 --------- Signed-off-by: Philipp Burckhardt <[email protected]> Co-authored-by: Philipp Burckhardt <[email protected]> Reviewed-by: Philipp Burckhardt <[email protected]>
- Loading branch information
1 parent
d125530
commit 7cc8bb9
Showing
19 changed files
with
254 additions
and
363 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,18 +59,16 @@ The function has the following parameters: | |
- **out**: output [`Float64Array`][@stdlib/array/float64] whose first element is the sum and whose second element is the number of non-NaN elements. | ||
- **strideOut**: index increment for `out`. | ||
|
||
The `N` and `stride` parameters determine which elements are accessed at runtime. For example, to compute the sum of every other element in `x`, | ||
The `N` and stride parameters determine which elements are accessed at runtime. For example, to compute the sum of every other element in `x`, | ||
|
||
```javascript | ||
var Float32Array = require( '@stdlib/array/float32' ); | ||
var Float64Array = require( '@stdlib/array/float64' ); | ||
var floor = require( '@stdlib/math/base/special/floor' ); | ||
|
||
var x = new Float32Array( [ 1.0, 2.0, NaN, -7.0, NaN, 3.0, 4.0, 2.0 ] ); | ||
var out = new Float64Array( 2 ); | ||
var N = floor( x.length / 2 ); | ||
|
||
var v = dsnannsumors( N, x, 2, out, 1 ); | ||
var v = dsnannsumors( 4, x, 2, out, 1 ); | ||
// returns <Float64Array>[ 5.0, 2 ] | ||
``` | ||
|
||
|
@@ -81,17 +79,14 @@ Note that indexing is relative to the first index. To introduce an offset, use [ | |
```javascript | ||
var Float32Array = require( '@stdlib/array/float32' ); | ||
var Float64Array = require( '@stdlib/array/float64' ); | ||
var floor = require( '@stdlib/math/base/special/floor' ); | ||
|
||
var x0 = new Float32Array( [ 2.0, 1.0, NaN, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); | ||
var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element | ||
|
||
var out0 = new Float64Array( 4 ); | ||
var out1 = new Float64Array( out0.buffer, out0.BYTES_PER_ELEMENT*2 ); // start at 3rd element | ||
|
||
var N = floor( x0.length / 2 ); | ||
|
||
var v = dsnannsumors( N, x1, 2, out1, 1 ); | ||
var v = dsnannsumors( 4, x1, 2, out1, 1 ); | ||
// returns <Float64Array>[ 5.0, 4 ] | ||
``` | ||
|
||
|
@@ -120,13 +115,11 @@ While [`typed array`][mdn-typed-array] views mandate a view offset based on the | |
```javascript | ||
var Float32Array = require( '@stdlib/array/float32' ); | ||
var Float64Array = require( '@stdlib/array/float64' ); | ||
var floor = require( '@stdlib/math/base/special/floor' ); | ||
|
||
var x = new Float32Array( [ 2.0, 1.0, NaN, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); | ||
var out = new Float64Array( 4 ); | ||
var N = floor( x.length / 2 ); | ||
|
||
var v = dsnannsumors.ndarray( N, x, 2, 1, out, 2, 1 ); | ||
var v = dsnannsumors.ndarray( 4, x, 2, 1, out, 2, 1 ); | ||
// returns <Float64Array>[ 0.0, 5.0, 0.0, 4 ] | ||
``` | ||
|
||
|
@@ -152,23 +145,23 @@ var v = dsnannsumors.ndarray( N, x, 2, 1, out, 2, 1 ); | |
<!-- eslint no-undef: "error" --> | ||
|
||
```javascript | ||
var randu = require( '@stdlib/random/base/randu' ); | ||
var round = require( '@stdlib/math/base/special/round' ); | ||
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); | ||
var bernoulli = require( '@stdlib/random/base/bernoulli' ); | ||
var filledarrayBy = require( '@stdlib/array/filled-by' ); | ||
var Float32Array = require( '@stdlib/array/float32' ); | ||
var Float64Array = require( '@stdlib/array/float64' ); | ||
var dsnannsumors = require( '@stdlib/blas/ext/base/dsnannsumors' ); | ||
|
||
var x; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
var i; | ||
|
||
x = new Float32Array( 10 ); | ||
for ( i = 0; i < x.length; i++ ) { | ||
if ( randu() < 0.2 ) { | ||
x[ i ] = NaN; | ||
} else { | ||
x[ i ] = round( randu()*100.0 ); | ||
|
||
function rand() { | ||
if ( bernoulli( 0.5 ) < 0.2 ) { | ||
This comment has been minimized.
Sorry, something went wrong.
kgryte
Member
|
||
return NaN; | ||
} | ||
return discreteUniform( 0, 100 ); | ||
} | ||
|
||
x = filledarrayBy( 10, 'float32', rand ); | ||
console.log( x ); | ||
|
||
var out = new Float64Array( 2 ); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
1 comment
on commit 7cc8bb9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coverage Report
Package | Statements | Branches | Functions | Lines |
---|---|---|---|---|
blas/ext/base/dsnannsumors |
|
|
|
|
The above coverage report was generated for the changes in this push.
@Planeshifter This declaration should be moved down to L164.