Skip to content

Commit 3e58da7

Browse files
committed
test: update implementation
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 74887f8 commit 3e58da7

29 files changed

+1017
-160
lines changed
Lines changed: 296 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,296 @@
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+
# cher2
22+
23+
> Perform the hermitian rank 1 operation `A = alpha*x*x**H + A`, where `alpha` is a real scalar, `X` is an `N` element vector and `A` is an `N` by `N` hermitian matrix.
24+
25+
<section class="usage">
26+
27+
## Usage
28+
29+
```javascript
30+
var cher2 = require( '@stdlib/blas/base/cher2' );
31+
```
32+
33+
#### cher2( order, uplo, N, α, x, strideX, y, strideY, A, LDA )
34+
35+
Performs the hermitian rank 1 operation `A = alpha*x*x**H + A`, where `alpha` is a real scalar, `X` is an `N` element vector and `A` is an `N` by `N` hermitian matrix.
36+
37+
```javascript
38+
var Complex64Array = require( '@stdlib/array/complex64' );
39+
var Complex64 = require( '@stdlib/complex/float32/ctor' );
40+
41+
var x = new Complex64Array( [ 1.0, 1.0, 1.0, 1.0 ] );
42+
var y = new Complex64Array( [ 1.0, 1.0, 1.0, 1.0 ] );
43+
var A = new Complex64Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 3.0, 4.0, 0.0 ] );
44+
var alpha = new Complex64( 1.0, 0.0 );
45+
46+
cher2( 'row-major', 'lower', x.length, alpha, x, 1, y, 1, A, 2 );
47+
// A => <Complex64Array>[ 5.0, 0.0, 0.0, 0.0, 6.0, 3.0, 8.0, 0.0 ]
48+
```
49+
50+
The function has the following parameters:
51+
52+
- **order**: storage layout.
53+
- **uplo**: specifies whether the upper or lower triangular part of the matrix `A` is supplied.
54+
- **N**: specifies the order of the matrix `A`.
55+
- **α**: scalar constant.
56+
- **x**: first input vector [`Complex64Array`][@stdlib/array/complex64].
57+
- **strideX**: index increment for `x`.
58+
- **y**: second input vector [`Complex64Array`][@stdlib/array/complex64].
59+
- **strideY**: index increment for `y`.
60+
- **A**: input matrix stored in linear memory as [`Complex64Array`][@stdlib/array/complex64].
61+
- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`).
62+
63+
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,
64+
65+
```javascript
66+
var Complex64Array = require( '@stdlib/array/complex64' );
67+
var Complex64 = require( '@stdlib/complex/float32/ctor' );
68+
69+
var x = new Complex64Array( [ 1.0, 1.0, 1.0, 1.0 ] );
70+
var y = new Complex64Array( [ 1.0, 1.0, 1.0, 1.0 ] );
71+
var A = new Complex64Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 3.0, 4.0, 0.0 ] );
72+
var alpha = new Complex64( 1.0, 0.0 );
73+
74+
cher2( 'row-major', 'lower', x.length, alpha, x, 1, y, 1, A, 2 );
75+
// A => <Complex64Array>[ 5.0, 0.0, 0.0, 0.0, 6.0, 3.0, 8.0, 0.0 ]
76+
```
77+
78+
Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views.
79+
80+
<!-- eslint-disable stdlib/capitalized-comments -->
81+
82+
```javascript
83+
var Complex64Array = require( '@stdlib/array/complex64' );
84+
var Complex64 = require( '@stdlib/complex/float32/ctor' );
85+
86+
// Initial array:
87+
var x0 = new Complex64Array( [ 0.0, 0.0, 1.0, 1.0, 1.0, 1.0 ] );
88+
var y0 = new Complex64Array( [ 0.0, 0.0, 1.0, 1.0, 1.0, 1.0 ] );
89+
90+
var alpha = new Complex64( 1.0, 0.0 );
91+
92+
// Define a input matrix:
93+
var A = new Complex64Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 3.0, 4.0, 0.0 ] );
94+
95+
// Create an offset view:
96+
var x1 = new Complex64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
97+
var y1 = new Complex64Array( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
98+
99+
cher2( 'row-major', 'lower', x1.length, alpha, x1, 1, y1, 1, A, 2 );
100+
// A => <Complex64Array>[ 5.0, 0.0, 0.0, 0.0, 6.0, 3.0, 8.0, 0.0 ]
101+
```
102+
103+
<!-- lint disable maximum-heading-length -->
104+
105+
#### cher2.ndarray( uplo, N, α, x, strideX, offsetX, y, strideY, offsetY, A, strideA1, strideA2, offsetA )
106+
107+
Performs the hermitian rank 1 operation `A = alpha*x*x**H + A`, where `alpha` is a real scalar, `X` is an `N` element vector and `A` is an `N` by `N` hermitian matrix using alternative indexing semantics.
108+
109+
```javascript
110+
var Complex64Array = require( '@stdlib/array/complex64' );
111+
var Complex64 = require( '@stdlib/complex/float32/ctor' );
112+
113+
var x = new Complex64Array( [ 1.0, 1.0, 1.0, 1.0 ] );
114+
var y = new Complex64Array( [ 1.0, 1.0, 1.0, 1.0 ] );
115+
var A = new Complex64Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 3.0, 4.0, 0.0 ] );
116+
var alpha = new Complex64( 1.0, 0.0 );
117+
118+
cher2.ndarray( 'lower', x.length, alpha, x, 1, 0, y, 1, 0, A, 2, 1, 0 );
119+
// A => <Complex64Array>[ 5.0, 0.0, 0.0, 0.0, 6.0, 3.0, 8.0, 0.0 ]
120+
```
121+
122+
The function has the following additional parameters:
123+
124+
- **strideA1**: stride of the first dimension of `A`.
125+
- **strideA2**: stride of the second dimension of `A`.
126+
- **offsetX**: starting index for `x`.
127+
- **offsetY**: starting index for `y`.
128+
- **offsetA**: starting index for `A`.
129+
130+
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to scale every other value in the input strided array starting from the second element,
131+
132+
```javascript
133+
var Complex64Array = require( '@stdlib/array/complex64' );
134+
var Complex64 = require( '@stdlib/complex/float32/ctor' );
135+
136+
var x = new Complex64Array( [ 1.0, 1.0, 1.0, 1.0 ] );
137+
var y = new Complex64Array( [ 1.0, 1.0, 1.0, 1.0 ] );
138+
var A = new Complex64Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 3.0, 4.0, 0.0 ] );
139+
var alpha = new Complex64( 1.0, 0.0 );
140+
141+
cher2.ndarray( 'lower', x.length, alpha, x, -1, 0, y, -1, 0, A, 2, 1, 0 );
142+
// A => <Complex64Array>[ 5.0, 0.0, 0.0, 0.0, 6.0, 3.0, 8.0, 0.0 ]
143+
```
144+
145+
</section>
146+
147+
<!-- /.usage -->
148+
149+
<section class="notes">
150+
151+
## Notes
152+
153+
- If `N = 0` or `realf( α ) = 0.0` or `imagf( α ) = 0.0`, both functions return `x` unchanged.
154+
- `cher2()` corresponds to the [BLAS][blas] level 2 function [`cher2`][cher2].
155+
156+
</section>
157+
158+
<!-- /.notes -->
159+
160+
<section class="examples">
161+
162+
## Examples
163+
164+
<!-- eslint no-undef: "error" -->
165+
166+
```javascript
167+
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
168+
var filledarrayBy = require( '@stdlib/array/filled-by' );
169+
var Complex64 = require( '@stdlib/complex/float32/ctor' );
170+
var logEach = require( '@stdlib/console/log-each' );
171+
var cher2 = require( '@stdlib/blas/base/cher2' );
172+
173+
function rand() {
174+
return new Complex64( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) );
175+
}
176+
177+
var x = filledarrayBy( 3, 'complex64', rand );
178+
console.log( x.get( 0 ).toString() );
179+
180+
var y = filledarrayBy( 3, 'complex64', rand );
181+
console.log( y.get( 0 ).toString() );
182+
183+
var A = filledarrayBy( 9, 'complex64', rand );
184+
console.log( A.get( 0 ).toString() );
185+
186+
var alpha = new Complex64( 2.0, 2.0 );
187+
console.log( alpha.toString() );
188+
189+
cher2( 'row-major', 'upper', 3, alpha, x, 1, y, 1, A, 3 );
190+
191+
// Print the results:
192+
logEach( '(%s)', A );
193+
194+
cher2.ndarray( 'upper', 3, alpha, x, 1, 0, y, 1, 0, A, 3, 1, 0 );
195+
196+
// Print the results:
197+
logEach( '(%s)', A );
198+
```
199+
200+
</section>
201+
202+
<!-- /.examples -->
203+
204+
<!-- C interface documentation. -->
205+
206+
* * *
207+
208+
<section class="c">
209+
210+
## C APIs
211+
212+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
213+
214+
<section class="intro">
215+
216+
</section>
217+
218+
<!-- /.intro -->
219+
220+
<!-- C usage documentation. -->
221+
222+
<section class="usage">
223+
224+
### Usage
225+
226+
```c
227+
TODO
228+
```
229+
230+
#### TODO
231+
232+
TODO.
233+
234+
```c
235+
TODO
236+
```
237+
238+
TODO
239+
240+
```c
241+
TODO
242+
```
243+
244+
</section>
245+
246+
<!-- /.usage -->
247+
248+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
249+
250+
<section class="notes">
251+
252+
</section>
253+
254+
<!-- /.notes -->
255+
256+
<!-- C API usage examples. -->
257+
258+
<section class="examples">
259+
260+
### Examples
261+
262+
```c
263+
TODO
264+
```
265+
266+
</section>
267+
268+
<!-- /.examples -->
269+
270+
</section>
271+
272+
<!-- /.c -->
273+
274+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
275+
276+
<section class="related">
277+
278+
</section>
279+
280+
<!-- /.related -->
281+
282+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
283+
284+
<section class="links">
285+
286+
[blas]: http://www.netlib.org/blas
287+
288+
[cher2]: https://www.netlib.org/lapack/explore-html/dd/de5/group__her2_gaf421f493e6422d08e3acfc6d33bfbf46.html
289+
290+
[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
291+
292+
[@stdlib/array/complex64]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/complex64
293+
294+
</section>
295+
296+
<!-- /.links -->

lib/node_modules/@stdlib/blas/base/cher2/docs/types/index.d.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020

2121
/// <reference types="@stdlib/types"/>
2222

23-
import Complex64 from '@stdlib/complex/float32/ctor';
2423
import { Complex64Array } from '@stdlib/types/array';
24+
import { Complex64 } from '@stdlib/types/complex';
2525
import { Layout, MatrixTriangle } from '@stdlib/types/blas';
2626

2727
/**
@@ -37,23 +37,23 @@ interface Routine {
3737
* @param alpha - scalar constant
3838
* @param x - first input array
3939
* @param strideX - `x` stride length
40-
* @param y - second input array
40+
* @param y - second input array
4141
* @param strideY - `y` stride length
4242
* @param A - input matrix
4343
* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`)
4444
* @returns input matrix
4545
*
4646
* @example
4747
* var Complex64Array = require( '@stdlib/array/complex64' );
48-
* var Complex64 = require( '@stdlib/complex/float32/ctor' );
49-
*
50-
* var x = new Complex64Array( [ 1.0, 1.0, 1.0, 1.0 ] );
51-
* var y = new Complex64Array( [ 1.0, 1.0, 1.0, 1.0 ] );
52-
* var A = new Complex64Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 3.0, 4.0, 0.0 ] );
53-
* var alpha = new Complex64( 1.0, 0.0 );
54-
*
55-
* cher2( 'lower', x.length, alpha, x, 1, y, 1, A, 2, 1 );
56-
* // A => <Complex64Array>[ 5.0, 0.0, 0.0, 0.0, 6.0, 3.0, 8.0, 0.0 ]
48+
* var Complex64 = require( '@stdlib/complex/float32/ctor' );
49+
*
50+
* var x = new Complex64Array( [ 1.0, 1.0, 1.0, 1.0 ] );
51+
* var y = new Complex64Array( [ 1.0, 1.0, 1.0, 1.0 ] );
52+
* var A = new Complex64Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 3.0, 4.0, 0.0 ] );
53+
* var alpha = new Complex64( 1.0, 0.0 );
54+
*
55+
* cher2( 'row-major', 'lower', x.length, alpha, x, 1, y, 1, A, 2 );
56+
* // A => <Complex64Array>[ 5.0, 0.0, 0.0, 0.0, 6.0, 3.0, 8.0, 0.0 ]
5757
*/
5858
( order: Layout, uplo: MatrixTriangle, N: number, alpha: Complex64, x: Complex64Array, strideX: number, y: Complex64Array, strideY: number, A: Complex64Array, LDA: number ): Complex64Array;
5959

@@ -66,7 +66,7 @@ interface Routine {
6666
* @param x - first input array
6767
* @param strideX - `x` stride length
6868
* @param offsetX - starting `x` index
69-
* @param y - second input array
69+
* @param y - second input array
7070
* @param strideY - `y` stride length
7171
* @param offsetY - starting `y` index
7272
* @param A - input matrix
@@ -77,15 +77,15 @@ interface Routine {
7777
*
7878
* @example
7979
* var Complex64Array = require( '@stdlib/array/complex64' );
80-
* var Complex64 = require( '@stdlib/complex/float32/ctor' );
81-
*
82-
* var x = new Complex64Array( [ 1.0, 1.0, 1.0, 1.0 ] );
83-
* var y = new Complex64Array( [ 1.0, 1.0, 1.0, 1.0 ] );
84-
* var A = new Complex64Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 3.0, 4.0, 0.0 ] );
85-
* var alpha = new Complex64( 1.0, 0.0 );
86-
*
87-
* cher2( 'lower', x.length, alpha, x, 1, 0, y, 1, 0, A, 2, 1, 0 );
88-
* // A => <Complex64Array>[ 5.0, 0.0, 0.0, 0.0, 6.0, 3.0, 8.0, 0.0 ]
80+
* var Complex64 = require( '@stdlib/complex/float32/ctor' );
81+
*
82+
* var x = new Complex64Array( [ 1.0, 1.0, 1.0, 1.0 ] );
83+
* var y = new Complex64Array( [ 1.0, 1.0, 1.0, 1.0 ] );
84+
* var A = new Complex64Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 3.0, 4.0, 0.0 ] );
85+
* var alpha = new Complex64( 1.0, 0.0 );
86+
*
87+
* cher2( 'lower', x.length, alpha, x, 1, 0, y, 1, 0, A, 2, 1, 0 );
88+
* // A => <Complex64Array>[ 5.0, 0.0, 0.0, 0.0, 6.0, 3.0, 8.0, 0.0 ]
8989
*/
9090
ndarray( uplo: MatrixTriangle, N: number, alpha: Complex64, x: Complex64Array, strideX: number, offsetX: number, y: Complex64Array, strideY: number, offsetY: number, A: Complex64Array, strideA1: number, strideA2: number, offsetA: number ): Complex64Array;
9191
}
@@ -114,7 +114,7 @@ interface Routine {
114114
* var A = new Complex64Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 3.0, 4.0, 0.0 ] );
115115
* var alpha = new Complex64( 1.0, 0.0 );
116116
*
117-
* cher2( 'lower', x.length, alpha, x, 1, y, 1, A, 2, 1 );
117+
* cher2( 'row-major', 'lower', x.length, alpha, x, 1, y, 1, A, 2 );
118118
* // A => <Complex64Array>[ 5.0, 0.0, 0.0, 0.0, 6.0, 3.0, 8.0, 0.0 ]
119119
*
120120
* @example

0 commit comments

Comments
 (0)