# Dot Products

> NumKong for JavaScript

Dot products are separate from distances because dtype tagging and low-precision storage matter more here.

```ts
import { dot, inner } from "numkong";

const a = new Float32Array([1, 2, 3]);
const b = new Float32Array([4, 5, 6]);

console.log(dot(a, b));
console.log(inner(a, b)); // alias for ecosystem familiarity
```

For non-native numeric layouts, pass an explicit `DType` or wrap the storage in a typed NumKong view.

`import * as numkong from 'numkong';`

## inner

Computes the inner product of two vectors, the same as the dot product.

```typescript
function inner(a: NumericArray, b: NumericArray): number
```

```typescript
function inner(
    a: DistanceArray,
    b: DistanceArray,
    dtype: DType,
): number
```

```typescript
function inner(a: TensorBase, b: TensorBase): number
```

- `a`: The first vector, as TypedArray or TensorBase.
- `b`: The second vector, matching the type and length of `a`.
- `dtype`: Optional dtype string for custom types, e.g. 'f16', 'bf16', 'e4m3'.

## dot

Computes the dot product of two vectors, the same as the inner product.

```typescript
function dot(a: NumericArray, b: NumericArray): number
```

```typescript
function dot(
    a: DistanceArray,
    b: DistanceArray,
    dtype: DType,
): number
```

```typescript
function dot(a: TensorBase, b: TensorBase): number
```

- `a`: The first vector, as TypedArray or TensorBase.
- `b`: The second vector, matching the type and length of `a`.
- `dtype`: Optional dtype string for custom types, e.g. 'f16', 'bf16', 'e4m3'.

