Skip to content

Commit b114091

Browse files
committed
fix: clean up incomplete implementation of zlacgv
1 parent c17c673 commit b114091

File tree

10 files changed

+89
-169
lines changed

10 files changed

+89
-169
lines changed

lib/node_modules/@stdlib/lapack/base/zlacgv/docs/types/index.d.ts

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { Complex128Array } from '@stdlib/types/array';
2727
*/
2828
interface Routine {
2929
/**
30-
* Scales a double-precision complex floating-point vector by a double-precision complex floating-point constant.
30+
* Conjugates a double-precision complex floating-point vector.
3131
*
3232
* @param N - number of indexed elements
3333
* @param zx - input array
@@ -36,7 +36,6 @@ interface Routine {
3636
*
3737
* @example
3838
* var Complex128Array = require( '@stdlib/array/complex128' );
39-
* var Complex128 = require( '@stdlib/complex/float64/ctor' );
4039
* var real = require( '@stdlib/complex/float64/real' );
4140
* var imag = require( '@stdlib/complex/float64/imag' );
4241
*
@@ -48,15 +47,15 @@ interface Routine {
4847
* // returns <Complex128>
4948
*
5049
* var re = real( z );
51-
* // returns -2.0
50+
* // returns 1.0
5251
*
5352
* var im = imag( z );
54-
* // returns 6.0
53+
* // returns -2.0
5554
*/
5655
( N: number, zx: Complex128Array, strideX: number ): Complex128Array;
5756

5857
/**
59-
* Scales a double-precision complex floating-point vector by a double-precision complex floating-point constant.
58+
* Conjugates a double-precision complex floating-point vector.
6059
*
6160
* @param N - number of indexed elements
6261
* @param zx - input array
@@ -66,7 +65,6 @@ interface Routine {
6665
*
6766
* @example
6867
* var Complex128Array = require( '@stdlib/array/complex128' );
69-
* var Complex128 = require( '@stdlib/complex/float64/ctor' );
7068
* var real = require( '@stdlib/complex/float64/real' );
7169
* var imag = require( '@stdlib/complex/float64/imag' );
7270
*
@@ -78,16 +76,16 @@ interface Routine {
7876
* // returns <Complex128>
7977
*
8078
* var re = real( z );
81-
* // returns -2.0
79+
* // returns 1.0
8280
*
8381
* var im = imag( z );
84-
* // returns 6.0
82+
* // returns -2.0
8583
*/
8684
ndarray( N: number, zx: Complex128Array, strideX: number, offsetX: number ): Complex128Array;
8785
}
8886

8987
/**
90-
* Scales a double-precision complex floating-point vector by a double-precision complex floating-point constant.
88+
* Conjugates a double-precision complex floating-point vector.
9189
*
9290
* @param N - number of indexed elements
9391
* @param zx - input array
@@ -96,7 +94,6 @@ interface Routine {
9694
*
9795
* @example
9896
* var Complex128Array = require( '@stdlib/array/complex128' );
99-
* var Complex128 = require( '@stdlib/complex/float64/ctor' );
10097
* var real = require( '@stdlib/complex/float64/real' );
10198
* var imag = require( '@stdlib/complex/float64/imag' );
10299
*
@@ -108,14 +105,13 @@ interface Routine {
108105
* // returns <Complex128>
109106
*
110107
* var re = real( z );
111-
* // returns -2.0
108+
* // returns 3.0
112109
*
113110
* var im = imag( z );
114-
* // returns 14.0
111+
* // returns -4.0
115112
*
116113
* @example
117114
* var Complex128Array = require( '@stdlib/array/complex128' );
118-
* var Complex128 = require( '@stdlib/complex/float64/ctor' );
119115
* var real = require( '@stdlib/complex/float64/real' );
120116
* var imag = require( '@stdlib/complex/float64/imag' );
121117
*
@@ -127,10 +123,10 @@ interface Routine {
127123
* // returns <Complex128>
128124
*
129125
* var re = real( z );
130-
* // returns -2.0
126+
* // returns 3.0
131127
*
132128
* var im = imag( z );
133-
* // returns 14.0
129+
* // returns -4.0
134130
*/
135131
declare var zlacgv: Routine;
136132

lib/node_modules/@stdlib/lapack/base/zlacgv/docs/types/test.ts

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,7 @@ import zlacgv = require( './index' );
4343
zlacgv( ( zx: number ): number => zx, zx, 1 ); // $ExpectError
4444
}
4545

46-
// The compiler throws an error if the function is provided a second argument which is not a complex number...
47-
{
48-
const zx = new Complex128Array( 10 );
49-
50-
zlacgv( zx.length, 10, zx, 1 ); // $ExpectError
51-
zlacgv( zx.length, '10', zx, 1 ); // $ExpectError
52-
zlacgv( zx.length, true, zx, 1 ); // $ExpectError
53-
zlacgv( zx.length, false, zx, 1 ); // $ExpectError
54-
zlacgv( zx.length, null, zx, 1 ); // $ExpectError
55-
zlacgv( zx.length, undefined, zx, 1 ); // $ExpectError
56-
zlacgv( zx.length, [ '1' ], zx, 1 ); // $ExpectError
57-
zlacgv( zx.length, {}, zx, 1 ); // $ExpectError
58-
zlacgv( zx.length, ( zx: number ): number => zx, zx, 1 ); // $ExpectError
59-
}
60-
61-
// The compiler throws an error if the function is provided a third argument which is not a Complex128Array...
46+
// The compiler throws an error if the function is provided a second argument which is not a Complex128Array...
6247
{
6348
const zx = new Complex128Array( 10 );
6449

@@ -73,7 +58,7 @@ import zlacgv = require( './index' );
7358
zlacgv( zx.length, ( zx: number ): number => zx, 1 ); // $ExpectError
7459
}
7560

76-
// The compiler throws an error if the function is provided a fourth argument which is not a number...
61+
// The compiler throws an error if the function is provided a third argument which is not a number...
7762
{
7863
const zx = new Complex128Array( 10 );
7964

@@ -93,7 +78,6 @@ import zlacgv = require( './index' );
9378

9479
zlacgv(); // $ExpectError
9580
zlacgv( zx.length ); // $ExpectError
96-
zlacgv( zx.length ); // $ExpectError
9781
zlacgv( zx.length, zx ); // $ExpectError
9882
zlacgv( zx.length, zx, 1, 10 ); // $ExpectError
9983
}
@@ -119,22 +103,7 @@ import zlacgv = require( './index' );
119103
zlacgv.ndarray( ( zx: number ): number => zx, zx, 1, 0 ); // $ExpectError
120104
}
121105

122-
// The compiler throws an error if the `ndarray` method is provided a second argument which is not a complex number...
123-
{
124-
const zx = new Complex128Array( 10 );
125-
126-
zlacgv.ndarray( zx.length, 10, zx, 1, 0 ); // $ExpectError
127-
zlacgv.ndarray( zx.length, '10', zx, 1, 0 ); // $ExpectError
128-
zlacgv.ndarray( zx.length, true, zx, 1, 0 ); // $ExpectError
129-
zlacgv.ndarray( zx.length, false, zx, 1, 0 ); // $ExpectError
130-
zlacgv.ndarray( zx.length, null, zx, 1, 0 ); // $ExpectError
131-
zlacgv.ndarray( zx.length, undefined, zx, 1, 0 ); // $ExpectError
132-
zlacgv.ndarray( zx.length, [ '1' ], zx, 1, 0 ); // $ExpectError
133-
zlacgv.ndarray( zx.length, {}, zx, 1, 0 ); // $ExpectError
134-
zlacgv.ndarray( zx.length, ( zx: number ): number => zx, zx, 1, 0 ); // $ExpectError
135-
}
136-
137-
// The compiler throws an error if the `ndarray` method is provided a third argument which is not a Complex128Array...
106+
// The compiler throws an error if the `ndarray` method is provided a second argument which is not a Complex128Array...
138107
{
139108
const zx = new Complex128Array( 10 );
140109

@@ -149,7 +118,7 @@ import zlacgv = require( './index' );
149118
zlacgv( zx.length, ( zx: number ): number => zx, 1, 0 ); // $ExpectError
150119
}
151120

152-
// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number...
121+
// The compiler throws an error if the `ndarray` method is provided a third argument which is not a number...
153122
{
154123
const zx = new Complex128Array( 10 );
155124

@@ -163,7 +132,7 @@ import zlacgv = require( './index' );
163132
zlacgv.ndarray( zx.length, zx, ( zx: number ): number => zx, 0 ); // $ExpectError
164133
}
165134

166-
// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number...
135+
// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number...
167136
{
168137
const zx = new Complex128Array( 10 );
169138

@@ -183,7 +152,6 @@ import zlacgv = require( './index' );
183152

184153
zlacgv.ndarray(); // $ExpectError
185154
zlacgv.ndarray( zx.length ); // $ExpectError
186-
zlacgv.ndarray( zx.length ); // $ExpectError
187155
zlacgv.ndarray( zx.length, zx ); // $ExpectError
188156
zlacgv.ndarray( zx.length, zx, 1 ); // $ExpectError
189157
zlacgv.ndarray( zx.length, zx, 1, 0, 10 ); // $ExpectError

lib/node_modules/@stdlib/lapack/base/zlacgv/examples/c/example.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ int main( void ) {
3030
// Specify stride length:
3131
const int strideX = 1;
3232

33-
// Scale the elements of the array:
33+
// Conjugate the elements of the array:
3434
c_zlacgv( N, (void *)zx, strideX );
3535

3636
// Print the result:

lib/node_modules/@stdlib/lapack/base/zlacgv/include/stdlib/blas/base/zlacgv_fortran.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ extern "C" {
3232
#endif
3333

3434
/**
35-
* Scales a double-precision complex floating-point vector by a double-precision complex floating-point constant.
35+
* Conjugates a double-precision complex floating-point vector.
3636
*/
37-
void zlacgv( const int *, const stdlib_complex128_t *, void *, const int * );
37+
void zlacgv( const int *, void *, const int * );
3838

3939
#ifdef __cplusplus
4040
}

lib/node_modules/@stdlib/lapack/base/zlacgv/lib/ndarray.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,20 @@ function zlacgv( N, zx, strideX, offsetX ) {
6161
if ( N <= 0 || strideX <= 0 ) {
6262
return zx;
6363
}
64+
65+
// Interpret the complex input array as a float64 array
6466
zx64 = reinterpret( zx, 0 );
67+
68+
// Compute a stride and an index to be incremented
6569
sx = strideX*2;
6670
ix = (offsetX*2) + 1;
71+
72+
// Conjugate the complex elements
6773
for ( i = 0; i < N; i++ ) {
6874
zx64[ ix ] = -zx64[ ix ];
6975
ix += sx;
7076
}
77+
7178
return zx;
7279
}
7380

lib/node_modules/@stdlib/lapack/base/zlacgv/lib/zlacgv.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ function zlacgv( N, zx, strideX ) {
5858
var ix;
5959
var i;
6060

61+
// Interpret the complex vector as a float64 array
6162
zx64 = reinterpret( zx, 0 );
6263

6364
if ( N <= 0 || strideX <= 0 ) {
@@ -66,19 +67,23 @@ function zlacgv( N, zx, strideX ) {
6667
if ( strideX === 1 ) {
6768
N2 = N * 2;
6869

69-
// Code for stride equal to `1`...
70+
// Code for stride equal to `1`
7071
for ( i = 1; i <= N2; i+=2 ) {
7172
zx64[ i ] = -zx64[ i ];
7273
}
7374
return zx;
7475
}
75-
// Code for stride not equal to `1`...
76+
77+
// Compute a stride and an index to be incremented
7678
sx = strideX * 2;
7779
ix = 1;
80+
81+
// Conjugate the complex elements for stride not equal to 1
7882
for ( i = 0; i < N; i++ ) {
7983
zx64[ ix ] = -zx64[ ix ];
8084
ix += sx;
8185
}
86+
8287
return zx;
8388
}
8489

lib/node_modules/@stdlib/lapack/base/zlacgv/src/addon.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
* @return Node-API value
3333
*/
3434
static napi_value addon( napi_env env, napi_callback_info info ) {
35-
STDLIB_NAPI_ARGV( env, info, argv, argc, 4 );
35+
STDLIB_NAPI_ARGV( env, info, argv, argc, 3 );
3636
STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 );
37-
STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 );
38-
STDLIB_NAPI_ARGV_STRIDED_COMPLEX128ARRAY( env, ZX, N, strideX, argv, 2 );
37+
STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 );
38+
STDLIB_NAPI_ARGV_STRIDED_COMPLEX128ARRAY( env, ZX, N, strideX, argv, 1 );
3939
c_zlacgv( N, (void *)ZX, strideX );
4040
return NULL;
4141
}

lib/node_modules/@stdlib/lapack/base/zlacgv/src/zlacgv.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,18 @@
3030
* @param strideX ZX stride length
3131
*/
3232
void API_SUFFIX(c_zlacgv)( const CBLAS_INT N, void *ZX, const CBLAS_INT strideX ) {
33-
stdlib_complex128_t z;
33+
stdlib_complex128_t* zp;
3434
CBLAS_INT i;
3535

3636
uint8_t *ip1 = (uint8_t *)ZX;
37-
int64_t is1 = 16 * strideX;
37+
int64_t is1 = (int64_t)(16 * strideX);
3838

3939
if ( N <= 0 || strideX <= 0 ) {
4040
return;
4141
}
4242
for ( i = 0; i < N; i++, ip1 += is1 ) {
43-
z = *(stdlib_complex128_t *)ip1;
44-
*(stdlib_complex128_t *)ip1 = stdlib_base_complex128_conj( z );
43+
zp = (stdlib_complex128_t *)ip1;
44+
zp->im = -zp->im;
4545
}
4646
return;
4747
}

lib/node_modules/@stdlib/lapack/base/zlacgv/test/test.ndarray.native.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@ tape( 'if provided an `strideX` parameter less than or equal to `0`, the functio
234234

235235
tape( 'the function supports complex access patterns', opts, function test( t ) {
236236
var expected;
237-
var za;
238237
var zx;
239238

240239
zx = new Complex128Array([
@@ -254,7 +253,7 @@ tape( 'the function supports complex access patterns', opts, function test( t )
254253
3.0 // 2
255254
]);
256255

257-
zlacgv( 2, za, zx, 3, 3 );
256+
zlacgv( 2, zx, 3, 3 );
258257

259258
expected = new Complex128Array([
260259
0.1,

0 commit comments

Comments
 (0)