@@ -78,7 +78,7 @@ tape( 'the function scales elements from `cx` by `ca` and adds the result to `cy
7878 var cx ;
7979 var cy ;
8080
81- cx = new Complex64Array ( [
81+ cx = new Complex64Array ( [
8282 0.7 , // 1
8383 - 0.8 , // 1
8484 - 0.4 , // 2
@@ -93,8 +93,8 @@ tape( 'the function scales elements from `cx` by `ca` and adds the result to `cy
9393 0.4 ,
9494 - 0.6 ,
9595 0.6
96- ] ) ;
97- cy = new Complex64Array ( [
96+ ] ) ;
97+ cy = new Complex64Array ( [
9898 0.6 , // 1
9999 - 0.6 , // 1
100100 - 0.9 , // 2
@@ -109,13 +109,13 @@ tape( 'the function scales elements from `cx` by `ca` and adds the result to `cy
109109 - 0.3 ,
110110 0.8 ,
111111 - 0.7
112- ] ) ;
112+ ] ) ;
113113 ca = new Complex64 ( 0.4 , - 0.7 ) ;
114114
115115 caxpy ( 4 , ca , cx , 1 , cy , 1 ) ;
116116
117117 viewY = new Float32Array ( cy . buffer ) ;
118- expected = new Float32Array ( [
118+ expected = new Float32Array ( [
119119 0.32 , // 1
120120 - 1.41 , // 1
121121 - 1.55 , // 2
@@ -130,7 +130,7 @@ tape( 'the function scales elements from `cx` by `ca` and adds the result to `cy
130130 - 0.3 ,
131131 0.8 ,
132132 - 0.7
133- ] ) ;
133+ ] ) ;
134134 isApprox ( t , viewY , expected , 10.0 ) ;
135135 t . end ( ) ;
136136} ) ;
@@ -142,7 +142,7 @@ tape( 'the function supports a `cx` stride', function test( t ) {
142142 var cx ;
143143 var cy ;
144144
145- cx = new Complex64Array ( [
145+ cx = new Complex64Array ( [
146146 0.7 , // 1
147147 - 0.8 , // 1
148148 - 0.4 ,
@@ -157,8 +157,8 @@ tape( 'the function supports a `cx` stride', function test( t ) {
157157 0.4 ,
158158 - 0.6 , // 4
159159 0.6 // 4
160- ] ) ;
161- cy = new Complex64Array ( [
160+ ] ) ;
161+ cy = new Complex64Array ( [
162162 0.6 , // 1
163163 - 0.6 , // 1
164164 - 0.9 , // 2
@@ -173,13 +173,13 @@ tape( 'the function supports a `cx` stride', function test( t ) {
173173 - 0.3 ,
174174 0.8 ,
175175 - 0.7
176- ] ) ;
176+ ] ) ;
177177 ca = new Complex64 ( 0.4 , - 0.7 ) ;
178178
179179 caxpy ( 4 , ca , cx , 2 , cy , 1 ) ;
180180
181181 viewY = new Float32Array ( cy . buffer ) ;
182- expected = new Float32Array ( [
182+ expected = new Float32Array ( [
183183 0.32 , // 1
184184 - 1.41 , // 1
185185 - 1.57 , // 2
@@ -194,7 +194,7 @@ tape( 'the function supports a `cx` stride', function test( t ) {
194194 - 0.3 ,
195195 0.8 ,
196196 - 0.7
197- ] ) ;
197+ ] ) ;
198198 isApprox ( t , viewY , expected , 10.0 ) ;
199199 t . end ( ) ;
200200} ) ;
@@ -206,7 +206,7 @@ tape( 'the function supports a `cy` stride', function test( t ) {
206206 var cx ;
207207 var cy ;
208208
209- cx = new Complex64Array ( [
209+ cx = new Complex64Array ( [
210210 0.7 , // 1
211211 - 0.8 , // 1
212212 - 0.4 , // 2
@@ -221,8 +221,8 @@ tape( 'the function supports a `cy` stride', function test( t ) {
221221 0.4 ,
222222 - 0.6 ,
223223 0.6
224- ] ) ;
225- cy = new Complex64Array ( [
224+ ] ) ;
225+ cy = new Complex64Array ( [
226226 0.6 , // 1
227227 - 0.6 , // 1
228228 - 0.9 ,
@@ -237,13 +237,13 @@ tape( 'the function supports a `cy` stride', function test( t ) {
237237 - 0.3 ,
238238 0.8 , // 4
239239 - 0.7 // 4
240- ] ) ;
240+ ] ) ;
241241 ca = new Complex64 ( 0.4 , - 0.7 ) ;
242242
243243 caxpy ( 4 , ca , cx , 1 , cy , 2 ) ;
244244
245245 viewY = new Float32Array ( cy . buffer ) ;
246- expected = new Float32Array ( [
246+ expected = new Float32Array ( [
247247 0.32 , // 1
248248 - 1.41 , // 1
249249 - 0.9 ,
@@ -258,7 +258,7 @@ tape( 'the function supports a `cy` stride', function test( t ) {
258258 - 0.3 ,
259259 0.32 , // 4
260260 - 1.16 // 4
261- ] ) ;
261+ ] ) ;
262262 isApprox ( t , viewY , expected , 10.0 ) ;
263263 t . end ( ) ;
264264} ) ;
@@ -279,6 +279,29 @@ tape( 'the function returns a reference to the output array', function test( t )
279279 t . end ( ) ;
280280} ) ;
281281
282+ tape ( 'if provided `ca` parameter equal to `0`, the function returns the second input array unchanged' , function test ( t ) {
283+ var expected ;
284+ var viewY ;
285+ var ca ;
286+ var cx ;
287+ var cy ;
288+
289+ cx = new Complex64Array ( [ 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0 , 8.0 ] ) ;
290+ cy = new Complex64Array ( [ 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 ] ) ;
291+ ca = new Complex64 ( 0.0 , 0.0 ) ;
292+
293+ viewY = new Float32Array ( cy . buffer ) ;
294+ expected = new Float32Array ( [ 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 ] ) ;
295+
296+ caxpy ( - 1 , ca , cx , 1 , 0 , cy , 1 , 0 ) ;
297+ t . deepEqual ( viewY , expected , 'returns expected value' ) ;
298+
299+ caxpy ( 0 , ca , cx , 1 , 0 , cy , 1 , 0 ) ;
300+ t . deepEqual ( viewY , expected , 'returns expected value' ) ;
301+
302+ t . end ( ) ;
303+ } ) ;
304+
282305tape ( 'if provided an `N` parameter less than or equal to `0`, the function returns the second input array unchanged' , function test ( t ) {
283306 var expected ;
284307 var viewY ;
@@ -309,7 +332,7 @@ tape( 'the function supports negative `cx` strides', function test( t ) {
309332 var cx ;
310333 var cy ;
311334
312- cx = new Complex64Array ( [
335+ cx = new Complex64Array ( [
313336 0.7 , // 4
314337 - 0.8 , // 4
315338 - 0.4 ,
@@ -324,8 +347,8 @@ tape( 'the function supports negative `cx` strides', function test( t ) {
324347 0.4 ,
325348 - 0.6 , // 1
326349 0.6 // 1
327- ] ) ;
328- cy = new Complex64Array ( [
350+ ] ) ;
351+ cy = new Complex64Array ( [
329352 0.6 , // 1
330353 - 0.6 , // 1
331354 - 0.9 , // 2
@@ -340,13 +363,13 @@ tape( 'the function supports negative `cx` strides', function test( t ) {
340363 - 0.3 ,
341364 0.8 ,
342365 - 0.7
343- ] ) ;
366+ ] ) ;
344367 ca = new Complex64 ( 0.4 , - 0.7 ) ;
345368
346369 caxpy ( 4 , ca , cx , - 2 , cy , 1 ) ;
347370
348371 viewY = new Float32Array ( cy . buffer ) ;
349- expected = new Float32Array ( [
372+ expected = new Float32Array ( [
350373 0.78 , // 1
351374 0.06 , // 1
352375 - 1.54 , // 2
@@ -361,7 +384,7 @@ tape( 'the function supports negative `cx` strides', function test( t ) {
361384 - 0.3 ,
362385 0.8 ,
363386 - 0.7
364- ] ) ;
387+ ] ) ;
365388 isApprox ( t , viewY , expected , 10.0 ) ;
366389 t . end ( ) ;
367390} ) ;
@@ -373,7 +396,7 @@ tape( 'the function supports negative `cy` strides', function test( t ) {
373396 var cx ;
374397 var cy ;
375398
376- cx = new Complex64Array ( [
399+ cx = new Complex64Array ( [
377400 0.7 , // 1
378401 - 0.8 , // 1
379402 - 0.4 ,
@@ -388,8 +411,8 @@ tape( 'the function supports negative `cy` strides', function test( t ) {
388411 0.4 ,
389412 - 0.6 , // 4
390413 0.6 // 4
391- ] ) ;
392- cy = new Complex64Array ( [
414+ ] ) ;
415+ cy = new Complex64Array ( [
393416 0.6 , // 4
394417 - 0.6 , // 4
395418 - 0.9 ,
@@ -404,13 +427,13 @@ tape( 'the function supports negative `cy` strides', function test( t ) {
404427 - 0.3 ,
405428 0.8 , // 1
406429 - 0.7 // 1
407- ] ) ;
430+ ] ) ;
408431 ca = new Complex64 ( 0.4 , - 0.7 ) ;
409432
410433 caxpy ( 4 , ca , cx , 2 , cy , - 2 ) ;
411434
412435 viewY = new Float32Array ( cy . buffer ) ;
413- expected = new Float32Array ( [
436+ expected = new Float32Array ( [
414437 0.78 , // 4
415438 0.06 , // 4
416439 - 0.9 ,
@@ -425,7 +448,7 @@ tape( 'the function supports negative `cy` strides', function test( t ) {
425448 - 0.3 ,
426449 0.52 , // 1
427450 - 1.51 // 1
428- ] ) ;
451+ ] ) ;
429452 isApprox ( t , viewY , expected , 10.0 ) ;
430453 t . end ( ) ;
431454} ) ;
@@ -437,7 +460,7 @@ tape( 'the function supports complex access patterns', function test( t ) {
437460 var cx ;
438461 var cy ;
439462
440- cx = new Complex64Array ( [
463+ cx = new Complex64Array ( [
441464 0.7 , // 4
442465 - 0.8 , // 4
443466 - 0.4 , // 3
@@ -452,8 +475,8 @@ tape( 'the function supports complex access patterns', function test( t ) {
452475 0.4 ,
453476 - 0.6 ,
454477 0.6
455- ] ) ;
456- cy = new Complex64Array ( [
478+ ] ) ;
479+ cy = new Complex64Array ( [
457480 0.6 , // 4
458481 - 0.6 , // 4
459482 - 0.9 ,
@@ -468,13 +491,13 @@ tape( 'the function supports complex access patterns', function test( t ) {
468491 - 0.3 ,
469492 0.8 , // 1
470493 - 0.7 // 1
471- ] ) ;
494+ ] ) ;
472495 ca = new Complex64 ( 0.4 , - 0.7 ) ;
473496
474497 caxpy ( 4 , ca , cx , - 1 , cy , - 2 ) ;
475498
476499 viewY = new Float32Array ( cy . buffer ) ;
477- expected = new Float32Array ( [
500+ expected = new Float32Array ( [
478501 0.32 , // 4
479502 - 1.41 , // 4
480503 - 0.9 ,
@@ -489,7 +512,7 @@ tape( 'the function supports complex access patterns', function test( t ) {
489512 - 0.3 ,
490513 0.32 , // 1
491514 - 1.16 // 1
492- ] ) ;
515+ ] ) ;
493516 isApprox ( t , viewY , expected , 10.0 ) ;
494517 t . end ( ) ;
495518} ) ;
0 commit comments