# xarray.DataArray.dot

#### DataArray.dot(other, dim=None)[[source]](https://github.com/pydata/xarray/blob/main/xarray/core/dataarray.py#L5285-L5351)

Perform dot product of two DataArrays along their shared dims.

Equivalent to taking taking tensordot over all shared dims.

* **Parameters:**
  * **other** ([`DataArray`](xarray.DataArray.html.md#xarray.DataArray)) – The other array with which the dot product is performed.
  * **dim** ([`...`](https://docs.python.org/3/builtins/constants.html#Ellipsis), [`str`](xarray.DataArray.str.html.md#xarray.DataArray.str), `Iterable` of `Hashable` or [`None`](https://docs.python.org/3/builtins/constants.html#None), *optional*) – Which dimensions to sum over. Ellipsis (…) sums over all dimensions.
    If not specified, then all the common dimensions are summed over.
* **Returns:**
  **result** ([`DataArray`](xarray.DataArray.html.md#xarray.DataArray)) – Array resulting from the dot product over all shared dimensions.

#### SEE ALSO
[`dot`](xarray.dot.html.md#xarray.dot), [`numpy.tensordot`](https://numpy.org/doc/stable/reference/generated/numpy.tensordot.html#numpy.tensordot)

### Notes

This method automatically aligns coordinates by their values (not their order).
See [Automatic alignment](../user-guide/computation.html.md#math-automatic-alignment) and [`xarray.dot()`](xarray.dot.html.md#xarray.dot) for more details.

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('b3abc333-4b3c-463a-83b8-a12af80f37e8','4f4e94f6-d7b7-40f8-874e-8788b5649eb0','a570295b-e8b3-4e50-b02e-d3c2e8cc79ec','../lite/tree/../notebooks/index.html?path=54ae33fb_9097_414b_b5c2_cb912ef9c3ec.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> da_vals = np.arange(6 * 5 * 4).reshape((6, 5, 4))
>>> da = xr.DataArray(da_vals, dims=["x", "y", "z"])
>>> dm_vals = np.arange(4)
>>> dm = xr.DataArray(dm_vals, dims=["z"])
```

```pycon
>>> dm.dims
('z',)
```

```pycon
>>> da.dims
('x', 'y', 'z')
```

```pycon
>>> dot_result = da.dot(dm)
>>> dot_result.dims
('x', 'y')
```

Coordinates are aligned by their values:

```pycon
>>> x = xr.DataArray([1, 10], coords=[("foo", ["a", "b"])])
>>> y = xr.DataArray([2, 20], coords=[("foo", ["b", "a"])])
>>> x.dot(y)
<xarray.DataArray ()> Size: 8B
array(40)
```

<div id="a570295b-e8b3-4e50-b02e-d3c2e8cc79ec" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('b3abc333-4b3c-463a-83b8-a12af80f37e8','a570295b-e8b3-4e50-b02e-d3c2e8cc79ec')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('b3abc333-4b3c-463a-83b8-a12af80f37e8','a570295b-e8b3-4e50-b02e-d3c2e8cc79ec')">Open In Tab</button></div><div id="4f4e94f6-d7b7-40f8-874e-8788b5649eb0" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
