op_vvec_size_get()
Abstract
Returns the number of elements in a given value vector.
Syntax
op_vvec_size_get (vector)
| Argument | Type | Description |
|---|---|---|
vector |
Vvec_Vector |
vector of interest [This vector is the subject of this procedure, which returns the number of elements in the vector.] |
Return Type
int
Total size (in elements) of the specified vector.
Example
/* Determine the size of a vector before applying it to an esys interface. */
op_ima_obj_attr_get (interface_id, "dimension", &interface_dim);
if (op_vvec_size_get (src_vector) == interface_dim)
{
/* apply the vector value. */
op_esys_interface_vector_set (interface_id, op_sim_time (), src_vector, 0);
}
else
{
printf ("Error: interface dimension and vector size do not match.\n");
}
Details
Not all elements need to be defined in order to be counted toward the vector size. The size of the value vector is 1 plus the index number of the last element in the vector. The following vector, for example, has a size of 6:
vector = {0, 1, 2, 3, 4, 5}
Purpose
Provides a mechanism to determine the number of elements in a value vector.
Errors
- Recoverable Error: Value vector is invalid.
Reference
- Use the KP op_vvec_from_value() to convert a value to a bit representation of that value
- Use the KP op_vvec_to_value() to convert a bit representation to a value
- Use the KP op_vvec_type_get() to determine the data type of a vector