def full_matrix( func: Callable[[int, int], float], row_dimension: int, column_dimension: Optional[int] = None, ) -> Matrix: return Matrix( starmap( func, product(range(row_dimension), range(default(column_dimension, row_dimension)))), (row_dimension, default(column_dimension, row_dimension)), )
def empty_column() -> Matrix: return Matrix((), (0, 1))
def singleton_matrix(scalar: float) -> Matrix: return Matrix((scalar, ), (1, 1))
def empty_row() -> Matrix: return Matrix((), (1, 0))
def empty_matrix() -> Matrix: return Matrix((), (0, 0))
def rows(scalars: Sequence[Sequence[float]]) -> Matrix: return Matrix(flattened(scalars), (len(scalars), len(scalars[0]) if scalars else 0))
def column(scalars: Sequence[float]) -> Matrix: return Matrix(scalars, (len(scalars), 1))
def row(scalars: Sequence[float]) -> Matrix: return Matrix(scalars, (1, len(scalars)))