@@ -30,43 +30,43 @@ limitations under the License.
30
30
var zaxpy = require ( ' @stdlib/blas/base/zaxpy' );
31
31
```
32
32
33
- #### zaxpy( N, za, zx , strideX, zy , strideY )
33
+ #### zaxpy( N, alpha, x , strideX, y , strideY )
34
34
35
- Scales values from ` zx ` by ` za ` and adds the result to ` zy ` .
35
+ Scales values from ` x ` by ` alpha ` and adds the result to ` y ` .
36
36
37
37
``` javascript
38
38
var Complex128Array = require ( ' @stdlib/array/complex128' );
39
39
var Complex128 = require ( ' @stdlib/complex/float64/ctor' );
40
40
41
- var zx = new Complex128Array ( [ 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 ] );
42
- var zy = new Complex128Array ( [ 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 ] );
43
- var za = new Complex128 ( 2.0 , 2.0 );
41
+ var x = new Complex128Array ( [ 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 ] );
42
+ var y = new Complex128Array ( [ 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 ] );
43
+ var alpha = new Complex128 ( 2.0 , 2.0 );
44
44
45
- zaxpy ( 3 , za, zx , 1 , zy , 1 );
46
- // zy => <Complex128Array>[ -1.0, 7.0, -1.0, 15.0, -1.0, 23.0 ]
45
+ zaxpy ( 3 , alpha, x , 1 , y , 1 );
46
+ // y => <Complex128Array>[ -1.0, 7.0, -1.0, 15.0, -1.0, 23.0 ]
47
47
```
48
48
49
49
The function has the following parameters:
50
50
51
51
- ** N** : number of indexed elements.
52
- - ** za ** : scalar [ ` Complex128 ` ] [ @stdlib/complex/float64/ctor ] constant.
53
- - ** zx ** : first input [ ` Complex128Array ` ] [ @stdlib/array/complex128 ] .
54
- - ** strideX** : index increment for ` zx ` .
55
- - ** zy ** : second input [ ` Complex128Array ` ] [ @stdlib/array/complex128 ] .
56
- - ** strideY** : index increment for ` zy ` .
52
+ - ** alpha ** : scalar [ ` Complex128 ` ] [ @stdlib/complex/float64/ctor ] constant.
53
+ - ** x ** : first input [ ` Complex128Array ` ] [ @stdlib/array/complex128 ] .
54
+ - ** strideX** : index increment for ` x ` .
55
+ - ** y ** : second input [ ` Complex128Array ` ] [ @stdlib/array/complex128 ] .
56
+ - ** strideY** : index increment for ` y ` .
57
57
58
- The ` N ` and stride parameters determine how values from ` zx ` are scaled by ` za ` and added to ` zy ` . For example, to scale every other value in ` zx ` by ` za ` and add the result to every other value of ` zy ` ,
58
+ The ` N ` and stride parameters determine how values from ` x ` are scaled by ` alpha ` and added to ` y ` . For example, to scale every other value in ` x ` by ` alpha ` and add the result to every other value of ` y ` ,
59
59
60
60
``` javascript
61
61
var Complex128Array = require ( ' @stdlib/array/complex128' );
62
62
var Complex128 = require ( ' @stdlib/complex/float64/ctor' );
63
63
64
- var zx = new Complex128Array ( [ 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0 , 8.0 ] );
65
- var zy = new Complex128Array ( [ 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 ] );
66
- var za = new Complex128 ( 2.0 , 2.0 );
64
+ var x = new Complex128Array ( [ 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0 , 8.0 ] );
65
+ var y = new Complex128Array ( [ 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 ] );
66
+ var alpha = new Complex128 ( 2.0 , 2.0 );
67
67
68
- zaxpy ( 2 , za, zx , 2 , zy , 2 );
69
- // zy => <Complex128Array>[ -1.0, 7.0, 1.0, 1.0, -1.0, 23.0, 1.0, 1.0 ]
68
+ zaxpy ( 2 , alpha, x , 2 , y , 2 );
69
+ // y => <Complex128Array>[ -1.0, 7.0, 1.0, 1.0, -1.0, 23.0, 1.0, 1.0 ]
70
70
```
71
71
72
72
Note that indexing is relative to the first index. To introduce an offset, use [ ` typed array ` ] [ mdn-typed-array ] views.
@@ -78,54 +78,54 @@ var Complex128Array = require( '@stdlib/array/complex128' );
78
78
var Complex128 = require ( ' @stdlib/complex/float64/ctor' );
79
79
80
80
// Initial arrays...
81
- var zx0 = new Complex128Array ( [ 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0 , 8.0 ] );
82
- var zy0 = new Complex128Array ( [ 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 ] );
81
+ var x0 = new Complex128Array ( [ 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0 , 8.0 ] );
82
+ var y0 = new Complex128Array ( [ 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 ] );
83
83
84
84
// Define a scalar constant:
85
- var za = new Complex128 ( 2.0 , 2.0 );
85
+ var alpha = new Complex128 ( 2.0 , 2.0 );
86
86
87
87
// Create offset views...
88
- var zx1 = new Complex128Array ( zx0 .buffer , zx0 .BYTES_PER_ELEMENT * 1 ); // start at 2nd element
89
- var zy1 = new Complex128Array ( zy0 .buffer , zy0 .BYTES_PER_ELEMENT * 2 ); // start at 3rd element
88
+ var x1 = new Complex128Array ( x0 .buffer , x0 .BYTES_PER_ELEMENT * 1 ); // start at 2nd element
89
+ var y1 = new Complex128Array ( y0 .buffer , y0 .BYTES_PER_ELEMENT * 2 ); // start at 3rd element
90
90
91
- // Scales values of `zx0 ` by `za ` starting from second index and add the result to `zy0 ` starting from third index...
92
- zaxpy ( 2 , za, zx1 , 1 , zy1 , 1 );
93
- // zy0 => <Complex128Array>[ 1.0, 1.0, 1.0, 1.0, -1.0, 15.0, -1.0, 23.0 ]
91
+ // Scales values of `x0 ` by `alpha ` starting from second index and add the result to `y0 ` starting from third index...
92
+ zaxpy ( 2 , alpha, x1 , 1 , y1 , 1 );
93
+ // y0 => <Complex128Array>[ 1.0, 1.0, 1.0, 1.0, -1.0, 15.0, -1.0, 23.0 ]
94
94
```
95
95
96
- #### zaxpy.ndarray( N, za, zx , strideX, offsetX, zy , strideY, offsetY )
96
+ #### zaxpy.ndarray( N, alpha, x , strideX, offsetX, y , strideY, offsetY )
97
97
98
- Scales values from ` zx ` by ` za ` and adds the result to ` zy ` using alternative indexing semantics.
98
+ Scales values from ` x ` by ` alpha ` and adds the result to ` y ` using alternative indexing semantics.
99
99
100
100
``` javascript
101
101
var Complex128Array = require ( ' @stdlib/array/complex128' );
102
102
var Complex128 = require ( ' @stdlib/complex/float64/ctor' );
103
103
104
- var zx = new Complex128Array ( [ 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 ] );
105
- var zy = new Complex128Array ( [ 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 ] );
106
- var za = new Complex128 ( 2.0 , 2.0 );
104
+ var x = new Complex128Array ( [ 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 ] );
105
+ var y = new Complex128Array ( [ 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 ] );
106
+ var alpha = new Complex128 ( 2.0 , 2.0 );
107
107
108
- zaxpy .ndarray ( 3 , za, zx , 1 , 0 , zy , 1 , 0 );
109
- // zy => <Complex128Array>[ -1.0, 7.0, -1.0, 15.0, -1.0, 23.0 ]
108
+ zaxpy .ndarray ( 3 , alpha, x , 1 , 0 , y , 1 , 0 );
109
+ // y => <Complex128Array>[ -1.0, 7.0, -1.0, 15.0, -1.0, 23.0 ]
110
110
```
111
111
112
112
The function has the following additional parameters:
113
113
114
- - ** offsetX** : starting index for ` zx ` .
115
- - ** offsetY** : starting index for ` zy ` .
114
+ - ** offsetX** : starting index for ` x ` .
115
+ - ** offsetY** : starting index for ` y ` .
116
116
117
117
While [ ` typed array ` ] [ mdn-typed-array ] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, to scale values in the first input strided array starting from the second element and add the result to the second input array starting from the second element,
118
118
119
119
``` javascript
120
120
var Complex128Array = require ( ' @stdlib/array/complex128' );
121
121
var Complex128 = require ( ' @stdlib/complex/float64/ctor' );
122
122
123
- var zx = new Complex128Array ( [ 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0 , 8.0 ] );
124
- var zy = new Complex128Array ( [ 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 ] );
125
- var za = new Complex128 ( 2.0 , 2.0 );
123
+ var x = new Complex128Array ( [ 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0 , 8.0 ] );
124
+ var y = new Complex128Array ( [ 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 ] );
125
+ var alpha = new Complex128 ( 2.0 , 2.0 );
126
126
127
- zaxpy .ndarray ( 3 , za, zx , 1 , 1 , zy , 1 , 1 );
128
- // zy => <Complex128Array>[ 1.0, 1.0, -1.0, 15.0, -1.0, 23.0, -1.0, 31.0 ]
127
+ zaxpy .ndarray ( 3 , alpha, x , 1 , 1 , y , 1 , 1 );
128
+ // y => <Complex128Array>[ 1.0, 1.0, -1.0, 15.0, -1.0, 23.0, -1.0, 31.0 ]
129
129
```
130
130
131
131
</section >
@@ -136,7 +136,7 @@ zaxpy.ndarray( 3, za, zx, 1, 1, zy, 1, 1 );
136
136
137
137
## Notes
138
138
139
- - If ` N <= 0 ` , both functions return ` zy ` unchanged.
139
+ - If ` N <= 0 ` , both functions return ` y ` unchanged.
140
140
- ` zaxpy() ` corresponds to the [ BLAS] [ blas ] level 1 function [ ` zaxpy ` ] [ zaxpy ] .
141
141
142
142
</section >
@@ -162,17 +162,17 @@ function rand() {
162
162
return new Complex128 ( discreteUniform ( 0 , 10 ), discreteUniform ( - 5 , 5 ) );
163
163
}
164
164
165
- var zx = filledarrayBy ( 10 , ' complex128' , rand );
166
- var zy = filledarrayBy ( 10 , ' complex128' , rand );
167
- var zyc = zcopy ( zy .length , zy , 1 , zeros ( zy .length , ' complex128' ), 1 );
165
+ var x = filledarrayBy ( 10 , ' complex128' , rand );
166
+ var y = filledarrayBy ( 10 , ' complex128' , rand );
167
+ var yc = zcopy ( y .length , y , 1 , zeros ( y .length , ' complex128' ), 1 );
168
168
169
- var za = new Complex128 ( 2.0 , 2.0 );
169
+ var alpha = new Complex128 ( 2.0 , 2.0 );
170
170
171
- // Scale values from `zx ` by `za ` and add the result to `zy `:
172
- zaxpy ( zx .length , za, zx , 1 , zy , 1 );
171
+ // Scale values from `x ` by `alpha ` and add the result to `y `:
172
+ zaxpy ( x .length , alpha, x , 1 , y , 1 );
173
173
174
174
// Print the results:
175
- logEach ( ' (%s)*(%s) + (%s) = %s' , za, zx, zyc, zy );
175
+ logEach ( ' (%s)*(%s) + (%s) = %s' , alpha, x, yc, y );
176
176
```
177
177
178
178
</section >
0 commit comments