|
| 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 | +# iladlr |
| 22 | + |
| 23 | +> Find the index of the last non-zero row in a matrix `A`. |
| 24 | +
|
| 25 | +<section class="usage"> |
| 26 | + |
| 27 | +## Usage |
| 28 | + |
| 29 | +```javascript |
| 30 | +var iladlr = require( '@stdlib/lapack/base/iladlr' ); |
| 31 | +``` |
| 32 | + |
| 33 | +#### iladlr( order, M, N, A, LDA ) |
| 34 | + |
| 35 | +Returns the index of the last non-zero row in a matrix `A`. |
| 36 | + |
| 37 | +```javascript |
| 38 | +var Float64Array = require( '@stdlib/array/float64' ); |
| 39 | + |
| 40 | +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); |
| 41 | + |
| 42 | +/* |
| 43 | + A = [ |
| 44 | + [ 1.0, 2.0 ], |
| 45 | + [ 3.0, 4.0 ], |
| 46 | + [ 0.0, 0.0 ] |
| 47 | + ] |
| 48 | +*/ |
| 49 | + |
| 50 | +var out = iladlr( 'row-major', 3, 2, A, 2 ); |
| 51 | +// returns 1 |
| 52 | +``` |
| 53 | + |
| 54 | +The function has the following parameters: |
| 55 | + |
| 56 | +- **order**: storage layout. |
| 57 | +- **M**: number of rows in `A`. |
| 58 | +- **N**: number of columns in `A`. |
| 59 | +- **A**: input [`Float64Array`][mdn-float64array]. |
| 60 | +- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). |
| 61 | + |
| 62 | +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. |
| 63 | + |
| 64 | +<!-- eslint-disable stdlib/capitalized-comments --> |
| 65 | + |
| 66 | +```javascript |
| 67 | +var Float64Array = require( '@stdlib/array/float64' ); |
| 68 | + |
| 69 | +// Initial array: |
| 70 | +var A0 = new Float64Array( [ 9999.0, 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); |
| 71 | + |
| 72 | +// Create an offset view: |
| 73 | +var A1 = new Float64Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 2nd element |
| 74 | + |
| 75 | +var out = iladlr( 'row-major', 3, 2, A1, 2 ); |
| 76 | +// returns 1 |
| 77 | +``` |
| 78 | + |
| 79 | +#### iladlr.ndarray( M, N, A, strideA1, strideA2, offsetA ) |
| 80 | + |
| 81 | +Returns the index of the last non-zero row in a matrix `A` using alternative indexing semantics. |
| 82 | + |
| 83 | +```javascript |
| 84 | +var Float64Array = require( '@stdlib/array/float64' ); |
| 85 | + |
| 86 | +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); |
| 87 | + |
| 88 | +/* |
| 89 | + A = [ |
| 90 | + [ 1.0, 2.0 ], |
| 91 | + [ 3.0, 4.0 ], |
| 92 | + [ 0.0, 0.0 ] |
| 93 | + ] |
| 94 | +*/ |
| 95 | + |
| 96 | +var out = iladlr.ndarray( 3, 2, A, 2, 1, 0 ); |
| 97 | +// returns 1 |
| 98 | +``` |
| 99 | + |
| 100 | +The function has the following parameters: |
| 101 | + |
| 102 | +- **M**: number of rows in `A`. |
| 103 | +- **N**: number of columns in `A`. |
| 104 | +- **A**: input [`Float64Array`][mdn-float64array]. |
| 105 | +- **strideA1**: stride of the first dimension of `A`. |
| 106 | +- **strideA2**: stride of the second dimension of `A`. |
| 107 | +- **offsetA**: starting index for `A`. |
| 108 | + |
| 109 | +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, |
| 110 | + |
| 111 | +```javascript |
| 112 | +var Float64Array = require( '@stdlib/array/float64' ); |
| 113 | + |
| 114 | +var A = new Float64Array( [ 9999.0, 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); |
| 115 | + |
| 116 | +/* |
| 117 | + A = [ |
| 118 | + [ 1.0, 2.0 ], |
| 119 | + [ 3.0, 4.0 ], |
| 120 | + [ 0.0, 0.0 ] |
| 121 | + ] |
| 122 | +*/ |
| 123 | + |
| 124 | +var out = iladlr.ndarray( 3, 2, A, 2, 1, 1 ); |
| 125 | +// returns 1 |
| 126 | +``` |
| 127 | + |
| 128 | +</section> |
| 129 | + |
| 130 | +<!-- /.usage --> |
| 131 | + |
| 132 | +<section class="notes"> |
| 133 | + |
| 134 | +## Notes |
| 135 | + |
| 136 | +- This routine is commonly used throughout LAPACK to shrink work domains (e.g., before bulge-chasing, deflation, or when trimming Householder panels), thus ensuring that higher-level routines operate only on numerically relevant sub-matrices. |
| 137 | +- `iladlr()` corresponds to the [LAPACK][lapack] routine [`iladlr`][lapack-iladlr]. |
| 138 | + |
| 139 | +</section> |
| 140 | + |
| 141 | +<!-- /.notes --> |
| 142 | + |
| 143 | +<section class="examples"> |
| 144 | + |
| 145 | +## Examples |
| 146 | + |
| 147 | +<!-- eslint no-undef: "error" --> |
| 148 | + |
| 149 | +```javascript |
| 150 | +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); |
| 151 | +var Float64Array = require( '@stdlib/array/float64' ); |
| 152 | +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); |
| 153 | +var iladlr = require( '@stdlib/lapack/base/iladlr' ); |
| 154 | + |
| 155 | +var shape = [ 3, 3 ]; |
| 156 | +var order = 'row-major'; |
| 157 | +var strides = shape2strides( shape, order ); |
| 158 | + |
| 159 | +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 0.0, 0.0, 0.0 ] ); |
| 160 | +console.log( ndarray2array( A, shape, strides, 0, order ) ); |
| 161 | + |
| 162 | +var out = iladlr( order, shape[ 0 ], shape[ 1 ], A, strides[ 0 ] ); |
| 163 | +console.log( out ); |
| 164 | +``` |
| 165 | + |
| 166 | +</section> |
| 167 | + |
| 168 | +<!-- /.examples --> |
| 169 | + |
| 170 | +<!-- C interface documentation. --> |
| 171 | + |
| 172 | +* * * |
| 173 | + |
| 174 | +<section class="c"> |
| 175 | + |
| 176 | +## C APIs |
| 177 | + |
| 178 | +<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> |
| 179 | + |
| 180 | +<section class="intro"> |
| 181 | + |
| 182 | +</section> |
| 183 | + |
| 184 | +<!-- /.intro --> |
| 185 | + |
| 186 | +<!-- C usage documentation. --> |
| 187 | + |
| 188 | +<section class="usage"> |
| 189 | + |
| 190 | +### Usage |
| 191 | + |
| 192 | +```c |
| 193 | +TODO |
| 194 | +``` |
| 195 | + |
| 196 | +#### TODO |
| 197 | + |
| 198 | +TODO. |
| 199 | + |
| 200 | +```c |
| 201 | +TODO |
| 202 | +``` |
| 203 | + |
| 204 | +TODO |
| 205 | + |
| 206 | +```c |
| 207 | +TODO |
| 208 | +``` |
| 209 | + |
| 210 | +</section> |
| 211 | + |
| 212 | +<!-- /.usage --> |
| 213 | + |
| 214 | +<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 215 | + |
| 216 | +<section class="notes"> |
| 217 | + |
| 218 | +</section> |
| 219 | + |
| 220 | +<!-- /.notes --> |
| 221 | + |
| 222 | +<!-- C API usage examples. --> |
| 223 | + |
| 224 | +<section class="examples"> |
| 225 | + |
| 226 | +### Examples |
| 227 | + |
| 228 | +```c |
| 229 | +TODO |
| 230 | +``` |
| 231 | + |
| 232 | +</section> |
| 233 | + |
| 234 | +<!-- /.examples --> |
| 235 | + |
| 236 | +</section> |
| 237 | + |
| 238 | +<!-- /.c --> |
| 239 | + |
| 240 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
| 241 | + |
| 242 | +<section class="related"> |
| 243 | + |
| 244 | +</section> |
| 245 | + |
| 246 | +<!-- /.related --> |
| 247 | + |
| 248 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 249 | + |
| 250 | +<section class="links"> |
| 251 | + |
| 252 | +[lapack]: https://www.netlib.org/lapack/explore-html/ |
| 253 | + |
| 254 | +[lapack-iladlr]: https://www.netlib.org/lapack/explore-html/da/d60/group__ilalr_gadb53a9bd5cc7a6e3bbca7bf4eca32208.html |
| 255 | + |
| 256 | +[mdn-float64array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array |
| 257 | + |
| 258 | +[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray |
| 259 | + |
| 260 | +</section> |
| 261 | + |
| 262 | +<!-- /.links --> |
0 commit comments