Skip to content

Commit 707d360

Browse files
Shabareesh ShettyShabareesh Shetty
authored andcommitted
refactor: add assign API
1 parent ae427cf commit 707d360

File tree

1 file changed

+83
-0
lines changed
  • lib/node_modules/@stdlib/blas/base/zdotu/lib

1 file changed

+83
-0
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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 muladd = require( '@stdlib/complex/float64/base/mul-add' ).strided;
24+
var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' );
25+
26+
27+
// MAIN //
28+
29+
/**
30+
* Computes the dot product of two double-precision complex floating-point vectors.
31+
*
32+
* @param {integer} N - number of indexed elements
33+
* @param {Complex128Array} x - first input array
34+
* @param {integer} strideX - `x` stride length
35+
* @param {NonNegativeInteger} offsetX - starting index for `x`
36+
* @param {Complex128Array} y - second input array
37+
* @param {integer} strideY - `y` stride length
38+
* @param {NonNegativeInteger} offsetY - starting index for `y`
39+
* @returns {Complex128Array} dot product array
40+
*
41+
* @example
42+
* var Complex128Array = require( '@stdlib/array/complex128' );
43+
*
44+
* var x = new Complex128Array( [ 4.0, 2.0, -3.0, 5.0, -1.0, 7.0 ] );
45+
* var y = new Complex128Array( [ 2.0, 6.0, -1.0, -4.0, 8.0, 9.0 ] );
46+
*
47+
* var z = zdotu( 3, x, 1, 0, y, 1, 0 );
48+
* // returns <Complex128Array>[ -52.0, 82.0 ]
49+
*/
50+
function zdotu( N, x, strideX, offsetX, y, strideY, offsetY, out, strideOut, offsetOut ) {
51+
var viewOut;
52+
var viewX;
53+
var viewY;
54+
var ix;
55+
var iy;
56+
var i;
57+
58+
if ( N <= 0 ) {
59+
return out;
60+
}
61+
viewX = reinterpret( x, 0 );
62+
viewY = reinterpret( y, 0 );
63+
viewOut = reinterpret( out, 0 );
64+
ix = offsetX;
65+
iy = offsetY;
66+
for ( i = 0; i < N; i++ ) {
67+
muladd( viewX[ ix ], 1, 0, viewY[ iy ], 1, 0, viewOut, strideOut, offsetOut, viewOut, strideOut, offsetOut );
68+
ix += strideX;
69+
iy += strideY;
70+
}
71+
return out;
72+
}
73+
var Complex128Array = require( '@stdlib/array/complex128' );
74+
75+
var x = new Complex128Array( [ 4.0, 2.0, -3.0, 5.0, -1.0, 7.0 ] );
76+
var y = new Complex128Array( [ 2.0, 6.0, -1.0, -4.0, 8.0, 9.0 ] );
77+
var out = new Complex128Array( 1 );
78+
var z = zdotu( 3, x, 1, 0, y, 1, 0, out, 1, 0 );
79+
console.log( z.toString() );
80+
81+
// EXPORTS //
82+
83+
module.exports = zdotu;

0 commit comments

Comments
 (0)