From: Tamas Nepusz Date: Wed, 2 Jan 2019 15:51:48 +0000 (+0100) Subject: [PATCH] use a different starting vector for igraph_community_leading_eigenvector... X-Git-Tag: archive/raspbian/0.8.2+ds-1+rpi1~1^2^2~1 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=5a8fec91d960bd218287bf19770c0fd18bb84a8a;p=igraph.git [PATCH] use a different starting vector for igraph_community_leading_eigenvector() to prevent errors with ARPACK 3.6.3 Gbp-Pq: Name different_starting_vector.patch --- diff --git a/src/community.c b/src/community.c index 3370679..5e836dc 100644 --- a/src/community.c +++ b/src/community.c @@ -1736,13 +1736,19 @@ int igraph_community_leading_eigenvector(const igraph_t *graph, igraph_set_error_handler(errh); igraph_set_warning_handler(warnh); if (options->nconv < 1) { - /* Call again, from a fixed starting point */ + /* Call again from a fixed starting point. Note that we cannot use a + * fixed all-1 starting vector as sometimes ARPACK would return a + * 'starting vector is zero' error -- this is of course not true but + * it's a result of ARPACK >= 3.6.3 trying to force the starting vector + * into the range of OP (i.e. the matrix being solved). The initial + * vector we use here seems to work, but I have no theoretical argument + * for its usage; it just happens to work. */ options->start=1; options->info=0; options->ncv=0; options->lworkl = 0; /* we surely have enough space */ for (i=0; i < options->n ; i++) { - storage.resid[i] = 1; + storage.resid[i] = i % 2 ? 1 : -1; } IGRAPH_CHECK(igraph_arpack_rssolve(arpcb2, &extra, options, &storage, /*values=*/ 0, /*vectors=*/ 0)); @@ -1774,12 +1780,13 @@ int igraph_community_leading_eigenvector(const igraph_t *graph, /*values=*/ 0, /*vectors=*/ 0); igraph_set_error_handler(errh); if (options->nconv < 1) { - /* Call again from a fixed starting point */ + /* Call again from a fixed starting point. See the comment a few lines + * above about the exact choice of this starting vector */ options->start=1; options->info=0; options->ncv=0; options->lworkl = 0; /* we surely have enough space */ - for (i=0; i < options->n; i++) { storage.resid[i] = 1; } + for (i=0; i < options->n; i++) { storage.resid[i] = i % 2 ? 1 : -1; } IGRAPH_CHECK(igraph_arpack_rssolve(arpcb1, &extra, options, &storage, /*values=*/ 0, /*vectors=*/ 0)); options->start=0;