Skip to content

Commit bcd87ca

Browse files
committed
feat: add blas/ext/base/ccusome
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: missing_dependencies - task: lint_c_benchmarks status: missing_dependencies - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed ---
1 parent e6e7d42 commit bcd87ca

33 files changed

Lines changed: 3831 additions & 0 deletions
Lines changed: 345 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,345 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2026 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+
# ccusome
22+
23+
> Cumulatively test whether at least `k` elements in a single-precision complex floating-point strided array are truthy.
24+
25+
<section class="intro">
26+
27+
</section>
28+
29+
<!-- /.intro -->
30+
31+
<section class="usage">
32+
33+
## Usage
34+
35+
```javascript
36+
var ccusome = require( '@stdlib/blas/ext/base/ccusome' );
37+
```
38+
39+
#### ccusome( N, k, x, strideX, out, strideOut )
40+
41+
Cumulatively tests whether at least `k` elements in a single-precision complex floating-point strided array are truthy.
42+
43+
```javascript
44+
var Complex64Array = require( '@stdlib/array/complex64' );
45+
var BooleanArray = require( '@stdlib/array/bool' );
46+
47+
var x = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0 ] );
48+
var out = new BooleanArray( 4 );
49+
50+
ccusome( x.length, 2, x, 1, out, 1 );
51+
// out => <BooleanArray>[ false, false, false, true ]
52+
```
53+
54+
The function has the following parameters:
55+
56+
- **N**: number of indexed elements.
57+
- **k**: minimum number of truthy elements.
58+
- **x**: input [`Complex64Array`][@stdlib/array/complex64].
59+
- **strideX**: stride length for `x`.
60+
- **out**: output [`BooleanArray`][@stdlib/array/bool].
61+
- **strideOut**: stride length for `out`.
62+
63+
The `N` and stride parameters determine which elements in the strided arrays are accessed at runtime. For example, to cumulatively test every other element:
64+
65+
<!-- eslint-disable max-len -->
66+
67+
```javascript
68+
var Complex64Array = require( '@stdlib/array/complex64' );
69+
var BooleanArray = require( '@stdlib/array/bool' );
70+
71+
var x = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0 ] );
72+
var out = new BooleanArray( 4 );
73+
74+
ccusome( 4, 2, x, 2, out, 1 );
75+
// out => <BooleanArray>[ false, false, false, true ]
76+
```
77+
78+
Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views.
79+
80+
<!-- eslint-disable stdlib/capitalized-comments -->
81+
82+
```javascript
83+
var Complex64Array = require( '@stdlib/array/complex64' );
84+
var BooleanArray = require( '@stdlib/array/bool' );
85+
86+
// Initial arrays...
87+
var x0 = new Complex64Array( [ 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0 ] );
88+
var o0 = new BooleanArray( x0.length );
89+
90+
// Create offset views...
91+
var x1 = new Complex64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
92+
var o1 = new BooleanArray( o0.buffer, o0.BYTES_PER_ELEMENT*2 ); // start at 3rd element
93+
94+
ccusome( 2, 2, x1, 1, o1, 1 );
95+
// o0 => <BooleanArray>[ false, false, false, true ]
96+
```
97+
98+
#### ccusome.ndarray( N, k, x, strideX, offsetX, out, strideOut, offsetOut )
99+
100+
Cumulatively tests whether at least `k` elements in a single-precision complex floating-point strided array are truthy using alternative indexing semantics.
101+
102+
```javascript
103+
var Complex64Array = require( '@stdlib/array/complex64' );
104+
var BooleanArray = require( '@stdlib/array/bool' );
105+
106+
var x = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0 ] );
107+
var out = new BooleanArray( 4 );
108+
109+
ccusome.ndarray( x.length, 2, x, 1, 0, out, 1, 0 );
110+
// out => <BooleanArray>[ false, false, false, true ]
111+
```
112+
113+
The function has the following additional parameters:
114+
115+
- **offsetX**: starting index for `x`.
116+
- **offsetOut**: starting index for `out`.
117+
118+
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, offset parameters support indexing semantics based on starting indices. For example, to cumulatively test every other element starting from the second element:
119+
120+
```javascript
121+
var Complex64Array = require( '@stdlib/array/complex64' );
122+
var BooleanArray = require( '@stdlib/array/bool' );
123+
124+
var x = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0 ] );
125+
var out = new BooleanArray( 2 );
126+
127+
ccusome.ndarray( 2, 2, x, 2, 1, out, 1, 0 );
128+
// out => <BooleanArray>[ false, false ]
129+
```
130+
131+
</section>
132+
133+
<!-- /.usage -->
134+
135+
<section class="notes">
136+
137+
## Notes
138+
139+
- If `N <= 0`, both functions return `out` unchanged.
140+
- Both functions explicitly treat `NaN` values as falsy.
141+
142+
</section>
143+
144+
<!-- /.notes -->
145+
146+
<section class="examples">
147+
148+
## Examples
149+
150+
<!-- eslint no-undef: "error" -->
151+
152+
```javascript
153+
var Complex64Array = require( '@stdlib/array/complex64' );
154+
var bernoulli = require( '@stdlib/random/array/bernoulli' );
155+
var ccusome = require( '@stdlib/blas/ext/base/ccusome' );
156+
var logEach = require( '@stdlib/console/log-each' );
157+
var BooleanArray = require( '@stdlib/array/bool' );
158+
159+
var xbuf = bernoulli( 20, 0.5, {
160+
'dtype': 'float64'
161+
});
162+
var x = new Complex64Array( xbuf.buffer );
163+
logEach( '%s', x );
164+
165+
var out = new BooleanArray( x.length );
166+
ccusome( x.length, 2, x, 1, out, 1 );
167+
logEach( '%s', out );
168+
```
169+
170+
</section>
171+
172+
<!-- /.examples -->
173+
174+
<!-- C interface documentation. -->
175+
176+
* * *
177+
178+
<section class="c">
179+
180+
## C APIs
181+
182+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
183+
184+
<section class="intro">
185+
186+
</section>
187+
188+
<!-- /.intro -->
189+
190+
<!-- C usage documentation. -->
191+
192+
<section class="usage">
193+
194+
### Usage
195+
196+
```c
197+
#include "stdlib/blas/ext/base/ccusome.h"
198+
```
199+
200+
#### stdlib_strided_ccusome( N, k, \*X, strideX, \*Out, strideOut )
201+
202+
Cumulatively tests whether at least `k` elements in a single-precision complex floating-point strided array are truthy.
203+
204+
```c
205+
#include "stdlib/complex/float32/ctor.h"
206+
#include <stdbool.h>
207+
208+
float x[] = { 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f };
209+
bool out[] = { false, false, false, false };
210+
211+
stdlib_strided_ccusome( 4, 2, (const stdlib_complex64_t *)x, 1, out, 1 );
212+
```
213+
214+
The function accepts the following arguments:
215+
216+
- **N**: `[in] CBLAS_INT` number of indexed elements.
217+
- **k**: `[in] CBLAS_INT` minimum number of truthy elements.
218+
- **X**: `[in] stdlib_complex64_t*` input array.
219+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
220+
- **Out**: `[out] bool*` output array.
221+
- **strideOut**: `[in] CBLAS_INT` stride length for `Out`.
222+
223+
```c
224+
void stdlib_strided_ccusome( const CBLAS_INT N, const CBLAS_INT k, const stdlib_complex64_t *X, const CBLAS_INT strideX, bool *Out, const CBLAS_INT strideOut );
225+
```
226+
227+
<!-- lint disable maximum-heading-length -->
228+
229+
#### stdlib_strided_ccusome_ndarray( N, k, \*X, strideX, offsetX, \*Out, strideOut, offsetOut )
230+
231+
<!-- lint enable maximum-heading-length -->
232+
233+
Cumulatively tests whether at least `k` elements in a single-precision complex floating-point strided array are truthy using alternative indexing semantics.
234+
235+
```c
236+
#include "stdlib/complex/float32/ctor.h"
237+
#include <stdbool.h>
238+
239+
float x[] = { 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f };
240+
bool out[] = { false, false, false, false };
241+
242+
stdlib_strided_ccusome_ndarray( 4, 2, (const stdlib_complex64_t *)x, 1, 0, out, 1, 0 );
243+
```
244+
245+
The function accepts the following arguments:
246+
247+
- **N**: `[in] CBLAS_INT` number of indexed elements.
248+
- **k**: `[in] CBLAS_INT` minimum number of truthy elements.
249+
- **X**: `[in] stdlib_complex64_t*` input array.
250+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
251+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
252+
- **Out**: `[out] bool*` output array.
253+
- **strideOut**: `[in] CBLAS_INT` stride length for `Out`.
254+
- **offsetOut**: `[in] CBLAS_INT` starting index for `Out`.
255+
256+
```c
257+
void stdlib_strided_ccusome_ndarray( const CBLAS_INT N, const CBLAS_INT k, const stdlib_complex64_t *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, bool *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut );
258+
```
259+
260+
</section>
261+
262+
<!-- /.usage -->
263+
264+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
265+
266+
<section class="notes">
267+
268+
### Notes
269+
270+
- Both functions explicitly treat `NaN` values as falsy.
271+
272+
</section>
273+
274+
<!-- /.notes -->
275+
276+
<!-- C API usage examples. -->
277+
278+
<section class="examples">
279+
280+
### Examples
281+
282+
```c
283+
#include "stdlib/blas/ext/base/ccusome.h"
284+
#include "stdlib/complex/float32/ctor.h"
285+
#include <stdbool.h>
286+
#include <stdio.h>
287+
288+
int main( void ) {
289+
// Create strided arrays:
290+
const float x[] = { 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f };
291+
bool out[] = { false, false, false, false };
292+
293+
// Specify the number of indexed elements:
294+
const int N = 4;
295+
296+
// Specify the minimum number of truthy elements:
297+
const int k = 2;
298+
299+
// Specify strides:
300+
const int strideX = 1;
301+
const int strideOut = 1;
302+
303+
// Cumulatively test whether at least k elements are truthy:
304+
stdlib_strided_ccusome( N, k, (const stdlib_complex64_t *)x, strideX, out, strideOut );
305+
306+
// Print the results:
307+
for ( int i = 0; i < 4; i++ ) {
308+
printf( "Out[ %i ] = %s\n", i, out[ i ] ? "true" : "false" );
309+
}
310+
}
311+
```
312+
313+
</section>
314+
315+
<!-- /.examples -->
316+
317+
</section>
318+
319+
<!-- /.c -->
320+
321+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
322+
323+
<section class="related">
324+
325+
</section>
326+
327+
<!-- /.related -->
328+
329+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
330+
331+
<section class="links">
332+
333+
[@stdlib/array/complex64]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/complex64
334+
335+
[@stdlib/array/bool]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/bool
336+
337+
[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
338+
339+
<!-- <related-links> -->
340+
341+
<!-- </related-links> -->
342+
343+
</section>
344+
345+
<!-- /.links -->

0 commit comments

Comments
 (0)