input: a 'scalar' and two vectors 'x' and 'y' output: a vector computes the axpy operation
(scalar, x, y)
| 224 | |
| 225 | |
| 226 | def axpy(scalar, x, y): |
| 227 | """ |
| 228 | input: a 'scalar' and two vectors 'x' and 'y' |
| 229 | output: a vector |
| 230 | computes the axpy operation |
| 231 | """ |
| 232 | # precondition |
| 233 | assert ( |
| 234 | isinstance(x, Vector) |
| 235 | and (isinstance(y, Vector)) |
| 236 | and (isinstance(scalar, int) or isinstance(scalar, float)) |
| 237 | ) |
| 238 | return x * scalar + y |
| 239 | |
| 240 | |
| 241 | def randomVector(N, a, b): |