Module vector provides class Vector, function and some exception.
Module vector provides classes as follows.
Class Vector is an elemental class of vector.
>>> aVector=Vector(list)Variable aVector initializes to Vector object.
>>> u=Vector([0,1,3]) >>> v=Vector([2,1,2]) >>> z=Vector([0]*3) >>> z Vector [0, 0, 0]
>>> u+v Vector [2, 2, 5] >>> -u Vector [0, -1, -3]
>>> v*3 Vector [6, 3, 6]
>>> len(u) 3
>>> repr(u) 'Vector [0, 1, 3]'
>>> str(u) '[0, 1, 3]'
>>> x=u.copy() >>> x Vector [0, 1, 3]
>>> x.set([2,1]) >>> x Vector [2, 1]
>>> u.indexOfNoneZero() 2 >>> x.indexOfNoneZero() 1 >>> z.indexOfNoneZero() Traceback (most recent call last): File "<stdin>", line 1, in ? File "vector.py", line 94, in indexOfNoneZero raise Exception, "all zero" Exception: all zero
Class VectorSizeError defines Exception VectorSizeError.
Module vector provides functions as follows.
return innerProduct.
>>> innerProduct(u,v) 7
Module vector provide exceptions as follows.
Exception VectorSizeError occurs additive operation with two vector of different length.
>>> u=Vector([0,1,3]) >>> w=Vector([4,3,2,0]) >>> u+w Traceback (most recent call last): File "<stdin>", line 1, in ? File "vector.py", line 31, in __add__ raise VectorSizeError VectorSizeError
This module can be used independently of other NZMATH modules.
innerProduct with imaginary module are not implemented.