Parallelised
>>> from vector import vecnpadd
>>> vecnpadd((1, 2), ((3, 4, 5),
... (6, 7, 8)))
array([[4, 6, 5],
[7, 9, 8]])
Prefixed by vecnp... (vector numpy).
numpy-versions of the functions are also provided, to operate on multiple vectors at once. They behave like the ones in numpy.polynomial.polynomial, but also work on 2D-arrays (and all combinations of 1D & 2D arrays) and broadcast to multiple dimensions like the usual numpy operations (but adjust the shapes accordingly).
vecnpzero is np.array([0]) like numpy.polynomial.polynomial.polyzero, not veczero=() (empty tuple, no zero coefficient left) like in the functions and class above.
Padding is done with numpy.int64(0).
They return scalars or numpy.ndarrays.
Creation routines have a dimension argument d. If left to None, the returned values are 1D, so a single vector. If given, the routines return a 2D-array representing multiple vectors in rows.
Creation
vecnpzero(d=None)
Return d zero vectors.
The returned value is a (d, 1)-array of zeros if d is not None
or [0] otherwise.
Source code in vector\parallelised.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 | |
vecnpbasis(i, c=1, d=None)
Return d many i-th basis vectors times c.
The returned value is a (d, i+1)-array if d is not None
or (i+1,) otherwise.
Source code in vector\parallelised.py
34 35 36 37 38 39 40 41 42 43 | |
vecnprand(n, d=None)
Return d random vectors of n uniform coefficients in [0, 1[.
The returned value is a (d, n)-array if d is not None
or (n,) otherwise.
Source code in vector\parallelised.py
45 46 47 48 49 50 51 | |
vecnprandn(n, normed=True, d=None)
Return d random vectors of n normal distributed coefficients.
The returned value is a (d, n)-array if d is not None
or (n,) otherwise.
Source code in vector\parallelised.py
53 54 55 56 57 58 59 60 | |
Utility
vecnpdim(v)
Return the number of allocated dimensions in this vector or vectors.
Source code in vector\parallelised.py
64 65 66 | |
vecnpeq(v, w)
Return if two vectors are equal.
Source code in vector\parallelised.py
68 69 70 71 72 73 74 | |
vecnptrim(v, tol=1e-09)
Remove all trailing near zero (abs(v_i)<=tol) coefficients.
Source code in vector\parallelised.py
76 77 78 79 80 81 82 83 84 | |
vecnpround(v, ndigits=0)
Wrapper for numpy.round.
Source code in vector\parallelised.py
86 87 88 | |
Hilbert space
vecnpabsq(v)
Return the sum of absolute squares of the coefficients.
Source code in vector\parallelised.py
92 93 94 | |
vecnpabs(v)
Return the Euclidean/L2-norm.
Source code in vector\parallelised.py
96 97 98 | |
vecnpdot(v, w)
Return the inner product of two vectors without conjugation.
Source code in vector\parallelised.py
100 101 102 103 104 105 | |
vecnpparallel(v, w)
Return if two vectors are parallel.
Source code in vector\parallelised.py
107 108 109 110 | |
Vector space
vecnppos(v)
Return the vector with the unary positive operator applied.
Source code in vector\parallelised.py
114 115 116 | |
vecnpneg(v)
Return the vector with the unary negative operator applied.
Source code in vector\parallelised.py
118 119 120 | |
vecnpadd(*vs)
Return the sum of vectors.
Source code in vector\parallelised.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
vecnpsub(v, w)
Return the difference of two vectors.
Source code in vector\parallelised.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
vecnpmul(a, v)
Return the product of a scalar and a vector.
Source code in vector\parallelised.py
157 158 159 | |
vecnptruediv(v, a)
Return the true division of a vector and a scalar.
Source code in vector\parallelised.py
161 162 163 | |
vecnpfloordiv(v, a)
Return the floor division of a vector and a scalar.
Source code in vector\parallelised.py
165 166 167 | |
vecnpmod(v, a)
Return the elementwise mod of a vector and a scalar.
Source code in vector\parallelised.py
169 170 171 | |