Skip to content

Commit 43d693e

Browse files
authored
Merge branch 'develop' into migrate-dcumaxabs-3
Signed-off-by: Athan <kgryte@gmail.com>
2 parents 3bb92d5 + 1fa197d commit 43d693e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+11261
-62
lines changed

.github/workflows/good_first_issue.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
GH_REPO: ${{ github.repository }}
5757
NUMBER: ${{ github.event.issue.number }}
5858
BODY: |
59-
# :rotating_light: Important: PLEASE READ :rotating_light:
59+
# :wave: Important: PLEASE READ :wave:
6060
6161
This issue has been labeled as a **good first issue** and is available for anyone to work on.
6262

.mailmap

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# A
1010

1111
Aayush Khanna <aayushiitbhu23@gmail.com> <96649223+aayush0325@users.noreply.github.com>
12+
Aayush Khanna <aayushiitbhu23@gmail.com> <ayush25khanna@gmail.com>
1213
Aayush Khanna <aayushiitbhu23@gmail.com> aayush0325
1314

1415
Abhijit Raut <abhijitmraut8010@gmail.com> <121740684+AbhijitRaut04@users.noreply.github.com>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2025 The Stdlib Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
21+
# clacgv
22+
23+
> Conjugate each element in a single-precision complex floating-point vector.
24+
25+
<section class="usage">
26+
27+
## Usage
28+
29+
```javascript
30+
var clacgv = require( '@stdlib/lapack/base/clacgv' );
31+
```
32+
33+
#### clacgv( N, cx, strideCX )
34+
35+
Conjugates each element in a single-precision complex floating-point vector.
36+
37+
```javascript
38+
var Complex64Array = require( '@stdlib/array/complex64' );
39+
var realf = require( '@stdlib/complex/float32/real' );
40+
var imagf = require( '@stdlib/complex/float32/imag' );
41+
42+
var cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
43+
44+
clacgv( 2, cx, 1 );
45+
46+
var z = cx.get( 0 );
47+
// returns <Complex64>
48+
49+
var re = realf( z );
50+
// returns 1.0
51+
52+
var im = imagf( z );
53+
// returns -2.0
54+
```
55+
56+
The function has the following parameters:
57+
58+
- **N**: number of indexed elements.
59+
- **cx**: input [`Complex64Array`][@stdlib/array/complex64].
60+
- **strideCX**: stride length for `cx`.
61+
62+
The `N` and stride parameters determine which elements in `cx` are conjugated. For example, to conjugate every other element in `cx`,
63+
64+
```javascript
65+
var Complex64Array = require( '@stdlib/array/complex64' );
66+
var realf = require( '@stdlib/complex/float32/real' );
67+
var imagf = require( '@stdlib/complex/float32/imag' );
68+
69+
var cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
70+
71+
clacgv( 2, cx, 2 );
72+
73+
var z = cx.get( 0 );
74+
// returns <Complex64>
75+
76+
var re = realf( z );
77+
// returns 1.0
78+
79+
var im = imagf( z );
80+
// returns -2.0
81+
```
82+
83+
Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views.
84+
85+
<!-- eslint-disable stdlib/capitalized-comments -->
86+
87+
```javascript
88+
var Complex64Array = require( '@stdlib/array/complex64' );
89+
var Complex64 = require( '@stdlib/complex/float32/ctor' );
90+
var realf = require( '@stdlib/complex/float32/real' );
91+
var imagf = require( '@stdlib/complex/float32/imag' );
92+
93+
// Initial array:
94+
var cx0 = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
95+
96+
// Create an offset view:
97+
var cx1 = new Complex64Array( cx0.buffer, cx0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
98+
99+
// Conjugate every element in `cx1`:
100+
clacgv( 3, cx1, 1 );
101+
102+
var z = cx0.get( 1 );
103+
// returns <Complex64>
104+
105+
var re = realf( z );
106+
// returns 3.0
107+
108+
var im = imagf( z );
109+
// returns -4.0
110+
```
111+
112+
#### clacgv.ndarray( N, cx, strideCX, offsetCX )
113+
114+
Conjugates each element in a single-precision floating-point vector using alternative indexing semantics.
115+
116+
```javascript
117+
var Complex64Array = require( '@stdlib/array/complex64' );
118+
var realf = require( '@stdlib/complex/float32/real' );
119+
var imagf = require( '@stdlib/complex/float32/imag' );
120+
121+
var cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
122+
123+
clacgv.ndarray( 3, cx, 1, 0 );
124+
125+
var z = cx.get( 0 );
126+
// returns <Complex64>
127+
128+
var re = realf( z );
129+
// returns 1.0
130+
131+
var im = imagf( z );
132+
// returns -2.0
133+
```
134+
135+
The function has the following additional parameters:
136+
137+
- **offsetCX**: starting index for `cx`.
138+
139+
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to conjugate every other element in the input strided array starting from the second element,
140+
141+
```javascript
142+
var Complex64Array = require( '@stdlib/array/complex64' );
143+
var realf = require( '@stdlib/complex/float32/real' );
144+
var imagf = require( '@stdlib/complex/float32/imag' );
145+
146+
var cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
147+
148+
clacgv.ndarray( 2, cx, 2, 1 );
149+
150+
var z = cx.get( 3 );
151+
// returns <Complex64>
152+
153+
var re = realf( z );
154+
// returns 7.0
155+
156+
var im = imagf( z );
157+
// returns -8.0
158+
```
159+
160+
</section>
161+
162+
<!-- /.usage -->
163+
164+
<section class="notes">
165+
166+
## Notes
167+
168+
- If `N <= 0`, both functions return `cx` unchanged.
169+
- `clacgv()` corresponds to the [LAPACK][lapack] BLAS-like level 1 routine [`clacgv`][clacgv].
170+
171+
</section>
172+
173+
<!-- /.notes -->
174+
175+
<section class="examples">
176+
177+
## Examples
178+
179+
<!-- eslint no-undef: "error" -->
180+
181+
```javascript
182+
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
183+
var filledarrayBy = require( '@stdlib/array/filled-by' );
184+
var Complex64 = require( '@stdlib/complex/float32/ctor' );
185+
var clacgv = require( '@stdlib/lapack/base/clacgv' );
186+
187+
function rand() {
188+
return new Complex64( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) );
189+
}
190+
191+
var cx = filledarrayBy( 10, 'complex64', rand );
192+
console.log( cx.toString() );
193+
194+
// Conjugate elements:
195+
clacgv( cx.length, cx, 1 );
196+
console.log( cx.get( cx.length-1 ).toString() );
197+
```
198+
199+
</section>
200+
201+
<!-- /.examples -->
202+
203+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
204+
205+
<section class="related">
206+
207+
</section>
208+
209+
<!-- /.related -->
210+
211+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
212+
213+
<section class="links">
214+
215+
[lapack]: https://www.netlib.org/lapack
216+
217+
[clacgv]: https://www.netlib.org/lapack/explore-html/d9/d50/group__lacgv_ga689d8db6749fa9b193ff8520bfd6b2e9.html#ga689d8db6749fa9b193ff8520bfd6b2e9
218+
219+
[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
220+
221+
[@stdlib/array/complex64]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/complex64
222+
223+
</section>
224+
225+
<!-- /.links -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var uniform = require( '@stdlib/random/array/uniform' );
25+
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
26+
var pow = require( '@stdlib/math/base/special/pow' );
27+
var Complex64Array = require( '@stdlib/array/complex64' );
28+
var pkg = require( './../package.json' ).name;
29+
var clacgv = require( './../lib/clacgv.js' );
30+
31+
32+
// VARIABLES //
33+
34+
var options = {
35+
'dtype': 'float32'
36+
};
37+
38+
39+
// FUNCTIONS //
40+
41+
/**
42+
* Creates a benchmark function.
43+
*
44+
* @private
45+
* @param {PositiveInteger} len - array length
46+
* @returns {Function} benchmark function
47+
*/
48+
function createBenchmark( len ) {
49+
var cxbuf;
50+
var cx;
51+
52+
cxbuf = uniform( len*2, -100.0, 100.0, options );
53+
cx = new Complex64Array( cxbuf.buffer );
54+
55+
return benchmark;
56+
57+
/**
58+
* Benchmark function.
59+
*
60+
* @private
61+
* @param {Benchmark} b - benchmark instance
62+
*/
63+
function benchmark( b ) {
64+
var i;
65+
66+
b.tic();
67+
for ( i = 0; i < b.iterations; i++ ) {
68+
clacgv( cx.length, cx, 1 );
69+
if ( isnanf( cxbuf[ i%(len*2) ] ) ) {
70+
b.fail( 'should not return NaN' );
71+
}
72+
}
73+
b.toc();
74+
if ( isnanf( cxbuf[ i%(len*2) ] ) ) {
75+
b.fail( 'should not return NaN' );
76+
}
77+
b.pass( 'benchmark finished' );
78+
b.end();
79+
}
80+
}
81+
82+
83+
// MAIN //
84+
85+
/**
86+
* Main execution sequence.
87+
*
88+
* @private
89+
*/
90+
function main() {
91+
var len;
92+
var min;
93+
var max;
94+
var f;
95+
var i;
96+
97+
min = 1; // 10^min
98+
max = 6; // 10^max
99+
100+
for ( i = min; i <= max; i++ ) {
101+
len = pow( 10, i );
102+
f = createBenchmark( len );
103+
bench( pkg+':len='+len, f );
104+
}
105+
}
106+
107+
main();

0 commit comments

Comments
 (0)