Example #1
0
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)),
    )
Example #2
0
def empty_column() -> Matrix:
    return Matrix((), (0, 1))
Example #3
0
def singleton_matrix(scalar: float) -> Matrix:
    return Matrix((scalar, ), (1, 1))
Example #4
0
def empty_row() -> Matrix:
    return Matrix((), (1, 0))
Example #5
0
def empty_matrix() -> Matrix:
    return Matrix((), (0, 0))
Example #6
0
def rows(scalars: Sequence[Sequence[float]]) -> Matrix:
    return Matrix(flattened(scalars),
                  (len(scalars), len(scalars[0]) if scalars else 0))
Example #7
0
def column(scalars: Sequence[float]) -> Matrix:
    return Matrix(scalars, (len(scalars), 1))
Example #8
0
def row(scalars: Sequence[float]) -> Matrix:
    return Matrix(scalars, (1, len(scalars)))