# `BB.Math.Covariance6`
[🔗](https://github.com/beam-bots/bb/blob/main/lib/bb/math/covariance6.ex#L5)

A 6x6 covariance matrix, backed by an Nx tensor.

Used to express uncertainty over 6-DOF pose or twist estimates (3
translation + 3 rotation, or 3 linear + 3 angular). The matrix is
mathematically expected to be symmetric and positive semi-definite;
this module does not enforce those invariants on construction.

Follows the same typed-Nx-wrapper pattern as `BB.Math.Covariance3`.

## Examples

    iex> c = BB.Math.Covariance6.diagonal([0.01, 0.01, 0.01, 0.001, 0.001, 0.001])
    iex> BB.Math.Covariance6.get(c, 3, 3)
    0.001

# `t`

```elixir
@type t() :: %BB.Math.Covariance6{tensor: Nx.Tensor.t()}
```

# `diagonal`

```elixir
@spec diagonal([number()] | Nx.Tensor.t()) :: t()
```

Builds a diagonal covariance from a list of six variances or a `{6}`
tensor.

## Examples

    iex> c = BB.Math.Covariance6.diagonal([1.0, 2.0, 3.0, 4.0, 5.0, 6.0])
    iex> BB.Math.Covariance6.get(c, 5, 5)
    6.0

# `from_tensor`

```elixir
@spec from_tensor(Nx.Tensor.t()) :: t()
```

Wraps an existing `{6, 6}` tensor. Convenience alias for `new/1`.

# `get`

```elixir
@spec get(t(), 0..5, 0..5) :: float()
```

Reads a scalar element at row/column `(i, j)`.

# `identity`

```elixir
@spec identity() :: t()
```

Returns the 6x6 identity matrix as a covariance.

## Examples

    iex> c = BB.Math.Covariance6.identity()
    iex> {BB.Math.Covariance6.get(c, 0, 0), BB.Math.Covariance6.get(c, 0, 1)}
    {1.0, 0.0}

# `new`

```elixir
@spec new(Nx.Tensor.t()) :: t()
```

Creates a covariance from a `{6, 6}` tensor.

# `to_tensor`

```elixir
@spec to_tensor(t()) :: Nx.Tensor.t()
```

Returns the underlying tensor.

# `zero`

```elixir
@spec zero() :: t()
```

Returns the zero covariance.

## Examples

    iex> c = BB.Math.Covariance6.zero()
    iex> BB.Math.Covariance6.get(c, 0, 0)
    0.0

---

*Consult [api-reference.md](api-reference.md) for complete listing*
