Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions lib/node_modules/@stdlib/blas/base/gscal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ limitations under the License.

# gscal

> Multiply a vector `x` by a constant `alpha`.
> Multiply a vector `x` by a scalar constant `alpha`.

<section class="usage">

Expand All @@ -30,9 +30,9 @@ limitations under the License.
var gscal = require( '@stdlib/blas/base/gscal' );
```

#### gscal( N, alpha, x, stride )
#### gscal( N, alpha, x, strideX )

Multiplies a vector `x` by a constant `alpha`.
Multiplies a vector `x` by a scalar constant `alpha`.

```javascript
var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];
Expand All @@ -46,9 +46,9 @@ The function has the following parameters:
- **N**: number of indexed elements.
- **alpha**: scalar constant.
- **x**: input [`Array`][mdn-array] or [`typed array`][mdn-typed-array].
- **stride**: index increment.
- **strideX**: stride length.

The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to multiply every other value by a constant
The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to multiply every other value by a scalar constant

```javascript
var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];
Expand All @@ -75,9 +75,9 @@ gscal( 3, 5.0, x1, 2 );

If either `N` or `stride` is less than or equal to `0`, the function returns `x` unchanged.

#### gscal.ndarray( N, alpha, x, stride, offset )
#### gscal.ndarray( N, alpha, x, strideX, offsetX )

Multiplies a vector `x` by a constant `alpha` using alternative indexing semantics.
Multiplies a vector `x` by a scalar constant `alpha` using alternative indexing semantics.

```javascript
var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];
Expand All @@ -88,9 +88,9 @@ gscal.ndarray( x.length, 5.0, x, 1, 0 );

The function has the following additional parameters:

- **offset**: starting index.
- **offsetX**: starting index.

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 multiply the last three elements of `x` by a constant
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 multiply the last three elements:

```javascript
var x = [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ];
Expand Down
48 changes: 23 additions & 25 deletions lib/node_modules/@stdlib/blas/base/gscal/docs/repl.txt
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@

{{alias}}( N, alpha, x, stride )
Multiplies a vector `x` by a constant `alpha`.
{{alias}}( N, alpha, x, strideX )
Multiplies a vector `x` by a scalar constant `alpha`.

The `N` and `stride` parameters determine which elements in `x` are accessed
at runtime.
The `N` and stride parameters determine which elements in the strided array
are accessed at runtime.

Indexing is relative to the first index. To introduce an offset, use typed
array views.

If `N <= 0` or `stride <= 0`, the function returns `x` unchanged.
If `N <= 0` or `strideX <= 0`, the function returns `x` unchanged.

Parameters
----------
N: integer
Number of indexed elements.

alpha: number
Constant.
Scalar constant.

x: Array<number>|TypedArray
Input array.

stride: integer
Index increment for `x`.
strideX: integer
Stride length.

Returns
-------
Expand All @@ -32,13 +32,12 @@
Examples
--------
// Standard Usage:
> var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ];
> var alpha = 5.0;
> {{alias}}( x.length, alpha, x, 1 )
[ -10.0, 5.0, 15.0, -25.0, 20.0, -5.0, -15.0 ]
> var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];
> {{alias}}( x.length, 5.0, x, 1 )
[ -10.0, 5.0, 15.0, -25.0, 20.0, 0.0, -5.0, -15.0 ]

// Using `N` and `stride` parameters:
> x = [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ];
// Using `N` and stride parameters:
> x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0 -1.0, -3.0 ];
> {{alias}}( 3, 5.0, x, 2 )
[ -10.0, 1.0, 15.0, -5.0, 20.0, -1.0, -3.0 ]

Expand All @@ -51,11 +50,11 @@
<Float64Array>[ 1.0, -10.0, 3.0, -20.0, 5.0, -30.0 ]


{{alias}}.ndarray( N, alpha, x, stride, offset )
Multiplies `x` by a constant `alpha` using alternative indexing semantics.
{{alias}}.ndarray( N, alpha, x, strideX, offsetX )
Multiplies `x` by a scalar constant `alpha` using alternative indexing semantics.

While typed array views mandate a view offset based on the underlying
buffer, the `offset` parameter supports indexing semantics based on a
buffer, the offset parameter supports indexing semantics based on a
starting index.

Parameters
Expand All @@ -64,16 +63,16 @@
Number of indexed elements.

alpha: number
Constant.
Scalar constant.

x: Array<number>|TypedArray
Input array.

stride: integer
Index increment for `x`.
strideX: integer
Stride length.

offset: integer
Starting index of `x`.
offsetX: integer
Starting index.

Returns
-------
Expand All @@ -83,9 +82,9 @@
Examples
--------
// Standard Usage:
> var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ];
> var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];
> {{alias}}.ndarray( x.length, 5.0, x, 1, 0 )
[ -10.0, 5.0, 15.0, -25.0, 20.0, -5.0, -15.0 ]
[ -10.0, 5.0, 15.0, -25.0, 20.0, 0.0, -5.0, -15.0 ]

// Using an index offset:
> x = [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ];
Expand All @@ -94,4 +93,3 @@

See Also
--------

22 changes: 11 additions & 11 deletions lib/node_modules/@stdlib/blas/base/gscal/docs/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ type InputArray = NumericArray | Collection<number> | AccessorArrayLike<number>;
*/
interface Routine {
/**
* Multiplies a vector `x` by a constant `alpha`.
* Multiplies a vector `x` by a scalar constant `alpha`.
*
* @param N - number of indexed elements
* @param alpha - constant
* @param alpha - scalar constant
* @param x - input array
* @param stride - stride length
* @param strideX - stride length
* @returns input array
*
* @example
Expand All @@ -46,16 +46,16 @@ interface Routine {
* gscal( x.length, 5.0, x, 1 );
* // x => [ -10.0, 5.0, 15.0, -25.0, 20.0, 0.0, -5.0, -15.0 ]
*/
<T extends InputArray>( N: number, alpha: number, x: T, stride: number ): T;
<T extends InputArray>( N: number, alpha: number, x: T, strideX: number ): T;

/**
* Multiplies a vector `x` by a constant `alpha` using alternative indexing semantics.
* Multiplies a vector `x` by a scalar constant `alpha` using alternative indexing semantics.
*
* @param N - number of indexed elements
* @param alpha - constant
* @param alpha - scalar constant
* @param x - input array
* @param stride - stride length
* @param offset - starting index
* @param strideX - stride length
* @param offsetX - starting index
* @returns input array
*
* @example
Expand All @@ -64,16 +64,16 @@ interface Routine {
* gscal.ndarray( x.length, 5.0, x, 1, 0 );
* // x => [ -10.0, 5.0, 15.0, -25.0, 20.0, 0.0, -5.0, -15.0 ]
*/
ndarray<T extends InputArray>( N: number, alpha: number, x: T, stride: number, offset: number ): T;
ndarray<T extends InputArray>( N: number, alpha: number, x: T, strideX: number, offsetX: number ): T;
}

/**
* Multiplies a vector `x` by a constant `alpha`.
*
* @param N - number of indexed elements
* @param alpha - constant
* @param alpha - scalar constant
* @param x - input array
* @param stride - stride length
* @param strideX - stride length
* @returns input array
*
* @example
Expand Down
2 changes: 1 addition & 1 deletion lib/node_modules/@stdlib/blas/base/gscal/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'use strict';

/**
* BLAS level 1 routine to multiply `x` by a constant.
* BLAS level 1 routine to multiply `x` by a scalar constant.
*
* @module @stdlib/blas/base/gscal
*
Expand Down
8 changes: 4 additions & 4 deletions lib/node_modules/@stdlib/blas/base/gscal/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ var ndarray = require( './ndarray.js' );
* Multiplies `x` by a scalar `alpha`.
*
* @param {PositiveInteger} N - number of indexed elements
* @param {number} alpha - scalar
* @param {number} alpha - scalar constant
* @param {NumericArray} x - input array
* @param {PositiveInteger} stride - index increment
* @param {PositiveInteger} strideX - stride length
* @returns {NumericArray} input array
*
* @example
Expand All @@ -41,8 +41,8 @@ var ndarray = require( './ndarray.js' );
* gscal( x.length, 5.0, x, 1 );
* // x => [ -10.0, 5.0, 15.0, -25.0, 20.0, 0.0, -5.0, -15.0 ]
*/
function gscal( N, alpha, x, stride ) {
return ndarray( N, alpha, x, stride, stride2offset( N, stride ) );
function gscal( N, alpha, x, strideX ) {
return ndarray( N, alpha, x, strideX, stride2offset( N, strideX ) );
}


Expand Down
18 changes: 9 additions & 9 deletions lib/node_modules/@stdlib/blas/base/gscal/lib/ndarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ var M = 5;
* @param {PositiveInteger} N - number of indexed elements
* @param {number} alpha - scalar
* @param {NumericArray} x - input array
* @param {integer} stride - index increment
* @param {NonNegativeInteger} offset - starting index
* @param {integer} strideX - stride length
* @param {NonNegativeInteger} offsetX - starting index
* @returns {NumericArray} input array
*
* @example
Expand All @@ -47,7 +47,7 @@ var M = 5;
* gscal( 3, 5.0, x, 1, x.length-3 );
* // x => [ 1.0, -2.0, 3.0, -20.0, 25.0, -30.0 ]
*/
function gscal( N, alpha, x, stride, offset ) {
function gscal( N, alpha, x, strideX, offsetX ) {
var ix;
var m;
var o;
Expand All @@ -58,25 +58,25 @@ function gscal( N, alpha, x, stride, offset ) {
}
o = arraylike2object( x );
if ( o.accessorProtocol ) {
accessors( N, alpha, o, stride, offset );
accessors( N, alpha, o, strideX, offsetX );
return x;
}

ix = offset;
if ( stride === 0 ) {
ix = offsetX;
if ( strideX === 0 ) {
x[ ix ] *= alpha * N;
return x;
}

// Use loop unrolling if the stride is equal to `1`...
if ( stride === 1 ) {
if ( strideX === 1 ) {
m = N % M;

// If we have a remainder, run a clean-up loop...
if ( m > 0 ) {
for ( i = 0; i < m; i++ ) {
x[ ix ] *= alpha;
ix += stride;
ix += strideX;
}
}
if ( N < M ) {
Expand All @@ -94,7 +94,7 @@ function gscal( N, alpha, x, stride, offset ) {
}
for ( i = 0; i < N; i++ ) {
x[ ix ] *= alpha;
ix += stride;
ix += strideX;
}
return x;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/node_modules/@stdlib/blas/base/gscal/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@stdlib/blas/base/gscal",
"version": "0.0.0",
"description": "Multiply a vector by a constant.",
"description": "Multiply a vector by a scalar constant.",
"license": "Apache-2.0",
"author": {
"name": "The Stdlib Authors",
Expand Down
Loading