Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
79a0bcf
feat: add blas/base/icamax
ShabiShett07 Feb 5, 2025
5cbf955
docs: files completed
ShabiShett07 Feb 11, 2025
f1afdc1
fix: resolve lint errors
stdlib-bot Feb 11, 2025
0b7117d
chore: update copyright years
stdlib-bot Feb 19, 2025
aefb83a
Update package.json
aman-095 Feb 19, 2025
ea43236
Update README.md
aman-095 Feb 19, 2025
ec7efeb
fix: resolved errors
ShabiShett07 Feb 20, 2025
61c28cf
fix: resolved errors
ShabiShett07 Feb 20, 2025
229f39c
Merge remote-tracking branch 'upstream/develop' into feature/icamax
stdlib-bot Apr 22, 2025
a6b105b
chore: update implementation
ShabiShett07 Apr 23, 2025
eb6d0b0
chore: update variable name
ShabiShett07 Apr 23, 2025
117f26e
chore: update implementation
ShabiShett07 Jun 12, 2025
a0e1f2e
chore: update implementation
ShabiShett07 Jun 12, 2025
ff25470
chore: add ndarray example
ShabiShett07 Jun 12, 2025
2486f5f
chore: minor clean-up
ShabiShett07 Jun 12, 2025
aad7629
Merge remote-tracking branch 'upstream/develop' into feature/icamax
stdlib-bot Jun 13, 2025
c218d94
chore: minor clean-up
ShabiShett07 Jun 13, 2025
cfa22e8
chore: minor clean-up
ShabiShett07 Jun 13, 2025
4e71757
chore: minor clean-up
ShabiShett07 Jun 13, 2025
66ef6c5
chore: clean-up
ShabiShett07 Jun 27, 2025
939fff6
chore: clean-up
ShabiShett07 Jun 27, 2025
aed923a
chore: clean-up
ShabiShett07 Jun 27, 2025
9ec9c5c
chore: minor clean-up
ShabiShett07 Jun 27, 2025
54132e0
chore: minor clean-up
ShabiShett07 Jun 27, 2025
9d0ba9e
chore: change y to idx
ShabiShett07 Jul 18, 2025
2e8d355
chore: add appropriate statements
ShabiShett07 Jul 18, 2025
c2fa56c
test: add negative stride
ShabiShett07 Jul 18, 2025
d793db6
docs: update jsdoc
ShabiShett07 Jul 18, 2025
e4f78af
chore: update comment
ShabiShett07 Jul 18, 2025
ce66993
chore: reducing variable
ShabiShett07 Jul 18, 2025
d7fb24e
chore: add appropriate keyword
ShabiShett07 Jul 18, 2025
99d56c1
test: remove duplicate
ShabiShett07 Jul 18, 2025
9f4ecb6
refactor: reduce variable
ShabiShett07 Jul 18, 2025
dcd48eb
chore: add appropriate parameter value
ShabiShett07 Jul 18, 2025
6b8fe35
refactor: avoid re-materializing complex number instances
kgryte Sep 2, 2025
be9ffd8
fix: address parentheses
kgryte Sep 2, 2025
dd74e87
Merge remote-tracking branch 'upstream/develop' into feature/icamax
stdlib-bot Sep 2, 2025
7dff8e1
docs: fix constructor name
kgryte Sep 2, 2025
dc104d2
Merge remote-tracking branch 'upstream/develop' into feature/icamax
stdlib-bot Nov 19, 2025
dafe6c0
feat: adds c and fortran implementation
DhruvArvindSingh Mar 14, 2026
cd11af3
fix: copyright year
DhruvArvindSingh Mar 14, 2026
475e68d
fix: correct documentation comments in blas/base/icamax
DhruvArvindSingh Mar 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
295 changes: 295 additions & 0 deletions lib/node_modules/@stdlib/blas/base/icamax/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,295 @@
<!--

@license Apache-2.0

Copyright (c) 2026 The Stdlib Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->

# icamax

> Find the index of the first element having maximum |Re(.)| + |Im(.)|.

<section class="usage">

## Usage

```javascript
var icamax = require( '@stdlib/blas/base/icamax' );
```

#### icamax( N, x, strideX )

Finds the index of the first element having maximum |Re(.)| + |Im(.)|.

```javascript
var Complex64Array = require( '@stdlib/array/complex64' );

var x = new Complex64Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] );

var idx = icamax( x.length, x, 1 );
// returns 1
```

The function has the following parameters:

- **N**: number of indexed elements.
- **x**: input [`Complex64Array`][@stdlib/array/complex64].
- **strideX**: index increment for `x`.

The `N` and `strideX` parameters determine which elements in `x` are accessed at runtime. For example, to traverse every other value,

```javascript
var Complex64Array = require( '@stdlib/array/complex64' );

var x = new Complex64Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] );

var idx = icamax( 2, x, 2 );
// returns 1
```

Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views.

```javascript
var Complex64Array = require( '@stdlib/array/complex64' );

// Initial array:
var x0 = new Complex64Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] );

// Create an offset view:
var x1 = new Complex64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element

// Find index of element having the maximum |Re(.)| + |Im(.)|:
var idx = icamax( 2, x1, 1 );
// returns 1
```

#### icamax.ndarray( N, x, strideX, offsetX )

Finds the index of the first element having maximum |Re(.)| + |Im(.)| using alternative indexing semantics.

```javascript
var Complex64Array = require( '@stdlib/array/complex64' );

var x = new Complex64Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] );

var idx = icamax.ndarray( x.length, x, 1, 0 );
// returns 1
```

The function has the following additional parameters:

- **offsetX**: starting index.

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,

```javascript
var Complex64Array = require( '@stdlib/array/complex64' );

var x = new Complex64Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 ] );

var idx = icamax.ndarray( 3, x, 1, 1 );
// returns 2
```

</section>

<!-- /.usage -->

<section class="notes">

## Notes

- If `N < 1`, both functions return `-1`.
- `icamax()` corresponds to the [BLAS][blas] level 1 function [`icamax`][icamax].

</section>

<!-- /.notes -->

<section class="examples">

## Examples

<!-- eslint no-undef: "error" -->

```javascript
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
var filledarrayBy = require( '@stdlib/array/filled-by' );
var Complex64 = require( '@stdlib/complex/float32/ctor' );
var icamax = require( '@stdlib/blas/base/icamax' );

function rand() {
return new Complex64( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) );
}

// Generate random input arrays:
var x = filledarrayBy( 10, 'complex64', rand );
console.log( x.toString() );

var idx = icamax( x.length, x, 1 );
console.log( idx );
```

</section>

<!-- /.examples -->

<!-- C interface documentation. -->

* * *

<section class="c">

## C APIs

<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->

<section class="intro">

</section>

<!-- /.intro -->

<!-- C usage documentation. -->

<section class="usage">

### Usage

```c
#include "stdlib/blas/base/icamax.h"
```

#### c_icamax( N, \*X, strideX )

Finds the index of the first element having maximum |Re(.)| + |Im(.)|.

```c
const float x[] = { 4.0f, 2.0f, -3.0f, 5.0f, -1.0f, 2.0f };

CBLAS_INT idx = c_icamax( 3, x, 1 );
// returns 1
```

The function accepts the following arguments:

- **N**: `[in] CBLAS_INT` number of indexed elements.
- **X**: `[in] void*` input array.
- **strideX**: `[in] CBLAS_INT` index increment for `X`.

```c
CBLAS_INT c_icamax( const CBLAS_INT N, const void *X, const CBLAS_INT strideX );
```

#### c_icamax_ndarray( N, \*X, strideX, offsetX )

Finds the index of the first element having maximum |Re(.)| + |Im(.)| using alternative indexing semantics.

```c
const float x[] = { 4.0f, 2.0f, -3.0f, 5.0f, -1.0f, 2.0f };

CBLAS_INT idx = c_icamax_ndarray( 3, x, 1, 0 );
// returns 1
```

The function accepts the following arguments:

- **N**: `[in] CBLAS_INT` number of indexed elements.
- **X**: `[in] void*` input array.
- **strideX**: `[in] CBLAS_INT` index increment for `X`.
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.

```c
CBLAS_INT c_icamax_ndarray( const CBLAS_INT N, const void *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
```

</section>

<!-- /.usage -->

<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="notes">

</section>

<!-- /.notes -->

<!-- C API usage examples. -->

<section class="examples">

### Examples

```c
#include "stdlib/blas/base/icamax.h"
#include <stdio.h>

int main( void ) {
// Create strided array:
const float x[] = { 1.0f, -2.0f, 3.0f, -4.0f, 5.0f, -6.0f, 7.0f, -8.0f };

// Specify the number of elements:
const int N = 4;

// Specify stride:
const int strideX = 1;

// Compute the index of the maximum value:
CBLAS_INT idx = c_icamax( N, x, strideX );

// Print the result:
printf( "index value: %d\n", idx );

// Compute the index of the maximum value:
idx = c_icamax_ndarray( N, x, -strideX, N-1 );

// Print the result:
printf( "index value: %d\n", idx );
}
```

</section>

<!-- /.examples -->

</section>

<!-- /.c -->

<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->

<section class="related">

</section>

<!-- /.related -->

<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="links">

[blas]: http://www.netlib.org/blas

[icamax]: https://www.netlib.org/lapack/explore-html/dd/d52/group__iamax_gafdf273dcc3f020e2aa5c716c1b3d7265.html

[@stdlib/array/complex64]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/complex64

[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray

</section>

<!-- /.links -->
Loading
Loading