|
| 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 | +# zlaset |
| 22 | + |
| 23 | +> Set the off-diagonal elements and the diagonal elements of a double-precision complex floating-point matrix to specified values. |
| 24 | +
|
| 25 | +<section class="usage"> |
| 26 | + |
| 27 | +## Usage |
| 28 | + |
| 29 | +```javascript |
| 30 | +var zlaset = require( '@stdlib/lapack/base/zlaset' ); |
| 31 | +``` |
| 32 | + |
| 33 | +#### zlaset( order, uplo, M, N, alpha, beta, A, LDA ) |
| 34 | + |
| 35 | +Sets the off-diagonal elements and the diagonal elements of a double-precision complex floating-point matrix to specified values. |
| 36 | + |
| 37 | +```javascript |
| 38 | +var Complex128Array = require( '@stdlib/array/complex128' ); |
| 39 | +var Complex128 = require( '@stdlib/complex/float64/ctor' ); |
| 40 | +var real = require( '@stdlib/complex/float64/real' ); |
| 41 | +var imag = require( '@stdlib/complex/float64/imag' ); |
| 42 | + |
| 43 | +var A = new Complex128Array( 4 ); |
| 44 | + |
| 45 | +var alpha = new Complex128( 1.0, 2.0 ); |
| 46 | +var beta = new Complex128( 3.0, 4.0 ); |
| 47 | + |
| 48 | +zlaset( 'row-major', 'all', 2, 2, alpha, beta, A, 2 ); |
| 49 | + |
| 50 | +var z = A.get( 0 ); |
| 51 | +// returns <Complex128> |
| 52 | + |
| 53 | +var re = real( z ); |
| 54 | +// returns 3.0 |
| 55 | + |
| 56 | +var im = imag( z ); |
| 57 | +// returns 4.0 |
| 58 | + |
| 59 | +z = A.get( 1 ); |
| 60 | +// returns <Complex128> |
| 61 | + |
| 62 | +re = real( z ); |
| 63 | +// returns 1.0 |
| 64 | + |
| 65 | +im = imag( z ); |
| 66 | +// returns 2.0 |
| 67 | +``` |
| 68 | + |
| 69 | +The function has the following parameters: |
| 70 | + |
| 71 | +- **order**: storage layout. |
| 72 | +- **uplo**: specifies whether to set the upper or lower triangular/trapezoidal part of a matrix `A`. |
| 73 | +- **M**: number of rows in `A`. |
| 74 | +- **N**: number of columns in `A`. |
| 75 | +- **alpha**: value assigned to off-diagonal elements. |
| 76 | +- **beta**: value assigned to diagonal elements. |
| 77 | +- **A**: input [`Complex128Array`][@stdlib/array/complex128]. |
| 78 | +- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). |
| 79 | + |
| 80 | +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. |
| 81 | + |
| 82 | +<!-- eslint-disable stdlib/capitalized-comments --> |
| 83 | + |
| 84 | +```javascript |
| 85 | +var Complex128Array = require( '@stdlib/array/complex128' ); |
| 86 | +var Complex128 = require( '@stdlib/complex/float64/ctor' ); |
| 87 | +var real = require( '@stdlib/complex/float64/real' ); |
| 88 | +var imag = require( '@stdlib/complex/float64/imag' ); |
| 89 | + |
| 90 | +// Initial array: |
| 91 | +var A0 = new Complex128Array( 5 ); |
| 92 | + |
| 93 | +// Create offset view: |
| 94 | +var A1 = new Complex128Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 2nd element |
| 95 | + |
| 96 | +var alpha = new Complex128( 1.0, 2.0 ); |
| 97 | +var beta = new Complex128( 3.0, 4.0 ); |
| 98 | + |
| 99 | +zlaset( 'row-major', 'all', 2, 2, alpha, beta, A1, 2 ); |
| 100 | + |
| 101 | +var z = A0.get( 1 ); |
| 102 | +// returns <Complex128> |
| 103 | + |
| 104 | +var re = real( z ); |
| 105 | +// returns 3.0 |
| 106 | + |
| 107 | +var im = imag( z ); |
| 108 | +// returns 4.0 |
| 109 | +``` |
| 110 | + |
| 111 | +#### zlaset.ndarray( uplo, M, N, alpha, beta, A, sa1, sa2, oa ) |
| 112 | + |
| 113 | +Sets the off-diagonal elements and the diagonal elements of a double-precision complex floating-point matrix to specified values using alternative indexing semantics. |
| 114 | + |
| 115 | +```javascript |
| 116 | +var Complex128Array = require( '@stdlib/array/complex128' ); |
| 117 | +var Complex128 = require( '@stdlib/complex/float64/ctor' ); |
| 118 | +var real = require( '@stdlib/complex/float64/real' ); |
| 119 | +var imag = require( '@stdlib/complex/float64/imag' ); |
| 120 | + |
| 121 | +var A = new Complex128Array( 4 ); |
| 122 | + |
| 123 | +var alpha = new Complex128( 1.0, 2.0 ); |
| 124 | +var beta = new Complex128( 3.0, 4.0 ); |
| 125 | + |
| 126 | +zlaset.ndarray( 'all', 2, 2, alpha, beta, A, 2, 1, 0 ); |
| 127 | + |
| 128 | +var z = A.get( 0 ); |
| 129 | +// returns <Complex128> |
| 130 | + |
| 131 | +var re = real( z ); |
| 132 | +// returns 3.0 |
| 133 | + |
| 134 | +var im = imag( z ); |
| 135 | +// returns 4.0 |
| 136 | + |
| 137 | +z = A.get( 1 ); |
| 138 | +// returns <Complex128> |
| 139 | + |
| 140 | +re = real( z ); |
| 141 | +// returns 1.0 |
| 142 | + |
| 143 | +im = imag( z ); |
| 144 | +// returns 2.0 |
| 145 | +``` |
| 146 | + |
| 147 | +The function has the following parameters: |
| 148 | + |
| 149 | +- **uplo**: specifies whether to set the upper or lower triangular/trapezoidal part of a matrix `A`. |
| 150 | +- **M**: number of rows in `A`. |
| 151 | +- **N**: number of columns in `A`. |
| 152 | +- **alpha**: value assigned to off-diagonal elements. |
| 153 | +- **beta**: value assigned to diagonal elements. |
| 154 | +- **A**: input [`Complex128Array`][@stdlib/array/complex128]. |
| 155 | +- **sa1**: stride of the first dimension of `A`. |
| 156 | +- **sa2**: stride of the second dimension of `A`. |
| 157 | +- **oa**: starting index for `A`. |
| 158 | + |
| 159 | +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, |
| 160 | + |
| 161 | +```javascript |
| 162 | +var Complex128Array = require( '@stdlib/array/complex128' ); |
| 163 | +var Complex128 = require( '@stdlib/complex/float64/ctor' ); |
| 164 | +var real = require( '@stdlib/complex/float64/real' ); |
| 165 | +var imag = require( '@stdlib/complex/float64/imag' ); |
| 166 | + |
| 167 | +var A = new Complex128Array( 5 ); |
| 168 | + |
| 169 | +var alpha = new Complex128( 1.0, 2.0 ); |
| 170 | +var beta = new Complex128( 3.0, 4.0 ); |
| 171 | + |
| 172 | +zlaset.ndarray( 'all', 2, 2, alpha, beta, A, 2, 1, 1 ); |
| 173 | + |
| 174 | +var z = A.get( 0 ); |
| 175 | +// returns <Complex128> |
| 176 | + |
| 177 | +var re = real( z ); |
| 178 | +// returns 0.0 |
| 179 | + |
| 180 | +var im = imag( z ); |
| 181 | +// returns 0.0 |
| 182 | + |
| 183 | +z = A.get( 1 ); |
| 184 | +// returns <Complex128> |
| 185 | + |
| 186 | +re = real( z ); |
| 187 | +// returns 3.0 |
| 188 | + |
| 189 | +im = imag( z ); |
| 190 | +// returns 4.0 |
| 191 | +``` |
| 192 | + |
| 193 | +</section> |
| 194 | + |
| 195 | +<!-- /.usage --> |
| 196 | + |
| 197 | +<section class="notes"> |
| 198 | + |
| 199 | +## Notes |
| 200 | + |
| 201 | +- `zlaset()` corresponds to the [LAPACK][lapack] routine [`zlaset`][lapack-zlaset]. |
| 202 | + |
| 203 | +</section> |
| 204 | + |
| 205 | +<!-- /.notes --> |
| 206 | + |
| 207 | +<section class="examples"> |
| 208 | + |
| 209 | +## Examples |
| 210 | + |
| 211 | +<!-- eslint no-undef: "error" --> |
| 212 | + |
| 213 | +```javascript |
| 214 | +var Complex128Array = require( '@stdlib/array/complex128' ); |
| 215 | +var Complex128 = require( '@stdlib/complex/float64/ctor' ); |
| 216 | +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); |
| 217 | +var numel = require( '@stdlib/ndarray/base/numel' ); |
| 218 | +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); |
| 219 | +var zlaset = require( '@stdlib/lapack/base/zlaset' ); |
| 220 | + |
| 221 | +var shape = [ 5, 8 ]; |
| 222 | +var order = 'row-major'; |
| 223 | +var strides = shape2strides( shape, order ); |
| 224 | + |
| 225 | +var N = numel( shape ); |
| 226 | + |
| 227 | +var A = new Complex128Array( N ); |
| 228 | +console.log( ndarray2array( A, shape, strides, 0, order ) ); |
| 229 | + |
| 230 | +var alpha = new Complex128( 1.0, 2.0 ); |
| 231 | +var beta = new Complex128( 3.0, 4.0 ); |
| 232 | + |
| 233 | +zlaset( order, 'all', shape[ 0 ], shape[ 1 ], alpha, beta, A, strides[ 0 ] ); |
| 234 | +console.log( ndarray2array( A, shape, strides, 0, order ) ); |
| 235 | +``` |
| 236 | + |
| 237 | +</section> |
| 238 | + |
| 239 | +<!-- /.examples --> |
| 240 | + |
| 241 | +<!-- C interface documentation. --> |
| 242 | + |
| 243 | +* * * |
| 244 | + |
| 245 | +<section class="c"> |
| 246 | + |
| 247 | +## C APIs |
| 248 | + |
| 249 | +<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> |
| 250 | + |
| 251 | +<section class="intro"> |
| 252 | + |
| 253 | +</section> |
| 254 | + |
| 255 | +<!-- /.intro --> |
| 256 | + |
| 257 | +<!-- C usage documentation. --> |
| 258 | + |
| 259 | +<section class="usage"> |
| 260 | + |
| 261 | +### Usage |
| 262 | + |
| 263 | +```c |
| 264 | +TODO |
| 265 | +``` |
| 266 | + |
| 267 | +#### TODO |
| 268 | + |
| 269 | +TODO. |
| 270 | + |
| 271 | +```c |
| 272 | +TODO |
| 273 | +``` |
| 274 | + |
| 275 | +TODO |
| 276 | + |
| 277 | +```c |
| 278 | +TODO |
| 279 | +``` |
| 280 | + |
| 281 | +</section> |
| 282 | + |
| 283 | +<!-- /.usage --> |
| 284 | + |
| 285 | +<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 286 | + |
| 287 | +<section class="notes"> |
| 288 | + |
| 289 | +</section> |
| 290 | + |
| 291 | +<!-- /.notes --> |
| 292 | + |
| 293 | +<!-- C API usage examples. --> |
| 294 | + |
| 295 | +<section class="examples"> |
| 296 | + |
| 297 | +### Examples |
| 298 | + |
| 299 | +```c |
| 300 | +TODO |
| 301 | +``` |
| 302 | + |
| 303 | +</section> |
| 304 | + |
| 305 | +<!-- /.examples --> |
| 306 | + |
| 307 | +</section> |
| 308 | + |
| 309 | +<!-- /.c --> |
| 310 | + |
| 311 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
| 312 | + |
| 313 | +<section class="related"> |
| 314 | + |
| 315 | +</section> |
| 316 | + |
| 317 | +<!-- /.related --> |
| 318 | + |
| 319 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 320 | + |
| 321 | +<section class="links"> |
| 322 | + |
| 323 | +[lapack]: https://www.netlib.org/lapack/explore-html/ |
| 324 | + |
| 325 | +[lapack-zlaset]: https://netlib.org/lapack/explore-html-3.6.1/d9/dd5/zlaset_8f_aa4389d0e0e031c70c351acf7dbad6a85.html#aa4389d0e0e031c70c351acf7dbad6a85 |
| 326 | + |
| 327 | +[@stdlib/array/complex128]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/complex128 |
| 328 | + |
| 329 | +[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray |
| 330 | + |
| 331 | +</section> |
| 332 | + |
| 333 | +<!-- /.links --> |
0 commit comments