def test_basis_creation(): assert Vector.basis(0, 2) == Vector(1, 0) assert Vector.basis(3, 6) == Vector(0, 0, 0, 1, 0, 0)
def test_vector_splitting_to_basis_products(): product_vector = Vector.zero(len(a)) for i, component in enumerate(a): product_vector += Vector.basis(i, len(a)) * component assert product_vector == a
def identity(cls, m: int) -> 'Matrix': """ Returns the identity matrix m by m """ return cls(rows=(Vector.basis(i, m) for i in range(m)))