> ## Documentation Index
> Fetch the complete documentation index at: https://numpyts.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Logical Operations

> Element-wise logical AND, OR, NOT, and XOR operations that return boolean arrays.

### logical\_and

Compute element-wise logical AND. Inputs are broadcast together. Truthy values (non-zero) are treated as `true`.

```typescript theme={null}
function logical_and(x1: ArrayLike, x2: ArrayLike | number): NDArray
```

| Name | Type        | Default | Description         |
| ---- | ----------- | ------- | ------------------- |
| `x1` | `ArrayLike` | --      | First input array.  |
| `x2` | `ArrayLike` | --      | Second input array. |

**Returns:** `NDArray` -- Boolean array where each element is `x1[i] && x2[i]`.

```typescript theme={null}
import * as np from 'numpy-ts';

const result = np.logical_and([true, true, false, false], [true, false, true, false]);
// array([true, false, false, false])

// Works with numeric arrays (0 is false, non-zero is true)
np.logical_and([1, 0, 3], [1, 1, 0]);
// array([true, false, false])
```

***

### logical\_or

Compute element-wise logical OR. Inputs are broadcast together.

```typescript theme={null}
function logical_or(x1: ArrayLike, x2: ArrayLike | number): NDArray
```

| Name | Type        | Default | Description         |
| ---- | ----------- | ------- | ------------------- |
| `x1` | `ArrayLike` | --      | First input array.  |
| `x2` | `ArrayLike` | --      | Second input array. |

**Returns:** `NDArray` -- Boolean array where each element is `x1[i] || x2[i]`.

```typescript theme={null}
import * as np from 'numpy-ts';

const result = np.logical_or([true, true, false, false], [true, false, true, false]);
// array([true, true, true, false])

np.logical_or([0, 0, 1], [0, 1, 0]);
// array([false, true, true])
```

***

### logical\_not

Compute element-wise logical NOT.

```typescript theme={null}
function logical_not(x: ArrayLike): NDArray
```

| Name | Type        | Default | Description  |
| ---- | ----------- | ------- | ------------ |
| `x`  | `ArrayLike` | --      | Input array. |

**Returns:** `NDArray` -- Boolean array where each element is `!x[i]`.

```typescript theme={null}
import * as np from 'numpy-ts';

const result = np.logical_not([true, false, true]);
// array([false, true, false])

np.logical_not([0, 1, -1, 0.0]);
// array([true, false, false, true])
```

***

### logical\_xor

Compute element-wise logical XOR. Inputs are broadcast together.

```typescript theme={null}
function logical_xor(x1: ArrayLike, x2: ArrayLike | number): NDArray
```

| Name | Type        | Default | Description         |
| ---- | ----------- | ------- | ------------------- |
| `x1` | `ArrayLike` | --      | First input array.  |
| `x2` | `ArrayLike` | --      | Second input array. |

**Returns:** `NDArray` -- Boolean array where each element is `true` when exactly one of `x1[i]` or `x2[i]` is truthy.

```typescript theme={null}
import * as np from 'numpy-ts';

const result = np.logical_xor([true, true, false, false], [true, false, true, false]);
// array([false, true, true, false])

np.logical_xor([1, 0, 1], [1, 1, 0]);
// array([false, true, true])
```
