matrix.kronecker_product ======================== .. py:module:: matrix.kronecker_product .. autoapi-nested-parse:: Perform Kronecker product of two matrices. https://en.wikipedia.org/wiki/Kronecker_product Functions --------- .. autoapisummary:: matrix.kronecker_product.is_2d matrix.kronecker_product.kronecker_product Module Contents --------------- .. py:function:: is_2d(matrix: list[list[int]]) -> bool >>> is_2d([]) True >>> is_2d([1, 2]) False >>> is_2d([[1, 2], [3, 4]]) True .. py:function:: kronecker_product(matrix_a: list[list[int]], matrix_b: list[list[int]]) -> list[list[int]] :param matrix_a: A 2-D Matrix with dimension m x n :param matrix_b: Another 2-D Matrix with dimension p x q :return: Result of matrix_a ⊗ matrix_b :raises ValueError: If the matrices are not 2-D. >>> kronecker_product([[1, 2]], [[5, 6], [7, 8]]) [[5, 6, 10, 12], [7, 8, 14, 16]] >>> kronecker_product([[1, 2], [4, 5]], [[5, 6], [7, 8]]) [[5, 6, 10, 12], [7, 8, 14, 16], [20, 24, 25, 30], [28, 32, 35, 40]] >>> kronecker_product([1, 2], [[5, 6], [7, 8]]) Traceback (most recent call last): ... ValueError: Input matrices must be 2-D.