You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/node_modules/@stdlib/blas/ext/base/gapxsumkbn2/README.md
+3
Original file line number
Diff line number
Diff line change
@@ -109,6 +109,7 @@ var v = gapxsumkbn2.ndarray( 4, 5.0, x, 2, 1 );
109
109
## Notes
110
110
111
111
- If `N <= 0`, both functions return `0.0`.
112
+
- Both functions support array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/base/accessor`][@stdlib/array/base/accessor])
112
113
- Depending on the environment, the typed versions ([`dapxsumkbn2`][@stdlib/blas/ext/base/dapxsumkbn2], [`sapxsumkbn2`][@stdlib/blas/ext/base/sapxsumkbn2], etc.) are likely to be significantly more performant.
* Adds a scalar constant to each strided array element and computes the sum using a second-order iterative Kahan–Babuška algorithm and alternative indexing semantics.
@@ -59,7 +63,7 @@ interface Routine {
59
63
* var v = gapxsumkbn2.ndarray( x.length, 5.0, x, 1, 0 );
tape('if provided an `N` parameter less than or equal to `0`, the function returns `0.0`',functiontest(t){
71
98
varx;
72
99
varv;
@@ -95,7 +122,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first
95
122
});
96
123
97
124
tape('the function supports a `stride` parameter',functiontest(t){
98
-
varN;
99
125
varx;
100
126
varv;
101
127
@@ -110,15 +136,34 @@ tape( 'the function supports a `stride` parameter', function test( t ) {
110
136
2.0
111
137
];
112
138
113
-
N=floor(x.length/2);
114
-
v=gapxsumkbn2(N,5.0,x,2);
139
+
v=gapxsumkbn2(4,5.0,x,2);
140
+
141
+
t.strictEqual(v,25.0,'returns expected value');
142
+
t.end();
143
+
});
144
+
145
+
tape('the function supports a `stride` parameter (accessors)',functiontest(t){
146
+
varx;
147
+
varv;
148
+
149
+
x=[
150
+
1.0,// 0
151
+
2.0,
152
+
2.0,// 1
153
+
-7.0,
154
+
-2.0,// 2
155
+
3.0,
156
+
4.0,// 3
157
+
2.0
158
+
];
159
+
160
+
v=gapxsumkbn2(4,5.0,toAccessorArray(x),2);
115
161
116
162
t.strictEqual(v,25.0,'returns expected value');
117
163
t.end();
118
164
});
119
165
120
166
tape('the function supports a negative `stride` parameter',functiontest(t){
121
-
varN;
122
167
varx;
123
168
varv;
124
169
@@ -133,8 +178,28 @@ tape( 'the function supports a negative `stride` parameter', function test( t )
133
178
2.0
134
179
];
135
180
136
-
N=floor(x.length/2);
137
-
v=gapxsumkbn2(N,5.0,x,-2);
181
+
v=gapxsumkbn2(4,5.0,x,-2);
182
+
183
+
t.strictEqual(v,25.0,'returns expected value');
184
+
t.end();
185
+
});
186
+
187
+
tape('the function supports a negative `stride` parameter (accessors)',functiontest(t){
188
+
varx;
189
+
varv;
190
+
191
+
x=[
192
+
1.0,// 3
193
+
2.0,
194
+
2.0,// 2
195
+
-7.0,
196
+
-2.0,// 1
197
+
3.0,
198
+
4.0,// 0
199
+
2.0
200
+
];
201
+
202
+
v=gapxsumkbn2(4,5.0,toAccessorArray(x),-2);
138
203
139
204
t.strictEqual(v,25.0,'returns expected value');
140
205
t.end();
@@ -152,10 +217,21 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f
152
217
t.end();
153
218
});
154
219
220
+
tape('if provided a `stride` parameter equal to `0`, the function returns the first element plus a constant repeated N times (accessors)',functiontest(t){
0 commit comments