input: a 'scalar' and two vectors 'x' and 'y' output: a vector computes the axpy operation
(scalar,x,y)
| 165 | |
| 166 | |
| 167 | def axpy(scalar,x,y): |
| 168 | """ |
| 169 | input: a 'scalar' and two vectors 'x' and 'y' |
| 170 | output: a vector |
| 171 | computes the axpy operation |
| 172 | """ |
| 173 | # precondition |
| 174 | assert(isinstance(x,Vector) and (isinstance(y,Vector)) \ |
| 175 | and (isinstance(scalar,int) or isinstance(scalar,float))) |
| 176 | return (x*scalar + y) |
| 177 | |
| 178 | |
| 179 | def randomVector(N,a,b): |