Skip to content

Commit

Permalink
docs: files completed
Browse files Browse the repository at this point in the history
  • Loading branch information
ShabiShett07 committed Feb 11, 2025
1 parent 79a0bcf commit 5cbf955
Show file tree
Hide file tree
Showing 12 changed files with 1,040 additions and 22 deletions.
172 changes: 172 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,172 @@
<!--
@license Apache-2.0
Copyright (c) 2025 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

> Finds the index of the first element having maximum |Re(.)| + |Im(.)|.
<section class="usage">

## Usage

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

#### icamax( N, cx, strideX )

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

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

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

var icx = icamax( cx.length, cx, 1 );
// returns 1
```

The function has the following parameters:

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

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

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

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

var icx = icamax( 2, cx, 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 cx0 = new Complex64Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] );

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

// Find index of element having the maximum absolute value:
var icx = icamax( 2, cx1, 1 );
// returns 1
```

#### icamax.ndarray( N, cx, strideX, offset )

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

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

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

var icx = icamax.ndarray( cx.length, cx, 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 cx = new Complex64Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 ] );

var icx = icamax.ndarray( 3, cx, 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 cx = filledarrayBy( 10, 'complex64', rand );
console.log( cx.toString() );

var icx = icamax( cx.length, cx, 1 );
console.log( icx );
```

</section>

<!-- /.examples -->

<!-- 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://netlib.org/lapack/explore-html/d0/da5/izamax_8f.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 -->
91 changes: 91 additions & 0 deletions lib/node_modules/@stdlib/blas/base/icamax/docs/repl.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@

{{alias}}( N, cx, strideX )
Finds the index of the first element having maximum |Re(.)| + |Im(.)|.

The `N` and `strideX` parameters determine which elements in `cx` are
accessed at runtime.

Indexing is relative to the first index. To introduce an offset, use typed
array views.

If `N < 1`, the function returns `-1`.

Parameters
----------
N: integer
Number of indexed elements.

cx: Complex64Array
Input array.

strideX: integer
Index increment for `cx`.

Returns
-------
icx: integer
Index value.

Examples
--------
// Standard Usage:
> var cx;
> cx = new {{alias:@stdlib/array/complex64}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0 ] );
> var icx = {{alias}}( cx.length, cx, 1 )
1

// Using `N` and `strideX` parameters:
> cx = new {{alias:@stdlib/array/complex64}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0 ] );
> icx = {{alias}}( 2, cx, 2 )
1

// Using view offsets:
> var cx0 = new {{alias:@stdlib/array/complex64}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] );
> var cx1 = new {{alias:@stdlib/array/complex64}}( cx0.buffer, cx0.BYTES_PER_ELEMENT*1 );
> icx = {{alias}}( 2, cx1, 1 )
1


{{alias}}.ndarray( N, cx, strideX, offsetX )
Finds the index of the first element having the maximum absolute value using
alternative indexing semantics.

While typed array views mandate a view offset based on the underlying
buffer, the `offsetX` parameter supports indexing semantics based on a
starting index.

Parameters
----------
N: integer
Number of indexed elements.

cx: Complex64Array
Input array.

strideX: integer
Index increment for `cx`.

offsetX: integer
Starting index of `cx`.

Returns
-------
icx: integer
Index value.

Examples
--------
// Standard Usage:
> var cx;
> cx = new {{alias:@stdlib/array/complex64}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0 ] );
> var icx = {{alias}}.ndarray( cx.length, cx, 1, 0 )
1

// Using an index offset:
> cx = new {{alias:@stdlib/array/complex64}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] );
> icx = {{alias}}.ndarray( 2, cx, 1, 1 )
1

See Also
--------

96 changes: 96 additions & 0 deletions lib/node_modules/@stdlib/blas/base/icamax/docs/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* @license Apache-2.0
*
* Copyright (c) 2025 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.
*/

// TypeScript Version: 4.1

/// <reference types="@stdlib/types"/>

import { Complex64Array } from '@stdlib/types/array';

/**
* Interface describing `icamax`.
*/
interface Routine {
/**
* Finds the index of the first element having maximum |Re(.)| + |Im(.)|.
*
* @param N - number of indexed elements
* @param cx - input array
* @param strideX - stride length for `cx`
* @returns index value
*
* @example
* var Complex64Array = require( '@stdlib/array/complex64' );
*
* var cx = new Complex64Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] );
*
* var icx = icamax( cx.length, cx, 1 );
* // returns 1
*/
( N: number, zx: Complex64Array, strideX: number ): number;

/**
* Finds the index of the first element having maximum |Re(.)| + |Im(.)| using alternative indexing semantics.
*
* @param N - number of indexed elements
* @param cx - input array
* @param strideX - stride length for `zx`
* @param offsetX - starting index for `zx`
* @returns index value
*
* @example
* var Complex64Array = require( '@stdlib/array/complex64' );
*
* var cx = new Complex64Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] );
*
* var icx = icamax.ndarray( cx.length, cx, 1, 0 );
* // returns 1
*/
ndarray( N: number, zx: Complex64Array, strideX: number, offsetX: number ): number;
}

/**
* Finds the index of the first element having maximum |Re(.)| + |Im(.)|
*
* @param N - number of indexed elements
* @param zx - input array
* @param strideX - stride length for `cx`
* @returns index value
*
* @example
* var Complex64Array = require( '@stdlib/array/complex64' );
*
* var cx = new Complex64Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] );
*
* var icx = icamax( cx.length, cx, 1 );
* // returns 1
*
* @example
* var Complex64Array = require( '@stdlib/array/complex64' );
*
* var cx = new Complex64Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] );
*
* var icx = icamax.ndarray( cx.length, cx, 1, 0 );
* // returns 1
*/
declare var icamax: Routine;


// EXPORTS //

export = icamax;
Loading

0 comments on commit 5cbf955

Please sign in to comment.