Skip to content

Commit e03ed0d

Browse files
committed
Auto-generated commit
1 parent 6eefd96 commit e03ed0d

File tree

14 files changed

+2318
-2
lines changed

14 files changed

+2318
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
### Features
1212

13+
- [`2501de9`](https://github.com/stdlib-js/stdlib/commit/2501de9d60e1239dc54568fff1c6ecdf2770e3fa) - add `ndarray/vector/float64`
1314
- [`e8064cd`](https://github.com/stdlib-js/stdlib/commit/e8064cdc716fc9381a143620ef291722dba49228) - add `ndarray/vector/float32`
1415
- [`b2cefbe`](https://github.com/stdlib-js/stdlib/commit/b2cefbe2b2192cb705b85c43ffac2f57ca782c42) - add custom `valueOf` method
1516
- [`848f226`](https://github.com/stdlib-js/stdlib/commit/848f226d45aad2d627453c8306ae192c75338ac3) - add `factory` method
@@ -392,6 +393,9 @@ A total of 15 issues were closed in this release:
392393

393394
<details>
394395

396+
- [`2501de9`](https://github.com/stdlib-js/stdlib/commit/2501de9d60e1239dc54568fff1c6ecdf2770e3fa) - **feat:** add `ndarray/vector/float64` _(by Athan Reines)_
397+
- [`f75732b`](https://github.com/stdlib-js/stdlib/commit/f75732ba5e3117ae0f9336722834307243eca2be) - **docs:** update example _(by Athan Reines)_
398+
- [`5662f92`](https://github.com/stdlib-js/stdlib/commit/5662f920d833b3033ac24e38ef2a13b7506f7495) - **docs:** update example _(by Athan Reines)_
395399
- [`b599489`](https://github.com/stdlib-js/stdlib/commit/b5994896400e31d3850ba003a2eb016142bf6c9a) - **docs:** fix signature _(by Athan Reines)_
396400
- [`e8064cd`](https://github.com/stdlib-js/stdlib/commit/e8064cdc716fc9381a143620ef291722dba49228) - **feat:** add `ndarray/vector/float32` _(by Athan Reines)_
397401
- [`fbc6b85`](https://github.com/stdlib-js/stdlib/commit/fbc6b852fae5eb77c36e04208c4aad574d146459) - **docs:** fix comments _(by Athan Reines)_

vector/ctor/docs/repl.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@
189189

190190
Examples
191191
--------
192-
> var buf = new {{alias:@stdlib/array/buffer}}( 16 );
192+
> var buf = new {{alias:@stdlib/array/buffer}}( 32 );
193193
> var arr = {{alias}}( buf, 0, 4, 'float32' )
194194
<ndarray>
195195
> var dt = {{alias:@stdlib/ndarray/dtype}}( arr )

vector/float32/docs/repl.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@
164164

165165
Examples
166166
--------
167-
> var buf = new {{alias:@stdlib/array/buffer}}( 16 );
167+
> var buf = new {{alias:@stdlib/array/buffer}}( 32 );
168168
> var arr = {{alias}}( buf, 0, 4 )
169169
<ndarray>
170170
> var len = {{alias:@stdlib/ndarray/numel}}( arr )

vector/float64/README.md

Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2025 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+
# Float64Vector
22+
23+
> Create a double-precision floating-point vector (i.e., a one-dimensional [ndarray][@stdlib/ndarray/ctor]).
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 Float64Vector = require( '@stdlib/ndarray/vector/float64' );
41+
```
42+
43+
#### Float64Vector( \[options] )
44+
45+
Returns a one-dimensional double-precision floating-point [ndarray][@stdlib/ndarray/ctor].
46+
47+
```javascript
48+
var numel = require( '@stdlib/ndarray/numel' );
49+
50+
var arr = new Float64Vector();
51+
// returns <ndarray>
52+
53+
var len = numel( arr );
54+
// returns 0
55+
```
56+
57+
The function accepts the following options:
58+
59+
- **order**: specifies whether an [ndarray][@stdlib/ndarray/ctor] is `'row-major'` (C-style) or `'column-major'` (Fortran-style). Default: `'row-major'`.
60+
- **mode**: specifies how to handle indices which exceed array dimensions (see [`ndarray`][@stdlib/ndarray/ctor]). Default: `'throw'`.
61+
- **readonly**: boolean indicating whether an array should be **read-only**. Default: `false`.
62+
63+
#### Float64Vector( length\[, options] )
64+
65+
Returns a one-dimensional double-precision floating-point [ndarray][@stdlib/ndarray/ctor] having a specified `length`.
66+
67+
```javascript
68+
var numel = require( '@stdlib/ndarray/numel' );
69+
70+
var arr = new Float64Vector( 5 );
71+
// returns <ndarray>
72+
73+
var len1 = numel( arr );
74+
// returns 5
75+
```
76+
77+
#### Float64Vector( obj\[, options] )
78+
79+
Creates a one-dimensional double-precision floating-point [ndarray][@stdlib/ndarray/ctor] from an array-like object or iterable.
80+
81+
```javascript
82+
var numel = require( '@stdlib/ndarray/numel' );
83+
84+
var arr = new Float64Vector( [ 1.0, 2.0, 3.0 ] );
85+
// returns <ndarray>
86+
87+
var len1 = numel( arr );
88+
// returns 3
89+
```
90+
91+
#### Float64Vector( buffer\[, byteOffset\[, length]]\[, options] )
92+
93+
Returns a one-dimensional double-precision floating-point [ndarray][@stdlib/ndarray/ctor] view of an [`ArrayBuffer`][@stdlib/array/buffer].
94+
95+
```javascript
96+
var ArrayBuffer = require( '@stdlib/array/buffer' );
97+
var numel = require( '@stdlib/ndarray/numel' );
98+
99+
var buf = new ArrayBuffer( 64 );
100+
101+
var arr1 = new Float64Vector( buf );
102+
// returns <ndarray>
103+
104+
var len1 = numel( arr1 );
105+
// returns 8
106+
107+
var arr2 = new Float64Vector( buf, 16 );
108+
// returns <ndarray>
109+
110+
var len2 = numel( arr2 );
111+
// returns 6
112+
113+
var arr3 = new Float64Vector( buf, 16, 1 );
114+
// returns <ndarray>
115+
116+
var len3 = numel( arr3 );
117+
// returns 1
118+
```
119+
120+
</section>
121+
122+
<!-- /.usage -->
123+
124+
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
125+
126+
<section class="notes">
127+
128+
</section>
129+
130+
<!-- /.notes -->
131+
132+
<!-- Package usage examples. -->
133+
134+
<section class="examples">
135+
136+
## Examples
137+
138+
<!-- eslint no-undef: "error" -->
139+
140+
```javascript
141+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
142+
var sum = require( '@stdlib/blas/ext/sum' );
143+
var map = require( '@stdlib/ndarray/map' );
144+
var Float64Vector = require( '@stdlib/ndarray/vector/float64' );
145+
146+
// Create a vector containing random values:
147+
var x = new Float64Vector( discreteUniform( 10, 0, 100 ) );
148+
149+
// Compute the sum:
150+
var v = sum( x );
151+
console.log( v.get() );
152+
153+
// Define a function which applies a threshold to individual values:
154+
function threshold( v ) {
155+
return ( v > 10 ) ? v : 0;
156+
}
157+
158+
// Apply threshold:
159+
var y = map( x, threshold );
160+
161+
// Recompute the sum:
162+
v = sum( y );
163+
console.log( v.get() );
164+
```
165+
166+
</section>
167+
168+
<!-- /.examples -->
169+
170+
<!-- 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. -->
171+
172+
<section class="references">
173+
174+
</section>
175+
176+
<!-- /.references -->
177+
178+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
179+
180+
<section class="related">
181+
182+
</section>
183+
184+
<!-- /.related -->
185+
186+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
187+
188+
<section class="links">
189+
190+
[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer
191+
192+
[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray/tree/main/ctor
193+
194+
</section>
195+
196+
<!-- /.links -->

vector/float64/benchmark/benchmark.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' );
25+
var pkg = require( './../package.json' ).name;
26+
var Float64Vector = require( './../lib' );
27+
28+
29+
// MAIN //
30+
31+
bench( pkg, function benchmark( b ) {
32+
var arr;
33+
var i;
34+
b.tic();
35+
for ( i = 0; i < b.iterations; i++ ) {
36+
arr = new Float64Vector( 0 );
37+
if ( arr.length !== 0 ) {
38+
b.fail( 'should have length 0' );
39+
}
40+
}
41+
b.toc();
42+
if ( !isndarrayLike( arr ) ) {
43+
b.fail( 'should return an ndarray' );
44+
}
45+
b.pass( 'benchmark finished' );
46+
b.end();
47+
});
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var pow = require( '@stdlib/math/base/special/pow' );
25+
var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' );
26+
var pkg = require( './../package.json' ).name;
27+
var Float64Vector = require( './../lib' );
28+
29+
30+
// FUNCTIONS //
31+
32+
/**
33+
* Creates a benchmark function.
34+
*
35+
* @private
36+
* @param {PositiveInteger} len - array length
37+
* @returns {Function} benchmark function
38+
*/
39+
function createBenchmark( len ) {
40+
return benchmark;
41+
42+
/**
43+
* Benchmark function.
44+
*
45+
* @private
46+
* @param {Benchmark} b - benchmark instance
47+
*/
48+
function benchmark( b ) {
49+
var arr;
50+
var i;
51+
52+
b.tic();
53+
for ( i = 0; i < b.iterations; i++ ) {
54+
arr = new Float64Vector( len );
55+
if ( arr.length !== len ) {
56+
b.fail( 'unexpected length' );
57+
}
58+
}
59+
b.toc();
60+
if ( !isndarrayLike( arr ) ) {
61+
b.fail( 'should return an ndarray' );
62+
}
63+
b.pass( 'benchmark finished' );
64+
b.end();
65+
}
66+
}
67+
68+
69+
// MAIN //
70+
71+
/**
72+
* Main execution sequence.
73+
*
74+
* @private
75+
*/
76+
function main() {
77+
var len;
78+
var min;
79+
var max;
80+
var f;
81+
var i;
82+
83+
min = 1; // 10^min
84+
max = 6; // 10^max
85+
86+
for ( i = min; i <= max; i++ ) {
87+
len = pow( 10, i );
88+
f = createBenchmark( len );
89+
bench( pkg+':size='+len, f );
90+
}
91+
}
92+
93+
main();

0 commit comments

Comments
 (0)