-
Notifications
You must be signed in to change notification settings - Fork 36
Closed
Description
The implementation for vecdot
should conjugate its first argument for complex numbers, but unfortunately the present implementation does not:
array-api-compat/array_api_compat/common/_aliases.py
Lines 469 to 483 in 8d3f5d5
def vecdot(x1: ndarray, x2: ndarray, /, xp, *, axis: int = -1) -> ndarray: | |
if x1.shape[axis] != x2.shape[axis]: | |
raise ValueError("x1 and x2 must have the same size along the given axis") | |
if hasattr(xp, 'broadcast_tensors'): | |
_broadcast = xp.broadcast_tensors | |
else: | |
_broadcast = xp.broadcast_arrays | |
x1_ = xp.moveaxis(x1, axis, -1) | |
x2_ = xp.moveaxis(x2, axis, -1) | |
x1_, x2_ = _broadcast(x1_, x2_) | |
res = x1_[..., None, :] @ x2_[..., None] | |
return res[..., 0, 0] |
p.s. Found this while implementing a new quantity class that uses the array API to handle any type of array that can be passed in -- array_api_compat
has been a great boon!
p.s.2 I found the problem for dask
, which actually seems to be able to handle np.vecdot
fine (and give the correct answer).
Metadata
Metadata
Assignees
Labels
No labels