Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Sep 16, 2024
1 parent f4d3ada commit 05fb4ab
Show file tree
Hide file tree
Showing 37 changed files with 3,813 additions and 16 deletions.
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@

##### Features

- [`7e11338`](https://github.com/stdlib-js/stdlib/commit/7e11338ae6642c1389e51557262710bd6ebe44aa) - add `blas/ext/base/zfill` [(#2907)](https://github.com/stdlib-js/stdlib/pull/2907)
- [`fadff3a`](https://github.com/stdlib-js/stdlib/commit/fadff3a44660678d9ccce8bb101f579ca1913a64) - add `blas/ext/base/cfill` [(#2901)](https://github.com/stdlib-js/stdlib/pull/2901)

</section>
Expand All @@ -254,6 +255,28 @@

<!-- /.package -->

<section class="package" id="blas-ext-base-zfill-unreleased">

#### [@stdlib/blas/ext/base/zfill](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/blas/ext/base/zfill)

<details>

<section class="features">

##### Features

- [`7e11338`](https://github.com/stdlib-js/stdlib/commit/7e11338ae6642c1389e51557262710bd6ebe44aa) - add `blas/ext/base/zfill` [(#2907)](https://github.com/stdlib-js/stdlib/pull/2907)

</section>

<!-- /.features -->

</details>

</section>

<!-- /.package -->

<section class="package" id="blas-sdot-unreleased">

#### [@stdlib/blas/sdot](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/blas/sdot)
Expand Down Expand Up @@ -359,6 +382,7 @@ A total of 6 people contributed to this release. Thank you to the following cont

<details>

- [`7e11338`](https://github.com/stdlib-js/stdlib/commit/7e11338ae6642c1389e51557262710bd6ebe44aa) - **feat:** add `blas/ext/base/zfill` [(#2907)](https://github.com/stdlib-js/stdlib/pull/2907) _(by Muhammad Haris, Athan Reines)_
- [`edcea47`](https://github.com/stdlib-js/stdlib/commit/edcea4761bc3065f9c5218c162b38ebec4a6c423) - **feat:** add C `ndarray` implementation for `blas/base/sswap` and `blas/base/dswap` [(#2905)](https://github.com/stdlib-js/stdlib/pull/2905) _(by Aman Bhansali, Athan Reines)_
- [`6c769ad`](https://github.com/stdlib-js/stdlib/commit/6c769ad65cf528389012efc400b29b6e57a4f352) - **fix:** update error message _(by Athan Reines)_
- [`a90c34d`](https://github.com/stdlib-js/stdlib/commit/a90c34d316f09ce5dfe165439fbcb2785fcea5a0) - **fix:** update error message _(by Athan Reines)_
Expand Down
2 changes: 1 addition & 1 deletion ext/base/cfill/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ var Complex64 = require( '@stdlib/complex/float32/ctor' );
var realf = require( '@stdlib/complex/float32/real' );
var imagf = require( '@stdlib/complex/float32/imag' );

// Create the underlying floating-point array
// Create the underlying floating-point array:
var arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );

// Initial array:
Expand Down
28 changes: 14 additions & 14 deletions ext/base/cfill/docs/repl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@
-5.0

// Using `N` and stride parameters:
> var x = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
> var alpha = new {{alias:@stdlib/complex/float32/ctor}}( 5.0, -5.0 );
> x = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
> alpha = new {{alias:@stdlib/complex/float32/ctor}}( 5.0, -5.0 );
> {{alias}}( 2, alpha, x, 2 );
> var z = x.get( 0 );
> var re = {{alias:@stdlib/complex/float32/real}}( z )
> z = x.get( 0 );
> re = {{alias:@stdlib/complex/float32/real}}( z )
5.0
> var im = {{alias:@stdlib/complex/float32/imag}}( z )
> im = {{alias:@stdlib/complex/float32/imag}}( z )
-5.0
> z = x.get( 1 );
> re = {{alias:@stdlib/complex/float32/real}}( z )
Expand All @@ -60,12 +60,12 @@
// Using view offsets:
> var x0 = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
> var x1 = new {{alias:@stdlib/array/complex64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
> var alpha = new {{alias:@stdlib/complex/float32/ctor}}( 5.0, -5.0 );
> alpha = new {{alias:@stdlib/complex/float32/ctor}}( 5.0, -5.0 );
> {{alias}}( 2, alpha, x1, 1 );
> var z = x0.get( 0 );
> var re = {{alias:@stdlib/complex/float32/real}}( z )
> z = x0.get( 0 );
> re = {{alias:@stdlib/complex/float32/real}}( z )
1.0
> var im = {{alias:@stdlib/complex/float32/imag}}( z )
> im = {{alias:@stdlib/complex/float32/imag}}( z )
2.0
> z = x0.get( 1 );
> re = {{alias:@stdlib/complex/float32/real}}( z )
Expand Down Expand Up @@ -117,13 +117,13 @@
2.0

// Using an index offset:
> var x = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
> var alpha = new {{alias:@stdlib/complex/float32/ctor}}( 5.0, -5.0 );
> x = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
> alpha = new {{alias:@stdlib/complex/float32/ctor}}( 5.0, -5.0 );
> {{alias}}.ndarray( 2, alpha, x, 2, 1 );
> var z = x.get( 0 );
> var re = {{alias:@stdlib/complex/float32/real}}( z )
> z = x.get( 0 );
> re = {{alias:@stdlib/complex/float32/real}}( z )
1.0
> var im = {{alias:@stdlib/complex/float32/imag}}( z )
> im = {{alias:@stdlib/complex/float32/imag}}( z )
2.0
> z = x.get( 1 );
> re = {{alias:@stdlib/complex/float32/real}}( z )
Expand Down
2 changes: 1 addition & 1 deletion ext/base/cfill/lib/ndarray.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var addon = require( './cfill.native.js' );
* Fills a single-precision complex floating-point strided array with a specified scalar constant.
*
* @param {PositiveInteger} N - number of indexed elements
* @param {number} alpha - scalar constant
* @param {ComplexLike} alpha - scalar constant
* @param {Complex64Array} x - input array
* @param {integer} stride - index increment
* @param {NonNegativeInteger} offset - starting index
Expand Down
281 changes: 281 additions & 0 deletions ext/base/zfill/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,281 @@
<!--
@license Apache-2.0
Copyright (c) 2024 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.
-->

# zfill

> Fill a double-precision complex floating-point strided array with a specified scalar constant.
<section class="usage">

## Usage

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

#### zfill( N, alpha, x, stride )

Fills a double-precision complex floating-point strided array `x` with a specified scalar constant `alpha`.

```javascript
var Float64Array = require( '@stdlib/array/float64' );
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 arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
var x = new Complex128Array( arr );

var alpha = new Complex128( 10.0, 10.0 );

zfill( x.length, alpha, x, 1 );

var y = x.get( 0 );
// returns <Complex128>

var re = real( y );
// returns 10.0

var im = imag( y );
// returns 10.0
```

The function has the following parameters:

- **N**: number of indexed elements.
- **alpha**: scalar constant.
- **x**: input [`Complex128Array`][@stdlib/array/complex128].
- **stride**: index increment.

The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to fill every other element

```javascript
var Float64Array = require( '@stdlib/array/float64' );
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 arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
var x = new Complex128Array( arr );

var alpha = new Complex128( 10.0, 10.0 );

zfill( 2, alpha, x, 2 );

var y = x.get( 0 );
// returns <Complex128>

var re = real( y );
// returns 10.0

var im = imag( y );
// returns 10.0

y = x.get( 1 );
// returns <Complex128>

re = real( y );
// returns 3.0

im = imag( y );
// returns 4.0
```

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

```javascript
var Float64Array = require( '@stdlib/array/float64' );
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' );

// Create the underlying floating-point array:
var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );

// Initial array:
var x0 = new Complex128Array( arr );

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

// Define a scalar constant:
var alpha = new Complex128( 10.0, 10.0 );

// Fill every other element:
zfill( 2, alpha, x1, 2 );

var y = x0.get( 0 );
// returns <Complex128>

var re = real( y );
// returns 1.0

var im = imag( y );
// returns 2.0

y = x0.get( 1 );
// returns <Complex128>

re = real( y );
// returns 10.0

im = imag( y );
// returns 10.0
```

#### zfill.ndarray( N, alpha, x, stride, offset )

Fills a double-precision complex floating-point strided array `x` with a specified scalar constant `alpha` using alternative indexing semantics.

```javascript
var Float64Array = require( '@stdlib/array/float64' );
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 arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
var x = new Complex128Array( arr );

var alpha = new Complex128( 10.0, 10.0 );

zfill.ndarray( x.length, alpha, x, 1, 0 );

var y = x.get( 0 );
// returns <Complex128>

var re = real( y );
// returns 10.0

var im = imag( y );
// returns 10.0
```

The function has the following additional parameters:

- **offset**: starting index.

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 access only the last two elements of the strided array

```javascript
var Float64Array = require( '@stdlib/array/float64' );
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 arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
var x = new Complex128Array( arr );

var alpha = new Complex128( 10.0, 10.0 );

zfill.ndarray( 2, alpha, x, 1, x.length-2 );

var y = x.get( 0 );
// returns <Complex128>

var re = real( y );
// returns 1.0

var im = imag( y );
// returns 2.0

y = x.get( 1 );
// returns <Complex128>

re = real( y );
// returns 10.0

im = imag( y );
// returns 10.0

y = x.get( 2 );
// returns <Complex128>

re = real( y );
// returns 10.0

im = imag( y );
// returns 10.0
```

</section>

<!-- /.usage -->

<section class="notes">

## Notes

- If `N <= 0`, both functions return the strided array unchanged.

</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 zfill = require( '@stdlib/blas/ext/base/zfill' );

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

var x = filledarrayBy( 10, 'complex128', rand );
var alpha = new Complex128( 10.0, 10.0 );

zfill( x.length, alpha, x, 1 );
console.log( x.get( 0 ).toString() );
```

</section>

<!-- /.examples -->

<!-- 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">

[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128

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

</section>

<!-- /.links -->
Loading

0 comments on commit 05fb4ab

Please sign in to comment.