KonaVector (base class)¶
-
class
kona.linalg.vectors.common.
KonaVector
(memory_obj, user_vector=None)[source]¶ Bases:
object
An abstract vector class connected to the Kona memory, containing a common set of algebraic member functions. Allows Kona to operate on data spaces allocated by the user.
Parameters: - memory_obj (KonaMemory) – Pointer to the Kona user memory.
- user_vector (BaseVector) – User defined vector object that contains data and operations on data.
Variables: - _memory (UserMemory) – Pointer to the Kona user memory.
- base (BaseVector) – User defined vector object that contains data and operations on data.
-
divide_by
(val)[source]¶ Used as the division operator.
Divides the vector by the given scalar value.
Parameters: value (float) – Vector to be added.
-
equals
(val)[source]¶ Used as the assignment operator.
If val is a scalar, all vector elements are set to the scalar value.
If val is a vector, the two vectors are set equal.
Parameters: val (float or KonaVector) – Right hand side term for assignment.
-
equals_ax_p_by
(a, X, b, Y)[source]¶ Performs the scaled summation operation,
a*X + b*Y
, between two vectors, and stores the result in place.Parameters: - a (float) – Scalar coefficient for
X
. - X (KonaVector) – Vector for the operation.
- b (float) – Scalar coefficient for
Y
. - Y (KonaVector) – Vector for the operation.
- a (float) – Scalar coefficient for
-
exp
(vector)[source]¶ Performs an element-wise exponential operation on the given vector and stores the result in-place.
Parameters: vector (KonaVector) – Vector for the operation.
-
infty
¶ Computes the infinity norm of the vector
Returns: Infinity norm. Return type: float
-
inner
(vector)[source]¶ Computes an inner product with another vector.
Returns: Inner product. Return type: float
-
log
(vector)[source]¶ Performs an element-wise natural log operation on the given vector and stores the result in-place.
Parameters: vector (KonaVector) – Vector for the operation.
-
minus
(vector)[source]¶ Used as the subtraction operator.
Subtracts the incoming vector from the current vector in place.
Parameters: vector (KonaVector) – Vector to be subtracted.
-
norm2
¶ Computes the L2 (Euclidian) norm of the vector.
Returns: L2 norm. Return type: float
-
plus
(vector)[source]¶ Used as the addition operator.
Adds the incoming vector to the current vector in place.
Parameters: vector (KonaVector) – Vector to be added.
-
times
(factor)[source]¶ Used as the multiplication operator.
Can multiply both by scalars or element-wise by vectors.
Parameters: factor (float or KonaVector) – Scalar or vector-valued multiplication factor.