(self, other: int)
| 338 | ) |
| 339 | |
| 340 | def __pow__(self, other: int) -> Matrix: |
| 341 | if not isinstance(other, int): |
| 342 | raise TypeError("A Matrix can only be raised to the power of an int") |
| 343 | if not self.is_square: |
| 344 | raise ValueError("Only square matrices can be raised to a power") |
| 345 | if other == 0: |
| 346 | return self.identity() |
| 347 | if other < 0: |
| 348 | if self.is_invertable(): |
| 349 | return self.inverse() ** (-other) |
| 350 | raise ValueError( |
| 351 | "Only invertable matrices can be raised to a negative power" |
| 352 | ) |
| 353 | result = self |
| 354 | for _ in range(other - 1): |
| 355 | result *= self |
| 356 | return result |
| 357 | |
| 358 | @classmethod |
| 359 | def dot_product(cls, row: list[int], column: list[int]) -> int: |
nothing calls this directly
no test coverage detected