Skip to content

Commit 6fc0eaf

Browse files
committed
docs: add README
1 parent 6cdb5ff commit 6fc0eaf

File tree

1 file changed

+269
-0
lines changed
  • lib/node_modules/@stdlib/blas/base/sger

1 file changed

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

0 commit comments

Comments
 (0)