MCPcopy Create free account
hub / github.com/subbarayudu-j/TheAlgorithms-Python / unitBasisVector

Function unitBasisVector

linear_algebra_python/src/lib.py:155–164  ·  view source on GitHub ↗

returns a unit basis vector with a One at index 'pos' (indexing at 0)

(dimension,pos)

Source from the content-addressed store, hash-verified

153
154
155def 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
167def axpy(scalar,x,y):

Callers 1

test_unitBasisVectorMethod · 0.85

Calls 1

VectorClass · 0.85

Tested by 1

test_unitBasisVectorMethod · 0.68