Skip to content

Commit dd429e6

Browse files
committed
chore: update examples
1 parent 411c9b1 commit dd429e6

File tree

2 files changed

+29
-13
lines changed

2 files changed

+29
-13
lines changed

lib/node_modules/@stdlib/blas/base/zaxpy/examples/c/example.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222

2323
int main( void ) {
2424
// Create strided arrays:
25-
double zx[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 };
26-
double zy[] = { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 };
25+
double x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 };
26+
double y[] = { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 };
2727

2828
// Create a complex scalar:
29-
const stdlib_complex128_t za = stdlib_complex128( 2.0, 2.0 );
29+
const stdlib_complex128_t alpha = stdlib_complex128( 2.0, 2.0 );
3030

3131
// Specify the number of elements:
3232
const int N = 4;
@@ -35,11 +35,19 @@ int main( void ) {
3535
const int strideX = 1;
3636
const int strideY = 1;
3737

38-
// Copy elements:
39-
c_zaxpy( N, za, (void *)zx, strideX, (void *)zy, strideY );
38+
// Scale values from `x` by `alpha` and add the result to `y`:
39+
c_zaxpy( N, alpha, (void *)x, strideX, (void *)y, strideY );
4040

4141
// Print the result:
4242
for ( int i = 0; i < N; i++ ) {
43-
printf( "zaxpy[ %i ] = %f + %fj\n", i, zy[ i * 2 ], zy[ ( i * 2 ) + 1 ] );
43+
printf( "zaxpy[ %i ] = %lf + %lfj\n", i, y[ i * 2 ], y[ ( i * 2 ) + 1 ] );
44+
}
45+
46+
// Scale values from `x` by `alpha` and add the result to `y` using alternative indexing semantics:
47+
c_zaxpy_ndarray( N, alpha, (void *)x, strideX, 0, (void *)y, strideY, 0 );
48+
49+
// Print the result:
50+
for ( int i = 0; i < N; i++ ) {
51+
printf( "zaxpy[ %i ] = %lf + %lfj\n", i, y[ i * 2 ], y[ ( i * 2 ) + 1 ] );
4452
}
4553
}

lib/node_modules/@stdlib/blas/base/zaxpy/examples/index.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,22 @@ function rand() {
3030
return new Complex128( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) );
3131
}
3232

33-
var zx = filledarrayBy( 10, 'complex128', rand );
34-
var zy = filledarrayBy( 10, 'complex128', rand );
35-
var zyc = zcopy( zy.length, zy, 1, zeros( zy.length, 'complex128' ), 1 );
33+
var x = filledarrayBy( 10, 'complex128', rand );
34+
var y = filledarrayBy( 10, 'complex128', rand );
35+
var yc = zcopy( y.length, y, 1, zeros( y.length, 'complex128' ), 1 );
3636

37-
var za = new Complex128( 2.0, 2.0 );
37+
var alpha = new Complex128( 2.0, 2.0 );
3838

39-
// Scale values from `zx` by `za` and add the result to `zy`:
40-
zaxpy( zx.length, za, zx, 1, zy, 1 );
39+
// Scale values from `x` by `alpha` and add the result to `y`:
40+
zaxpy( x.length, alpha, x, 1, y, 1 );
4141

4242
// Print the results:
43-
logEach( '(%s)*(%s) + (%s) = %s', za, zx, zyc, zy );
43+
logEach( '(%s)*(%s) + (%s) = %s', alpha, x, yc, y );
44+
45+
yc = zcopy( y.length, y, 1, zeros( y.length, 'complex128' ), 1 );
46+
47+
// Scale values from `x` by `alpha` and add the result to `y` using alternative indexing semantics:
48+
zaxpy.ndarray( x.length, alpha, x, 1, 0, y, 1, 0 );
49+
50+
// Print the results:
51+
logEach( '(%s)*(%s) + (%s) = %s', alpha, x, yc, y );

0 commit comments

Comments
 (0)