| igraph Reference Manual |
|---|
igraph_vector_init — Initializes a vector object (constructor).igraph_vector_init_copy — Initializes a vector from an ordinary C array (constructor).igraph_vector_init_seq — Initializes a vector with a sequence.igraph_vector_copy — Initializes a vector from another vector object (constructor).igraph_vector_destroy — Destroys a vector object.igraph_vector_t objects have to be initialized before using
them, this is analogous to calling a constructor on them. There are a
number of igraph_vector_t constructors, for your
convenience. igraph_vector_init() is the basic constructor, it
creates a vector of the given length, filled with zeros.
igraph_vector_copy() creates a new identical copy
of an already existing and initialized vector. igraph_vector_init_copy() creates a vector by copying a regular C array.
igraph_vector_init_seq() creates a vector containing a regular
sequence with increment one.
igraph_vector_view() is a special constructor, it allows you to
handle a regular C array as a vector without copying
its elements.
If a igraph_vector_t object is not needed any more, it
should be destroyed to free its allocated memory by calling the
igraph_vector_t destructor, igraph_vector_destroy().
Note that vectors created by igraph_vector_view() are special,
you mustn't call igraph_vector_destroy() on these.
int igraph_vector_init (igraph_vector_t* v, int long size);
Every vector needs to be initialized before it can be used, and there are a number of initialization functions or otherwise called constructors.
Every vector object initialized by this function should be
destroyed (ie. the memory allocated for it should be freed) when it
is not needed anymore, the igraph_vector_destroy() function is
responsible for this.
Arguments:
|
Pointer to a not yet initialized vector object. |
|
The size of the vector. |
Returns:
error code:
|
Time complexity: operating system dependent, the amount of “time” required to allocate O(n) elements, n is the number of elements.
int igraph_vector_init_copy(igraph_vector_t *v, igraph_real_t *data, long int length);
Arguments:
|
Pointer to an uninitialized vector object. |
|
A regular C array. |
|
The length of the C array. |
Returns:
Error code:
|
Time complexity: operating system specific, usually
O(length).
int igraph_vector_init_seq(igraph_vector_t *v, igraph_real_t from, igraph_real_t to);
The vector will contain the numbers from,
from+1, ..., to.
Arguments:
|
Pointer to an uninitialized vector object. |
|
The lower limit in the sequence (inclusive). |
|
The upper limit in the sequence (inclusive). |
Returns:
Error code:
|
Time complexity: O(n), the number of elements in the vector.
int igraph_vector_copy(igraph_vector_t *to, const igraph_vector_t *from);
The contents of the existing vector object will be copied to the new one.
Arguments:
|
Pointer to a not yet initialized vector object. |
|
The original vector object to copy. |
Returns:
Error code:
|
Time complexity: operating system dependent, usually O(n), n is the size of the vector.
void igraph_vector_destroy (igraph_vector_t* v);
All vectors initialized by igraph_vector_init() should be properly
destroyed by this function. A destroyed vector needs to be
reinitialized by igraph_vector_init(), igraph_vector_init_copy() or
another constructor.
Arguments:
|
Pointer to the (previously initialized) vector object to destroy. |
Time complexity: operating system dependent.
| << 2.1. About igraph_vector_t objects | 2.3. Initializing elements >> |