Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
307 changes: 307 additions & 0 deletions lib/node_modules/@stdlib/blas/base/cgeru/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,307 @@
<!--

@license Apache-2.0

Copyright (c) 2026 The Stdlib Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->

# cgeru

> Perform the rank 1 operation `A = α*x*y^T + A`.

<section class="intro">

</section>

<!-- /.intro -->

<section class="usage">

## Usage

```javascript
var cgeru = require( '@stdlib/blas/base/cgeru' );
```

#### cgeru( ord, M, N, α, x, sx, y, sy, A, lda )

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.

<!-- eslint-disable max-len -->

```javascript
var Complex64Array = require( '@stdlib/array/complex64' );
var Complex64 = require( '@stdlib/complex/float32/ctor' );

var A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0 ] );
var x = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0 ] );
var y = new Complex64Array( [ 3.0, 3.0, 2.0, 2.0, 1.0, 1.0 ] );
var alpha = new Complex64( 0.5, 0.5 );

cgeru( 'row-major', 2, 3, alpha, x, 1, y, 1, A, 3 );
// A => <Complex64Array>[ -2.0, 4.0, 0.0, 4.0, 2.0, 4.0, -2.0, 10.0, 1.0, 9.0, 4.0, 8.0 ]
```

The function has the following parameters:

- **ord**: storage layout.
- **M**: number of rows in the matrix `A`.
- **N**: number of columns in the matrix `A`.
- **α**: scalar constant.
- **x**: an `M` element [`Complex64Array`][@stdlib/array/complex64].
- **sx**: stride length for `x`.
- **y**: an `N` element [`Complex64Array`][@stdlib/array/complex64].
- **sy**: stride length for `y`.
- **A**: input matrix stored in linear memory as a [`Complex64Array`][@stdlib/array/complex64].
- **lda**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`).

The stride parameters determine which elements in the strided arrays are accessed at runtime. For example, to iterate over every other element in `x` and `y`,

<!-- eslint-disable max-len -->

```javascript
var Complex64Array = require( '@stdlib/array/complex64' );
var Complex64 = require( '@stdlib/complex/float32/ctor' );

var A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0 ] );
var x = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 2.0, 2.0 ] );
var y = new Complex64Array( [ 3.0, 3.0, 0.0, 0.0, 2.0, 2.0, 0.0, 0.0, 1.0, 1.0 ] );
var alpha = new Complex64( 0.5, 0.5 );

cgeru( 'row-major', 2, 3, alpha, x, 2, y, 2, A, 3 );
// A => <Complex64Array>[ -2.0, 4.0, 0.0, 4.0, 2.0, 4.0, -2.0, 10.0, 1.0, 9.0, 4.0, 8.0 ]
```

Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views.

<!-- eslint-disable stdlib/capitalized-comments -->

<!-- eslint-disable max-len -->

```javascript
var Complex64Array = require( '@stdlib/array/complex64' );
var Complex64 = require( '@stdlib/complex/float32/ctor' );

// Initial arrays...
var x0 = new Complex64Array( [ 0.0, 0.0, 2.0, 2.0, 1.0, 1.0 ] );
var y0 = new Complex64Array( [ 0.0, 0.0, 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] );
var A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0 ] );

var alpha = new Complex64( 0.5, 0.5 );

// Create offset views...
var x1 = new Complex64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
var y1 = new Complex64Array( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); // start at 2nd element

cgeru( 'row-major', 2, 3, alpha, x1, -1, y1, -1, A, 3 );
// A => <Complex64Array>[ -2.0, 4.0, 0.0, 4.0, 2.0, 4.0, -2.0, 10.0, 1.0, 9.0, 4.0, 8.0 ]
```

#### cgeru.ndarray( M, N, α, x, sx, ox, y, sy, oy, A, sa1, sa2, oa )

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.

<!-- eslint-disable max-len -->

```javascript
var Complex64Array = require( '@stdlib/array/complex64' );
var Complex64 = require( '@stdlib/complex/float32/ctor' );

var A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0 ] );
var x = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0 ] );
var y = new Complex64Array( [ 3.0, 3.0, 2.0, 2.0, 1.0, 1.0 ] );

var alpha = new Complex64( 0.5, 0.5 );

cgeru.ndarray( 2, 3, alpha, x, 1, 0, y, 1, 0, A, 3, 1, 0 );
// A => <Complex64Array>[ -2.0, 4.0, 0.0, 4.0, 2.0, 4.0, -2.0, 10.0, 1.0, 9.0, 4.0, 8.0 ]
```

The function has the following additional parameters:

- **sa1**: stride of the first dimension of `A`.
- **sa2**: stride of the second dimension of `A`.
- **oa**: starting index for `A`.
- **ox**: starting index for `x`.
- **oy**: starting index for `y`.

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,

<!-- eslint-disable max-len -->

```javascript
var Complex64Array = require( '@stdlib/array/complex64' );
var Complex64 = require( '@stdlib/complex/float32/ctor' );

var A = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0 ] );
var x = new Complex64Array( [ 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 2.0, 2.0 ] );
var y = new Complex64Array( [ 0.0, 0.0, 3.0, 3.0, 0.0, 0.0, 2.0, 2.0, 0.0, 0.0, 1.0, 1.0 ] );
var alpha = new Complex64( 0.5, 0.5 );

cgeru.ndarray( 2, 3, alpha, x, 2, 1, y, 2, 1, A, 3, 1, 2 );
// A => <Complex64Array>[ 0.0, 0.0, 0.0, 0.0, -2.0, 4.0, 0.0, 4.0, 2.0, 4.0, -2.0, 10.0, 1.0, 9.0, 4.0, 8.0 ]
```

</section>

<!-- /.usage -->

<section class="notes">

## Notes

- `cgeru()` corresponds to the [BLAS][blas] level 2 function [`cgeru`][cgeru].

</section>

<!-- /.notes -->

<section class="examples">

## Examples

<!-- eslint no-undef: "error" -->

<!-- eslint-disable max-len -->

```javascript
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
var Complex64 = require( '@stdlib/complex/float32/ctor' );
var filledarrayBy = require( '@stdlib/array/filled-by' );
var logEach = require( '@stdlib/console/log-each' );
var cgeru = require( '@stdlib/blas/base/cgeru' );

function rand() {
return new Complex64( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) );
}

var M = 3;
var N = 3;

var x = filledarrayBy( N, 'complex64', rand );
var y = filledarrayBy( M, 'complex64', rand );
var A = filledarrayBy( M*N, 'complex64', rand );

var alpha = new Complex64( 0.5, 0.5 );

cgeru( 'row-major', M, N, alpha, x, 1, y, 1, A, N );

// Print the results:
logEach( '%s', A );

cgeru.ndarray( M, N, alpha, x, 1, 0, y, 1, 0, A, N, 1, 0 );

// Print the results:
logEach( '%s', A );
```

</section>

<!-- /.examples -->

<!-- C interface documentation. -->

* * *

<section class="c">

## C APIs

<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->

<section class="intro">

</section>

<!-- /.intro -->

<!-- C usage documentation. -->

<section class="usage">

### Usage

```c
TODO
```

#### TODO

TODO.

```c
TODO
```

TODO

```c
TODO
```

</section>

<!-- /.usage -->

<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="notes">

</section>

<!-- /.notes -->

<!-- C API usage examples. -->

<section class="examples">

### Examples

```c
TODO
```

</section>

<!-- /.examples -->

</section>

<!-- /.c -->

<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->

<section class="related">

</section>

<!-- /.related -->

<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="links">

[blas]: http://www.netlib.org/blas

[cgeru]: https://www.netlib.org/lapack/explore-html/d8/d75/group__ger_gae4b09e995412b77f425ceccc6a3801e3.html

[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray

[@stdlib/array/complex64]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/complex64

</section>

<!-- /.links -->
Loading