Skip to content

Commit 5cbf955

Browse files
committed
docs: files completed
1 parent 79a0bcf commit 5cbf955

File tree

12 files changed

+1040
-22
lines changed

12 files changed

+1040
-22
lines changed
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
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+
# icamax
22+
23+
> Finds the index of the first element having maximum |Re(.)| + |Im(.)|.
24+
25+
<section class="usage">
26+
27+
## Usage
28+
29+
```javascript
30+
var icamax = require( '@stdlib/blas/base/icamax' );
31+
```
32+
33+
#### icamax( N, cx, strideX )
34+
35+
Finds the index of the first element having maximum |Re(.)| + |Im(.)|.
36+
37+
```javascript
38+
var Complex64Array = require( '@stdlib/array/complex64' );
39+
40+
var cx = new Complex64Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] );
41+
42+
var icx = icamax( cx.length, cx, 1 );
43+
// returns 1
44+
```
45+
46+
The function has the following parameters:
47+
48+
- **N**: number of indexed elements.
49+
- **cx**: input [`Complex64Array`][@stdlib/array/complex64].
50+
- **strideX**: index increment for `cx`.
51+
52+
The `N` and `strideX` parameters determine which elements in `cx` are accessed at runtime. For example, to traverse every other value,
53+
54+
```javascript
55+
var Complex64Array = require( '@stdlib/array/complex64' );
56+
57+
var cx = new Complex64Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] );
58+
59+
var icx = icamax( 2, cx, 2 );
60+
// returns 1
61+
```
62+
63+
Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views.
64+
65+
```javascript
66+
var Complex64Array = require( '@stdlib/array/complex64' );
67+
68+
// Initial array:
69+
var cx0 = new Complex64Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] );
70+
71+
// Create an offset view:
72+
var cx1 = new Complex64Array( cx0.buffer, cx0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
73+
74+
// Find index of element having the maximum absolute value:
75+
var icx = icamax( 2, cx1, 1 );
76+
// returns 1
77+
```
78+
79+
#### icamax.ndarray( N, cx, strideX, offset )
80+
81+
Finds the index of the first element having maximum |Re(.)| + |Im(.)| using alternative indexing semantics.
82+
83+
```javascript
84+
var Complex64Array = require( '@stdlib/array/complex64' );
85+
86+
var cx = new Complex64Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] );
87+
88+
var icx = icamax.ndarray( cx.length, cx, 1, 0 );
89+
// returns 1
90+
```
91+
92+
The function has the following additional parameters:
93+
94+
- **offsetX**: starting index.
95+
96+
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 start from the second index,
97+
98+
```javascript
99+
var Complex64Array = require( '@stdlib/array/complex64' );
100+
101+
var cx = new Complex64Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 ] );
102+
103+
var icx = icamax.ndarray( 3, cx, 1, 1 );
104+
// returns 2
105+
```
106+
107+
</section>
108+
109+
<!-- /.usage -->
110+
111+
<section class="notes">
112+
113+
## Notes
114+
115+
- If `N < 1`, both functions return `-1`.
116+
- `icamax()` corresponds to the [BLAS][blas] level 1 function [`icamax`][icamax].
117+
118+
</section>
119+
120+
<!-- /.notes -->
121+
122+
<section class="examples">
123+
124+
## Examples
125+
126+
<!-- eslint no-undef: "error" -->
127+
128+
```javascript
129+
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
130+
var filledarrayBy = require( '@stdlib/array/filled-by' );
131+
var complex64 = require( '@stdlib/complex/float32/ctor' );
132+
var icamax = require( '@stdlib/blas/base/icamax' );
133+
134+
function rand() {
135+
return new complex64( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) );
136+
}
137+
138+
// Generate random input arrays:
139+
var cx = filledarrayBy( 10, 'complex64', rand );
140+
console.log( cx.toString() );
141+
142+
var icx = icamax( cx.length, cx, 1 );
143+
console.log( icx );
144+
```
145+
146+
</section>
147+
148+
<!-- /.examples -->
149+
150+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
151+
152+
<section class="related">
153+
154+
</section>
155+
156+
<!-- /.related -->
157+
158+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
159+
160+
<section class="links">
161+
162+
[blas]: http://www.netlib.org/blas
163+
164+
[icamax]: https://netlib.org/lapack/explore-html/d0/da5/izamax_8f.html
165+
166+
[@stdlib/array/complex64]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/complex64
167+
168+
[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
169+
170+
</section>
171+
172+
<!-- /.links -->
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
2+
{{alias}}( N, cx, strideX )
3+
Finds the index of the first element having maximum |Re(.)| + |Im(.)|.
4+
5+
The `N` and `strideX` parameters determine which elements in `cx` are
6+
accessed at runtime.
7+
8+
Indexing is relative to the first index. To introduce an offset, use typed
9+
array views.
10+
11+
If `N < 1`, the function returns `-1`.
12+
13+
Parameters
14+
----------
15+
N: integer
16+
Number of indexed elements.
17+
18+
cx: Complex64Array
19+
Input array.
20+
21+
strideX: integer
22+
Index increment for `cx`.
23+
24+
Returns
25+
-------
26+
icx: integer
27+
Index value.
28+
29+
Examples
30+
--------
31+
// Standard Usage:
32+
> var cx;
33+
> cx = new {{alias:@stdlib/array/complex64}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0 ] );
34+
> var icx = {{alias}}( cx.length, cx, 1 )
35+
1
36+
37+
// Using `N` and `strideX` parameters:
38+
> cx = new {{alias:@stdlib/array/complex64}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0 ] );
39+
> icx = {{alias}}( 2, cx, 2 )
40+
1
41+
42+
// Using view offsets:
43+
> var cx0 = new {{alias:@stdlib/array/complex64}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] );
44+
> var cx1 = new {{alias:@stdlib/array/complex64}}( cx0.buffer, cx0.BYTES_PER_ELEMENT*1 );
45+
> icx = {{alias}}( 2, cx1, 1 )
46+
1
47+
48+
49+
{{alias}}.ndarray( N, cx, strideX, offsetX )
50+
Finds the index of the first element having the maximum absolute value using
51+
alternative indexing semantics.
52+
53+
While typed array views mandate a view offset based on the underlying
54+
buffer, the `offsetX` parameter supports indexing semantics based on a
55+
starting index.
56+
57+
Parameters
58+
----------
59+
N: integer
60+
Number of indexed elements.
61+
62+
cx: Complex64Array
63+
Input array.
64+
65+
strideX: integer
66+
Index increment for `cx`.
67+
68+
offsetX: integer
69+
Starting index of `cx`.
70+
71+
Returns
72+
-------
73+
icx: integer
74+
Index value.
75+
76+
Examples
77+
--------
78+
// Standard Usage:
79+
> var cx;
80+
> cx = new {{alias:@stdlib/array/complex64}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0 ] );
81+
> var icx = {{alias}}.ndarray( cx.length, cx, 1, 0 )
82+
1
83+
84+
// Using an index offset:
85+
> cx = new {{alias:@stdlib/array/complex64}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] );
86+
> icx = {{alias}}.ndarray( 2, cx, 1, 1 )
87+
1
88+
89+
See Also
90+
--------
91+
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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+
// TypeScript Version: 4.1
20+
21+
/// <reference types="@stdlib/types"/>
22+
23+
import { Complex64Array } from '@stdlib/types/array';
24+
25+
/**
26+
* Interface describing `icamax`.
27+
*/
28+
interface Routine {
29+
/**
30+
* Finds the index of the first element having maximum |Re(.)| + |Im(.)|.
31+
*
32+
* @param N - number of indexed elements
33+
* @param cx - input array
34+
* @param strideX - stride length for `cx`
35+
* @returns index value
36+
*
37+
* @example
38+
* var Complex64Array = require( '@stdlib/array/complex64' );
39+
*
40+
* var cx = new Complex64Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] );
41+
*
42+
* var icx = icamax( cx.length, cx, 1 );
43+
* // returns 1
44+
*/
45+
( N: number, zx: Complex64Array, strideX: number ): number;
46+
47+
/**
48+
* Finds the index of the first element having maximum |Re(.)| + |Im(.)| using alternative indexing semantics.
49+
*
50+
* @param N - number of indexed elements
51+
* @param cx - input array
52+
* @param strideX - stride length for `zx`
53+
* @param offsetX - starting index for `zx`
54+
* @returns index value
55+
*
56+
* @example
57+
* var Complex64Array = require( '@stdlib/array/complex64' );
58+
*
59+
* var cx = new Complex64Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] );
60+
*
61+
* var icx = icamax.ndarray( cx.length, cx, 1, 0 );
62+
* // returns 1
63+
*/
64+
ndarray( N: number, zx: Complex64Array, strideX: number, offsetX: number ): number;
65+
}
66+
67+
/**
68+
* Finds the index of the first element having maximum |Re(.)| + |Im(.)|
69+
*
70+
* @param N - number of indexed elements
71+
* @param zx - input array
72+
* @param strideX - stride length for `cx`
73+
* @returns index value
74+
*
75+
* @example
76+
* var Complex64Array = require( '@stdlib/array/complex64' );
77+
*
78+
* var cx = new Complex64Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] );
79+
*
80+
* var icx = icamax( cx.length, cx, 1 );
81+
* // returns 1
82+
*
83+
* @example
84+
* var Complex64Array = require( '@stdlib/array/complex64' );
85+
*
86+
* var cx = new Complex64Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] );
87+
*
88+
* var icx = icamax.ndarray( cx.length, cx, 1, 0 );
89+
* // returns 1
90+
*/
91+
declare var icamax: Routine;
92+
93+
94+
// EXPORTS //
95+
96+
export = icamax;

0 commit comments

Comments
 (0)