|
| 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 | +# ssyr2k |
| 22 | + |
| 23 | +> Perform one of the symmetric rank `2K` operations `C = α*A*B**T + C = α*B*A**T + β*C` or `C = α*A**T*B + α*B**T*A + β*C` where `α` and `β` are scalars, `C` is an `N` by `N` symmetric matrix and `A` and `B` are `N` by `K` matrices in the first case and `K` by `N` matrices in the second case. |
| 24 | +
|
| 25 | +<section class="usage"> |
| 26 | + |
| 27 | +## Usage |
| 28 | + |
| 29 | +```javascript |
| 30 | +var ssyr2k = require( '@stdlib/blas/base/ssyr2k' ); |
| 31 | +``` |
| 32 | + |
| 33 | +#### ssyr2k( ord, uplo, trans, N, K, α, A, lda, B, ldb, β, C, ldc ) |
| 34 | + |
| 35 | +Performs one of the symmetric rank `2K` operations `C = α*A*B**T + C = α*B*A**T + β*C` or `C = α*A**T*B + α*B**T*A + β*C` where `α` and `β` are scalars, `C` is an `N` by `N` symmetric matrix and `A` and `B` are `N` by `K` matrices in the first case and `K` by `N` matrices in the second case. |
| 36 | + |
| 37 | +```javascript |
| 38 | +var Float32Array = require( '@stdlib/array/float32' ); |
| 39 | + |
| 40 | +var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); |
| 41 | +var B = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); |
| 42 | +var C = new Float32Array( [ 1.0, 2.0, 3.0, 0.0, 4.0, 5.0, 0.0, 0.0, 6.0 ] ); |
| 43 | + |
| 44 | +ssyr2k( 'row-major', 'upper', 'no-transpose', 3, 3, 1.0, A, 3, B, 3, 1.0, C, 3 ); |
| 45 | +// C => <Float32Array>[ 29.0, 66.0, 103.0, 0.0, 158.0, 249.0, 0.0, 0.0, 394.0 ] |
| 46 | +``` |
| 47 | + |
| 48 | +The function has the following parameters: |
| 49 | + |
| 50 | +- **ord**: storage layout. |
| 51 | +- **uplo**: specifies whether the upper or lower triangular part of the symmetric matrix `C` is supplied. |
| 52 | +- **trans**: specifies whether `C` should be transposed, conjugate-transposed, or not transposed. |
| 53 | +- **N**: order of the matrix `C`. |
| 54 | +- **K**: number of columns or number of rows of the matrices `A` and `B`. |
| 55 | +- **α**: scalar constant. |
| 56 | +- **A**: first input matrix stored in linear memory as a [`Float32Array`][mdn-float32array]. |
| 57 | +- **lda**: stride of the first dimension of `A` (leading dimension of `A`). |
| 58 | +- **B**: second input matrix stored in linear memory as a [`Float32Array`][mdn-float32array]. |
| 59 | +- **ldb**: stride of the first dimension of `B` (leading dimension of `B`). |
| 60 | +- **β**: scalar constant. |
| 61 | +- **C**: third input matrix stored in linear memory as a [`Float32Array`][mdn-float32array]. |
| 62 | +- **ldc**: stride of the first dimension of `C` (leading dimension of `C`). |
| 63 | + |
| 64 | +The stride parameters determine how elements in the input arrays are accessed at runtime. For example, to perform matrix multiplication of two subarrays |
| 65 | + |
| 66 | +<!-- lint disable maximum-len --> |
| 67 | + |
| 68 | +```javascript |
| 69 | +var Float32Array = require( '@stdlib/array/float32' ); |
| 70 | + |
| 71 | +var A = new Float32Array( [ 1.0, 2.0, 3.0, 0.0, 0.0, 0.0, 4.0, 5.0, 6.0, 0.0, 0.0, 0.0, 7.0, 8.0, 9.0 ] ); |
| 72 | +var B = new Float32Array( [ 1.0, 2.0, 3.0, 0.0, 0.0, 0.0, 4.0, 5.0, 6.0, 0.0, 0.0, 0.0, 7.0, 8.0, 9.0 ] ); |
| 73 | +var C = new Float32Array( [ 1.0, 2.0, 3.0, 0.0, 4.0, 5.0, 0.0, 0.0, 6.0 ] ); |
| 74 | + |
| 75 | +ssyr2k( 'row-major', 'upper', 'no-transpose', 3, 3, 1.0, A, 6, B, 6, 1.0, C, 3 ); |
| 76 | +// C => <Float32Array>[ 29.0, 66.0, 103.0, 0.0, 158.0, 249.0, 0.0, 0.0, 394.0 ] |
| 77 | +``` |
| 78 | + |
| 79 | +<!-- lint disable maximum-heading-length --> |
| 80 | + |
| 81 | +#### ssyr2k.ndarray( uplo, trans, N, K, α, A, sa1, sa2, oa, B, sb1, sb2, ob, β, C, sc1, sc2, oc ) |
| 82 | + |
| 83 | +Performs one of the symmetric rank `2K` operations `C = α*A*B**T + C = α*B*A**T + β*C` or `C = α*A**T*B + α*B**T*A + β*C`, using alternative indexing semantics and where `α` and `β` are scalars, `C` is an `N` by `N` symmetric matrix and `A` and `B` are `N` by `K` matrices in the first case and `K` by `N` matrices in the second case. |
| 84 | + |
| 85 | +```javascript |
| 86 | +var Float32Array = require( '@stdlib/array/float32' ); |
| 87 | + |
| 88 | +var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); |
| 89 | +var B = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); |
| 90 | +var C = new Float32Array( [ 1.0, 2.0, 3.0, 0.0, 4.0, 5.0, 0.0, 0.0, 6.0 ] ); |
| 91 | + |
| 92 | +ssyr2k.ndarray( 'upper', 'no-transpose', 3, 3, 1.0, A, 3, 1, 0, B, 3, 1, 0, 1.0, C, 3, 1, 0 ); |
| 93 | +// C => <Float32Array>[ 29.0, 66.0, 103.0, 0.0, 158.0, 249.0, 0.0, 0.0, 394.0 ] |
| 94 | +``` |
| 95 | + |
| 96 | +The function has the following additional parameters: |
| 97 | + |
| 98 | +- **sa1**: stride of the first dimension of `A`. |
| 99 | +- **sa2**: stride of the second dimension of `A`. |
| 100 | +- **oa**: starting index for `A`. |
| 101 | +- **sb1**: stride of the first dimension of `B`. |
| 102 | +- **sb2**: stride of the second dimension of `B`. |
| 103 | +- **ob**: starting index for `B`. |
| 104 | +- **sc1**: stride of the first dimension of `C`. |
| 105 | +- **sc2**: stride of the second dimension of `C`. |
| 106 | +- **oc**: starting index for `C`. |
| 107 | + |
| 108 | +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, |
| 109 | + |
| 110 | +```javascript |
| 111 | +var Float32Array = require( '@stdlib/array/float32' ); |
| 112 | + |
| 113 | +var A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); |
| 114 | +var B = new Float32Array( [ 0.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); |
| 115 | +var C = new Float32Array( [ 0.0, 0.0, 0.0, 1.0, 2.0, 3.0, 0.0, 4.0, 5.0, 0.0, 0.0, 6.0 ] ); |
| 116 | + |
| 117 | +ssyr2k.ndarray( 'upper', 'no-transpose', 3, 3, 1.0, A, 3, 1, 1, B, 3, 1, 2, 1.0, C, 3, 1, 3 ); |
| 118 | +// C => <Float32Array>[ 0.0, 0.0, 0.0, 29.0, 66.0, 103.0, 0.0, 158.0, 249.0, 0.0, 0.0, 394.0 ] |
| 119 | +``` |
| 120 | + |
| 121 | +</section> |
| 122 | + |
| 123 | +<!-- /.usage --> |
| 124 | + |
| 125 | +<section class="notes"> |
| 126 | + |
| 127 | +## Notes |
| 128 | + |
| 129 | +- `ssyr2k()` corresponds to the [BLAS][blas] level 3 function [`ssyr2k`][blas-ssyr2k]. |
| 130 | + |
| 131 | +</section> |
| 132 | + |
| 133 | +<!-- /.notes --> |
| 134 | + |
| 135 | +<section class="examples"> |
| 136 | + |
| 137 | +## Examples |
| 138 | + |
| 139 | +<!-- eslint no-undef: "error" --> |
| 140 | + |
| 141 | +```javascript |
| 142 | +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); |
| 143 | +var ssyr2k = require( '@stdlib/blas/base/ssyr2k' ); |
| 144 | + |
| 145 | +var opts = { |
| 146 | + 'dtype': 'float32' |
| 147 | +}; |
| 148 | + |
| 149 | +var N = 4; |
| 150 | + |
| 151 | +var A = discreteUniform( N*N, 0, 10, opts ); // 4x4 |
| 152 | +var B = discreteUniform( N*N, 0, 10, opts ); // 4x4 |
| 153 | +var C = discreteUniform( N*N, 0, 10, opts ); // 4x4 |
| 154 | + |
| 155 | +ssyr2k( 'row-major', 'lower', 'no-transpose', N, N, 1.0, A, N, B, N, 1.0, C, N ); |
| 156 | +console.log( C ); |
| 157 | + |
| 158 | +ssyr2k.ndarray( 'lower', 'no-transpose', N, N, 1.0, A, N, 1, 0, B, N, 1, 0, 1.0, C, N, 1, 0 ); |
| 159 | +console.log( C ); |
| 160 | +``` |
| 161 | + |
| 162 | +</section> |
| 163 | + |
| 164 | +<!-- /.examples --> |
| 165 | + |
| 166 | +<!-- C interface documentation. --> |
| 167 | + |
| 168 | +* * * |
| 169 | + |
| 170 | +<section class="c"> |
| 171 | + |
| 172 | +## C APIs |
| 173 | + |
| 174 | +<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> |
| 175 | + |
| 176 | +<section class="intro"> |
| 177 | + |
| 178 | +</section> |
| 179 | + |
| 180 | +<!-- /.intro --> |
| 181 | + |
| 182 | +<!-- C usage documentation. --> |
| 183 | + |
| 184 | +<section class="usage"> |
| 185 | + |
| 186 | +### Usage |
| 187 | + |
| 188 | +```c |
| 189 | +#include "stdlib/blas/base/ssyr2k.h" |
| 190 | +``` |
| 191 | + |
| 192 | +#### TODO |
| 193 | + |
| 194 | +TODO. |
| 195 | + |
| 196 | +```c |
| 197 | +TODO |
| 198 | +``` |
| 199 | + |
| 200 | +TODO |
| 201 | + |
| 202 | +```c |
| 203 | +TODO |
| 204 | +``` |
| 205 | + |
| 206 | +</section> |
| 207 | + |
| 208 | +<!-- /.usage --> |
| 209 | + |
| 210 | +<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 211 | + |
| 212 | +<section class="notes"> |
| 213 | + |
| 214 | +</section> |
| 215 | + |
| 216 | +<!-- /.notes --> |
| 217 | + |
| 218 | +<!-- C API usage examples. --> |
| 219 | + |
| 220 | +<section class="examples"> |
| 221 | + |
| 222 | +### Examples |
| 223 | + |
| 224 | +```c |
| 225 | +TODO |
| 226 | +``` |
| 227 | + |
| 228 | +</section> |
| 229 | + |
| 230 | +<!-- /.examples --> |
| 231 | + |
| 232 | +</section> |
| 233 | + |
| 234 | +<!-- /.c --> |
| 235 | + |
| 236 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
| 237 | + |
| 238 | +<section class="related"> |
| 239 | + |
| 240 | +</section> |
| 241 | + |
| 242 | +<!-- /.related --> |
| 243 | + |
| 244 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 245 | + |
| 246 | +<section class="links"> |
| 247 | + |
| 248 | +[blas]: http://www.netlib.org/blas |
| 249 | + |
| 250 | +[blas-ssyr2k]: https://www.netlib.org/lapack/explore-html-3.6.1/d1/d54/group__double__blas__level3_ga51f6c38a43599163e670f0f6f5645587.html |
| 251 | + |
| 252 | +[mdn-float32array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array |
| 253 | + |
| 254 | +[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray |
| 255 | + |
| 256 | +</section> |
| 257 | + |
| 258 | +<!-- /.links --> |
0 commit comments