|  | 
|  | 1 | +<!-- | 
|  | 2 | +
 | 
|  | 3 | +@license Apache-2.0 | 
|  | 4 | +
 | 
|  | 5 | +Copyright (c) 2024 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 | +# sspr | 
|  | 22 | + | 
|  | 23 | +> Perform the symmetric rank 1 operation `A = α*x*x^T + A`. | 
|  | 24 | +
 | 
|  | 25 | +<section class = "usage"> | 
|  | 26 | + | 
|  | 27 | +## Usage | 
|  | 28 | + | 
|  | 29 | +```javascript | 
|  | 30 | +var sspr = require( '@stdlib/blas/base/sspr' ); | 
|  | 31 | +``` | 
|  | 32 | + | 
|  | 33 | +#### sspr( order, uplo, N, α, x, sx, AP ) | 
|  | 34 | + | 
|  | 35 | +Performs the symmetric rank 1 operation `A = α*x*x^T + A` where `α` is a scalar, `x` is an `N` element vector, and `A` is an `N` by `N` symmetric matrix supplied in packed form. | 
|  | 36 | + | 
|  | 37 | +```javascript | 
|  | 38 | +var Float32Array = require( '@stdlib/array/float32' ); | 
|  | 39 | + | 
|  | 40 | +var AP = new Float32Array( [ 1.0, 2.0, 3.0, 1.0, 2.0, 1.0 ] ); | 
|  | 41 | +var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); | 
|  | 42 | + | 
|  | 43 | +sspr( 'row-major', 'upper', 3, 1.0, x, 1, AP ); | 
|  | 44 | +// AP => <Float32Array>[ 2.0, 4.0, 6.0, 5.0, 8.0, 10.0 ] | 
|  | 45 | +``` | 
|  | 46 | + | 
|  | 47 | +The function has the following parameters: | 
|  | 48 | + | 
|  | 49 | +- **order**: storage layout. | 
|  | 50 | +- **uplo**: specifies whether the upper or lower triangular part of the symmetric matrix `A` is supplied. | 
|  | 51 | +- **N**: number of elements along each dimension of `A`. | 
|  | 52 | +- **α**: scalar constant. | 
|  | 53 | +- **x**: input [`Float32Array`][mdn-float32array]. | 
|  | 54 | +- **sx**: index increment for `x`. | 
|  | 55 | +- **AP**: packed form of a symmetric matrix `A` stored as a [`Float32Array`][mdn-float32array]. | 
|  | 56 | + | 
|  | 57 | +The stride parameters determine how elements in the input arrays are accessed at runtime. For example, to iterate over the elements of `x` in reverse order, | 
|  | 58 | + | 
|  | 59 | +```javascript | 
|  | 60 | +var Float32Array = require( '@stdlib/array/float32' ); | 
|  | 61 | + | 
|  | 62 | +var AP = new Float32Array( [ 1.0, 2.0, 3.0, 1.0, 2.0, 1.0 ] ); | 
|  | 63 | +var x = new Float32Array( [ 3.0, 2.0, 1.0 ] ); | 
|  | 64 | + | 
|  | 65 | +sspr( 'row-major', 'upper', 3, 1.0, x, -1, AP ); | 
|  | 66 | +// AP => <Float32Array>[ 2.0, 4.0, 6.0, 5.0, 8.0, 10.0 ] | 
|  | 67 | +``` | 
|  | 68 | + | 
|  | 69 | +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. | 
|  | 70 | + | 
|  | 71 | +<!-- eslint-disable stdlib/capitalized-comments --> | 
|  | 72 | + | 
|  | 73 | +```javascript | 
|  | 74 | +var Float32Array = require( '@stdlib/array/float32' ); | 
|  | 75 | + | 
|  | 76 | +// Initial arrays... | 
|  | 77 | +var x0 = new Float32Array( [ 0.0, 3.0, 2.0, 1.0 ] ); | 
|  | 78 | +var AP = new Float32Array( [ 1.0, 2.0, 3.0, 1.0, 2.0, 1.0 ] ); | 
|  | 79 | + | 
|  | 80 | +// Create offset views... | 
|  | 81 | +var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element | 
|  | 82 | + | 
|  | 83 | +sspr( 'row-major', 'upper', 3, 1.0, x1, -1, AP ); | 
|  | 84 | +// AP => <Float32Array>[ 2.0, 4.0, 6.0, 5.0, 8.0, 10.0 ] | 
|  | 85 | +``` | 
|  | 86 | + | 
|  | 87 | +#### sspr.ndarray( uplo, N, α, x, sx, ox, AP, sap, oap ) | 
|  | 88 | + | 
|  | 89 | +Performs the symmetric rank 1 operation `A = α*x*x^T + A`, using alternative indexing semantics and where `α` is a scalar, `x` is an `N` element vector, and `A` is an `N` by `N` symmetric matrix supplied in packed form. | 
|  | 90 | + | 
|  | 91 | +```javascript | 
|  | 92 | +var Float32Array = require( '@stdlib/array/float32' ); | 
|  | 93 | + | 
|  | 94 | +var AP = new Float32Array( [ 1.0, 1.0, 2.0, 1.0, 2.0, 3.0 ] ); | 
|  | 95 | +var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); | 
|  | 96 | + | 
|  | 97 | +sspr.ndarray( 'row-major', 'lower', 3, 1.0, x, 1, 0, AP, 1, 0 ); | 
|  | 98 | +// AP => <Float32Array>[ 2.0, 3.0, 6.0, 4.0, 8.0, 12.0 ] | 
|  | 99 | +``` | 
|  | 100 | + | 
|  | 101 | +The function has the following additional parameters: | 
|  | 102 | + | 
|  | 103 | +- **ox**: starting index for `x`. | 
|  | 104 | +- **sap**: `AP` stride length. | 
|  | 105 | +- **oap**: starting index for `AP`. | 
|  | 106 | + | 
|  | 107 | +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, | 
|  | 108 | + | 
|  | 109 | +```javascript | 
|  | 110 | +var Float32Array = require( '@stdlib/array/float32' ); | 
|  | 111 | + | 
|  | 112 | +var AP = new Float32Array( [ 1.0, 2.0, 3.0, 1.0, 2.0, 1.0 ] ); | 
|  | 113 | +var x = new Float32Array( [ 3.0, 2.0, 1.0 ] ); | 
|  | 114 | + | 
|  | 115 | +sspr.ndarray( 'row-major', 'upper', 3, 1.0, x, -1, 2, AP, 1, 0 ); | 
|  | 116 | +// AP => <Float32Array>[ 2.0, 4.0, 6.0, 5.0, 8.0, 10.0 ] | 
|  | 117 | +``` | 
|  | 118 | + | 
|  | 119 | +</section> | 
|  | 120 | + | 
|  | 121 | +<!-- /.usage --> | 
|  | 122 | + | 
|  | 123 | +<section class="notes"> | 
|  | 124 | + | 
|  | 125 | +## Notes | 
|  | 126 | + | 
|  | 127 | +- `sspr()` corresponds to the [BLAS][blas] level 2 function [`sspr`][blas-sspr]. | 
|  | 128 | + | 
|  | 129 | +</section> | 
|  | 130 | + | 
|  | 131 | +<!-- /.notes --> | 
|  | 132 | + | 
|  | 133 | +<section class="examples"> | 
|  | 134 | + | 
|  | 135 | +## Examples | 
|  | 136 | + | 
|  | 137 | +<!-- eslint no-undef: "error" --> | 
|  | 138 | + | 
|  | 139 | +```javascript | 
|  | 140 | +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); | 
|  | 141 | +var sspr = require( '@stdlib/blas/base/sspr' ); | 
|  | 142 | + | 
|  | 143 | +var opts = { | 
|  | 144 | + 'dtype': 'float32' | 
|  | 145 | +}; | 
|  | 146 | + | 
|  | 147 | +var N = 5; | 
|  | 148 | + | 
|  | 149 | +var AP = discreteUniform( N * ( N + 1 ) / 2, -10.0, 10.0, opts ); | 
|  | 150 | +var x = discreteUniform( N, -10.0, 10.0, opts ); | 
|  | 151 | + | 
|  | 152 | +sspr( 'column-major', 'upper', N, 1.0, x, 1, AP ); | 
|  | 153 | +console.log( AP ); | 
|  | 154 | + | 
|  | 155 | +sspr.ndarray( 'column-major', 'upper', N, 1.0, x, 1, 0, AP, 1, 0 ); | 
|  | 156 | +console.log( AP ); | 
|  | 157 | +``` | 
|  | 158 | + | 
|  | 159 | +</section> | 
|  | 160 | + | 
|  | 161 | +<!-- /.examples --> | 
|  | 162 | + | 
|  | 163 | +<!-- C interface documentation. --> | 
|  | 164 | + | 
|  | 165 | +* * * | 
|  | 166 | + | 
|  | 167 | +<section class="c"> | 
|  | 168 | + | 
|  | 169 | +## C APIs | 
|  | 170 | + | 
|  | 171 | +<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> | 
|  | 172 | + | 
|  | 173 | +<section class="intro"> | 
|  | 174 | + | 
|  | 175 | +</section> | 
|  | 176 | + | 
|  | 177 | +<!-- /.intro --> | 
|  | 178 | + | 
|  | 179 | +<!-- C usage documentation. --> | 
|  | 180 | + | 
|  | 181 | +<section class="usage"> | 
|  | 182 | + | 
|  | 183 | +### Usage | 
|  | 184 | + | 
|  | 185 | +```c | 
|  | 186 | +TODO | 
|  | 187 | +``` | 
|  | 188 | + | 
|  | 189 | +#### TODO | 
|  | 190 | + | 
|  | 191 | +TODO. | 
|  | 192 | + | 
|  | 193 | +```c | 
|  | 194 | +TODO | 
|  | 195 | +``` | 
|  | 196 | + | 
|  | 197 | +TODO | 
|  | 198 | + | 
|  | 199 | +```c | 
|  | 200 | +TODO | 
|  | 201 | +``` | 
|  | 202 | + | 
|  | 203 | +</section> | 
|  | 204 | + | 
|  | 205 | +<!-- /.usage --> | 
|  | 206 | + | 
|  | 207 | +<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> | 
|  | 208 | + | 
|  | 209 | +<section class="notes"> | 
|  | 210 | + | 
|  | 211 | +</section> | 
|  | 212 | + | 
|  | 213 | +<!-- /.notes --> | 
|  | 214 | + | 
|  | 215 | +<!-- C API usage examples. --> | 
|  | 216 | + | 
|  | 217 | +<section class="examples"> | 
|  | 218 | + | 
|  | 219 | +### Examples | 
|  | 220 | + | 
|  | 221 | +```c | 
|  | 222 | +TODO | 
|  | 223 | +``` | 
|  | 224 | + | 
|  | 225 | +</section> | 
|  | 226 | + | 
|  | 227 | +<!-- /.examples --> | 
|  | 228 | + | 
|  | 229 | +</section> | 
|  | 230 | + | 
|  | 231 | +<!-- /.c --> | 
|  | 232 | + | 
|  | 233 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> | 
|  | 234 | + | 
|  | 235 | +<section class="related"> | 
|  | 236 | + | 
|  | 237 | +</section> | 
|  | 238 | + | 
|  | 239 | +<!-- /.related --> | 
|  | 240 | + | 
|  | 241 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> | 
|  | 242 | + | 
|  | 243 | +<section class="links"> | 
|  | 244 | + | 
|  | 245 | +[blas]: http://www.netlib.org/blas | 
|  | 246 | + | 
|  | 247 | +[blas-sspr]: https://www.netlib.org/lapack/explore-html/d5/df9/group__hpr_ga7cacbe603f23f8b0aca186fba51ad490.html#ga7cacbe603f23f8b0aca186fba51ad490 | 
|  | 248 | + | 
|  | 249 | +[mdn-float32array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array | 
|  | 250 | + | 
|  | 251 | +[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray | 
|  | 252 | + | 
|  | 253 | +</section> | 
|  | 254 | + | 
|  | 255 | +<!-- /.links --> | 
0 commit comments