input: a 'scalar' and two vectors 'x' and 'y' output: a vector computes the axpy operation
(scalar: float, x: Vector, y: Vector)
| 216 | |
| 217 | |
| 218 | def axpy(scalar: float, x: Vector, y: Vector) -> Vector: |
| 219 | """ |
| 220 | input: a 'scalar' and two vectors 'x' and 'y' |
| 221 | output: a vector |
| 222 | computes the axpy operation |
| 223 | """ |
| 224 | # precondition |
| 225 | assert isinstance(x, Vector) |
| 226 | assert isinstance(y, Vector) |
| 227 | assert isinstance(scalar, (int, float)) |
| 228 | return x * scalar + y |
| 229 | |
| 230 | |
| 231 | def random_vector(n: int, a: int, b: int) -> Vector: |