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