MMatrixCairn
Workflows

Coding workflows · Bounded integer matrix multiplication

03
Built around your work

A concrete starting point

Multiply rectangular integer matrices with at most 64 rows and columns each. Test empty and single-cell inputs, rejecting ragged rows, incompatible dimensions and Boolean cells without modifying the matrices.

01

Open the context

Choose the project folder and name the files or behavior involved.

02

Define the change

Describe the input, expected output and boundaries that must stay intact.

03

Inspect the work

Review the proposed edits and any commands before relying on their result.

04

Check the outcome

Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.

Bounded integer matrix multiplication

A concrete starting point
def matrix_product(left, right):
    left, right = [tuple(r) for r in left], [tuple(r) for r in right]
    widths = []
    for matrix in (left, right):
        width = len(matrix[0]) if matrix else 0
        if len(matrix) > 64 or width > 64 or any(len(r) != width for r in matrix):
            raise ValueError("matrix.shape")
        if any(type(v) is not int for r in matrix for v in r):
            raise ValueError("cell.integer")
        widths.append(width)
    if widths[0] != len(right):
        raise ValueError("matrix.incompatible")
    return [[sum(row[k] * right[k][j] for k in range(widths[0]))
             for j in range(widths[1])] for row in left]

The example is a starting point for a real project, not a claim that generated code is already tested. Adjust paths, dependencies and expected behavior to match your application.

AI coding workspace

Your next change starts here.

Get the Windows app ↗