| 
 | 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 | +# izamax  | 
 | 22 | + | 
 | 23 | +> Find the index of the first element having the maximum absolute value.  | 
 | 24 | +
  | 
 | 25 | +<section class="usage">  | 
 | 26 | + | 
 | 27 | +## Usage  | 
 | 28 | + | 
 | 29 | +```javascript  | 
 | 30 | +var izamax = require( '@stdlib/blas/base/izamax' );  | 
 | 31 | +```  | 
 | 32 | + | 
 | 33 | +#### izamax( N, zx, strideX )  | 
 | 34 | + | 
 | 35 | +Finds the index of the first element having the maximum absolute value.  | 
 | 36 | + | 
 | 37 | +```javascript  | 
 | 38 | +var Complex128Array = require( '@stdlib/array/complex128' );  | 
 | 39 | + | 
 | 40 | +var zx = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] );  | 
 | 41 | + | 
 | 42 | +var idx = izamax( zx.length, zx, 1 );  | 
 | 43 | +// returns 1  | 
 | 44 | +```  | 
 | 45 | + | 
 | 46 | +The function has the following parameters:  | 
 | 47 | + | 
 | 48 | +-   **N**: number of indexed elements.  | 
 | 49 | +-   **zx**: input [`Complex128Array`][@stdlib/array/complex128].  | 
 | 50 | +-   **strideX**: index increment for `zx`.  | 
 | 51 | + | 
 | 52 | +The `N` and `strideX` parameters determine which elements in `zx` are accessed at runtime. For example, to traverse every other value,  | 
 | 53 | + | 
 | 54 | +```javascript  | 
 | 55 | +var Complex128Array = require( '@stdlib/array/complex128' );  | 
 | 56 | + | 
 | 57 | +var zx = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] );  | 
 | 58 | + | 
 | 59 | +var idx = izamax( 2, zx, 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 Complex128Array = require( '@stdlib/array/complex128' );  | 
 | 67 | + | 
 | 68 | +// Initial array:  | 
 | 69 | +var zx0 = new Complex128Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] );  | 
 | 70 | + | 
 | 71 | +// Create an offset view:  | 
 | 72 | +var zx1 = new Complex128Array( zx0.buffer, zx0.BYTES_PER_ELEMENT*1 ); // start at 2nd element  | 
 | 73 | + | 
 | 74 | +// Find index of element having the maximum absolute value:  | 
 | 75 | +var idx = izamax( 2, zx1, 1 );  | 
 | 76 | +// returns 1  | 
 | 77 | +```  | 
 | 78 | + | 
 | 79 | +#### izamax.ndarray( N, zx, strideX, offset )  | 
 | 80 | + | 
 | 81 | +Finds the index of the first element having the maximum absolute value using alternative indexing semantics.  | 
 | 82 | + | 
 | 83 | +```javascript  | 
 | 84 | +var Complex128Array = require( '@stdlib/array/complex128' );  | 
 | 85 | + | 
 | 86 | +var zx = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] );  | 
 | 87 | + | 
 | 88 | +var idx = izamax.ndarray( zx.length, zx, 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 Complex128Array = require( '@stdlib/array/complex128' );  | 
 | 100 | + | 
 | 101 | +var zx = new Complex128Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 ] );  | 
 | 102 | + | 
 | 103 | +var idx = izamax.ndarray( 3, zx, 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 | +-   `izamax()` corresponds to the [BLAS][blas] level 1 function [`izamax`][izamax].  | 
 | 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/array/discrete-uniform' );  | 
 | 130 | +var filledarrayBy = require( '@stdlib/array/filled-by' );  | 
 | 131 | +var Complex128 = require( '@stdlib/complex/float64/ctor' );  | 
 | 132 | +var izamax = require( '@stdlib/blas/base/izamax' );  | 
 | 133 | + | 
 | 134 | +function rand() {  | 
 | 135 | +    return new Complex128( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) );  | 
 | 136 | +}  | 
 | 137 | + | 
 | 138 | +// Generate random input arrays:  | 
 | 139 | +var zx = filledarrayBy( 10, 'complex128', rand );  | 
 | 140 | +console.log( zx.toString() );  | 
 | 141 | + | 
 | 142 | +var idx = izamax( zx.length, zx, 1 );  | 
 | 143 | +console.log( idx );  | 
 | 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 | +[izamax]: https://netlib.org/lapack/explore-html/d0/da5/izamax_8f.html  | 
 | 165 | + | 
 | 166 | +[@stdlib/array/complex128]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/complex128  | 
 | 167 | + | 
 | 168 | +[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray  | 
 | 169 | + | 
 | 170 | +</section>  | 
 | 171 | + | 
 | 172 | +<!-- /.links -->  | 
0 commit comments