TypeTensor - v0.1.0
    Preparing search index...

    Type Alias CanMatmul<A, B>

    CanMatmul: IsMatMulCompatible<A, B> extends true
        ? true
        : A extends readonly []
            ? ShapeError<
                "Cannot multiply scalar tensors. Matrix multiplication requires at least 1D tensors.",
                { shapeA: A; shapeB: B },
            >
            : B extends readonly []
                ? ShapeError<
                    "Cannot multiply with scalar tensor. Matrix multiplication requires at least 1D tensors.",
                    { shapeA: A; shapeB: B },
                >
                : ShapeError<
                    `Cannot multiply tensors with shapes [${ShapeToString<A>}] and [${ShapeToString<
                        B,
                    >}]. Matrix multiplication requires the last dimension of the first tensor (${LastDim<
                        A,
                    > & number}) to match the ${B extends readonly [unknown]
                        ? "dimension"
                        : "second-to-last dimension"} of the second tensor (${B extends readonly [
                        unknown,
                    ]
                        ? B[0] & number
                        : SecondToLast<B> & number}).`,
                    { shapeA: A; shapeB: B },
                >

    Validate if two shapes can be matrix multiplied with detailed error messages

    Returns true for compatible shapes, or a ShapeError for incompatible ones. This provides better developer experience than IsMatMulCompatible which returns boolean.

    Type Parameters

    type Valid = CanMatmul<[2, 3], [3, 4]> // true
    type Invalid = CanMatmul<[2, 3], [4, 5]> // ShapeError with detailed message