|
| 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 | +# dtrsm |
| 22 | + |
| 23 | +> Solve matrix equation `op(A) * X = α * B` or `X * op(A) = α * B` where `α` is a scalar, `X` and `B` are `M` by `N` matrices, `A` is a unit, or non-unit, upper or lower triangular matrix and `op(A)` is one of `op(A) = A` or `op(A) = A^T`. The matrix `X` is overwritten on `B`. |
| 24 | +
|
| 25 | +<section class = "usage"> |
| 26 | + |
| 27 | +## Usage |
| 28 | + |
| 29 | +```javascript |
| 30 | +var dtrsm = require( '@stdlib/blas/base/dtrsm' ); |
| 31 | +``` |
| 32 | + |
| 33 | +#### dtrsm( order, side, uplo, transa, diag, M, N, α, A, LDA, B, LDB ) |
| 34 | + |
| 35 | +Solves matrix equation `op(A) * X = α * B` or `X * op(A) = α * B` where `α` is a scalar, `X` and `B` are `M` by `N` matrices, `A` is a unit, or non-unit, upper or lower triangular matrix and `op(A)` is one of `op(A) = A` or `op(A) = A^T`. The matrix `X` is overwritten on `B`. |
| 36 | + |
| 37 | +```javascript |
| 38 | +var Float64Array = require( '@stdlib/array/float64' ); |
| 39 | + |
| 40 | +var A = new Float64Array( [ 1.0, 0.0, 0.0, 2.0, 3.0, 0.0, 4.0, 5.0, 6.0 ] ); |
| 41 | +var B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); |
| 42 | + |
| 43 | +dtrsm( 'row-major', 'left', 'lower', 'no-transpose', 'unit', 3, 3, 1.0, A, 3, B, 3 ); |
| 44 | +// B => <Float64Array>[ 1.0, 2.0, 3.0, 2.0, 1.0, 0.0, -7.0, -5.0, -3.0 ] |
| 45 | +``` |
| 46 | + |
| 47 | +The function has the following parameters: |
| 48 | + |
| 49 | +- **order**: storage layout of `A` and `B`. |
| 50 | +- **side**: specifies whether `op( A )` appears on the left or right side of `X`. |
| 51 | +- **uplo**: specifies whether the upper or lower triangular part of the matrix `A` is supplied. |
| 52 | +- **transa**: specifies the form of `op( A )` to be used in the matrix multiplication. |
| 53 | +- **diag**: specifies whether or not `A` is unit triangular. |
| 54 | +- **M**: number of rows in `B`. |
| 55 | +- **N**: number of columns in `B`. |
| 56 | +- **α**: scalar constant. |
| 57 | +- **A**: input matrix `A`. |
| 58 | +- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). |
| 59 | +- **B**: input matrix `B`. |
| 60 | +- **LDB**: stride of the first dimension of `B` (a.k.a., leading dimension of the matrix `B`). |
| 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 arrays... |
| 70 | +var A0 = new Float64Array( [ 0.0, 1.0, 0.0, 0.0, 2.0, 3.0, 0.0, 4.0, 5.0, 6.0 ] ); |
| 71 | +var B0 = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); |
| 72 | + |
| 73 | +// Create offset views... |
| 74 | +var A1 = new Float64Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 2nd element |
| 75 | +var B1 = new Float64Array( B0.buffer, B0.BYTES_PER_ELEMENT*1 ); // start at 2nd element |
| 76 | + |
| 77 | +dtrsm( 'row-major', 'left', 'lower', 'no-transpose', 'unit', 3, 3, 1.0, A, 3, B, 3 ); |
| 78 | +// B0 => <Float64Array>[ 0.0, 1.0, 2.0, 3.0, 2.0, 1.0, 0.0, -7.0, -5.0, -3.0 ] |
| 79 | +``` |
| 80 | + |
| 81 | +#### dtrsm.ndarray( s, ul, t, d, M, N, α, A, sa1, sa2, oa, B, sb1, sb2, ob ) |
| 82 | + |
| 83 | +Solves matrix equation `op(A) * X = α * B` or `X * op(A) = α * B` using alternative indexing semantics and where `α` is a scalar, `X` and `B` are `M` by `N` matrices, `A` is a unit, or non-unit, upper or lower triangular matrix and `op(A)` is one of `op(A) = A` or `op(A) = A^T`. The matrix `X` is overwritten on `B`. |
| 84 | + |
| 85 | +```javascript |
| 86 | +var Float64Array = require( '@stdlib/array/float64' ); |
| 87 | + |
| 88 | +var A = new Float64Array( [ 1.0, 0.0, 0.0, 2.0, 3.0, 0.0, 4.0, 5.0, 6.0 ] ); |
| 89 | +var B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); |
| 90 | + |
| 91 | +dtrsm( 'left', 'lower', 'no-transpose', 'unit', 3, 3, 1.0, A, 3, 1, 0, B, 3, 1, 0 ); |
| 92 | +// B => <Float64Array>[ 1.0, 2.0, 3.0, 2.0, 1.0, 0.0, -7.0, -5.0, -3.0 ] |
| 93 | +``` |
| 94 | + |
| 95 | +The function has the following parameters: |
| 96 | + |
| 97 | +- **side**: specifies whether `op( A )` appears on the left or right side of `X`. |
| 98 | +- **uplo**: specifies whether the upper or lower triangular part of the matrix `A` is supplied. |
| 99 | +- **transa**: specifies the form of `op( A )` to be used in the matrix multiplication. |
| 100 | +- **diag**: specifies whether or not `A` is unit triangular. |
| 101 | +- **M**: number of rows in `B`. |
| 102 | +- **N**: number of columns in `B`. |
| 103 | +- **α**: scalar constant. |
| 104 | +- **A**: input matrix `A`. |
| 105 | +- **sa1**: stride of the first dimension of `A`. |
| 106 | +- **sa2**: stride of the second dimension of `A`. |
| 107 | +- **oa**: starting index for `A`. |
| 108 | +- **B**: input matrix `B`. |
| 109 | +- **sb1**: stride of the first dimension of `B`. |
| 110 | +- **sb2**: stride of the second dimension of `B`. |
| 111 | +- **ob**: starting index for `B`. |
| 112 | + |
| 113 | +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, |
| 114 | + |
| 115 | +```javascript |
| 116 | +var Float64Array = require( '@stdlib/array/float64' ); |
| 117 | + |
| 118 | +var A = new Float64Array( [ 1.0, 0.0, 0.0, 2.0, 3.0, 0.0, 4.0, 5.0, 6.0 ] ); |
| 119 | +var B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); |
| 120 | + |
| 121 | +dtrsm( 'left', 'lower', 'no-transpose', 'unit', 3, 3, 1.0, A, 3, 1, 0, B, 3, 1, 0 ); |
| 122 | +// B => <Float64Array>[ 1.0, 2.0, 3.0, 2.0, 1.0, 0.0, -7.0, -5.0, -3.0 ] |
| 123 | +``` |
| 124 | + |
| 125 | +</section> |
| 126 | + |
| 127 | +<!-- /.usage --> |
| 128 | + |
| 129 | +<section class="notes"> |
| 130 | + |
| 131 | +## Notes |
| 132 | + |
| 133 | +- `dtrsm()` corresponds to the [BLAS][blas] level 3 function [`dtrsm`][dtrsm]. |
| 134 | + |
| 135 | +</section> |
| 136 | + |
| 137 | +<!-- /.notes --> |
| 138 | + |
| 139 | +<section class="examples"> |
| 140 | + |
| 141 | +## Examples |
| 142 | + |
| 143 | +<!-- eslint no-undef: "error" --> |
| 144 | + |
| 145 | +```javascript |
| 146 | +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); |
| 147 | +var dtrsm = require( '@stdlib/blas/base/dtrsm' ); |
| 148 | + |
| 149 | +var opts = { |
| 150 | + 'dtype': 'float64' |
| 151 | +}; |
| 152 | + |
| 153 | +var M = 3; |
| 154 | +var N = 3; |
| 155 | + |
| 156 | +var A = discreteUniform( M*N, -10.0, 10.0, opts ); |
| 157 | +var B = discreteUniform( M*N, -10.0, 10.0, opts ); |
| 158 | + |
| 159 | +var out = dtrsm( 'column-major', 'left', 'upper', 'no-transpose', 'non-unit', M, N, 1.0, A, N, B, N ); |
| 160 | +console.log( out ); |
| 161 | + |
| 162 | +out = dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', M, N, 1.0, A, N, 1, 0, B, N, 1, 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 | +[blas]: http://www.netlib.org/blas |
| 253 | + |
| 254 | +[dtrsm]: https://www.netlib.org/lapack/explore-html/d9/de5/group__trsm_ga7120d931d7b1a15e12d50d328799df8a.html |
| 255 | + |
| 256 | +[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray |
| 257 | + |
| 258 | +</section> |
| 259 | + |
| 260 | +<!-- /.links --> |
0 commit comments