@@ -30,43 +30,43 @@ limitations under the License.
30
30
var caxpy = require ( ' @stdlib/blas/base/caxpy' );
31
31
```
32
32
33
- #### caxpy( N, ca, cx , strideX, cy , strideY )
33
+ #### caxpy( N, alpha, x , strideX, y , strideY )
34
34
35
- Scales values from ` cx ` by ` ca ` and adds the result to ` cy ` .
35
+ Scales values from ` x ` by ` alpha ` and adds the result to ` y ` .
36
36
37
37
``` javascript
38
38
var Complex64Array = require ( ' @stdlib/array/complex64' );
39
39
var Complex64 = require ( ' @stdlib/complex/float32/ctor' );
40
40
41
- var cx = new Complex64Array ( [ 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 ] );
42
- var cy = new Complex64Array ( [ 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 ] );
43
- var ca = new Complex64 ( 2.0 , 2.0 );
41
+ var x = new Complex64Array ( [ 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 ] );
42
+ var y = new Complex64Array ( [ 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 ] );
43
+ var alpha = new Complex64 ( 2.0 , 2.0 );
44
44
45
- caxpy ( 3 , ca, cx , 1 , cy , 1 );
46
- // cy => <Complex64Array>[ -1.0, 7.0, -1.0, 15.0, -1.0, 23.0 ]
45
+ caxpy ( 3 , alpha, x , 1 , y , 1 );
46
+ // y => <Complex64Array>[ -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
- - ** ca ** : scalar [ ` Complex64 ` ] [ @stdlib/complex/float32/ctor ] constant.
53
- - ** cx ** : first input [ ` Complex64Array ` ] [ @stdlib/array/complex64 ] .
54
- - ** strideX** : index increment for ` cx ` .
55
- - ** cy ** : second input [ ` Complex64Array ` ] [ @stdlib/array/complex64 ] .
56
- - ** strideY** : index increment for ` cy ` .
52
+ - ** alpha ** : scalar [ ` Complex64 ` ] [ @stdlib/complex/float32/ctor ] constant.
53
+ - ** x ** : first input [ ` Complex64Array ` ] [ @stdlib/array/complex64 ] .
54
+ - ** strideX** : index increment for ` x ` .
55
+ - ** y ** : second input [ ` Complex64Array ` ] [ @stdlib/array/complex64 ] .
56
+ - ** strideY** : index increment for ` y ` .
57
57
58
- The ` N ` and stride parameters determine how values from ` cx ` are scaled by ` ca ` and added to ` cy ` . For example, to scale every other value in ` cx ` by ` ca ` and add the result to every other value of ` cy ` ,
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 Complex64Array = require ( ' @stdlib/array/complex64' );
62
62
var Complex64 = require ( ' @stdlib/complex/float32/ctor' );
63
63
64
- var cx = new Complex64Array ( [ 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0 , 8.0 ] );
65
- var cy = new Complex64Array ( [ 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 ] );
66
- var ca = new Complex64 ( 2.0 , 2.0 );
64
+ var x = new Complex64Array ( [ 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0 , 8.0 ] );
65
+ var y = new Complex64Array ( [ 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 ] );
66
+ var alpha = new Complex64 ( 2.0 , 2.0 );
67
67
68
- caxpy ( 2 , ca, cx , 2 , cy , 2 );
69
- // cy => <Complex64Array>[ -1.0, 7.0, 1.0, 1.0, -1.0, 23.0, 1.0, 1.0 ]
68
+ caxpy ( 2 , alpha, x , 2 , y , 2 );
69
+ // y => <Complex64Array>[ -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 Complex64Array = require( '@stdlib/array/complex64' );
78
78
var Complex64 = require ( ' @stdlib/complex/float32/ctor' );
79
79
80
80
// Initial arrays...
81
- var cx0 = new Complex64Array ( [ 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0 , 8.0 ] );
82
- var cy0 = new Complex64Array ( [ 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 ] );
81
+ var x0 = new Complex64Array ( [ 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0 , 8.0 ] );
82
+ var y0 = new Complex64Array ( [ 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 ca = new Complex64 ( 2.0 , 2.0 );
85
+ var alpha = new Complex64 ( 2.0 , 2.0 );
86
86
87
87
// Create offset views...
88
- var cx1 = new Complex64Array ( cx0 .buffer , cx0 .BYTES_PER_ELEMENT * 1 ); // start at 2nd element
89
- var cy1 = new Complex64Array ( cy0 .buffer , cy0 .BYTES_PER_ELEMENT * 2 ); // start at 3rd element
88
+ var x1 = new Complex64Array ( x0 .buffer , x0 .BYTES_PER_ELEMENT * 1 ); // start at 2nd element
89
+ var y1 = new Complex64Array ( y0 .buffer , y0 .BYTES_PER_ELEMENT * 2 ); // start at 3rd element
90
90
91
- // Scales values of `cx0 ` by `ca ` starting from second index and add the result to `cy0 ` starting from third index...
92
- caxpy ( 2 , ca, cx1 , 1 , cy1 , 1 );
93
- // cy0 => <Complex64Array>[ 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
+ caxpy ( 2 , alpha, x1 , 1 , y1 , 1 );
93
+ // y0 => <Complex64Array>[ 1.0, 1.0, 1.0, 1.0, -1.0, 15.0, -1.0, 23.0 ]
94
94
```
95
95
96
- #### caxpy.ndarray( N, ca, cx , strideX, offsetX, cy , strideY, offsetY )
96
+ #### caxpy.ndarray( N, alpha, x , strideX, offsetX, y , strideY, offsetY )
97
97
98
- Scales values from ` cx ` by ` ca ` and adds the result to ` cy ` 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 Complex64Array = require ( ' @stdlib/array/complex64' );
102
102
var Complex64 = require ( ' @stdlib/complex/float32/ctor' );
103
103
104
- var cx = new Complex64Array ( [ 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 ] );
105
- var cy = new Complex64Array ( [ 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 ] );
106
- var ca = new Complex64 ( 2.0 , 2.0 );
104
+ var x = new Complex64Array ( [ 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 ] );
105
+ var y = new Complex64Array ( [ 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 ] );
106
+ var alpha = new Complex64 ( 2.0 , 2.0 );
107
107
108
- caxpy .ndarray ( 3 , ca, cx , 1 , 0 , cy , 1 , 0 );
109
- // cy => <Complex64Array>[ -1.0, 7.0, -1.0, 15.0, -1.0, 23.0 ]
108
+ caxpy .ndarray ( 3 , alpha, x , 1 , 0 , y , 1 , 0 );
109
+ // y => <Complex64Array>[ -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 ` cx ` .
115
- - ** offsetY** : starting index for ` cy ` .
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 Complex64Array = require ( ' @stdlib/array/complex64' );
121
121
var Complex64 = require ( ' @stdlib/complex/float32/ctor' );
122
122
123
- var cx = new Complex64Array ( [ 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0 , 8.0 ] );
124
- var cy = new Complex64Array ( [ 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 ] );
125
- var ca = new Complex64 ( 2.0 , 2.0 );
123
+ var x = new Complex64Array ( [ 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0 , 8.0 ] );
124
+ var y = new Complex64Array ( [ 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 ] );
125
+ var alpha = new Complex64 ( 2.0 , 2.0 );
126
126
127
- caxpy .ndarray ( 3 , ca, cx , 1 , 1 , cy , 1 , 1 );
128
- // cy => <Complex64Array>[ 1.0, 1.0, -1.0, 15.0, -1.0, 23.0, -1.0, 31.0 ]
127
+ caxpy .ndarray ( 3 , alpha, x , 1 , 1 , y , 1 , 1 );
128
+ // y => <Complex64Array>[ 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 @@ caxpy.ndarray( 3, ca, cx, 1, 1, cy, 1, 1 );
136
136
137
137
## Notes
138
138
139
- - If ` N <= 0 ` , both functions return ` cy ` unchanged.
139
+ - If ` N <= 0 ` , both functions return ` y ` unchanged.
140
140
- ` caxpy() ` corresponds to the [ BLAS] [ blas ] level 1 function [ ` caxpy ` ] [ caxpy ] .
141
141
142
142
</section >
@@ -162,17 +162,17 @@ function rand() {
162
162
return new Complex64 ( discreteUniform ( 0 , 10 ), discreteUniform ( - 5 , 5 ) );
163
163
}
164
164
165
- var cx = filledarrayBy ( 10 , ' complex64' , rand );
166
- var cy = filledarrayBy ( 10 , ' complex64' , rand );
167
- var cyc = ccopy ( cy .length , cy , 1 , zeros ( cy .length , ' complex64' ), 1 );
165
+ var x = filledarrayBy ( 10 , ' complex64' , rand );
166
+ var y = filledarrayBy ( 10 , ' complex64' , rand );
167
+ var yc = ccopy ( y .length , y , 1 , zeros ( y .length , ' complex64' ), 1 );
168
168
169
- var ca = new Complex64 ( 2.0 , 2.0 );
169
+ var alpha = new Complex64 ( 2.0 , 2.0 );
170
170
171
- // Scale values from `cx ` by `ca ` and add the result to `cy `:
172
- caxpy ( cx .length , ca, cx , 1 , cy , 1 );
171
+ // Scale values from `x ` by `alpha ` and add the result to `y `:
172
+ caxpy ( x .length , alpha, x , 1 , y , 1 );
173
173
174
174
// Print the results:
175
- logEach ( ' (%s)*(%s) + (%s) = %s' , ca, cx, cyc, cy );
175
+ logEach ( ' (%s)*(%s) + (%s) = %s' , alpha, x, yc, y );
176
176
```
177
177
178
178
</section >
@@ -205,60 +205,60 @@ logEach( '(%s)*(%s) + (%s) = %s', ca, cx, cyc, cy );
205
205
#include " stdlib/blas/base/caxpy.h"
206
206
```
207
207
208
- #### c_caxpy( N, ca , \* CX , strideX, \* CY , strideY )
208
+ #### c_caxpy( N, alpha , \* X , strideX, \* Y , strideY )
209
209
210
- Scales values from ` cx ` by ` ca ` and adds the result to ` cy ` .
210
+ Scales values from ` X ` by ` alpha ` and adds the result to ` Y ` .
211
211
212
212
``` c
213
213
#include " stdlib/complex/float32/ctor.h"
214
214
215
- float cx [] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f };
216
- float cy [ ] = { -1.0f, -2.0f, -3.0f, -4.0f, -5.0f, -6.0f, -7.0f, -8.0f };
217
- const stdlib_complex64_t ca = stdlib_complex64( 2.0f, 2.0f );
215
+ float X [] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f };
216
+ float Y [ ] = { -1.0f, -2.0f, -3.0f, -4.0f, -5.0f, -6.0f, -7.0f, -8.0f };
217
+ const stdlib_complex64_t alpha = stdlib_complex64( 2.0f, 2.0f );
218
218
219
- c_caxpy ( 4, ca , (void * )cx , 1, (void * )cy , 1 );
219
+ c_caxpy ( 4, alpha , (void * )X , 1, (void * )Y , 1 );
220
220
```
221
221
222
222
The function accepts the following arguments:
223
223
224
224
- **N**: `[in] CBLAS_INT` number of indexed elements.
225
- - **ca **: `[in] stdlib_complex64_t` scalar constant.
226
- - **CX **: `[in] void*` input array.
227
- - **strideX**: `[in] CBLAS_INT` index increment for `CX `.
228
- - **CY **: `[inout] void*` output array.
229
- - **strideY**: `[in] CBLAS_INT` index increment for `CY `.
225
+ - **alpha **: `[in] stdlib_complex64_t` scalar constant.
226
+ - **X **: `[in] void*` input array.
227
+ - **strideX**: `[in] CBLAS_INT` index increment for `X `.
228
+ - **Y **: `[inout] void*` output array.
229
+ - **strideY**: `[in] CBLAS_INT` index increment for `Y `.
230
230
231
231
```c
232
- void c_caxpy( const CBLAS_INT N, const stdlib_complex64_t ca , const void *CX , const CBLAS_INT strideX, void *CY , const CBLAS_INT strideY );
232
+ void c_caxpy( const CBLAS_INT N, const stdlib_complex64_t alpha , const void *X , const CBLAS_INT strideX, void *Y , const CBLAS_INT strideY );
233
233
```
234
234
235
- #### c_caxpy_ndarray( N, ca , \* CX , strideX, offsetX, \* CY , strideY, offsetY )
235
+ #### c_caxpy_ndarray( N, alpha , \* X , strideX, offsetX, \* Y , strideY, offsetY )
236
236
237
- Scales values from ` cx ` by ` ca ` and adds the result to ` cy ` using alternative indexing semantics.
237
+ Scales values from ` X ` by ` alpha ` and adds the result to ` Y ` using alternative indexing semantics.
238
238
239
239
``` c
240
240
#include " stdlib/complex/float32/ctor.h"
241
241
242
- float cx [] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f };
243
- float cy [ ] = { -1.0f, -2.0f, -3.0f, -4.0f, -5.0f, -6.0f, -7.0f, -8.0f }
244
- const stdlib_complex64_t ca = stdlib_complex64( 2.0f, 2.0f );
242
+ float X [] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f };
243
+ float Y [ ] = { -1.0f, -2.0f, -3.0f, -4.0f, -5.0f, -6.0f, -7.0f, -8.0f }
244
+ const stdlib_complex64_t alpha = stdlib_complex64( 2.0f, 2.0f );
245
245
246
- c_caxpy_ndarray ( 4, ca , (void * )cx , 1, 0, (void * )cy , 1, 0 );
246
+ c_caxpy_ndarray ( 4, alpha , (void * )X , 1, 0, (void * )Y , 1, 0 );
247
247
```
248
248
249
249
The function accepts the following arguments:
250
250
251
251
- **N**: `[in] CBLAS_INT` number of indexed elements.
252
- - **ca **: `[in] stdlib_complex64_t` scalar constant.
253
- - **CX **: `[in] void*` input array.
254
- - **strideX**: `[in] CBLAS_INT` index increment for `CX `.
255
- - **offsetX**: `[in] CBLAS_INT` starting index for `CX `.
256
- - **CY **: `[inout] void*` output array.
257
- - **strideY**: `[in] CBLAS_INT` index increment for `CY `.
258
- - **offsetY**: `[in] CBLAS_INT` starting index for `CY `.
252
+ - **alpha **: `[in] stdlib_complex64_t` scalar constant.
253
+ - **X **: `[in] void*` input array.
254
+ - **strideX**: `[in] CBLAS_INT` index increment for `X `.
255
+ - **offsetX**: `[in] CBLAS_INT` starting index for `X `.
256
+ - **Y **: `[inout] void*` output array.
257
+ - **strideY**: `[in] CBLAS_INT` index increment for `Y `.
258
+ - **offsetY**: `[in] CBLAS_INT` starting index for `Y `.
259
259
260
260
```c
261
- void c_caxpy_ndarray( const CBLAS_INT N, const stdlib_complex64_t ca , const void *CX , const CBLAS_INT strideX, const CBLAS_INT offsetX, void *CY , const CBLAS_INT strideY, const CBLAS_INT offsetY );
261
+ void c_caxpy_ndarray( const CBLAS_INT N, const stdlib_complex64_t alpha , const void *X , const CBLAS_INT strideX, const CBLAS_INT offsetX, void *Y , const CBLAS_INT strideY, const CBLAS_INT offsetY );
262
262
```
263
263
264
264
</section >
@@ -286,11 +286,11 @@ void c_caxpy_ndarray( const CBLAS_INT N, const stdlib_complex64_t ca, const void
286
286
287
287
int main ( void ) {
288
288
// Create strided arrays of interleaved real and imaginary components...
289
- float cx [ ] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f };
290
- float cy [ ] = { -1.0f, -2.0f, -3.0f, -4.0f, -5.0f, -6.0f, -7.0f, -8.0f };
289
+ float X [ ] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f };
290
+ float Y [ ] = { -1.0f, -2.0f, -3.0f, -4.0f, -5.0f, -6.0f, -7.0f, -8.0f };
291
291
292
292
// Create a complex scalar:
293
- const stdlib_complex64_t ca = stdlib_complex64( 2.0f, 2.0f );
293
+ const stdlib_complex64_t alpha = stdlib_complex64( 2.0f, 2.0f );
294
294
295
295
// Specify the number of elements:
296
296
const int N = 4;
@@ -299,20 +299,20 @@ int main( void ) {
299
299
const int strideX = 1;
300
300
const int strideY = 1;
301
301
302
- // Scale values from `cx ` by `ca ` and adds the result to `cy `:
303
- c_caxpy( N, ca , (void *)cx , strideX, (void *)cy , strideY );
302
+ // Scale values from `X ` by `alpha ` and adds the result to `Y `:
303
+ c_caxpy( N, alpha , (void *)X , strideX, (void *)Y , strideY );
304
304
305
305
// Print the result:
306
306
for ( int i = 0; i < N; i++ ) {
307
- printf( "cy [ %i ] = %f + %fj\n", i, cy [ i*2 ], cy [ (i*2)+1 ] );
307
+ printf( "Y [ %i ] = %f + %fj\n", i, Y [ i*2 ], Y [ (i*2)+1 ] );
308
308
}
309
309
310
- // Scales values from `cx ` by `ca ` and adds the result to `cy ` using alternative indexing semantics:
311
- c_caxpy_ndarray( N, ca , (void *)cx , -strideX, 3, (void *)cy , -strideY, 3 );
310
+ // Scales values from `X ` by `alpha ` and adds the result to `Y ` using alternative indexing semantics:
311
+ c_caxpy_ndarray( N, alpha , (void *)X , -strideX, 3, (void *)Y , -strideY, 3 );
312
312
313
313
// Print the result:
314
314
for ( int i = 0; i < N; i++ ) {
315
- printf( "cy [ %i ] = %f + %fj\n", i, cy [ i*2 ], cy [ (i*2)+1 ] );
315
+ printf( "Y [ %i ] = %f + %fj\n", i, Y [ i*2 ], Y [ (i*2)+1 ] );
316
316
}
317
317
}
318
318
```
0 commit comments