Skip to content
Closed
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
323 changes: 323 additions & 0 deletions lib/node_modules/@stdlib/lapack/base/zlacgv/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,323 @@
<!--

@license Apache-2.0

Copyright (c) 2025 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.

-->

# zlacgv

> Conjugates a complex vector.

<section class="usage">

## Usage

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

#### zlacgv( N, zx, strideX )

Conjugate values of `zx`.

```javascript
var Complex128Array = require( '@stdlib/array/complex128' );
var real = require( '@stdlib/complex/float64/real' );
var imag = require( '@stdlib/complex/float64/imag' );

var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] );

zlacgv( 4, zx, 0 );

var z = zx.get( 0 );
// returns <Complex128>

var re = real( z );
// returns 2.0

var im = imag( z );
// returns -2.0
```

The function has the following parameters:

- **N**: number of indexed elements.
- **zx**: input [`Complex128Array`][@stdlib/array/complex128].
- **strideX**: index increment for `zx`.

The `N` and stride parameters determine how values from `zx` conjugated. For example, to conjugate every other value in `zx`,

```javascript
var Complex128Array = require( '@stdlib/array/complex128' );
var real = require( '@stdlib/complex/float64/real' );
var imag = require( '@stdlib/complex/float64/imag' );

var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );

zlacgv( 2, zx, 1 );

var z = zx.get( 0 );
// returns <Complex128>

var re = imag( z );
// returns 3.0

var im = imag( z );
// returns -4.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 -->

```javascript
var Complex128Array = require( '@stdlib/array/complex128' );
var Complex128 = require( '@stdlib/complex/float64/ctor' );
var real = require( '@stdlib/complex/float64/real' );
var imag = require( '@stdlib/complex/float64/imag' );

// Initial array:
var zx0 = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );

// Create an offset view:
var zx1 = new Complex128Array( zx0.buffer, zx0.BYTES_PER_ELEMENT*1 ); // start at 2nd element

// Conjugates every other value from `zx1`...
zlacgv( 3, zx1, 1 );

var z = zx0.get( 1 );
// returns <Complex128>

var re = real( z );
// returns -2.0

var im = imag( z );
// returns 14.0
```

#### zlacgv.ndarray( N, zx, strideX, offsetX )

Conjugate values from `zx` using alternative indexing semantics.

```javascript
var Complex128Array = require( '@stdlib/array/complex128' );
var real = require( '@stdlib/complex/float64/real' );
var imag = require( '@stdlib/complex/float64/imag' );

var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );

zlacgv.ndarray( 3, zx, 1, 0 );

var z = zx.get( 0 );
// returns <Complex128>

var re = real( z );
// returns -2.0

var im = imag( z );
// returns 6.0
```

The function has the following additional parameters:

- **offsetX**: starting index for `zx`.

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 conjugate every other value in the input strided array starting from the second element,

```javascript
var Complex128Array = require( '@stdlib/array/complex128' );
var real = require( '@stdlib/complex/float64/real' );
var imag = require( '@stdlib/complex/float64/imag' );

var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );

zlacgv.ndarray( 2, zx, 2, 1 );

var z = zx.get( 3 );
// returns <Complex128>

var re = real( z );
// returns -2.0

var im = imag( z );
// returns 30.0
```

</section>

<!-- /.usage -->

<section class="notes">

## Notes

- If `N <= 0` or `strideX <= 0` , both functions return `zx` unchanged.
- `zlacgv()` corresponds to the [BLAS][blas] level 1 function [`zlacgv`][zlacgv].

</section>

<!-- /.notes -->

<section class="examples">

## Examples

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

```javascript
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
var filledarrayBy = require( '@stdlib/array/filled-by' );
var Complex128 = require( '@stdlib/complex/float64/ctor' );
var zlacgv = require( '@stdlib/blas/base/zlacgv' );

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

var zx = filledarrayBy( 10, 'complex128', rand );
console.log( zx.toString() );

// Conjugates elements from `zx`:
zlacgv( zx.length, zx, 1 );
console.log( zx.get( zx.length-1 ).toString() );
```

</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
#include "stdlib/blas/base/zlacgv.h"
```

#### c_zlacgv( N, \*ZX, strideX )

Conjugate values from `ZX`.

```c
double zx[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 };

c_zlacgv( 4, (void *)zx, 1 );
```

The function accepts the following arguments:

- **N**: `[in] CBLAS_INT` number of indexed elements.
- **ZX**: `[inout] void*` input array.
- **strideX**: `[in] CBLAS_INT` index increment for `ZX`.

```c
void c_zlacgv( const CBLAS_INT N, void *ZX, const CBLAS_INT strideX );
```

</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
#include "stdlib/blas/base/zlacgv.h"
#include <stdio.h>

int main( void ) {
// Create a strided array of interleaved real and imaginary components:
double zx[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 };

// Specify the number of elements:
const int N = 4;

// Specify stride length:
const int strideX = 1;

// Conjugate elements of the array:
c_zlacgv( N, (void *)zx, strideX );

// Print the result:
for ( int i = 0; i < N; i++ ) {
printf( "zx[ %i ] = %f + %fj\n", i, zx[ i*2 ], zx[ (i*2)+1 ] );
}
}
```

</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

[zlacgv]: https://www.netlib.org/lapack/explore-html/d9/d50/group__lacgv_gae42087fcabd33130fcbac2aff031de8b.html#gae42087fcabd33130fcbac2aff031de8b

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

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

[@stdlib/complex/float64/ctor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor

</section>

<!-- /.links -->
Loading
Loading