Skip to content

Commit

Permalink
chore: apply review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
aman-095 committed Oct 18, 2024
1 parent 0cf68db commit 5eb3e05
Show file tree
Hide file tree
Showing 13 changed files with 101 additions and 177 deletions.
19 changes: 7 additions & 12 deletions lib/node_modules/@stdlib/blas/base/dasum-wasm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ The function has the following parameters:
- **x**: input [`Float64Array`][@stdlib/array/float64].
- **strideX**: index increment for `x`.

The `N` and `stride` parameters determine which elements in `x` are used to compute the sum. For example, to sum every other value,
The `N` and stride parameters determine which elements in the input strided array are accessed at runtime. For example, to compute the sum of every other value,

```javascript
var Float64Array = require( '@stdlib/array/float64' );
Expand All @@ -67,13 +67,12 @@ Note that indexing is relative to the first index. To introduce an offset, use [
```javascript
var Float64Array = require( '@stdlib/array/float64' );

// Initial array...
// Initial array:
var x0 = new Float64Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] );

// Create an offset view...
// Create a typed array view:
var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element

// Sum every other value...
var sum = dasum.main( 3, x1, 2 );
// returns 12.0
```
Expand All @@ -95,7 +94,7 @@ The function has the following additional parameters:

- **offsetX**: starting index for `x`.

While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the `offset` parameter supports indexing semantics based on a starting index. For example, to sum the last three elements,
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to compute the sum of last three elements,

```javascript
var Float64Array = require( '@stdlib/array/float64' );
Expand Down Expand Up @@ -175,9 +174,7 @@ mod.write( xptr, oneTo( N, dtype ) );

// Perform computation:
var sum = mod.main( N, xptr, 1 );

// Read out the result:
console.log( sum );
// returns 15.0
```

The function has the following parameters:
Expand Down Expand Up @@ -224,9 +221,7 @@ mod.write( xptr, oneTo( N, dtype ) );

// Perform computation:
var sum = mod.ndarray( N, xptr, 1, 0 );

// Read out the result:
console.log( sum );
// returns 15.0
```

The function has the following additional parameters:
Expand All @@ -243,7 +238,7 @@ The function has the following additional parameters:

## Notes

- If `N <= 0` the sum is `0`.
- If `N <= 0`, both `main` and `ndarray` methods return `0.0`.
- This package implements routines using WebAssembly. When provided arrays which are not allocated on a `dasum` module memory instance, data must be explicitly copied to module memory prior to computation. Data movement may entail a performance cost, and, thus, if you are using arrays external to module memory, you should prefer using [`@stdlib/blas/base/dasum`][@stdlib/blas/base/dasum]. However, if working with arrays which are allocated and explicitly managed on module memory, you can achieve better performance when compared to the pure JavaScript implementations found in [`@stdlib/blas/base/dasum`][@stdlib/blas/base/dasum]. Beware that such performance gains may come at the cost of additional complexity when having to perform manual memory management. Choosing between implementations depends heavily on the particular needs and constraints of your application, with no one choice universally better than the other.
- `dasum()` corresponds to the [BLAS][blas] level 1 function [`dasum`][dasum].

Expand Down
12 changes: 6 additions & 6 deletions lib/node_modules/@stdlib/blas/base/dasum-wasm/docs/repl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
> var s = {{alias}}.main( x.length, x, 1 )
15.0

// Sum every other value:
// Using `N` and stride parameters:
> s = {{alias}}.main( 3, x, 2 )
9.0

Expand Down Expand Up @@ -77,7 +77,7 @@
> var s = {{alias}}.ndarray( x.length, x, 1, 0 )
15.0

// Sum the last three elements:
// Using offset parameter:
> x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] );
> s = {{alias}}.ndarray( 3, x, -1, x.length-1 )
15.0
Expand Down Expand Up @@ -251,9 +251,9 @@
Reallocates the underlying WebAssembly memory instance to a specified number
of bytes.

WebAssembly memory can only **grow**, not shrink. Hence, if provided a
number of bytes which is less than or equal to the size of the current
memory, the function does nothing.
WebAssembly memory can only *grow*, not shrink. Hence, if provided a number
of bytes which is less than or equal to the size of the current memory, the
function does nothing.

When non-shared memory is resized, the underlying the `ArrayBuffer` is
detached, consequently invalidating any associated typed array views. Before
Expand Down Expand Up @@ -485,7 +485,7 @@
> mod.write( xptr, {{alias:@stdlib/array/one-to}}( 5, 'float64' ) );

// Perform computation:
> mod.ndarray( 5, xptr, 1, 0 )
> var sum = mod.ndarray( 5, xptr, 1, 0 )
15.0

See Also
Expand Down
Loading

0 comments on commit 5eb3e05

Please sign in to comment.