matrix.kronecker_product¶
Perform Kronecker product of two matrices. https://en.wikipedia.org/wiki/Kronecker_product
Functions¶
|
|
|
Module Contents¶
- matrix.kronecker_product.is_2d(matrix: list[list[int]]) bool¶
>>> is_2d([]) True >>> is_2d([1, 2]) False >>> is_2d([[1, 2], [3, 4]]) True
- matrix.kronecker_product.kronecker_product(matrix_a: list[list[int]], matrix_b: list[list[int]]) list[list[int]]¶
- Parameters:
matrix_a – A 2-D Matrix with dimension m x n
matrix_b – Another 2-D Matrix with dimension p x q
- Returns:
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.