> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/cuvs/llms.txt.
> For full documentation content, see https://docs.nvidia.com/cuvs/llms-full.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/cuvs/_mcp/server.

# Distance Module

_Rust module: `cuvs::distance`_

_Source: `rust/cuvs/src/distance/mod.rs`_

## pairwise_distance

```rust
pub fn pairwise_distance(
res: &Resources,
x: &ManagedTensor,
y: &ManagedTensor,
distances: &ManagedTensor,
metric: DistanceType,
metric_arg: Option<f32>,
) -> Result<()> { ... }
```

Compute pairwise distances between X and Y

#### Arguments

* `res` - Resources to use
* `x` - A matrix in device memory - shape (m, k)
* `y` - A matrix in device memory - shape (n, k)
* `distances` - A matrix in device memory that receives the output distances - shape (m, n)
* `metric` - DistanceType to use for building the index
* `metric_arg` - Optional value of `p` for Minkowski distances

_Source: `rust/cuvs/src/distance/mod.rs:21`_