Skip to content

Commit bc23559

Browse files
committed
feat!: add support for specifying the index offset for AP
BREAKING CHANGE: add offset parameter to `ndarray` method To migrate, users should set the `offsetAP` parameter. For most cases, this parameter will be zero, but supporting this parameter allows users to specify alternative starting indices, such as needed when working with ndarray views.
1 parent 43b84f7 commit bc23559

22 files changed

+210
-176
lines changed

lib/node_modules/@stdlib/blas/base/dspmv/README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ dspmv( 'row-major', 'upper', 2, 1.0, AP, x1, -1, 1.0, y1, -1 );
9191
// y0 => <Float64Array>[ 6.0, 4.0 ]
9292
```
9393

94-
#### dspmv.ndarray( order, uplo, N, α, AP, x, sx, ox, β, y, sy, oy )
94+
#### dspmv.ndarray( order, uplo, N, α, AP, oa, x, sx, ox, β, y, sy, oy )
9595

9696
Performs the matrix-vector operation `y = α*A*x + β*y` using alternative indexing semantics and where `α` and `β` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix supplied in packed form `AP`.
9797

@@ -102,12 +102,13 @@ var AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
102102
var x = new Float64Array( [ 1.0, 1.0, 1.0 ] );
103103
var y = new Float64Array( [ 1.0, 1.0, 1.0 ] );
104104

105-
dspmv.ndarray( 'column-major', 'lower', 3, 1.0, AP, x, 1, 0, 1.0, y, 1, 0 );
105+
dspmv.ndarray( 'column-major', 'lower', 3, 1.0, AP, 0, x, 1, 0, 1.0, y, 1, 0 );
106106
// y => <Float64Array>[ 7.0, 12.0, 15.0 ]
107107
```
108108

109109
The function has the following additional parameters:
110110

111+
- **oa**: starting index for `AP`.
111112
- **ox**: starting index for `x`.
112113
- **oy**: starting index for `y`.
113114

@@ -116,11 +117,11 @@ While [`typed array`][mdn-typed-array] views mandate a view offset based on the
116117
```javascript
117118
var Float64Array = require( '@stdlib/array/float64' );
118119

119-
var AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
120+
var AP = new Float64Array( [ 0.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
120121
var x = new Float64Array( [ 1.0, 1.0, 1.0 ] );
121122
var y = new Float64Array( [ 1.0, 1.0, 1.0 ] );
122123

123-
dspmv.ndarray( 'column-major', 'lower', 3, 1.0, AP, x, 1, 0, 1.0, y, -1, 2 );
124+
dspmv.ndarray( 'column-major', 'lower', 3, 1.0, AP, 2, x, 1, 0, 1.0, y, -1, 2 );
124125
// y => <Float64Array>[ 15.0, 12.0, 7.0 ]
125126
```
126127

@@ -158,7 +159,7 @@ var AP = discreteUniform( N * ( N + 1 ) / 2, -10, 10, opts );
158159
var x = discreteUniform( N, -10, 10, opts );
159160
var y = discreteUniform( N, -10, 10, opts );
160161

161-
dspmv.ndarray( 'row-major', 'upper', N, 1.0, AP, x, 1, 0, 1.0, y, 1, 0 );
162+
dspmv.ndarray( 'row-major', 'upper', N, 1.0, AP, 0, x, 1, 0, 1.0, y, 1, 0 );
162163
console.log( y );
163164
```
164165

lib/node_modules/@stdlib/blas/base/dspmv/benchmark/benchmark.ndarray.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function createBenchmark( len ) {
6363

6464
b.tic();
6565
for ( i = 0; i < b.iterations; i++ ) {
66-
z = dspmv( 'row-major', 'upper', len, 1.0, AP, x, 1, 0, 1.0, y, 1, 0 );
66+
z = dspmv( 'row-major', 'upper', len, 1.0, AP, 0, x, 1, 0, 1.0, y, 1, 0 );
6767
if ( isnan( z[ i%z.length ] ) ) {
6868
b.fail( 'should not return NaN' );
6969
}

lib/node_modules/@stdlib/blas/base/dspmv/docs/repl.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
<Float64Array>[ ~6.0, ~4.0 ]
7878

7979

80-
{{alias}}.ndarray( ord, uplo, N, α, AP, x, sx, ox, β, y, sy, oy )
80+
{{alias}}.ndarray( ord, uplo, N, α, AP, oa, x, sx, ox, β, y, sy, oy )
8181
Performs the matrix-vector operation `y = α*A*x + β*y` using alternative
8282
indexing semantics and where `α` and `β` are scalars, `x` and `y` are `N`
8383
element vectors, and `A` is an `N` by `N` symmetric matrix supplied in
@@ -106,6 +106,9 @@
106106
AP: Float64Array
107107
Matrix in packed form.
108108

109+
oa: integer
110+
Starting index for `AP`.
111+
109112
x: Float64Array
110113
Input vector `x`.
111114

@@ -140,14 +143,14 @@
140143
> var AP = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] );
141144
> var ord = 'row-major';
142145
> var uplo = 'upper';
143-
> {{alias}}.ndarray( ord, uplo, 2, 1.0, AP, x, 1, 0, 1.0, y, 1, 0 )
146+
> {{alias}}.ndarray( ord, uplo, 2, 1.0, AP, 0, x, 1, 0, 1.0, y, 1, 0 )
144147
<Float64Array>[ ~4.0, ~6.0 ]
145148

146149
// Advanced indexing:
147150
> x = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] );
148151
> y = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] );
149152
> AP = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] );
150-
> {{alias}}.ndarray( ord, uplo, 2, 1.0, AP, x, -1, 1, 1.0, y, -1, 1 )
153+
> {{alias}}.ndarray( ord, uplo, 2, 1.0, AP, 0, x, -1, 1, 1.0, y, -1, 1 )
151154
<Float64Array>[ ~6.0, ~4.0 ]
152155

153156
See Also

lib/node_modules/@stdlib/blas/base/dspmv/docs/types/index.d.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ interface Routine {
6161
* @param N - number of columns in the matrix `A`
6262
* @param alpha - scalar constant
6363
* @param AP - packed form of a symmetric matrix `A`
64+
* @param offsetAP - starting `AP` index
6465
* @param x - first input array
6566
* @param strideX - `x` stride length
6667
* @param offsetX - starting `x` index
@@ -77,10 +78,10 @@ interface Routine {
7778
* var x = new Float64Array( [ 1.0, 1.0, 1.0 ] );
7879
* var y = new Float64Array( [ 1.0, 1.0, 1.0 ] );
7980
*
80-
* dspmv.ndarray( 'column-major', 'lower', 3, 1.0, AP, x, 1, 0, 1.0, y, 1, 0 );
81+
* dspmv.ndarray( 'column-major', 'lower', 3, 1.0, AP, 0, x, 1, 0, 1.0, y, 1, 0 );
8182
* // y => <Float64Array>[ 7.0, 12.0, 15.0 ]
8283
*/
83-
ndarray( order: Layout, uplo: MatrixTriangle, N: number, alpha: number, AP: Float64Array, x: Float64Array, strideX: number, offsetX: number, beta: number, y: Float64Array, strideY: number, offsetY: number ): Float64Array;
84+
ndarray( order: Layout, uplo: MatrixTriangle, N: number, alpha: number, AP: Float64Array, offsetAP: number, x: Float64Array, strideX: number, offsetX: number, beta: number, y: Float64Array, strideY: number, offsetY: number ): Float64Array;
8485
}
8586

8687
/**
@@ -115,7 +116,7 @@ interface Routine {
115116
* var x = new Float64Array( [ 1.0, 1.0, 1.0 ] );
116117
* var y = new Float64Array( [ 1.0, 1.0, 1.0 ] );
117118
*
118-
* dspmv.ndarray( 'column-major', 'lower', 3, 1.0, AP, x, 1, 0, 1.0, y, -1, 2 );
119+
* dspmv.ndarray( 'column-major', 'lower', 3, 1.0, AP, 0, x, 1, 0, 1.0, y, -1, 2 );
119120
* // y => <Float64Array>[ 15.0, 12.0, 7.0 ]
120121
*/
121122
declare var dspmv: Routine;

0 commit comments

Comments
 (0)