Skip to content

Commit 90f0130

Browse files
committed
Auto-generated commit
1 parent f479bc7 commit 90f0130

File tree

13 files changed

+898
-1
lines changed

13 files changed

+898
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
55
<section class="release" id="unreleased">
66

7-
## Unreleased (2025-07-24)
7+
## Unreleased (2025-07-27)
88

99
<section class="features">
1010

1111
### Features
1212

13+
- [`0b79b81`](https://github.com/stdlib-js/stdlib/commit/0b79b81b45a018fa9a2f8a3a834164af9f944d40) - add `blas/base/ndarray/gdot` [(#7740)](https://github.com/stdlib-js/stdlib/pull/7740)
1314
- [`cf8cf0a`](https://github.com/stdlib-js/stdlib/commit/cf8cf0ac2b13ca1d2feb416e87154f713a37e507) - add `blas/ext/index-of` [(#7565)](https://github.com/stdlib-js/stdlib/pull/7565)
1415
- [`4f94e60`](https://github.com/stdlib-js/stdlib/commit/4f94e6071dbc28c204f01b2aae41618cc0bfc60b) - add C implementation to `blas/base/ssyr` [(#7127)](https://github.com/stdlib-js/stdlib/pull/7127)
1516
- [`9dc8cd1`](https://github.com/stdlib-js/stdlib/commit/9dc8cd1f528d402a9072014d9e54ac01172814ed) - add `gger` to namespace
@@ -551,6 +552,7 @@ A total of 25 issues were closed in this release:
551552

552553
<details>
553554

555+
- [`0b79b81`](https://github.com/stdlib-js/stdlib/commit/0b79b81b45a018fa9a2f8a3a834164af9f944d40) - **feat:** add `blas/base/ndarray/gdot` [(#7740)](https://github.com/stdlib-js/stdlib/pull/7740) _(by Gururaj Gurram, Athan Reines)_
554556
- [`821035c`](https://github.com/stdlib-js/stdlib/commit/821035c992e57ecadb7531c71f4bcb084b32461c) - **refactor:** only check properties when options has been provided _(by Philipp Burckhardt)_
555557
- [`4c956ca`](https://github.com/stdlib-js/stdlib/commit/4c956ca79f7be9a1cddcf8376760749913332718) - **docs:** fix JSDoc type _(by Philipp Burckhardt)_
556558
- [`f83b3c1`](https://github.com/stdlib-js/stdlib/commit/f83b3c136f2ecd76e4604f27059c60d391f1c2d5) - **bench:** update parameters for ndarray benchmarking [(#7732)](https://github.com/stdlib-js/stdlib/pull/7732) _(by Shabareesh Shetty)_

CONTRIBUTORS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Anshu Kumar <[email protected]>
3030
Anudeep Sanapala <[email protected]>
3131
Arihant Pal <[email protected]>
3232
Aryan Bhirud <[email protected]>
33+
3334
Athan Reines <[email protected]>
3435
Atharva Patil <[email protected]>
3536
@@ -177,6 +178,7 @@ Shivansh <[email protected]>
177178
Shraddheya Shendre <[email protected]>
178179
Shubh Mehta <[email protected]>
179180
Shubham Mishra <[email protected]>
181+
Siddhesh waje <[email protected]>
180182
Sivam Das <[email protected]>
181183
Snehil Shah <[email protected]>
182184
Soumajit Chatterjee <[email protected]>

base/ndarray/gdot/README.md

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
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+
# gdot
22+
23+
> Calculate the dot product of two one-dimensional ndarrays.
24+
25+
<section class="intro">
26+
27+
The [dot product][dot-product] (or scalar product) is defined as
28+
29+
<!-- <equation class="equation" label="eq:dot_product" align="center" raw="\mathbf{x}\cdot\mathbf{y} = \sum_{i=0}^{N-1} x_i y_i = x_0 y_0 + x_1 y_1 + \ldots + x_{N-1} y_{N-1}" alt="Dot product definition."> -->
30+
31+
```math
32+
\mathbf{x}\cdot\mathbf{y} = \sum_{i=0}^{N-1} x_i y_i = x_0 y_0 + x_1 y_1 + \ldots + x_{N-1} y_{N-1}
33+
```
34+
35+
<!-- <div class="equation" align="center" data-raw-text="\mathbf{x}\cdot\mathbf{y} = \sum_{i=0}^{N-1} x_i y_i = x_0 y_0 + x_1 y_1 + \ldots + x_{N-1} y_{N-1}" data-equation="eq:dot_product">
36+
<img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@6cf4829ce9c06ba9fa207a2ea3b395266f86a259/lib/node_modules/@stdlib/blas/base/ndarray/gdot/docs/img/equation_dot_product.svg" alt="Dot product definition.">
37+
<br>
38+
</div> -->
39+
40+
<!-- </equation> -->
41+
42+
</section>
43+
44+
<!-- /.intro -->
45+
46+
<section class="usage">
47+
48+
## Usage
49+
50+
```javascript
51+
var gdot = require( '@stdlib/blas/base/ndarray/gdot' );
52+
```
53+
54+
#### gdot( arrays )
55+
56+
Computes the dot product of two one-dimensional ndarrays.
57+
58+
```javascript
59+
var ndarray = require( '@stdlib/ndarray/base/ctor' );
60+
61+
var xbuf = [ 4.0, 2.0, -3.0, 5.0, -1.0 ];
62+
var x = new ndarray( 'generic', xbuf, [ 5 ], [ 1 ], 0, 'row-major' );
63+
64+
var ybuf = [ 2.0, 6.0, -1.0, -4.0, 8.0 ];
65+
var y = new ndarray( 'generic', ybuf, [ 5 ], [ 1 ], 0, 'row-major' );
66+
67+
var z = gdot( [ x, y ] );
68+
// returns -5.0
69+
```
70+
71+
The function has the following parameters:
72+
73+
- **arrays**: array-like object containing two one-dimensional input ndarrays.
74+
75+
</section>
76+
77+
<!-- /.usage -->
78+
79+
<section class="notes">
80+
81+
</section>
82+
83+
<!-- /.notes -->
84+
85+
<section class="examples">
86+
87+
## Examples
88+
89+
<!-- eslint no-undef: "error" -->
90+
91+
```javascript
92+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
93+
var ndarray = require( '@stdlib/ndarray/base/ctor' );
94+
var ndarray2array = require( '@stdlib/ndarray/to-array' );
95+
var gdot = require( '@stdlib/blas/base/ndarray/gdot' );
96+
97+
var opts = {
98+
'dtype': 'generic'
99+
};
100+
101+
var xbuf = discreteUniform( 10, 0, 500, opts );
102+
var x = new ndarray( opts.dtype, xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
103+
console.log( ndarray2array( x ) );
104+
105+
var ybuf = discreteUniform( 10, 0, 255, opts );
106+
var y = new ndarray( opts.dtype, ybuf, [ ybuf.length ], [ 1 ], 0, 'row-major' );
107+
console.log( ndarray2array( y ) );
108+
109+
var out = gdot( [ x, y ] );
110+
console.log( out );
111+
```
112+
113+
</section>
114+
115+
<!-- /.examples -->
116+
117+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
118+
119+
<section class="related">
120+
121+
</section>
122+
123+
<!-- /.related -->
124+
125+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
126+
127+
<section class="links">
128+
129+
[dot-product]: https://en.wikipedia.org/wiki/Dot_product
130+
131+
</section>
132+
133+
<!-- /.links -->
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
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 uniform = require( '@stdlib/random/array/uniform' );
25+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
26+
var pow = require( '@stdlib/math/base/special/pow' );
27+
var ndarray = require( '@stdlib/ndarray/base/ctor' );
28+
var pkg = require( './../package.json' ).name;
29+
var gdot = require( './../lib' );
30+
31+
32+
// VARIABLES //
33+
34+
var options = {
35+
'dtype': 'generic'
36+
};
37+
38+
39+
// FUNCTIONS //
40+
41+
/**
42+
* Creates a benchmark function.
43+
*
44+
* @private
45+
* @param {PositiveInteger} len - array length
46+
* @returns {Function} benchmark function
47+
*/
48+
function createBenchmark( len ) {
49+
var xbuf;
50+
var ybuf;
51+
var x;
52+
var y;
53+
54+
xbuf = uniform( len, -100.0, 100.0, options );
55+
x = new ndarray( options.dtype, xbuf, [ len ], [ 1 ], 0, 'row-major' );
56+
57+
ybuf = uniform( len, -100.0, 100.0, options );
58+
y = new ndarray( options.dtype, ybuf, [ len ], [ 1 ], 0, 'row-major' );
59+
60+
return benchmark;
61+
62+
/**
63+
* Benchmark function.
64+
*
65+
* @private
66+
* @param {Benchmark} b - benchmark instance
67+
*/
68+
function benchmark( b ) {
69+
var z;
70+
var i;
71+
72+
b.tic();
73+
for ( i = 0; i < b.iterations; i++ ) {
74+
z = gdot( [ x, y ] );
75+
if ( isnan( z ) ) {
76+
b.fail( 'should not return NaN' );
77+
}
78+
}
79+
b.toc();
80+
if ( isnan( z ) ) {
81+
b.fail( 'should not return NaN' );
82+
}
83+
b.pass( 'benchmark finished' );
84+
b.end();
85+
}
86+
}
87+
88+
89+
// MAIN //
90+
91+
/**
92+
* Main execution sequence.
93+
*
94+
* @private
95+
*/
96+
function main() {
97+
var len;
98+
var min;
99+
var max;
100+
var f;
101+
var i;
102+
103+
min = 1; // 10^min
104+
max = 6; // 10^max
105+
106+
for ( i = min; i <= max; i++ ) {
107+
len = pow( 10, i );
108+
f = createBenchmark( len );
109+
bench( pkg+':len='+len, f );
110+
}
111+
}
112+
113+
main();
Lines changed: 83 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)