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