@@ -37,12 +37,12 @@ Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`, where `α
3737``` javascript
3838var Float64Array = require ( ' @stdlib/array/float64' );
3939
40- var A = new Float64Array ( [ 1.0 , 2.0 , 3.0 , 0 .0 , 1.0 , 2.0 , 0 .0 , 0 .0 , 1.0 ] );
40+ var A = new Float64Array ( [ 1.0 , 2.0 , 3.0 , 2 .0 , 1.0 , 2.0 , 3 .0 , 2 .0 , 1.0 ] );
4141var x = new Float64Array ( [ 1.0 , 2.0 , 3.0 ] );
4242var y = new Float64Array ( [ 1.0 , 2.0 , 3.0 ] );
4343
4444dsyr2 ( ' row-major' , ' upper' , 3 , 1.0 , x, 1 , y, 1 , A , 3 );
45- // A => <Float64Array>[ 3.0, 6.0, 9.0, 0 .0, 9.0, 14.0, 0 .0, 0 .0, 19.0 ]
45+ // A => <Float64Array>[ 3.0, 6.0, 9.0, 2 .0, 9.0, 14.0, 3 .0, 2 .0, 19.0 ]
4646```
4747
4848The function has the following parameters:
@@ -52,9 +52,9 @@ The function has the following parameters:
5252- ** N** : number of elements along each dimension of ` A ` .
5353- ** α** : scalar constant.
5454- ** x** : first input [ ` Float64Array ` ] [ mdn-float64array ] .
55- - ** sx** : index increment for ` x ` .
55+ - ** sx** : stride length for ` x ` .
5656- ** y** : second input [ ` Float64Array ` ] [ mdn-float64array ] .
57- - ** sy** : index increment for ` y ` .
57+ - ** sy** : stride length for ` y ` .
5858- ** A** : input matrix stored in linear memory as a [ ` Float64Array ` ] [ mdn-float64array ] .
5959- ** lda** : stride of the first dimension of ` A ` (a.k.a., leading dimension of the matrix ` A ` ).
6060
@@ -63,12 +63,12 @@ The stride parameters determine how elements in the input arrays are accessed at
6363``` javascript
6464var Float64Array = require ( ' @stdlib/array/float64' );
6565
66- var A = new Float64Array ( [ 1.0 , 2.0 , 3.0 , 0 .0 , 1.0 , 2.0 , 0 .0 , 0 .0 , 1.0 ] );
66+ var A = new Float64Array ( [ 1.0 , 2.0 , 3.0 , 2 .0 , 1.0 , 2.0 , 3 .0 , 2 .0 , 1.0 ] );
6767var x = new Float64Array ( [ 1.0 , 2.0 , 3.0 , 4.0 , 5.0 ] );
6868var y = new Float64Array ( [ 1.0 , 2.0 , 3.0 ] );
6969
7070dsyr2 ( ' row-major' , ' upper' , 3 , 1.0 , x, 2 , y, 1 , A , 3 );
71- // A => <Float64Array>[ 3.0, 7.0, 11.0, 0 .0, 13.0, 21.0, 0 .0, 0 .0, 31.0 ]
71+ // A => <Float64Array>[ 3.0, 7.0, 11.0, 2 .0, 13.0, 21.0, 3 .0, 2 .0, 31.0 ]
7272```
7373
7474Note that indexing is relative to the first index. To introduce an offset, use [ ` typed array ` ] [ mdn-typed-array ] views.
@@ -81,14 +81,14 @@ var Float64Array = require( '@stdlib/array/float64' );
8181// Initial arrays...
8282var x0 = new Float64Array ( [ 0.0 , 1.0 , 1.0 , 1.0 ] );
8383var y0 = new Float64Array ( [ 0.0 , 1.0 , 2.0 , 3.0 ] );
84- var A = new Float64Array ( [ 1.0 , 2.0 , 3.0 , 0 .0 , 1.0 , 2.0 , 0 .0 , 0 .0 , 1.0 ] );
84+ var A = new Float64Array ( [ 1.0 , 2.0 , 3.0 , 2 .0 , 1.0 , 2.0 , 3 .0 , 2 .0 , 1.0 ] );
8585
8686// Create offset views...
8787var x1 = new Float64Array ( x0 .buffer , x0 .BYTES_PER_ELEMENT * 1 ); // start at 2nd element
8888var y1 = new Float64Array ( y0 .buffer , y0 .BYTES_PER_ELEMENT * 1 ); // start at 2nd element
8989
9090dsyr2 ( ' row-major' , ' upper' , 3 , 1.0 , x1, 1 , y1, 1 , A , 3 );
91- // A => <Float64Array>[ 3.0, 5.0, 7.0, 0 .0, 5.0, 7.0, 0 .0, 0 .0, 7.0 ]
91+ // A => <Float64Array>[ 3.0, 5.0, 7.0, 2 .0, 5.0, 7.0, 3 .0, 2 .0, 7.0 ]
9292```
9393
9494#### dsyr2.ndarray( uplo, N, α, x, sx, ox, y, sy, oy, A, sa1, sa2, oa )
@@ -98,12 +98,12 @@ Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`, using alt
9898``` javascript
9999var Float64Array = require ( ' @stdlib/array/float64' );
100100
101- var A = new Float64Array ( [ 1.0 , 2.0 , 3.0 , 0 .0 , 1.0 , 2.0 , 0 .0 , 0 .0 , 1.0 ] );
101+ var A = new Float64Array ( [ 1.0 , 2.0 , 3.0 , 2 .0 , 1.0 , 2.0 , 3 .0 , 2 .0 , 1.0 ] );
102102var x = new Float64Array ( [ 1.0 , 2.0 , 3.0 ] );
103103var y = new Float64Array ( [ 1.0 , 2.0 , 3.0 ] );
104104
105105dsyr2 .ndarray ( ' upper' , 3 , 1.0 , x, 1 , 0 , y, 1 , 0 , A , 3 , 1 , 0 );
106- // A => <Float64Array>[ 3.0, 6.0, 9.0, 0 .0, 9.0, 14.0, 0 .0, 0 .0, 19.0 ]
106+ // A => <Float64Array>[ 3.0, 6.0, 9.0, 2 .0, 9.0, 14.0, 3 .0, 2 .0, 19.0 ]
107107```
108108
109109The function has the following additional parameters:
@@ -119,12 +119,12 @@ While [`typed array`][mdn-typed-array] views mandate a view offset based on the
119119``` javascript
120120var Float64Array = require ( ' @stdlib/array/float64' );
121121
122- var A = new Float64Array ( [ 1.0 , 2.0 , 3.0 , 0 .0 , 1.0 , 2.0 , 0 .0 , 0 .0 , 1.0 ] );
122+ var A = new Float64Array ( [ 1.0 , 2.0 , 3.0 , 2 .0 , 1.0 , 2.0 , 3 .0 , 2 .0 , 1.0 ] );
123123var x = new Float64Array ( [ 1.0 , 2.0 , 3.0 , 4.0 , 5.0 ] );
124124var y = new Float64Array ( [ 1.0 , 2.0 , 3.0 ] );
125125
126126dsyr2 .ndarray ( ' upper' , 3 , 1.0 , x, - 2 , 4 , y, 1 , 0 , A , 3 , 1 , 0 );
127- // A => <Float64Array>[ 11.0, 15.0, 19.0, 0 .0, 13.0, 13.0, 0 .0, 0 .0, 7.0 ]
127+ // A => <Float64Array>[ 11.0, 15.0, 19.0, 2 .0, 13.0, 13.0, 3 .0, 2 .0, 7.0 ]
128128```
129129
130130</section >
@@ -158,12 +158,19 @@ var opts = {
158158
159159var N = 3 ;
160160
161- var A = ones ( N * N , opts .dtype );
161+ // Create N-by-N symmetric matrices:
162+ var A1 = ones ( N * N , opts .dtype );
163+ var A2 = ones ( N * N , opts .dtype );
164+
165+ // Create random vectors:
162166var x = discreteUniform ( N , - 10.0 , 10.0 , opts );
163167var y = discreteUniform ( N , - 10.0 , 10.0 , opts );
164168
165- dsyr2 ( ' row-major' , ' upper' , 3 , 1.0 , x, 1 , y, 1 , A , 3 );
166- console .log ( A );
169+ dsyr2 ( ' row-major' , ' upper' , 3 , 1.0 , x, 1 , y, 1 , A1 , 3 );
170+ console .log ( A1 );
171+
172+ dsyr2 .ndarray ( ' upper' , 3 , 1.0 , x, 1 , 0 , y, 1 , 0 , A2 , 3 , 1 , 0 );
173+ console .log ( A2 );
167174```
168175
169176</section >
@@ -193,21 +200,74 @@ console.log( A );
193200### Usage
194201
195202``` c
196- TODO
203+ #include " stdlib/blas/base/dsyr2.h"
204+ ```
205+
206+ #### c_dsyr2( order, uplo, N, alpha, \* X, sx, \* Y, sy, \* A, LDA )
207+
208+ Performs the symmetric rank 2 operation ` A = α*x*y^T + α*y*x^T + A ` where ` α ` is a scalar, ` x ` and ` y ` are ` N ` element vectors, and ` A ` is an ` N ` by ` N ` symmetric matrix.
209+
210+ ``` c
211+ #include " stdlib/blas/base/shared.h"
212+
213+ double A[] = { 1.0, 2.0, 3.0, 2.0, 1.0, 2.0, 3.0, 2.0, 1.0 };
214+ const double x[ ] = { 1.0, 2.0, 3.0 };
215+ const double y[ ] = { 1.0, 2.0, 3.0 };
216+
217+ c_dsyr2 ( CblasColMajor, CblasUpper, 3, 1.0, x, 1, y, 1, A, 3 );
197218```
198219
199- #### TODO
220+ The function accepts the following arguments:
200221
201- TODO.
222+ - **order**: `[in] CBLAS_LAYOUT` storage layout.
223+ - **uplo**: `[in] CBLAS_UPLO` specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced.
224+ - **N**: `[in] CBLAS_INT` number of elements along each dimension of `A`.
225+ - **alpha**: `[in] double` scalar constant.
226+ - **X**: `[in] double*` first input array.
227+ - **strideX**: `[in] CBLAS_INT` stride length for `X`.
228+ - **Y**: `[in] double*` second input array.
229+ - **strideY**: `[in] CBLAS_INT` stride length for `Y`.
230+ - **A**: `[inout] double*` input matrix.
231+ - **LDA**: `[in] CBLAS_INT` stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`).
202232
203233```c
204- TODO
234+ void c_dsyr2( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY, double *A, const CBLAS_INT LDA )
235+ ```
236+
237+ <!-- lint disable maximum-heading-length -->
238+
239+ #### c_dsyr2_ndarray( uplo, N, alpha, \* X, sx, ox, \* Y, sy, oy, \* A, sa1, sa2, oa )
240+
241+ Performs the symmetric rank 2 operation ` A = α*x*y^T + α*y*x^T + A ` , using alternative indexing semantics and where ` α ` is a scalar, ` x ` and ` y ` are ` N ` element vectors, and ` A ` is an ` N ` by ` N ` symmetric matrix.
242+
243+ ``` c
244+ #include " stdlib/blas/base/shared.h"
245+
246+ double A[] = { 1.0, 2.0, 3.0, 2.0, 1.0, 2.0, 3.0, 2.0, 1.0 };
247+ const double x[ ] = { 1.0, 2.0, 3.0 };
248+ const double y[ ] = { 1.0, 2.0, 3.0 };
249+
250+ c_dsyr2_ndarray ( CblasUpper, 3, 1.0, x, 1, 0, y, 1, 0, A, 3, 1, 0 );
205251```
206252
207- TODO
253+ The function accepts the following arguments:
254+
255+ - **uplo**: `[in] CBLAS_UPLO` specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced.
256+ - **N**: `[in] CBLAS_INT` number of elements along each dimension of `A`.
257+ - **alpha**: `[in] double` scalar constant.
258+ - **X**: `[in] double*` first input array.
259+ - **sx**: `[in] CBLAS_INT` stride length for `X`.
260+ - **ox**: `[in] CBLAS_INT` starting index for `X`.
261+ - **Y**: `[in] double` second input array.
262+ - **sy**: `[in] CBLAS_INT` stride length for `Y`.
263+ - **oy**: `[in] CBLAS_INT` starting index for `Y`.
264+ - **A**: `[inout] double*` input matrix.
265+ - **sa1**: `[in] CBLAS_INT` stride of the first dimension of `A`.
266+ - **sa2**: `[in] CBLAS_INT` stride of the second dimension of `A`.
267+ - **oa**: `[in] CBLAS_INT` starting index for `A`.
208268
209269```c
210- TODO
270+ void c_dsyr2_ndarray( const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const double *Y, CBLAS_INT strideY, const CBLAS_INT offsetY, double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA )
211271```
212272
213273</section >
@@ -229,7 +289,47 @@ TODO
229289### Examples
230290
231291``` c
232- TODO
292+ #include " stdlib/blas/base/dsyr2.h"
293+ #include " stdlib/blas/base/shared.h"
294+ #include < stdio.h>
295+
296+ int main ( void ) {
297+ // Define 3x3 symmetric matrices stored in row-major layout:
298+ double A1[ 3* 3 ] = {
299+ 1.0, 2.0, 3.0,
300+ 2.0, 1.0, 2.0,
301+ 3.0, 2.0, 1.0
302+ };
303+
304+ double A2[ 3*3 ] = {
305+ 1.0, 2.0, 3.0,
306+ 2.0, 1.0, 2.0,
307+ 3.0, 2.0, 1.0
308+ };
309+
310+ // Define `x` and `y` vectors:
311+ const double x[ 3 ] = { 1.0, 2.0, 3.0 };
312+ const double y[ 3 ] = { 1.0, 2.0, 3.0 };
313+
314+ // Specify the number of elements along each dimension of `A1` and `A2`:
315+ const int N = 3;
316+
317+ // Perform the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`:
318+ c_dsyr2( CblasColMajor, CblasUpper, N, 1.0, x, 1, y, 1, A1, N );
319+
320+ // Print the result:
321+ for ( int i = 0; i < N*N; i++ ) {
322+ printf( "A1[ %i ] = %lf\n", i, A1[ i ] );
323+ }
324+
325+ // Perform the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` using alternative indexing semantics:
326+ c_dsyr2_ndarray( CblasUpper, N, 1.0, x, 1, 0, y, 1, 0, A2, N, 1, 0 );
327+
328+ // Print the result:
329+ for ( int i = 0; i < N*N; i++ ) {
330+ printf( "A2[ %i ] = %lf\n", i, A2[ i ] );
331+ }
332+ }
233333```
234334
235335</section>
0 commit comments