• Keine Ergebnisse gefunden

5.3 Complexity of the AMG preprocess

5.3.1 C/F -Splitting process

First we take a closer look at the coarsening process and its involved components.

Definition 5.3.1. For the level l let

n:=nl be the dimension of the current matrix Al, ri:= #N¯i

the number of nonzero entries in its i-th row, ci the number of nonzero entries in its i-th column, si := #

Si

the number of strong (negative) neighbours of i, sTi := #

SiT

the number of variables which have ias a strong neighbour.

Furthermore, rav=Pn

i=1ri/n denotes the average number of nonzero entries in its rows and rmax:=

maxi=1,...,nri the maximal number of entries in a row. Similarly we define cmax,smax,sTmax,etc.

Preliminaries

We will use the symbols and notation of Section 5.2. Before we can apply Algorithm 2 we have to compute the sets Si and SiT for every i in Ω ={1, . . . , n}. Note that both sets can be computed in the same loop withPn

i=12ri = 2nrav comparisons (and as many assignments in the worst case).

Concerning the coarsening algorithm itself, first the weights λi (cf. (5.51)) have to be computed.

Since in the beginning, it is U = Ω and F = ∅, we have λi = # SiT

, for i = 1, . . . , n, requiring n assignments only, since the cardinality of the sets SiT should be computed on the fly by the above procedure. The first maximalλi is obtained while setting the initial weights.

Generating the C/F-Splitting and updating the weights

Setting i as a C-variable and all j ∈ SiT as F-variables should require not more than 1 + # SiT assignments if an arrayv of length nis held for storing the splitting, e.g. like:

v[i] =

(”true” i∈C,

”f alse” i∈F.

After assigning the new C- and F-variables, the according weights must be updated. Of course only the weights for which λi has changed must be treated. If imax is the variable chosen to be the new C-Variable (in line 2 of Algorithm 2) and Himax := SiTmax ∩U (cf. line 3 of the algorithm) the weights for all variables iwith

i∈Timax := (Simax ∪ [

j∈Himax

Sj)∩U (5.56)

have to be computed newly. Let λ(k)i be the weight of variable i and U(k), F(k) the according sets after the k-th iteration of the while loop beginning in line 1 of algorithm 2. Then the weights after the (k+ 1)-th iteration of the loop are:

λ(k+1)i = #

SiT ∩U(k+1) + 2#

SiT ∩F(k+1)

We are now looking for an update formula to computeλ(k+1)i in terms ofU(k),F(k), rather thanU(k+1) and F(k+1). This is evaluated in the following lemma.

Lemma 5.3.2. For the weights λ(k+1)i , i∈Ω the following relation holds:

λ(k+1)i(k)i + #

Proof. First we look at the according sets and observe:

(i.) otherwise, we can write the cardinality of the set as

#

Combining now (i.) and (ii.) completes the proof.

In the worst case, all variables whose weights have to updated, are yet undecided. Thus, for the cardinality ofTimax we have

#

) + 1 operations. Therefore, the computational cost of one iteration of the while loop is bounded by

4(smaxsTmax+smax(sTmax)2) +smax+smaxsTmax. (5.59) Now the number of variables erased fromU at each loop iteration is at least 1 and at most 1 +smax. Thus, the number of loop iterations is bounded above bynand below byn/(1 +smax). Summarizing the results, we can state the following

Lemma 5.3.3. The computational cost for updating the weights during the splitting process is bounded above by

n(smax+ 5smaxsTmax+ 4smax(sTmax)2). (5.60) Finding the next variable with maximal weight

The last problem, we have to deal with, is to find the next variable with maximal weightλmax. That this can be a problem might become clear if we claim two requirements for theC/F-Splitting process:

• Setting/accessing a weightλi must be possible in constant time O(1).

• Finding a maximal weight λmax = maxi∈Uλi must be possible in a time significantly smaller thanO(n).

Just storing theλi’s in an array fulfills the first requirement, but not the second. If we use a data structure like a priority queue, where updating a weight automatically causes the variable ito move up/down in the queue (according to its new weight), then we can fulfill the second requirement, but not the first.

As a way out of this dilemma, we propose a kind of combination of both data structures. This is possible due to the observation that the values for the weights have the upper bound

λi ≤2sTmax, ∀i∈Ω, (5.61)

and therefore many variables have the same weight. Thus, first of all, we store the weight of each variablei in an array λof length n (with λ[i] =λi). Then we group together all variables that have the same weight in an own linked list. Since there can be maximal 2sTmax+ 1 of such lists (including zero weight), we store them in an array, sayw, which we address by the weightsλ[i], meaning that at w[λ[i]] we find all variables with the according weight.

Accessing and updating the weight for a vaiableiin the arrayλcan now be done in constant time (λ[i] :=λnewi ). Updating the weight foriinwnow consists of accessing the linked listw[λi] (constant time), finding the variablei(we will get to this immediately), then removingiout of this list (constant time) and finally inserting it into the listw[λnewi ] (constant time).

Finding the variable i in the list w[λi] would normally be of time O(n) or O(logn) if we keep it sorted, unless we use an auxiliary data arraypof lengthnthat stores a pointer (or iterator in modern

programming languages) to the element i. Sop[i] indicates the position ofiinw[λi], which can thus be located in constant time.

Now we have shown that accessing and updating a weight can be realized inO(1) time complexity (and O(n) memory complexity). Finding a maximal new weight now simply consists of finding (any) element from the topmost non-empty list inw, which can be done in a maximal time ofO(2sTmax+ 1).

Of course, one has to point out, that variablesi, which are marked asCorF variables, are removed from their according list in w. Their weight inλ[i] might then be set to a negative value to indicate this.

Complexity of the C/F-Splitting process

Concludingly, we have proven the following theorem, which is an extension of Lemma 5.3.3.

Theorem 5.3.4 (Complexity of the C/F-Splitting process). The time complexity of the splitting procedure described in Algorithm 2 is

n(smax+ 5smaxsTmax+ 4smax(sTmax)2+ 2sTmax+ 1). (5.62) Since in the FEM context, the number of neighbours of a node depends only on the degree of the used elements and not on the mesh widthh, the values ofrmax andcmaxare independent ofn(indeed, they are equal for structured meshes). Furthermore, we note that smax ≤rmax and sTmax ≤cmax and therefore we have a linear complexity of the splitting procedure which we want to note down in a corollary.

Corollary 5.3.5. For matrices arizing from finite element discretizations, the time complexity of the C/F-Splitting procedure is bounded above by

O(n(3rmax+ 5(rmax)2+ 4(rmax)3+ 1)) =O(n(rmax)3) =O(n). (5.63) Moreover, the memory consumption is also of order O(n).