# Matrix transpose

`matrix-transpose` · version 1.0.0 · Vectors & matrices · free, no key needed

Transpose an MxN finite-number matrix into an NxM matrix.

**Use when you need to: matrix transpose · flip rows and columns.**

## Supported

- matrix transpose
- flip rows and columns

## Not supported

- conjugate transpose for complex numbers
- sparse matrix representation

## Behavior

- Input matrix is a rectangular array of 1 to 20 rows of 1 to 20 finite JSON numbers, magnitude bounded to at most 1000000.
- The result is the NxM matrix where result[c][r] = matrix[r][c]; no arithmetic is performed so values are exact, including for non-finite-checked inputs already rejected upstream.
- A result entry of -0 (only possible if the input already contained -0) is normalized to 0.

## Input

- `matrix` (array of array of number, required): min items 1; max items 20

## Output

- `result` (array of array of number, required)

## Limits

- max rows: 20
- max cols: 20
- max abs value: 1000000

## Example

Request input:

```json
{
  "matrix": [
    [
      1,
      2,
      3
    ],
    [
      4,
      5,
      6
    ]
  ]
}
```

Response:

```json
{
  "result": {
    "result": [
      [
        1,
        4
      ],
      [
        2,
        5
      ],
      [
        3,
        6
      ]
    ]
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "matrix-transpose",
  "version": "1.0.0",
  "input": {
    "matrix": [
      [
        1,
        2,
        3
      ],
      [
        4,
        5,
        6
      ]
    ]
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/matrix-transpose/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"matrix":[[1,2,3],[4,5,6]]}'
```

The machine-readable contract is at [/v1/tools/matrix-transpose/versions/1.0.0](/v1/tools/matrix-transpose/versions/1.0.0).

### CLI

```sh
node cli.mjs run matrix-transpose 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Matrix add](/tools/matrix-add): Add two equal-shape finite-number matrices elementwise.
- [Matrix determinant](/tools/matrix-determinant): Compute the determinant of a small square finite-number matrix.
- [Matrix hadamard](/tools/matrix-hadamard): Multiply two equal-shape finite-number matrices elementwise (Hadamard product).
- [Matrix identity](/tools/matrix-identity): Construct the NxN identity matrix for a given size.
- [Matrix inverse](/tools/matrix-inverse): Compute the inverse of a small square finite-number matrix.
- [Matrix multiply](/tools/matrix-multiply): Multiply an MxK finite-number matrix by a KxN finite-number matrix, producing an MxN matrix.
