returns a unit basis vector with a One at index 'pos' (indexing at 0)
(dimension,pos)
| 153 | |
| 154 | |
| 155 | def unitBasisVector(dimension,pos): |
| 156 | """ |
| 157 | returns a unit basis vector with a One |
| 158 | at index 'pos' (indexing at 0) |
| 159 | """ |
| 160 | #precondition |
| 161 | assert(isinstance(dimension,int) and (isinstance(pos,int))) |
| 162 | ans = [0]*dimension |
| 163 | ans[pos] = 1 |
| 164 | return Vector(ans) |
| 165 | |
| 166 | |
| 167 | def axpy(scalar,x,y): |