# HG changeset patch # User Minh Van Nguyen # Date 1305295810 25200 # Node ID 20adce9468afda8100405eb57a3e6667b0326a5b # Parent 3ee6854bb6e85a7dee5ec6242e853ad51d37851d vector of zeros; based on trunk #2463 The default behaviour of igraph_vector_init() is to construct a vector of a given size and then initializes each entry to zero. Document this and point out that one could just use igraph_vector_init() to create a vector of zeros, rather than first construct a vector and then use igraph_vector_null(). diff --git a/examples/simple/vector.c b/examples/simple/vector.c --- a/examples/simple/vector.c +++ b/examples/simple/vector.c @@ -43,6 +43,11 @@ igraph_vector_init(&v, 0); igraph_vector_destroy(&v); + /* vector of zeros */ + igraph_vector_init(&v, 10); + print_vector(&v, stdout); + igraph_vector_destroy(&v); + /* VECTOR(), igraph_vector_size */ igraph_vector_init(&v, 10); for (i=0; i * Every vector needs to be initialized before it can be used, and * there are a number of initialization functions or otherwise called - * constructors. + * constructors. This function constructs a vector of the given size and + * initializes each entry to 0. Note that \ref igraph_vector_null() can be + * used to set each element of a vector to zero. However, if you want a + * vector of zeros, it is much faster to use this function than to create a + * vector and then invoke \ref igraph_vector_null(). * * * Every vector object initialized by this function should be @@ -620,7 +624,8 @@ * * Note that \ref igraph_vector_init() sets the elements to zero as well, so * it makes no sense to call this function on a just initialized - * vector. + * vector. Thus if you want to construct a vector of zeros, then you should + * use \ref igraph_vector_init(). * \param v The vector object. * * Time complexity: O(n), the size of