BasicVector¶
-
class
kona.user.
BaseVector
(size, val=0)[source]¶ Bases:
object
Kona’s default data container, implemented on top of NumPy arrays.
Any user defined data container must implement all the methods below.
These vectors are initialized by the user-created BaseAllocator object. Therefore, the initialization implementation does not need to exactly follow the example below. The user is free to initialize these vector objects any which way they like, as long as it is in sync with the BaseAllocator implementation.
Parameters: - size (int) – Size of the 1-D numpy vector contained in this object.
- val (float or array-like, optional) – Data value for vector initialization.
Variables: data (numpy.array) – Numpy vector containing numerical data.
-
equals_ax_p_by
(a, x, b, y)[source]¶ Perform the elementwise scaled addition defined below:
\[a\mathbf{x} + b\mathbf{y}\]The result is saved into this vector.
Parameters: - a (double) – Scalar coefficient of
x
. - x (BaseVector) – Vector to be operated on.
- b (double) – Scalar coefficient of
y
. - y (BaseVector) – Vector to be operated on.
- a (double) – Scalar coefficient of
-
equals_value
(value)[source]¶ Set all elements of this vector to given scalar value.
Parameters: value (float) –
-
equals_vector
(vector)[source]¶ Set this vector equal to the given vector.
Parameters: vector (BaseVector) – Incoming vector for in-place operation.
-
exp
(vector)[source]¶ Calculate element-wise exponential operation on the vector.
Parameters: vector (BaseVector) – Incoming vector for in-place operation.
-
infty
¶ Infinity norm of the vector.
Returns: Infinity norm. Return type: float
-
inner
(vector)[source]¶ Perform an inner product between the given vector and this one.
Parameters: vector (BaseVector) – Incoming vector for in-place operation. Returns: Result of the operation. Return type: float
-
log
(vector)[source]¶ Calculate element-wise natural log operation on the vector.
Kona will never call this on zero-valued vectors. No special handling of zero values necessary.
Parameters: vector (BaseVector) – Incoming vector for in-place operation.
-
plus
(vector)[source]¶ Add the given vector to this vector.
Parameters: vector (BaseVector) – Incoming vector for in-place operation.
-
pow
(power)[source]¶ Calculate element-wise power operation on the vector.
Kona will never call a negative power on zero-valued vectors. No special handling of zero values necessary.
Parameters: power (float) –
-
times_scalar
(value)[source]¶ Multiply all elements of this vector with the given scalar.
Parameters: value (float) –
-
times_vector
(vector)[source]¶ Perform element-wise multiplication between vectors.
Parameters: vector (BaseVector) – Incoming vector for in-place operation.