forked from stdlib-js/stdlib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR-URL: stdlib-js#4789 Ref: stdlib-js#2464 Co-authored-by: Athan Reines <[email protected]> Reviewed-by: Athan Reines <[email protected]>
- Loading branch information
1 parent
488e74a
commit ab035bc
Showing
16 changed files
with
3,398 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,333 @@ | ||
<!-- | ||
@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. | ||
--> | ||
|
||
# zlaset | ||
|
||
> Set the off-diagonal elements and the diagonal elements of a double-precision complex floating-point matrix to specified values. | ||
<section class="usage"> | ||
|
||
## Usage | ||
|
||
```javascript | ||
var zlaset = require( '@stdlib/lapack/base/zlaset' ); | ||
``` | ||
|
||
#### zlaset( order, uplo, M, N, alpha, beta, A, LDA ) | ||
|
||
Sets the off-diagonal elements and the diagonal elements of a double-precision complex floating-point matrix to specified values. | ||
|
||
```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' ); | ||
|
||
var A = new Complex128Array( 4 ); | ||
|
||
var alpha = new Complex128( 1.0, 2.0 ); | ||
var beta = new Complex128( 3.0, 4.0 ); | ||
|
||
zlaset( 'row-major', 'all', 2, 2, alpha, beta, A, 2 ); | ||
|
||
var z = A.get( 0 ); | ||
// returns <Complex128> | ||
|
||
var re = real( z ); | ||
// returns 3.0 | ||
|
||
var im = imag( z ); | ||
// returns 4.0 | ||
|
||
z = A.get( 1 ); | ||
// returns <Complex128> | ||
|
||
re = real( z ); | ||
// returns 1.0 | ||
|
||
im = imag( z ); | ||
// returns 2.0 | ||
``` | ||
|
||
The function has the following parameters: | ||
|
||
- **order**: storage layout. | ||
- **uplo**: specifies whether to set the upper or lower triangular/trapezoidal part of a matrix `A`. | ||
- **M**: number of rows in `A`. | ||
- **N**: number of columns in `A`. | ||
- **alpha**: value assigned to off-diagonal elements. | ||
- **beta**: value assigned to diagonal elements. | ||
- **A**: input [`Complex128Array`][@stdlib/array/complex128]. | ||
- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). | ||
|
||
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 A0 = new Complex128Array( 5 ); | ||
|
||
// Create offset view: | ||
var A1 = new Complex128Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 2nd element | ||
|
||
var alpha = new Complex128( 1.0, 2.0 ); | ||
var beta = new Complex128( 3.0, 4.0 ); | ||
|
||
zlaset( 'row-major', 'all', 2, 2, alpha, beta, A1, 2 ); | ||
|
||
var z = A0.get( 1 ); | ||
// returns <Complex128> | ||
|
||
var re = real( z ); | ||
// returns 3.0 | ||
|
||
var im = imag( z ); | ||
// returns 4.0 | ||
``` | ||
|
||
#### zlaset.ndarray( uplo, M, N, alpha, beta, A, sa1, sa2, oa ) | ||
|
||
Sets the off-diagonal elements and the diagonal elements of a double-precision complex floating-point matrix to specified values using alternative indexing semantics. | ||
|
||
```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' ); | ||
|
||
var A = new Complex128Array( 4 ); | ||
|
||
var alpha = new Complex128( 1.0, 2.0 ); | ||
var beta = new Complex128( 3.0, 4.0 ); | ||
|
||
zlaset.ndarray( 'all', 2, 2, alpha, beta, A, 2, 1, 0 ); | ||
|
||
var z = A.get( 0 ); | ||
// returns <Complex128> | ||
|
||
var re = real( z ); | ||
// returns 3.0 | ||
|
||
var im = imag( z ); | ||
// returns 4.0 | ||
|
||
z = A.get( 1 ); | ||
// returns <Complex128> | ||
|
||
re = real( z ); | ||
// returns 1.0 | ||
|
||
im = imag( z ); | ||
// returns 2.0 | ||
``` | ||
|
||
The function has the following parameters: | ||
|
||
- **uplo**: specifies whether to set the upper or lower triangular/trapezoidal part of a matrix `A`. | ||
- **M**: number of rows in `A`. | ||
- **N**: number of columns in `A`. | ||
- **alpha**: value assigned to off-diagonal elements. | ||
- **beta**: value assigned to diagonal elements. | ||
- **A**: input [`Complex128Array`][@stdlib/array/complex128]. | ||
- **sa1**: stride of the first dimension of `A`. | ||
- **sa2**: stride of the second dimension of `A`. | ||
- **oa**: starting index for `A`. | ||
|
||
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, | ||
|
||
```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' ); | ||
|
||
var A = new Complex128Array( 5 ); | ||
|
||
var alpha = new Complex128( 1.0, 2.0 ); | ||
var beta = new Complex128( 3.0, 4.0 ); | ||
|
||
zlaset.ndarray( 'all', 2, 2, alpha, beta, A, 2, 1, 1 ); | ||
|
||
var z = A.get( 0 ); | ||
// returns <Complex128> | ||
|
||
var re = real( z ); | ||
// returns 0.0 | ||
|
||
var im = imag( z ); | ||
// returns 0.0 | ||
|
||
z = A.get( 1 ); | ||
// returns <Complex128> | ||
|
||
re = real( z ); | ||
// returns 3.0 | ||
|
||
im = imag( z ); | ||
// returns 4.0 | ||
``` | ||
|
||
</section> | ||
|
||
<!-- /.usage --> | ||
|
||
<section class="notes"> | ||
|
||
## Notes | ||
|
||
- `zlaset()` corresponds to the [LAPACK][lapack] routine [`zlaset`][lapack-zlaset]. | ||
|
||
</section> | ||
|
||
<!-- /.notes --> | ||
|
||
<section class="examples"> | ||
|
||
## Examples | ||
|
||
<!-- eslint no-undef: "error" --> | ||
|
||
```javascript | ||
var Complex128Array = require( '@stdlib/array/complex128' ); | ||
var Complex128 = require( '@stdlib/complex/float64/ctor' ); | ||
var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); | ||
var numel = require( '@stdlib/ndarray/base/numel' ); | ||
var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); | ||
var zlaset = require( '@stdlib/lapack/base/zlaset' ); | ||
|
||
var shape = [ 5, 8 ]; | ||
var order = 'row-major'; | ||
var strides = shape2strides( shape, order ); | ||
|
||
var N = numel( shape ); | ||
|
||
var A = new Complex128Array( N ); | ||
console.log( ndarray2array( A, shape, strides, 0, order ) ); | ||
|
||
var alpha = new Complex128( 1.0, 2.0 ); | ||
var beta = new Complex128( 3.0, 4.0 ); | ||
|
||
zlaset( order, 'all', shape[ 0 ], shape[ 1 ], alpha, beta, A, strides[ 0 ] ); | ||
console.log( ndarray2array( A, shape, strides, 0, order ) ); | ||
``` | ||
|
||
</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"> | ||
|
||
[lapack]: https://www.netlib.org/lapack/explore-html/ | ||
|
||
[lapack-zlaset]: https://netlib.org/lapack/explore-html-3.6.1/d9/dd5/zlaset_8f_aa4389d0e0e031c70c351acf7dbad6a85.html#aa4389d0e0e031c70c351acf7dbad6a85 | ||
|
||
[@stdlib/array/complex128]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/complex128 | ||
|
||
[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray | ||
|
||
</section> | ||
|
||
<!-- /.links --> |
Oops, something went wrong.