byslib-python

This documentation is automatically generated by online-judge-tools/verification-helper modified by bayashi_cl

View the Project on GitHub bayashi-cl/byslib-python

:warning: Matrix
(byslib/numeric/matrix.py)

Code

# @title Matrix
from collections import UserList
from typing import Generic, Iterable, Optional, TypeVar, Union

_T = TypeVar("_T", int, float)


class Vector(UserList, Generic[_T]):
    def __init__(self, initlist: Optional[Iterable[_T]]) -> None:
        super().__init__(initlist=initlist)

    def __add__(self, other: Union[Iterable[_T], _T]) -> "Vector[_T]":
        if isinstance(other, float) or isinstance(other, int):
            return Vector(map(lambda x: x + other, self))
        elif isinstance(other, Vector):
            if len(other) != len(self):
                raise ValueError

            for i in range(len(self)):
                self[i] += other[i]
            return self
        else:
            raise ValueError


class Matrix:
    ...
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.10.4/x64/lib/python3.10/site-packages/onlinejudge_verify/documentation/build.py", line 71, in _render_source_code_stat
    bundled_code = language.bundle(stat.path, basedir=basedir, options={'include_paths': [basedir], 'release': True}).decode()
  File "/opt/hostedtoolcache/Python/3.10.4/x64/lib/python3.10/site-packages/onlinejudge_verify/languages/python.py", line 80, in bundle
    raise NotImplementedError
NotImplementedError
Back to top page