| igraph Reference Manual |
|---|
igraph_vector_add_constant — Add a constant to the vector.igraph_vector_scale — Multiply all elements of a vector by a constantigraph_vector_add — Add two vectors.igraph_vector_sub — Subtract a vector from another one.igraph_vector_mul — Multiply two vectors.igraph_vector_div — Divide a vector by another one.
void igraph_vector_add_constant(igraph_vector_t *v, igraph_real_t plus);
plus is added to every element of v. Note that overflow
might happen.
Arguments:
|
The input vector. |
|
The constant to add. |
Time complexity: O(n), the number of elements.
void igraph_vector_scale(igraph_vector_t *v, igraph_real_t by);
Arguments:
|
The vector. |
|
The constant. |
Returns:
Error code. The current implementation always returns with success. |
Added in version 0.2.
Time complexity: O(n), the number of elements in a vector.
int igraph_vector_add(igraph_vector_t *v1, const igraph_vector_t *v2);
Add the elements of v2 to v1, the result is stored in v1. The two vectors must have the same length.
Arguments:
|
The first vector, the result will be stored here. |
|
The second vector, its contents will be unchanged. |
Returns:
Error code. |
Time complexity: O(n), the number of elements.
int igraph_vector_sub(igraph_vector_t *v1, const igraph_vector_t *v2);
Substract the elements of v2 from v1, the result is stored in
v1. The two vectors must have the same length.
Arguments:
|
The first vector, to subtract from. The result is stored here. |
|
The vector to subtract, it will be unchanged. |
Returns:
Error code. |
Time complexity: O(n), the length of the vectors.
int igraph_vector_mul(igraph_vector_t *v1, const igraph_vector_t *v2);
v1 will be multiplied by v2, elementwise. The two vectors
must have the same length.
Arguments:
|
The first vector, the result will be stored here. |
|
The second vector, it is left unchanged. |
Returns:
Error code. |
Time complexity: O(n), the number of elements.
int igraph_vector_div(igraph_vector_t *v1, const igraph_vector_t *v2);
v1 is divided by v2, elementwise. They must have the same length. If the
base type of the vector can generate divide by zero errors then
please make sure that v2 contains no zero if you want to avoid
trouble.
Arguments:
|
The dividend. The result is also stored here. |
|
The divisor, it is left unchanged. |
Returns:
Error code. |
Time complexity: O(n), the length of the vectors.
| << 2.7. Exchanging elements | 2.9. Finding minimum and maximum >> |