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 usercreated 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 1D numpy vector contained in this object.
 val (float or arraylike, 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 inplace operation.

exp
(vector)[source]¶ Calculate elementwise exponential operation on the vector.
Parameters: vector (BaseVector) – Incoming vector for inplace 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 inplace operation. Returns: Result of the operation. Return type: float

log
(vector)[source]¶ Calculate elementwise natural log operation on the vector.
Kona will never call this on zerovalued vectors. No special handling of zero values necessary.
Parameters: vector (BaseVector) – Incoming vector for inplace operation.

plus
(vector)[source]¶ Add the given vector to this vector.
Parameters: vector (BaseVector) – Incoming vector for inplace operation.

pow
(power)[source]¶ Calculate elementwise power operation on the vector.
Kona will never call a negative power on zerovalued 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 elementwise multiplication between vectors.
Parameters: vector (BaseVector) – Incoming vector for inplace operation.