Matrix multiply
matrix-multiply · version 1.0.0 · Vectors & matrices · free, no key needed
Multiply an MxK finite-number matrix by a KxN finite-number matrix, producing an MxN matrix.
Use when you need to: matrix multiplication · matrix product · multiply two matrices.
Supported
- matrix multiplication
- matrix product
- multiply two matrices
Not supported
- elementwise multiplication (use matrix-hadamard)
- incompatible inner dimensions
- sparse matrix representation
Behavior
- Input a is an MxK matrix and b is a KxN matrix of finite JSON numbers; a columns must equal b rows. M, K, N are each from 1 to 20.
- Each entry magnitude is bounded to at most 1000000 before multiplication.
- The result is the standard MxN matrix product, result[r][c] = sum over k of a[r][k] * b[k][c], accumulated left-to-right in IEEE-754 double precision.
- A result entry of -0 is normalized to 0.
Input
a(array of array of number, required): min items 1; max items 20b(array of array of number, required): min items 1; max items 20
Output
result(array of array of number, required)
Limits
- max dim: 20
- max abs value: 1000000
Example
Request input:
{
"a": [
[
1,
2
],
[
3,
4
]
],
"b": [
[
5,
6
],
[
7,
8
]
]
}
Response:
{
"result": {
"result": [
[
19,
22
],
[
43,
50
]
]
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "matrix-multiply",
"version": "1.0.0",
"input": {
"a": [
[
1,
2
],
[
3,
4
]
],
"b": [
[
5,
6
],
[
7,
8
]
]
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/matrix-multiply/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-multiply/versions/1.0.0.
CLI
node cli.mjs run matrix-multiply 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Matrix hadamard: Multiply two equal-shape finite-number matrices elementwise (Hadamard product).
- Matrix vector multiply: Multiply an MxN finite-number matrix by a length-N finite-number vector, producing a length-M vector.
- Vector outer product: Compute the outer product of two finite-number vectors, producing a matrix.
- Matrix scale: Multiply every entry of a finite-number matrix by a scalar.
- Vector dot: Compute the dot (scalar) product of two equal-length finite-number vectors.
- Vector hadamard: Multiply two equal-length finite-number vectors elementwise (Hadamard product).