> ## 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: NDArray, x2: NDArray | number): NDArray
```

| Name | Type | Default | Description |
| - | - | - | - |
| `x1` | `NDArray` | -- | First input array. |
| `x2` | `NDArray` | -- | 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(np.array([true, true, false, false], 'bool'), np.array([true, false, true, false], 'bool'));
// array([true, false, false, false])

// Works with numeric arrays (0 is false, non-zero is true)
np.logical_and(np.array([1, 0, 3]), np.array([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: NDArray, x2: NDArray | number): NDArray
```

| Name | Type | Default | Description |
| - | - | - | - |
| `x1` | `NDArray` | -- | First input array. |
| `x2` | `NDArray` | -- | 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(np.array([true, true, false, false], 'bool'), np.array([true, false, true, false], 'bool'));
// array([true, true, true, false])

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

***

### logical\_not

Compute element-wise logical NOT.

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

| Name | Type | Default | Description |
| - | - | - | - |
| `x` | `NDArray` | -- | 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(np.array([true, false, true], 'bool'));
// array([false, true, false])

np.logical_not(np.array([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: NDArray, x2: NDArray | number): NDArray
```

| Name | Type | Default | Description |
| - | - | - | - |
| `x1` | `NDArray` | -- | First input array. |
| `x2` | `NDArray` | -- | 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(np.array([true, true, false, false], 'bool'), np.array([true, false, true, false], 'bool'));
// array([false, true, true, false])

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


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.