Skip to content

Commit 46a3db3

Browse files
committed
Auto-generated commit
1 parent d1a8eba commit 46a3db3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+3881
-251
lines changed

CHANGELOG.md

+29-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
<section class="release" id="unreleased">
66

7-
## Unreleased (2024-12-30)
7+
## Unreleased (2024-12-31)
88

99
<section class="packages">
1010

@@ -86,6 +86,7 @@
8686

8787
##### Features
8888

89+
- [`1ddeba9`](https://github.com/stdlib-js/stdlib/commit/1ddeba98295bb53fb8098d1016f0de4b7f544e96) - add `scalar2ndarrayLike` to namespace
8990
- [`58e795d`](https://github.com/stdlib-js/stdlib/commit/58e795db467b7bd1d3dc6c5847f91a97fed2ccff) - update namespace TypeScript declarations [(#3937)](https://github.com/stdlib-js/stdlib/pull/3937)
9091
- [`14427c7`](https://github.com/stdlib-js/stdlib/commit/14427c79bc62f82b16cbadc9d34749901e48d105) - add `fill`, `map`, and `toReversed` to namespace
9192
- [`a0d6619`](https://github.com/stdlib-js/stdlib/commit/a0d66193409576538d0f16aa89cbaeedec7898be) - add `minSignedIntegerDataType` and `minUnsignedIntegerDataType` to namespace
@@ -170,6 +171,28 @@
170171

171172
<!-- /.package -->
172173

174+
<section class="package" id="ndarray-base-from-scalar-like-unreleased">
175+
176+
#### [@stdlib/ndarray/base/from-scalar-like](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/from-scalar-like)
177+
178+
<details>
179+
180+
<section class="features">
181+
182+
##### Features
183+
184+
- [`b2dcaa0`](https://github.com/stdlib-js/stdlib/commit/b2dcaa0d97eeb11585ab4cae5b7c319308e6b3c2) - add `ndarray/base/from-scalar-like`
185+
186+
</section>
187+
188+
<!-- /.features -->
189+
190+
</details>
191+
192+
</section>
193+
194+
<!-- /.package -->
195+
173196
<section class="package" id="ndarray-base-map-unreleased">
174197

175198
#### [@stdlib/ndarray/base/map](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/map)
@@ -435,6 +458,7 @@
435458

436459
##### Features
437460

461+
- [`259b682`](https://github.com/stdlib-js/stdlib/commit/259b682b2fb67d03e2987ca02b57d0cbc631ae8e) - add support for specifying an array index cache and add support for linear indexing
438462
- [`fb1ca76`](https://github.com/stdlib-js/stdlib/commit/fb1ca76ccf2f324c45b24411aa3fd1088a7a7b6e) - add `ndarray/to-fancy`
439463

440464
</section>
@@ -505,9 +529,13 @@ A total of 3 people contributed to this release. Thank you to the following cont
505529

506530
<details>
507531

532+
- [`259b682`](https://github.com/stdlib-js/stdlib/commit/259b682b2fb67d03e2987ca02b57d0cbc631ae8e) - **feat:** add support for specifying an array index cache and add support for linear indexing _(by Athan Reines)_
533+
- [`1ddeba9`](https://github.com/stdlib-js/stdlib/commit/1ddeba98295bb53fb8098d1016f0de4b7f544e96) - **feat:** add `scalar2ndarrayLike` to namespace _(by Athan Reines)_
534+
- [`b2dcaa0`](https://github.com/stdlib-js/stdlib/commit/b2dcaa0d97eeb11585ab4cae5b7c319308e6b3c2) - **feat:** add `ndarray/base/from-scalar-like` _(by Athan Reines)_
508535
- [`4301694`](https://github.com/stdlib-js/stdlib/commit/43016945387e02d6396d33cb7134c62c977b7fd8) - **docs:** update related packages sections [(#4362)](https://github.com/stdlib-js/stdlib/pull/4362) _(by stdlib-bot)_
509536
- [`cdf5e79`](https://github.com/stdlib-js/stdlib/commit/cdf5e79d125ce5da53cfa18df6ffbe2df5fe4d9f) - **docs:** update namespace table of contents [(#4365)](https://github.com/stdlib-js/stdlib/pull/4365) _(by stdlib-bot)_
510537
- [`25d8240`](https://github.com/stdlib-js/stdlib/commit/25d8240f51b27bd0ee85ca3ef70c89fd3778b902) - **feat:** update namespace TypeScript declarations [(#4363)](https://github.com/stdlib-js/stdlib/pull/4363) _(by stdlib-bot)_
538+
- [`7dc5c14`](https://github.com/stdlib-js/stdlib/commit/7dc5c14b995c7c4bd286087d04a20497057c0e71) - **refactor:** use assertion utility _(by Athan Reines)_
511539
- [`44547ea`](https://github.com/stdlib-js/stdlib/commit/44547ead986e505d5fdffac47d44cd1d18480f8c) - **feat:** add `ndarray2fancy` to namespace _(by Athan Reines)_
512540
- [`3f35e51`](https://github.com/stdlib-js/stdlib/commit/3f35e518a65e0cce1a8bcaf0ef6e4d45c08afc59) - **feat:** add `forEach` to namespace _(by Athan Reines)_
513541
- [`413827b`](https://github.com/stdlib-js/stdlib/commit/413827b397945f584daa5b2b2380e36d2d833ac3) - **feat:** add `ndindex` to namespace _(by Athan Reines)_

base/from-scalar-like/README.md

+142
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2024 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+
# scalar2ndarrayLike
22+
23+
> Convert a scalar value to a zero-dimensional ndarray having the same [data type][@stdlib/ndarray/dtypes] as a provided ndarray.
24+
25+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
26+
27+
<section class="intro">
28+
29+
</section>
30+
31+
<!-- /.intro -->
32+
33+
<!-- Package usage documentation. -->
34+
35+
<section class="usage">
36+
37+
## Usage
38+
39+
```javascript
40+
var scalar2ndarrayLike = require( '@stdlib/ndarray/base/from-scalar-like' );
41+
```
42+
43+
#### scalar2ndarrayLike( x, value )
44+
45+
Returns a zero-dimensional ndarray containing a provided scalar `value` and having the same [data type][@stdlib/ndarray/dtypes] as a provided ndarray.
46+
47+
```javascript
48+
var zeros = require( '@stdlib/ndarray/base/zeros' );
49+
50+
var x = zeros( 'float32', [ 2, 2 ], 'row-major' );
51+
// returns <ndarray>
52+
53+
var y = scalar2ndarrayLike( x, 1.0 );
54+
// returns <ndarray>
55+
56+
var sh = y.shape;
57+
// returns []
58+
59+
var dt = y.dtype;
60+
// returns 'float32'
61+
62+
var v = y.get();
63+
// returns 1.0
64+
```
65+
66+
</section>
67+
68+
<!-- /.usage -->
69+
70+
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
71+
72+
<section class="notes">
73+
74+
## Notes
75+
76+
- Along with data type and order, the function infers the "class" of the returned ndarray from the provided ndarray. For example, if provided a "base" [ndarray][@stdlib/ndarray/base/ctor], the function returns a base [ndarray][@stdlib/ndarray/base/ctor]. If provided a non-base [ndarray][@stdlib/ndarray/ctor], the function returns a non-base [ndarray][@stdlib/ndarray/ctor].
77+
- If `value` is a number and a provided ndarray has a complex [data type][@stdlib/ndarray/dtypes], the function returns a zero-dimensional ndarray containing a complex number whose real component equals the provided scalar `value` and whose imaginary component is zero.
78+
79+
</section>
80+
81+
<!-- /.notes -->
82+
83+
<!-- Package usage examples. -->
84+
85+
<section class="examples">
86+
87+
## Examples
88+
89+
<!-- eslint no-undef: "error" -->
90+
91+
```javascript
92+
var dtypes = require( '@stdlib/ndarray/dtypes' );
93+
var empty = require( '@stdlib/ndarray/base/empty' );
94+
var scalar2ndarrayLike = require( '@stdlib/ndarray/base/from-scalar-like' );
95+
96+
// Get a list of data types:
97+
var dt = dtypes();
98+
99+
// Generate zero-dimensional arrays...
100+
var x;
101+
var y;
102+
var i;
103+
for ( i = 0; i < dt.length; i++ ) {
104+
x = empty( dt[ i ], [ 2, 2 ], 'row-major' );
105+
y = scalar2ndarrayLike( x, i );
106+
console.log( y.get() );
107+
}
108+
```
109+
110+
</section>
111+
112+
<!-- /.examples -->
113+
114+
<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
115+
116+
<section class="references">
117+
118+
</section>
119+
120+
<!-- /.references -->
121+
122+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
123+
124+
<section class="related">
125+
126+
</section>
127+
128+
<!-- /.related -->
129+
130+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
131+
132+
<section class="links">
133+
134+
[@stdlib/ndarray/base/ctor]: https://github.com/stdlib-js/ndarray/tree/main/base/ctor
135+
136+
[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray/tree/main/ctor
137+
138+
[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray/tree/main/dtypes
139+
140+
</section>
141+
142+
<!-- /.links -->

0 commit comments

Comments
 (0)