# Matrix hadamard

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

Multiply two equal-shape finite-number matrices elementwise (Hadamard product).

**Use when you need to: matrix hadamard product · elementwise matrix multiplication · pointwise matrix product.**

## Supported

- matrix hadamard product
- elementwise matrix multiplication
- pointwise matrix product

## Not supported

- matrices of different shapes
- standard matrix multiplication (use matrix-multiply)
- arbitrary-precision arithmetic

## Behavior

- Inputs a and b are rectangular arrays of rows of finite JSON numbers with identical row and column counts (1 to 20 each), magnitude bounded to at most 1000000.
- The result is the elementwise IEEE-754 double-precision product result[r][c] = a[r][c] * b[r][c].
- A result entry of -0 is normalized to 0.

## Input

- `a` (array of array of number, required): min items 1; max items 20
- `b` (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
{
  "a": [
    [
      1,
      2
    ],
    [
      3,
      4
    ]
  ],
  "b": [
    [
      5,
      6
    ],
    [
      7,
      8
    ]
  ]
}
```

Response:

```json
{
  "result": {
    "result": [
      [
        5,
        12
      ],
      [
        21,
        32
      ]
    ]
  }
}
```

## How to call it

### MCP

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

```json
{
  "id": "matrix-hadamard",
  "version": "1.0.0",
  "input": {
    "a": [
      [
        1,
        2
      ],
      [
        3,
        4
      ]
    ],
    "b": [
      [
        5,
        6
      ],
      [
        7,
        8
      ]
    ]
  }
}
```

### HTTP (no key)

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

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

### CLI

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

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

## Related tools

- [Vector hadamard](/tools/vector-hadamard): Multiply two equal-length finite-number vectors elementwise (Hadamard product).
- [Matrix multiply](/tools/matrix-multiply): Multiply an MxK finite-number matrix by a KxN finite-number matrix, producing an MxN matrix.
- [Matrix add](/tools/matrix-add): Add two equal-shape finite-number matrices elementwise.
- [Matrix scale](/tools/matrix-scale): Multiply every entry of a finite-number matrix by a scalar.
- [Matrix subtract](/tools/matrix-subtract): Subtract two equal-shape finite-number matrices elementwise (a minus b).
- [Matrix vector multiply](/tools/matrix-vector-multiply): Multiply an MxN finite-number matrix by a length-N finite-number vector, producing a length-M vector.
