<<

Sparse storage and solution methods MATH2071: Numerical Methods in Scientific Computing II http://people.sc.fsu.edu/∼jburkardt/classes/math2071 2020/sparse/sparse.pdf

Let’s just concentrate on the seats that are occupied!

Sparse Matrices

Given a linear system in which the system has very few nonzero elements, find efficient methods for storing the matrix, and for solving the linear system.

1 Where do sparse matrices come from?

So far, the sparse matrices we have seen have had great regularity. Diagonal and tridiagonal matrices can be thought of as sparse, but their structure is so simple that there are many efficient ways to store the values and do operations. Matrices associated with a 2D or 3D finite difference scheme over a rectangular region are sparse, and sparse storage can be useful for them; however, these examples are not typical, since almost every row of the matrix has the same number of nonzeros, showing up at predictable locations. A more challenging example of a sparse matrix occurs in finite element methods, where an irregular region is meshed with triangles, or other polygonal shapes. Just as in finite differences, we write an equation at each node of the mesh, and that equation will involve the approximate solution values at the node, and at all the nodes which are the immediate neighbors. Unlike the finite difference example, we generally can’t predict in advance the locations of these neighbors, or their number. For example, in a study of the ice sheets of Greenland, a mesh involving 900,000 nodes was created. These nodes were placed in such a way that the mesh was very fine near the coast, and near locations of rapid icesheet movement. It was then necessary to organize these nodes into triangles, using a technique known as Delaunay triangulation and then to build the finite element matrix, in a process similar to what we have done for finite element problems.

1 Greenland, and a small portion of the mesh. Consider the fact that, in the picture of the mesh, each node will generate an equation. Each neighbor node, that is joined by a connecting line, will be associated with a nonzero coefficient in that equation. Thus, each row of our matrix will have an unknown number of nonzeros, at unknown locations, which cannot be predicted in advance, until we analyze the connections in the mesh.

2 Sparse tools in MATLAB

Given a matrix A stored in the usual m × n dense format, MATLAB provides us with some functions that can help us if we suspect that the matrix is sparse. Whether a matrix is stored using full or sparse storage, we can count the number of nonzeros and report the relative sparsity by the following commands: 1 count = nnz (A); 2 sparsity = count /m/ n; 3 fprintf ( 1, ’ Matrix has %d nonzeros, with sparsity %g\n’, count, sparsity ); To extract the values of the nonzeros in the matrix: 1 v = nonzeros (A); To determine the locations and values of the nonzeros: 1 [ i , j , v ] = find (A); To see a picture of the nonzero pattern of the matrix: 1 spy (A)

3 Exercise: Examine a matrix

Use the A=dif2 matrix(m,n) function from the web page to generate a dense second difference matrix of dimension 20 × 20. We can use the MATLAB sparse tools to analyze the matrix, extract the nonzeros, and see a picture of the sparsity pattern. Now let’s look at a random sparse matrix. Use MATLAB’s sprand(m,n,sparsity) function, which returns a matrix in sparse format, with a sparsity percentage of the entries being nonzero. The location and values of these entries are chosen at random.

2 1 m = 1 2 ; 2 n = 9 ; 3 sparsity = 0.15; 4 A= sprand ( m, n, sparsity ); Listing 1: How to define a random sparse matrix.

Determine the actual number of nonzeros, the actual sparsity, and extract the rows, columns, and values of the nonzero entries. Use spy(A) to see a picture of this matrix. Copy the file wathen sparse matrix.m, which, for a certain finite element problem, generates the system matrix in MATLAB sparse format. Create the matrix W = wathen sparse matrix(3, 3). Here the 3 × 3 is not the dimension of the grid, but a count of the number of elements used. This matrix will actually be of dimensions 40 × 40. Determine the number of nonzeros, the sparsity, and extract the rows, columns, and values of the nonzero entries for this matrix. Use spy(W) to see a picture of this matrix.

4 Creating a MATLAB sparse matrix

MATLAB can work with matrices in full (dense) or sparse format. If we have a matrix in full storage format, we can convert it to sparse format:

1 Asparse = sparse (A);

Similarly, if we have a matrix in sparse format, we can convert it to full format:

1 B f u l l = f u l l (B);

A matrix is a collection of values Ai,j. We could think of a matrix as a list of its nonzero entries, that is, a table of values i, j, v, where each v is a value Ai,j. This is how MATLAB thinks of a sparse matrix. If we have three such vectors of rows, columns, and values, we can create the corresponding MATLAB sparse matrix:

1 A = sparse ( i , j , v )

Consider the following matrix:  11 0 0 14 15   21 22 0 0 0  A =    0 0 33 0 0  41 0 0 44 45 We can up this matrix sparsely as:

1 i = [1,1,1,2,2,3,4,4,4]; 2 j = [1,4,5,1,2,3,1,4,5]; 3 v = [11,14,15,21,22,33,41,44,45]; 4 A = sparse ( i , j , v ) ; Listing 2: Converting i j v to a MATLAB sparse matrix.

3 5 Exercise: Set up a MATLAB sparse -1,2,-1 matrix

Consider the following 4 × 4 matrix C:  2 −1 0 0   −1 2 −1 0  C =    0 −1 2 −1  0 0 −1 2

Use MATLAB commands to define the vectors i, j, v, and create a sparse matrix C.

1. Determine the number of rows and columns in the matrix; 2. Determine the number of nonzero elements in C? 3. What command will return the vectors i, j, v from C? 4. What is the inverse of C? Is it also stored as a sparse matrix? Is it sparse? 5. What happens if you use the [V,L]=eigs(C) command to get information?

6 Reading a MATLAB sparse matrix from a file

Our example matrix could be described by the following table: i j v ------1 1 11 1 4 14 1 5 15 2 1 21 2 2 22 3 3 33 4 4 44 4 5 45 Suppose we had stored this information in a file: example sparse matrix.txt. We can read this data file into MATLAB using the load() function, which results in an 8 × 3 array, whose columns are the row index, column index, and value of the nonzeros. MATLAB has an spconvert() command that will convert this data to a sparse matrix in one step:

1 data = load ( ’ e x a m p l e s p a r s e matrix.txt’ ); 2 A = spconvert ( data ) ; Listing 3: Read sparse data from file to create sparse matrix.

7 The Sparse Triplet (ST) storage scheme

The sparse triplet storage scheme is extremely simple. We are given an m × n matrix A, which has nst nonzero elements. We can represent the matrix by storing, for each nonzero element Ai,j, the row index, column index, and value, in arrays ist(1:nst), jst(1:nst), vst(1:nst). Of course, the ST scheme only makes sense for large, sparse matrices, for which 3 ∗ nst << m ∗ n. We must also assume that, once we have replaced the dense matrix by the ST version, we can still perform any linear algebra tasks we need. We will see that can still be done with this representation. However, computing the LU factorization would not be possible, because the LU factors of a sparse matrix are not necessarily sparse at all.

4 As a reminder of how the ST scheme works, consider this 4 × 5 matrix A:

 11 0 0 14 15   21 22 0 0 0  A =    0 0 33 0 0  41 0 0 44 45

for which the nst = 8 nonzero entries could be stored in ST form as: ist jst vst 1 1 11 2 1 21 4 1 41 2 2 22 3 3 33 1 4 14 4 4 44 4 5 45

Consider that a “small” version of our 2d Poisson problem, using a 100 × 100 grid, involves 10,000 variables. The full matrix is therefore 100,000,000 entries. However, typically, there are at most 5 nonzero coefficients in each equation, for a total of nst ≈ 50, 000 nonzero values. Therefore, we could store this matrix using 50,000 real values (vst) and two integer arrays each of length 50,000. Our storage costs have gone down by a factor of roughly 700.

8 Matrix multiplication using ST

If we want to solve a big sparse linear system, we are likely to be using an . Most iterative methods require the ability to compute matrix-vector products like y = A ∗ x or y = A0 ∗ x. If we are using some kind of sparse storage, then we need to know how to produce such results efficiently. If our m × n matrix A is in ST storage format, how do we compute the product y = A ∗ x? Actually, this is quite simple. We initialize y to zero. Every nonzero matrix entry Ai,j must be used. We use it by multiplying it times xj and adding this to yi. This can be done the following code: 1 function y = st mv ( m, n, nst, ist, jst, vst, x ) 2 y = zeros ( m, 1 ) ; 3 for k = 1 : nst 4 i = i s t ( k ) ; 5 j = j s t ( k ) ; 6 aij=vst(k); 7 y(i)=y(i)+aij ∗ x ( j ) ; 8 end 9 return 10 end Listing 4: st mv.m: Matrix-vector multiplication for an ST matrix.

9 Exercise: ST Matrix multiplication

If you copy the file dif2 st matrix.m, you can create an m×n version of the second difference matrix −1, 2, −1 in Sparse Triplet form using the command:

1 [ nst, ist, jst, vst ]=dif2 s t matrix ( m, n )

5 Create a 100 × 100 second difference matrix this way. Then create a vector x

1 x=(1:100)’; % Don’t forget to the vector!

Now create the function st mv(), and use it to compute y = A ∗ x. The result y should be entirely zero, except for a final entry of 101.

10 Residual calculation using ST

The residual r = b − A ∗ x is useful to measure our error when using Gauss elimination, but also can be an important tool in Jacobi iteration. When the matrix is in ST format, we can write an appropriate function.

1 function r = s t resid ( nst, ist, jst, vst, b, x ) 2 r = b ; 3 for k = 1 : nst 4 i = i s t ( k ) ; 5 j = j s t ( k ) ; 6 aij=vst(k); 7 r ( i ) = r ( i ) − a i j ∗ x ( j ) ; 8 end 9 return 10 end Listing 5: st resid.m: Residual r

11 Jacobi iteration with a Sparse Triplet matrix

Now suppose we want to apply the to solve a linear system A ∗ x = b, where we have stored the matrix in ST format. The Jacobi iteration boils down to repeatedly applying the Jacobi update step. When A is in full storage, or MATLAB sparse storage, this step looks like this:

1 x = x + ( b − A ∗ x ) . / diag (A);

We have just seen how to compute the term ( b - A * x ) for the ST case, but how do we efficiently retrieve the diagonal elements? Although it is not part of the ST format requirements, we can make sure that we list the diagonal elements of the matrix first.

1 function x = s t j a c o b i update ( n, nst, ist, jst, vst, b, x ) 2 r = b ; 3 for k = 1 : nst 4 i = i s t ( k ) ; 5 j = j s t ( k ) ; 6 aij=vst(k); 7 r ( i ) = r ( i ) − a i j ∗ x ( j ) ; 8 end 9 10 for i = 1 : n 11 x(i)=x(i)+r(i) / vst(i); % vst(i) =A(i,i) 12 end 13 14 return 15 end Listing 6: st jacobi.m: One Jacobi update step in ST format.

6 12 Exercise: Sparse triplet Jacobi iteration

Use dif2 st matrix.m, to create a 20 × 20 version of the second difference matrix −1, 2, −1 in Sparse Triplet form.

1 n = 2 0 ; 2 [ nst, ist, jst, vst ]=dif2 s t matrix ( n, n );

Create a right hand side vector b:

1 b = zeros ( n , 1 ) ; 2 b ( n ) = n + 1 ;

The exact solution of the linear system A ∗ x = b is xexact=(1:20)’. Let’s just try 100 Jacobi iterations (with no convergence checks):

1 xexact=( 1:n)’; 2 x = zeros ( n , 1 ) ; 3 for i = 1 : 100 4 x = s t j a c o b i update ( n, nst, ist, jst, vst, b, x ); 5 end

After 100 iterations, what is norm(x-xexact)?

13 The Compressed Sparse Row (CSR) storage scheme

The Compressed Sparse Row (CSR) storage scheme is most easily explained as a slight improvement on Sparse Triplet (ST) storage. Note that the ST storage scheme does not require that the values be listed in any particular order. We happened to have listed them column by column, but the values could have been scrambled. It makes no difference. In order to use CSR, we need to be much more systematic in how we list the data. We begin by rearranging the ST data vectors so that they are sorted in order of row and then column. In other words, the nonzero entries in the matrix are recorded as though we started in the top left entry, (that is, A1,1), read across the first row, and then proceeded left to right along each subsequent row. For our example matrix, this would give us an ordering like this:

# ist jst vst 1 1 1 11 2 1 4 14 3 2 1 21 4 2 2 22 5 3 3 33 6 4 1 41 7 4 4 44 8 4 5 45

Now we list the data again, but we pay attention to the ist data, which lists the row index. This list will start at 1, repeat 1’s a few times, then move up to 2, then 3 and so on. We want to note the index at which each row index appears for the first time, and we include one more entry that points just past the end of the array. We store these in an array called icrs.

7 # ist row starts 1 1 1: row 1 starts at entry 1 2 1 - 3 2 3: row 2 starts at entry 3 4 2 - 5 3 5: row 3 starts at entry 5 6 4 6: row 4 starts at entry 6 7 4 - 8 4 8: row 5 starts at entry 8 9 * 9: row data ends before entry 9

The array icrs has length m + 1. In our example, icrs = [1,3,5,6,8,9]. You should realize that, from this array, we can reconstruct the ist array. Here’s how:

1 2 3 4 5 6 7 8 9 ist is equal to 1 from icrs(1) to icrs(2) - 1; 1 1 ist is equal to 2 from icrs(2) to icrs(3) - 1; 2 2 ist is equal to 3 from icrs(3) to icrs(4) - 1; 3 ist is equal to 4 from icrs(4) to icrs(5) - 1; 4 4 ist is equal to 5 from icrs(5) to icrs(6) - 1; 5 *

14 Exercise: Compressing the row index vector

Consider the following 5 × 4 matrix:

 11 0 0 14   0 22 0 0    A =  31 32 33 34     0 42 0 44  51 52 53 54

For this matrix, create the ST representation: ist, jst, vst: # ist jst vst 1 ...... 2 ...... 3 ...... 4 ...... 5 ...... 6 ...... 7 ...... 8 ...... 9 ...... 10 ...... 11 ...... 12 ...... 13 ...... To determine the CRS representation icrs, jcrs, vcrs, we have jcrs=jst, vcrs=vst, but we must com- press the row vector ist to get icrs:

8 # ist row starts 1 ...... 2 ...... 3 ...... 4 ...... 5 ...... 6 ...... 7 ...... 8 ...... 9 ...... 10 ...... 11 ...... 12 ...... 13 ...... 14 * ..... so we have that icrs is: # icrs 1 ..... 2 ..... 3 ..... 4 ..... 5 ..... 6 .....

15 Matrix multiplication using CSR

The textbook gives a procedure for carrying out matrix multiplication y = A ∗ x in cases where the m × n matrix A is stored in CRS format:

1 function y = crs mv ( m, n, icrs, jcrs, vcrs, x ) 2 y = zeros ( m, 1 ) ; 3 for i = 1 : m 4 for k = icrs(i) : icrs(i+1) − 1 5 j=jcrs(k); 6 y(i)=y(i)+vcrs(j) ∗ x ( j ) ; 7 end 8 end 9 return 10 end Listing 7: crs mv.m: CRS matrix multiplication.

16 Exercise: A*x using CSR

Consider again the 5 × 4 matrix:  11 0 0 14   0 22 0 0    A =  31 32 33 34     0 42 0 44  51 52 53 54

9 Given the vector x = [1,2,3,4]’, we know that y = A*x = [67,44,330,260,530]’. Create a MATLAB script that uses the CRS representation of A, and then uses the crs mv() function to compute y = A ∗ x. Verify that you get the right result.

17 Exercise: A’*x using CSR

For the same 5×4 matrix A, given the vector x = [1,2,3,4,5]’, we know that y = A’*x = [359,568,364,562]’. Create a MATLAB script that uses the CRS representation of A. Starting from crs mv(), make a new func- tion crs mtv() to compute y = A0 ∗ x. Verify that you get the right result. Hint: Only two lines of crs mv() need to be changed. The first line is changed to y=zeros(n,1).

18 Jacobi iteration using CSR

As you can imagine, you can also carry out Jacobi iteration using the CSR sparse matrix format. However, this is essentially the same as what we did for the ST format, with the additional step of compressing the row indices and making the corresponding change in the residual calculation. So we will not want to repeat the discussion we have already had.

19 Graphs, adjacency, and transitions

We can think of a graph as dots with lines between some of them. Mathematicaly, a graph is a set of nodes N, and a set of edges E. Each edge is a pair of node indices. If nodes i and j are connected, then there is an edge e = (i, j). In an undirected graph, the edges come in pairs, (i, j) and (j, i). In a directed graph, the existence of an edge (i, j), which is a path from node i to node j, does not imply the existence of an edge (j, i). A graph can be represented by an . ( 1, if (i, j) is an edge; Ai,j = 0, otherwise.

For an undirected graph, the adjacency matrix will be symmetric. For most graphs, the adjacency matrix will also be sparse. The adjacency matrix has further uses besides simply representing the structure of the graph. In particular, the k-th power of the adjacency matrix counts the number of paths of length k between nodes i and j:

k Ai,j = number of paths from node i to node j.

The adjacency matrix can also be used to model the transition problem, that is, the study of movements along the edges of a graph.

20 Example: Number of paths from one node to another

Given the following small example of a graph, we can ask how many paths of length k there are from node E to any node.

10 How can we reach other nodes from node E?

Let A be the adjacency matrix of the graph. You can access this matrix using the command A = graph adj(), available on the class web page.

 from/to ABCDEFG   A 0 1 1 0 1 0 0     B 1 0 1 1 0 0 1     C 1 1 0 1 0 1 0  A =    D 0 1 1 0 0 1 1     E 1 0 0 0 0 1 0     F 0 0 1 1 1 0 0  G 0 1 0 1 0 0 0

Obviously, A0 = I, and so row 5 of I tells us there is 1 path of length k = 0 from E to E, and no other paths. Similarly, A1 = A, tellings us that from E there is 1 path of length 1 from E to A, and from E to F. Let’s compute A2:  from/to ABCDEFG   A 3 1 1 2 0 2 1     B 1 4 2 2 1 2 1    2  C 1 2 4 2 2 1 2  A =    D 2 2 2 4 1 1 1     E 0 1 2 1 2 0 0     F 2 2 1 1 0 3 1  G 1 1 2 1 0 1 2 and if we concentrate on row E, there are no paths of length 2 from E to A, 1 from E to B, 2 from E to C

11 and so on. Although we already found a path of length 1 from E to A, we still haven’t found any path to G.  from/to ABCDEFG   A 2 7 8 5 5 3 3     B 7 6 9 9 3 5 6    3  C 8 9 6 9 2 8 4  A =    D 5 9 9 6 3 7 6     E 5 3 2 3 0 5 2     E 3 5 8 7 5 2 3  G 3 6 4 6 2 3 2 and we finally see, reading row E, that there are 2 different paths of length 3 by which we can travel to node G. Interestingly, we also see that there is no path from E back to itself that is exactly length 3.

21 Example: Modeling movement along a graph

Start with the adjacency matrix for a graph, and then scale each column of the matrix so that it sums to 1. This gives us what is called the transition matrix. To see what this would be for our example graph, you can access the file graph transit.m and type T=graph transit(). For our example graph, this matrix will be:  ABCDEFG  1 1 1  A 0 4 4 0 2 0 0   1 1 1 1   B 3 0 4 4 0 0 2   1 1 1 1   C 3 4 0 4 0 3 0  T =  1 1 1 1   D 0 4 4 0 0 3 2   1 1   E 3 0 0 0 0 3 0   1 1 1   F 0 0 4 4 2 0 0  1 1 G 0 4 0 4 0 0 0 Now let us suppose that we have a herd of 100 sheep, and that they start out at node E. We represent this by the vector x = [0, 0, 0, 0, 100, 0, 0]0. Being sheep, they want to wander. Since there are two paths to go on, half go to A and half go to F. We can predict this by computing T ∗ x = [50, 0, 0, 0, 0, 50, 0]. It’s harder for us to realize, but on step 2, the distribution of sheep is T 2 ∗ x = [0, 1/6, 1/3, 1/6, 1/3, 0, 0]0. And after that, things scramble for a while, but eventually we actually reach a steady solution: ABCDEFG 0 0 0 0 0 100 0 0 1 50 0 0 0 0 50 0 2 0 17 33 17 33 0 0 3 29 13 8 13 0 29 8 4 5 19 26 19 19 5 6 5 21 16 13 16 3 21 1

10 12 18 19 18 10 12 9

20 14 18 18 18 9 14 9

30 14 18 18 18 9 14 9 In other words, the vector x = [14, 18, 18, 18, 9, 14, 9]0 (approximately) is an eigenvector of the transition matrix T , with eigenvalue 1, because T ∗ x = x. Any undirected graph which is connected will have this property, that eventually the distribution of sheep will become constant, even though the sheep will continue to move. In mathematical terms, the transition

12 matrix will always have a single dominant eigenvalue 1, so that for any nonzero starting vector x0, the 2 sequence x0,T ∗ x0,T ∗ x0, ... will converge to the corresponding eigenvector. This will suggest a way of ranking web pages on the internet. Start with any single page, and then move your attention to the pages it links to, then spread out from those pages, and so on. Keep going until your attention is spread in such a way that it doesn’t change from step to step. Of course, we said that the trick works when the matrix is connected, but of course, that’s not true for the internet. We will look at a connected example for homework, but for the real internet, there are simple techniques to take care of the fact that all the web pages on the internet do not form a connected graph.

22 A Version of HITS

Search such as Google must look at all the web pages in the world, and decide which pages are the most important. This is called page ranking. When your search item is honey badger, Google looks at all the web pages associated with this topic, and shows them to you in order of importance, that is, based on the rankings it has computed. There are many ways to compute such rankings. One way is known as the HITS . To explain the algorithm, we think of the Internet as a large graph with directed edges. The nodes are web pages. The directed edges are links, that is, a reference on web page i to web page j corresponds to an edge Ai,j in the adjacency graph. Given a directed adjacency graph A, the HITS algorithm computes two vectors of node ratings: • a, the authority index, the degree to which a node is pointed to by reference (hub) nodes; • h, the hub index, the degree to which a node points to important (authoritative) nodes; If A is the adjacency matrix, the vectors satisfy: A0 ∗ h a = ||A0 ∗ h|| A ∗ a h = ||A ∗ a||

You may notice that a is an eigenvector of A0A and h is an eigenvector of AA0. Here is pseudocode algorithm to estimate the vectors a and h for a directed network of n nodes with adjacency matrix A.

1 function [ a, h ]=hits (A) 2 3 n = size ( A, 1 ) ; 4 5 a ( 1 : n ) = 1 % Initialize a and h vectors to 1, or randomly 6 h ( 1 : n ) = 1 7 8 do k times : % Iterate k times 9 10 for j = 1 to n 11 a ( j ) = sum o f h ( i ) ’ s for which node j is pointed to by node i 12 end for 13 a = a / norm ( a ) 14 15 for i = 1 to n 16 h ( i ) = sum o f a ( j ) ’ s for which node i points to node j 17 end for 18 h = h / norm ( h )

13 19 20 end do 21 22 return 23 end Listing 8: Pseudocode HITS algorithm.

Both loops that set a(j) and h(i) can be replaced by a single MATLAB command. To see what that command should be, think about how to use the nonzero matrix entries Ai,j (which will all be 1) to compute the result. Write a program that implements the HITS algorithm for a given adjacency matrix A. Assume that the matrix A is stored in sparse format in a file, so that the file must be read in, and then converted to a sparse matrix. After that, you can use standard MATLAB matrix multiplication notation A ∗ x or A0 ∗ x, because MATLAB automatically recognizes a sparse matrix and knows how to multiply by it. You can test your program on the “tiny” dataset whose adjacency matrix is available on the class web page as tiny sparse matrix.txt:

 0 0 0 0 0   1 0 1 0 0    A =  0 0 0 1 0     1 1 1 0 0  0 0 0 1 0

for which the results should be approximately:

 0.6572   0.0000   0.3690   0.6154      a =  0.6572  h =  0.0002       0.0004   0.7882  0.0000 0.0002

We can actually make a plot of this graph data using MATLAB:

1 data = load ( ’ t i n y s p a r s e matrix.txt’ ); 2 i = data(:,1); 3 j = data(:,2); 4 D=digraph ( i, j ); 5 plot (D); Listing 9: Plot tiny sparse matrix.txt.

The resulting plot is:

14 The directed graph stored in tiny sparse matrix.txt If you look at the graph, you can get some sense of why nodes 1 and 3 are the most “authoritative”: They have multiple nodes pointing to them. Similarly, nodes 2 and 4 are strong ”hubs”, because they point to many authoritative nodes. Once your program is able to compute these results, it is time to work with the “large” dataset. This is a directed graph whose 1, 458 × 1, 458 sparse adjacency matrix A is stored on the class web page as the file large sparse matrix.txt. This file contains 3,545 lines, one for each nonzero entry of A, of the form:

i j Aij <-- means that A(i,j) = Aij If you have copied the data file to your current directory, then a standard MATLAB sparse matrix A can be created by the commands:

1 data = load ( ’ l a r g e s p a r s e matrix.txt’ ); 2 A = spconvert ( data ) ;

Run your program on the “large” dataset, using k = 30 steps; when your iteration has completed, print the first 5 entries of the authority and hub vectors a and h. Send your program hw7.m to me at [email protected]. I would like to see your work by Friday, February 21.

15