Why Sparse Matrix?

Total Page:16

File Type:pdf, Size:1020Kb

Why Sparse Matrix? PRINCIPLES OF CIRCUIT SIMULAITON LectureLecture 9.9. LinearLinear Solver:Solver: LULU SolverSolver andand SparseSparse MatrixMatrix Guoyong Shi, PhD [email protected] School of Microelectronics Shanghai Jiao Tong University Fall 2010 2010-11-15 Slide 1 OutlineOutline Part 1: • Gaussian Elimination • LU Factorization • Pivoting • Doolittle method and Crout’s Method • Summary Part 2: Sparse Matrix 2010-11-15 Lecture 9 slide 2 MotivationMotivation • Either in Sparse Tableau Analysis (STA) or in Modified Nodal Analysis (MNA), we have to solve linear system of equations: Ax = b ⎛⎞A 00⎛⎞i ⎛0 ⎞ ⎜⎟ 00IAv−=T ⎜⎟ ⎜ ⎟ ⎜⎟⎜⎟ ⎜ ⎟ ⎜⎟⎜⎟ ⎜ ⎟ ⎡⎤11 1 KKiv0 ⎝⎠ e ⎝ S ⎠ GG ⎝⎠⎢⎥++22 −− RR13 R 3⎛⎞e1 ⎛⎞0 ⎢⎥⎜⎟= ⎜⎟ ⎢⎥111⎝⎠e2 ⎝⎠I S 5 ⎢⎥−+ ⎣ RRR343⎦ 2010-11-15 Lecture 9 slide 3 MotivationMotivation • Even in nonlinear circuit analysis, after "linearization", again one has to solve a system of linear equations: Ax = b. • Many other engineering problems require solving a system of linear equations. • Typically, matrix size is of 1000s to millions. • This needs to be solved 1000 to million times for one simulation cycle. • That's why we'd like to have very efficient linear solvers! 2010-11-15 Lecture 9 slide 4 ProblemProblem DescriptionDescription Problem: Solve Ax = b A: nxn (real, non-singular), x: nx1, b: nx1 Methods: – Direct Methods (this lecture) Gaussian Elimination, LU Decomposition, Crout – Indirect, Iterative Methods (another lecture) Gauss-Jacobi, Gauss-Seidel, Successive Over Relaxation (SOR), Krylov 2010-11-15 Lecture 9 slide 5 GaussianGaussian EliminationElimination ---- ExampleExample ⎧25xy+= ⎨ ⎩xy+=24 1 ⎛215⎞ − ⎛215⎞ ⎧x = 2 2 ⎜ 33⎟ ⎨ ⎜ 124⎟ ⎜0 ⎟ ⎩y = 1 ⎝ ⎠ ⎝ 22⎠ ⎛⎞⎛⎞10 21 ⎛⎞21 ⎜⎟⎜⎟ ⎜⎟= 13LU factorization ⎝⎠12 ⎜⎟⎜⎟10 ⎝⎠⎝⎠22 2010-11-15 Lecture 9 slide 6 UseUse ofof LULU FactorizationFactorization L U ⎛⎞⎛⎞10 21 ⎛21 ⎞⎛⎞xx⎜⎟⎜⎟⎛⎞ ⎛5⎞ ⎜ ⎟⎜⎟==13⎜⎟ ⎜⎟ ⎝12 ⎠⎝⎠yy⎜⎟⎜⎟10 ⎝⎠ ⎝4⎠ ⎝⎠⎝⎠22 Define ⎛⎞21 ⎛⎞ux⎜⎟ ⎛⎞ Solving the L-system: ⎜⎟:= 3 ⎜⎟ ⎝⎠vy⎜⎟0 ⎝⎠ ⎝⎠2 ⎛⎞10 ⎛⎞5 ⎛⎞u ⎛⎞5 ⎛⎞u ⎜⎟1 = ⎜⎟ ⎜⎟⎜⎟v ⎜⎟4 ⎜⎟= 3 1 ⎝⎠ ⎝⎠ ⎝⎠v ⎜⎟ ⎝⎠2 Solve ⎝⎠2 L Triangle systems are easy to solve (by back-substitution.) 2010-11-15 Lecture 9 slide 7 UseUse ofof LULU FactorizationFactorization ⎛⎞10 ⎛⎞u ⎛⎞5 ⎛⎞5 ⎜⎟ ⎛⎞u ⎜⎟ 1 ⎜⎟= ⎜⎟ ⎜⎟= 3 ⎜⎟1 ⎝⎠v ⎝⎠4 ⎝⎠v ⎜⎟ ⎝⎠2 ⎝⎠2 U U ⎛⎞21 ⎛ 5⎞ ⎛⎞21 ⎜⎟⎛⎞x ⎜⎟ ⎛⎞xu ⎛⎞ 33⎜⎟= ⎜⎟ ⎜⎟0 y ⎜⎟ 3 ⎜⎟= ⎜⎟ ⎝⎠ ⎜⎟0 ⎝⎠y ⎝v ⎠ ⎝⎠22 ⎝⎠ ⎝⎠2 Solving the U-system: ⎛⎞x ⎛2⎞ ⎜⎟= ⎜⎟ ⎝⎠y ⎝1⎠ 2010-11-15 Lecture 9 slide 8 LULU FactorizationFactorization A= LU= U The task of L & U L factorization is to find the elements in matrices L and U. Ax=== L( Ux) Ly b 1. Let y = Ux. 2. Solve y from Ly = b 3. Solve x from Ux = y 2010-11-15 Lecture 9 slide 9 AdvantagesAdvantages ofof LULU FactorizationFactorization • When solving Ax = b for multiple b, but the same A, then we only LU-factorize A only once. • In circuit simulation, entries of A may change, but structure of A does not alter. – This factor can used to speed up repeated LU- factorization. – Implemented as symbolic factorization in the “sparse1.3” solver in Spice 3f4. 2010-11-15 Lecture 9 slide 10 GaussianGaussian EliminationElimination • Gaussian elimination is a process of row transformation Ax = b aaa11 12 13 a1n b1 aaa21 22 23 a2n b2 aaa31 32 33 a3n b3 aaannn123 a nnbn Eliminate the lower triangular part 2010-11-15 Lecture 9 slide 11 GaussianGaussian EliminationElimination a11 ≠ 0 aa11 12 a13 a1n b1 aaa a b a 21 22 23 2n 2 − i 1 aa31 32 a33 a3n b3 a11 aann12an3 annbn aa11 12 a13 a1n b1 0 aa22 23 a2n b2 0 aa32 33 a3n b3 Entries updated 0 aann23 ann bn 2010-11-15 Lecture 9 slide 12 EliminatingEliminating 11stst ColumnColumn • Column elimination is equiv to row transformation ⎡ 100 0⎤ aaa a ⎡ 11 12 13 1n ⎤ b1 ⎢ a ⎥ ⎢ − 21 10 0⎥ ⎢ ⎥ a aaa21 22 23 a2n b ⎢ 11 ⎥ ⎢ ⎥ 2 ⎢ a ⎥ ⎢ − 31 01 0⎥ X ⎢aaa31 32 33 a3n ⎥ b3 ⎢ a 11 ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ a n 1 ⎢aaa a⎥ b ⎢ − 00 1⎥ ⎣ nnn123 nn⎦ n ⎣ a 11 ⎦ ⎡aa11 12 a 13 a1n ⎤ b1 ⎢ (2) (2) (2) ⎥ (2) 0 aa22 23 a2n b2 -1 (2) ⎢ ⎥ L A = A (2) 1 ⎢ 0 aa(2) (2) a(2) ⎥ b ⎢ 32 33 3n ⎥ 3 ⎢ ⎥ ⎢ (2) (2) (2) ⎥ (2) ⎣ 0 aann23 a nn⎦ bn 2010-11-15 Lecture 9 slide 13 EliminatingEliminating 22ndnd ColumnColumn ⎡ 100 0⎤ ⎡aa11 12 a 13 a1n ⎤ ⎢ 010 0⎥ ⎢ ⎥ ⎢ ⎥ 0 aa(2) (2) a(2) ⎢ (2) ⎥ ⎢ 22 23 2n ⎥ a 32 ⎢ − 10 ⎥ (2) (2) (2) a (2) X ⎢ ⎥ ⎢ 22 ⎥ 0 aa32 33 a3n ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ a (2) ⎥ n 2 ⎢ 001− (2) ⎥ ⎢ (2) (2) (2) ⎥ a ⎣ 22 ⎦ ⎣ 0 aann23 a nn⎦ (2) a22 ≠ 0 ⎡aa11 12 a 13 a1n ⎤ b1 ⎢ ⎥ 0 aa(2) (2) a(2) (2) ⎢ 22 23 2n ⎥ b2 L -1 A(2) = A(3) 2 ⎢ 00aa(3) (3) ⎥ b (3) ⎢ 33 3n ⎥ 3 ⎢ ⎥ ⎢ ⎥ 00aa(3) (3) (3) ⎣ nn3 n⎦ bn 2010-11-15 Lecture 9 slide 14 ContinueContinue onon EliminationElimination • Suppose all diagonals are nonzero aaa a ⎡ 11 12 13 1n ⎤ b1 ⎢ ⎥ aaa a b ⎢ 21 22 23 2n ⎥ 2 L -1 L -1 ••• L -1 L -1 n n-1 2 1 ⎢aaa31 32 33 a3n ⎥ b3 ⎢ ⎥ ⎢ ⎥ b ⎣⎢aaannn123 a nn⎦⎥ n Upper triangular aa a a ⎡ 11 12 13 1n ⎤ b1 ⎢ ⎥ 0 aa(2) (2) a(2) (2) ⎢ 22 23 (n) 2n ⎥ b2 (n) (n) ⎢ 00aaA(3) (3) ⎥ b (3) A x = b ⎢ 33 3n ⎥ 3 ⎢ ⎥ ⎢ ()n ⎥ b ()n ⎣ 00 0 ann ⎦ n 2010-11-15 Lecture 9 slide 15 TriangularTriangular SystemSystem Gaussian elimination ends up with the following upper triangular system of equations ⎡⎤aa11 12 a 13 a1n ⎛⎞x ⎛ b1 ⎞ ⎢⎥1 ⎜ ⎟ 0 aa(2) (2) a(2) ⎜⎟x b(2) ⎢⎥22 23 2n ⎜⎟2 ⎜ 2 ⎟ ⎢⎥(3) (3) ⎜ (3) ⎟ 00aa33 3n ⎜⎟x 3 = b3 ⎢⎥⎜⎟⎜ ⎟ ⎢⎥ ⎜⎟ ⎜ ⎟ ⎢⎥()nn⎜⎟x ⎜ ()⎟ ⎣⎦00 0 abnn ⎝⎠n ⎝n ⎠ Solve this system from bottom up: xn, xn-1, ..., x1 2010-11-15 Lecture 9 slide 16 LULU FactorizationFactorization • Gaussian elimination leads to LU factorization -1 -1 -1 -1 ( Ln Ln-1 ••• L2 L1 ) A = U L = (L L ••• L L ) A = (L1 L2 ••• Ln-1 Ln) U = LU 1 2 n-1 n ⎡ 100 0⎤ ⎡⎤aa11 12 a 13 a1n ⎢ a ⎥ ⎢ 21 10 0⎥ ⎢⎥(2) (2) (2) ⎢ a 11 ⎥ 0 aa22 23 a2n ⎢ ⎥ ⎢⎥ aa(2) (3) (3) ⎢ 31 32 10 ⎥ ⎢⎥00aa ⎢ (2) ⎥ 33 3n a 11 a ⎢⎥ ⎢ 22 ⎥ ⎢ ⎥ ⎢⎥ ⎢ (2) ⎥ aa ⎢⎥()n ⎢ nn12 ⎥ 00 0 a (2) *1 ⎣⎦nn ⎣⎢ a 11 a 22 ⎦⎥ 2010-11-15 Lecture 9 slide 17 ComplexityComplexity ofof LULU a11 ≠ 0 aa11 12 a13 a1n a − 21 aaa a a11 21 22 23 2n a 31 − aa31 32 a33 a3n a11 a − n 1 aann12an3 ann a11 # of mul / div = (n-1)*n ≈ n2 n >> 1 n 1 ∑in23=+(1n)(2n+1)∼ O(n) i =1 6 2010-11-15 Lecture 9 slide 18 CostCost ofof BackBack--SubstitutionSubstitution ⎡⎤aa11 12 a 13 a1n ⎛⎞x ⎛ b1 ⎞ ⎢⎥1 ⎜ ⎟ 0 aa(2) (2) a(2) ⎜⎟x b(2) ⎢⎥22 23 2n ⎜⎟2 ⎜ 2 ⎟ ⎢⎥(3) (3) ⎜ (3) ⎟ 00aa33 3n ⎜⎟x 3 = b3 ⎢⎥⎜⎟⎜ ⎟ ⎢⎥ ⎜⎟ ⎜ ⎟ ⎢⎥()nn⎜⎟x ⎜ ()⎟ ⎣⎦00 0 abnn ⎝⎠n ⎝n ⎠ (1)(1)nn b ()n bax− − − n x = nnnn−−11, x n = ()n n −1 (1)n − ann ann−−1, 1 n 1 Total # of mul / div = ∑innOn=+(1)()∼ 2 i =1 2 2010-11-15 Lecture 9 slide 19 ZeroZero DiagonalDiagonal Example 1: After two steps of Gaussian elimination: ×⎡ ×0 0 0⎤ 0 ×⎡ ×0 0 0⎤ 0 0⎢ × 0 0× ⎥ 0 ⎢ ⎥ 0⎢ × 0 0× ⎥ 0 ⎢ 1 1 ⎥ ⎢ ⎥ ⎢0 0 − 1 0⎥ ⎢ 1 1 ⎥ RR ⎢0 0 − 1 0⎥ ⎢ ⎥ RR ⎢ 1 1 ⎥ ⎢ ⎥ 0 0 − 0 1 0⎢ 0 0 0 1⎥ 1 ⎢ RR ⎥ ⎢ ⎥ 0⎢ 0 0 × × 0 ⎥ ⎢0 0 × 0× 0⎥ ⎢ ⎥ ⎢ ⎥ 0⎣⎢ 0 0 × × 0 ⎦⎥ 0⎣ 0 0 × × 0 ⎦ Gaussian elimination cannot continue 2010-11-15 Lecture 9 slide 20 PivotingPivoting Solution 1: Interchange rows to bring a non-zero element into position (k, k): ⎡⎤011 ⎡⎤xx0 ⎢⎥ ⎢⎥011 ⎢⎥××0 ⎢⎥ ⎣⎦⎢⎥××0 ⎣⎦⎢⎥xx0 Solution 2: How about column exchange? Yes Then the unknowns are re-ordered as well. ⎡101⎤ ⎡⎤011 ⎢ ⎥ ⎢⎥ xx0 ⎢⎥××0 ⎢ ⎥ ⎣⎦⎢⎥××0 ⎣⎢xx0⎦⎥ In general both rows and columns can be exchanged! 2010-11-15 Lecture 9 slide 21 SmallSmall DiagonalDiagonal − 4 1 . 25⎡ × 10 1⎤ .⎡ x 251 ⎤ 6⎡ . 25⎤ Example 2: ⎢ ⎥ ⎢ ⎥ = ⎢ ⎥ 12⎣⎢ . 5 12⎦⎥ ⎣ .x 2 5⎦ ⎣ 75 ⎦ Assume finite arithmetic: 3-digit floating point, we have 5 − 4 −10 1 .⎡ 25× 10 1 . 25 ⎤ ⎡ x 1 ⎤ 6⎡ . 25⎤ ⎢ ⎥ ⎢ ⎥ = ⎢ ⎥ ⎣⎢ 12 . 5 12 .⎦⎥ 5⎣ x 2 ⎦ ⎣ 75 ⎦ pivoting 1 . 25⎡ × 10− 4 1 . 25⎤ ⎡ x ⎤ ⎡ 6 . 25 ⎤ ⎢ ⎥ 1 = 5 ⎢ ⎥ ⎢ 5 ⎥ ⎣⎢ 0 1− . 25 × 10⎦⎥ ⎣ x 2 ⎦ 6⎣⎢− . 25 × 10⎦⎥ 12.5 rounded off ⎪⎧ x 2 = 5 ⎨ − 4 x = 0 ( 1 . 25⎩⎪ 10× )x 1 + ( 1 .x 252 = ) 6 .1 25 Unfortunately, (0, 5) is not the solution. Considering the 2nd equation: 12.5 * 0 + 12.5 * 5 = 62.5 ≠ 75. 2010-11-15 Lecture 9 slide 22 AccuracyAccuracy DependsDepends onon PivotingPivoting 5 − 4 −10 1 .⎡ 25× 10 1 . 25 ⎤ ⎡ x 1 ⎤ 6⎡ . 25⎤ ⎢ ⎥ ⎢ ⎥ = ⎢ ⎥ ⎣⎢ 12 . 5 12 .⎦⎥ 5⎣ x 2 ⎦ ⎣ 75 ⎦ pivoting Reason: a11 (the pivot) is too small relative to the other numbers! Solution: Don't choose small element to do elimination. Pick a large element by row / column interchanges. Correct solution to 5 digit accuracy is x1 = 1.0001 x2 = 5.0000 2010-11-15 Lecture 9 slide 23 WhatWhat causescauses accuracyaccuracy problem?problem? • Ill Conditioning: The A matrix close to singular • Round-off error: Relative magnitude too big x− y= 0 x+ y= 1 x− y =0 x+ y= 1 x− y= 0 x− y= 0 1x .− 01 y = 0 . 01 Í resulting in numerical errors ill-conditioned 2010-11-15 Lecture 9 slide 24 PivotingPivoting StrategiesStrategies 1. Partial Pivoting 2. Complete Pivoting 3. Threshold Pivoting 2010-11-15 Lecture 9 slide 25 PivotingPivoting StrategyStrategy 11 1. Partial Pivoting: (Row interchange only) Choose r as the smallest integer such that: ()k ()k k a rk = max a jk j= k,..., n U k Rows k to n L r Search Area 2010-11-15 Lecture 9 slide 26 PivotingPivoting StrategyStrategy 22 2.
Recommended publications
  • Recursive Approach in Sparse Matrix LU Factorization
    51 Recursive approach in sparse matrix LU factorization Jack Dongarra, Victor Eijkhout and the resulting matrix is often guaranteed to be positive Piotr Łuszczek∗ definite or close to it. However, when the linear sys- University of Tennessee, Department of Computer tem matrix is strongly unsymmetric or indefinite, as Science, Knoxville, TN 37996-3450, USA is the case with matrices originating from systems of Tel.: +865 974 8295; Fax: +865 974 8296 ordinary differential equations or the indefinite matri- ces arising from shift-invert techniques in eigenvalue methods, one has to revert to direct methods which are This paper describes a recursive method for the LU factoriza- the focus of this paper. tion of sparse matrices. The recursive formulation of com- In direct methods, Gaussian elimination with partial mon linear algebra codes has been proven very successful in pivoting is performed to find a solution of Eq. (1). Most dense matrix computations. An extension of the recursive commonly, the factored form of A is given by means technique for sparse matrices is presented. Performance re- L U P Q sults given here show that the recursive approach may per- of matrices , , and such that: form comparable to leading software packages for sparse ma- LU = PAQ, (2) trix factorization in terms of execution time, memory usage, and error estimates of the solution. where: – L is a lower triangular matrix with unitary diago- nal, 1. Introduction – U is an upper triangular matrix with arbitrary di- agonal, Typically, a system of linear equations has the form: – P and Q are row and column permutation matri- Ax = b, (1) ces, respectively (each row and column of these matrices contains single a non-zero entry which is A n n A ∈ n×n x where is by real matrix ( R ), and 1, and the following holds: PPT = QQT = I, b n b, x ∈ n and are -dimensional real vectors ( R ).
    [Show full text]
  • Lecture 5 - Triangular Factorizations & Operation Counts
    Lecture 5 - Triangular Factorizations & Operation Counts LU Factorization We have seen that the process of GE essentially factors a matrix A into LU. Now we want to see how this factorization allows us to solve linear systems and why in many cases it is the preferred algorithm compared with GE. Remember on paper, these methods are the same but computationally they can be different. First, suppose we want to solve A~x = ~b and we are given the factorization A = LU. It turns out that the system LU~x = ~b is \easy" to solve because we do a forward solve L~y = ~b and then back solve U~x = ~y. We have seen that we can easily implement the equations for the back solve and for homework you will write out the equations for the forward solve. Example If 0 2 −1 2 1 0 1 0 0 1 0 2 −1 2 1 A = @ 4 1 9 A = LU = @ 2 1 0 A @ 0 3 5 A 8 5 24 4 3 1 0 0 1 solve the linear system A~x = ~b where ~b = (0; −5; −16)T . ~ We first solve L~y = b to get y1 = 0, 2y1 +y2 = −5 implies y2 = −5 and 4y1 +3y2 +y3 = −16 T implies y3 = −1. Now we solve U~x = ~y = (0; −5; −1) . Back solving yields x3 = −1, 3x2 + 5x3 = −5 implies x2 = 0 and finally 2x1 − x2 + 2x3 = 0 implies x1 = 1 giving the solution (1; 0; −1)T . If GE and LU factorization are equivalent on paper, why would one be computationally advantageous in some settings? Recall that when we solve A~x = ~b by GE we must also multiply the right hand side by the Gauss transformation matrices.
    [Show full text]
  • LU Factorization LU Decomposition LU Decomposition: Motivation LU Decomposition
    LU Factorization LU Decomposition To further improve the efficiency of solving linear systems Factorizations of matrix A : LU and QR A matrix A can be decomposed into a lower triangular matrix L and upper triangular matrix U so that LU Factorization Methods: Using basic Gaussian Elimination (GE) A = LU ◦ Factorization of Tridiagonal Matrix ◦ LU decomposition is performed once; can be used to solve multiple Using Gaussian Elimination with pivoting ◦ right hand sides. Direct LU Factorization ◦ Similar to Gaussian elimination, care must be taken to avoid roundoff Factorizing Symmetrix Matrices (Cholesky Decomposition) ◦ errors (partial or full pivoting) Applications Special Cases: Banded matrices, Symmetric matrices. Analysis ITCS 4133/5133: Intro. to Numerical Methods 1 LU/QR Factorization ITCS 4133/5133: Intro. to Numerical Methods 2 LU/QR Factorization LU Decomposition: Motivation LU Decomposition Forward pass of Gaussian elimination results in the upper triangular ma- trix 1 u12 u13 u1n 0 1 u ··· u 23 ··· 2n U = 0 0 1 u3n . ···. 0 0 0 1 ··· We can determine a matrix L such that LU = A , and l11 0 0 0 l l 0 ··· 0 21 22 ··· L = l31 l32 l33 0 . ···. . l l l 1 n1 n2 n3 ··· ITCS 4133/5133: Intro. to Numerical Methods 3 LU/QR Factorization ITCS 4133/5133: Intro. to Numerical Methods 4 LU/QR Factorization LU Decomposition via Basic Gaussian Elimination LU Decomposition via Basic Gaussian Elimination: Algorithm ITCS 4133/5133: Intro. to Numerical Methods 5 LU/QR Factorization ITCS 4133/5133: Intro. to Numerical Methods 6 LU/QR Factorization LU Decomposition of Tridiagonal Matrix Banded Matrices Matrices that have non-zero elements close to the main diagonal Example: matrix with a bandwidth of 3 (or half band of 1) a11 a12 0 0 0 a21 a22 a23 0 0 0 a32 a33 a34 0 0 0 a43 a44 a45 0 0 0 a a 54 55 Efficiency: Reduced pivoting needed, as elements below bands are zero.
    [Show full text]
  • LU-Factorization 1 Introduction 2 Upper and Lower Triangular Matrices
    MAT067 University of California, Davis Winter 2007 LU-Factorization Isaiah Lankham, Bruno Nachtergaele, Anne Schilling (March 12, 2007) 1 Introduction Given a system of linear equations, a complete reduction of the coefficient matrix to Reduced Row Echelon (RRE) form is far from the most efficient algorithm if one is only interested in finding a solution to the system. However, the Elementary Row Operations (EROs) that constitute such a reduction are themselves at the heart of many frequently used numerical (i.e., computer-calculated) applications of Linear Algebra. In the Sections that follow, we will see how EROs can be used to produce a so-called LU-factorization of a matrix into a product of two significantly simpler matrices. Unlike Diagonalization and the Polar Decomposition for Matrices that we’ve already encountered in this course, these LU Decompositions can be computed reasonably quickly for many matrices. LU-factorizations are also an important tool for solving linear systems of equations. You should note that the factorization of complicated objects into simpler components is an extremely common problem solving technique in mathematics. E.g., we will often factor a polynomial into several polynomials of lower degree, and one can similarly use the prime factorization for an integer in order to simply certain numerical computations. 2 Upper and Lower Triangular Matrices We begin by recalling the terminology for several special forms of matrices. n×n A square matrix A =(aij) ∈ F is called upper triangular if aij = 0 for each pair of integers i, j ∈{1,...,n} such that i>j. In other words, A has the form a11 a12 a13 ··· a1n 0 a22 a23 ··· a2n A = 00a33 ··· a3n .
    [Show full text]
  • LU, QR and Cholesky Factorizations Using Vector Capabilities of Gpus LAPACK Working Note 202 Vasily Volkov James W
    LU, QR and Cholesky Factorizations using Vector Capabilities of GPUs LAPACK Working Note 202 Vasily Volkov James W. Demmel Computer Science Division Computer Science Division and Department of Mathematics University of California at Berkeley University of California at Berkeley Abstract GeForce Quadro GeForce GeForce GPU name We present performance results for dense linear algebra using 8800GTX FX5600 8800GTS 8600GTS the 8-series NVIDIA GPUs. Our matrix-matrix multiply routine # of SIMD cores 16 16 12 4 (GEMM) runs 60% faster than the vendor implementation in CUBLAS 1.1 and approaches the peak of hardware capabilities. core clock, GHz 1.35 1.35 1.188 1.458 Our LU, QR and Cholesky factorizations achieve up to 80–90% peak Gflop/s 346 346 228 93.3 of the peak GEMM rate. Our parallel LU running on two GPUs peak Gflop/s/core 21.6 21.6 19.0 23.3 achieves up to ~300 Gflop/s. These results are accomplished by memory bus, MHz 900 800 800 1000 challenging the accepted view of the GPU architecture and memory bus, pins 384 384 320 128 programming guidelines. We argue that modern GPUs should be viewed as multithreaded multicore vector units. We exploit bandwidth, GB/s 86 77 64 32 blocking similarly to vector computers and heterogeneity of the memory size, MB 768 1535 640 256 system by computing both on GPU and CPU. This study flops:word 16 18 14 12 includes detailed benchmarking of the GPU memory system that Table 1: The list of the GPUs used in this study. Flops:word is the reveals sizes and latencies of caches and TLB.
    [Show full text]
  • Triangular Factorization
    Chapter 1 Triangular Factorization This chapter deals with the factorization of arbitrary matrices into products of triangular matrices. Since the solution of a linear n n system can be easily obtained once the matrix is factored into the product× of triangular matrices, we will concentrate on the factorization of square matrices. Specifically, we will show that an arbitrary n n matrix A has the factorization P A = LU where P is an n n permutation matrix,× L is an n n unit lower triangular matrix, and U is an n ×n upper triangular matrix. In connection× with this factorization we will discuss pivoting,× i.e., row interchange, strategies. We will also explore circumstances for which A may be factored in the forms A = LU or A = LLT . Our results for a square system will be given for a matrix with real elements but can easily be generalized for complex matrices. The corresponding results for a general m n matrix will be accumulated in Section 1.4. In the general case an arbitrary m× n matrix A has the factorization P A = LU where P is an m m permutation× matrix, L is an m m unit lower triangular matrix, and U is an×m n matrix having row echelon structure.× × 1.1 Permutation matrices and Gauss transformations We begin by defining permutation matrices and examining the effect of premulti- plying or postmultiplying a given matrix by such matrices. We then define Gauss transformations and show how they can be used to introduce zeros into a vector. Definition 1.1 An m m permutation matrix is a matrix whose columns con- sist of a rearrangement of× the m unit vectors e(j), j = 1,...,m, in RI m, i.e., a rearrangement of the columns (or rows) of the m m identity matrix.
    [Show full text]
  • LU and Cholesky Decompositions. J. Demmel, Chapter 2.7
    LU and Cholesky decompositions. J. Demmel, Chapter 2.7 1/14 Gaussian Elimination The Algorithm — Overview Solving Ax = b using Gaussian elimination. 1 Factorize A into A = PLU Permutation Unit lower triangular Non-singular upper triangular 2/14 Gaussian Elimination The Algorithm — Overview Solving Ax = b using Gaussian elimination. 1 Factorize A into A = PLU Permutation Unit lower triangular Non-singular upper triangular 2 Solve PLUx = b (for LUx) : − LUx = P 1b 3/14 Gaussian Elimination The Algorithm — Overview Solving Ax = b using Gaussian elimination. 1 Factorize A into A = PLU Permutation Unit lower triangular Non-singular upper triangular 2 Solve PLUx = b (for LUx) : − LUx = P 1b − 3 Solve LUx = P 1b (for Ux) by forward substitution: − − Ux = L 1(P 1b). 4/14 Gaussian Elimination The Algorithm — Overview Solving Ax = b using Gaussian elimination. 1 Factorize A into A = PLU Permutation Unit lower triangular Non-singular upper triangular 2 Solve PLUx = b (for LUx) : − LUx = P 1b − 3 Solve LUx = P 1b (for Ux) by forward substitution: − − Ux = L 1(P 1b). − − 4 Solve Ux = L 1(P 1b) by backward substitution: − − − x = U 1(L 1P 1b). 5/14 Example of LU factorization We factorize the following 2-by-2 matrix: 4 3 l 0 u u = 11 11 12 . (1) 6 3 l21 l22 0 u22 One way to find the LU decomposition of this simple matrix would be to simply solve the linear equations by inspection. Expanding the matrix multiplication gives l11 · u11 + 0 · 0 = 4, l11 · u12 + 0 · u22 = 3, (2) l21 · u11 + l22 · 0 = 6, l21 · u12 + l22 · u22 = 3.
    [Show full text]
  • An Efficient Implementation of the Thomas-Algorithm for Block Penta
    An Efficient Implementation of the Thomas-Algorithm for Block Penta-diagonal Systems on Vector Computers Katharina Benkert1 and Rudolf Fischer2 1 High Performance Computing Center Stuttgart (HLRS), University of Stuttgart, 70569 Stuttgart, Germany [email protected] 2 NEC High Performance Computing Europe GmbH, Prinzenallee 11, 40549 Duesseldorf, Germany [email protected] Abstract. In simulations of supernovae, linear systems of equations with a block penta-diagonal matrix possessing small, dense matrix blocks occur. For an efficient solution, a compact multiplication scheme based on a restructured version of the Thomas algorithm and specifically adapted routines for LU factorization as well as forward and backward substi- tution are presented. On a NEC SX-8 vector system, runtime could be decreased between 35% and 54% for block sizes varying from 20 to 85 compared to the original code with BLAS and LAPACK routines. Keywords: Thomas algorithm, vector architecture. 1 Introduction Neutrino transport and neutrino interactions in dense matter play a crucial role in stellar core collapse, supernova explosions and neutron star formation. The multidimensional neutrino radiation hydrodynamics code PROMETHEUS / VERTEX [1] discretizes the angular moment equations of the Boltzmann equa- tion giving rise to a non-linear algebraic system. It is solved by a Newton Raphson procedure, which in turn requires the solution of multiple block-penta- diagonal linear systems with small, dense matrix blocks in each step. This is achieved by the Thomas algorithm and takes a major part of the overall com- puting time. Since the code already performs well on vector computers, this kind of architecture has been the focus of the current work.
    [Show full text]
  • Math 2270 - Lecture 27 : Calculating Determinants
    Math 2270 - Lecture 27 : Calculating Determinants Dylan Zwick Fall 2012 This lecture covers section 5.2 from the textbook. In the last lecture we stated and discovered a number of properties about determinants. However, we didn’t talk much about how to calculate them. In fact, the only general formula was the nasty formula mentioned at the beginning, namely n det(A)= sgn(σ) a . X Y iσ(i) σ∈Sn i=1 We also learned a formula for calculating the determinant in a very special case. Namely, if we have a triangular matrix, the determinant is just the product of the diagonals. Today, we’re going to discuss how that special triangular case can be used to calculate determinants in a very efficient manner, and we’ll derive the nasty formula. We’ll also go over one other way of calculating a deter- minnat, the “cofactor expansion”, that, to be honest, is not all that useful computationally, but can be very useful when you need to prove things. The assigned problems for this section are: Section 5.2 - 1, 3, 11, 15, 16 1 1 Calculating the Determinant from the Pivots In practice, the easiest way to calculate the determinant of a general matrix is to use elimination to get an upper-triangular matrix with the same de- terminant, and then just calculate the determinant of the upper-triangular matrix by taking the product of the diagonal terms, a.k.a. the pivots. If there are no row exchanges required for the LU decomposition of A, then A = LU, and det(A)= det(L)det(U).
    [Show full text]
  • LU Decomposition S = LU, Then We Can  1 0 0   2 4 −2   2 4 −2  Use It to Solve Sx = F
    LU-Decomposition Example 1 Compare with Example 1 in gaussian elimination.pdf. Consider I The Gaussian elimination for the solution of the linear system Sx = f transforms the augmented matrix (Sjf) into (Ujc), where U 0 2 4 −21 is upper triangular. The transformations are determined by the S = 4 9 −3 : (1) matrix S only. @ A If we have to solve a system Sx = f~ with a different right hand side −2 −3 7 f~, then we start over. Most of the computations that lead us from We express Gaussian Elimination using Matrix-Matrix-multiplications (Sjf~) into (Ujc~), depend only on S and are identical to the steps that we executed when we applied Gaussian elimination to Sx = f. 0 1 0 0 1 0 2 4 −2 1 0 2 4 −2 1 We now express Gaussian elimination as a sequence of matrix-matrix I @ −2 1 0 A @ 4 9 −3 A = @ 0 1 1 A multiplications. This representation leads to the decomposition of S 1 0 1 −2 −3 7 0 1 5 into a product of a lower triangular matrix L and an upper triangular | {z } | {z } | {z } matrix U, S = LU. This is known as the LU-Decomposition of S. =E1 =S =E1S I If we have computed the LU decomposition S = LU, then we can 0 1 0 0 1 0 2 4 −2 1 0 2 4 −2 1 use it to solve Sx = f. @ 0 1 0 A @ 0 1 1 A = @ 0 1 1 A I We replace S by LU, 0 −1 1 0 1 5 0 0 4 LUx = f; | {z } | {z } | {z } and introduce y = Ux.
    [Show full text]
  • Pivoting for LU Factorization
    Pivoting for LU Factorization Matthew W. Reid April 21, 2014 University of Puget Sound E-mail: [email protected] Copyright (C) 2014 Matthew W. Reid. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License". 1 INTRODUCTION 1 1 Introduction Pivoting for LU factorization is the process of systematically selecting pivots for Gaussian elimina- tion during the LU factorization of a matrix. The LU factorization is closely related to Gaussian elimination, which is unstable in its pure form. To guarantee the elimination process goes to com- pletion, we must ensure that there is a nonzero pivot at every step of the elimination process. This is the reason we need pivoting when computing LU factorizations. But we can do more with piv- oting than just making sure Gaussian elimination completes. We can reduce roundoff errors during computation and make our algorithm backward stable by implementing the right pivoting strategy. Depending on the matrix A, some LU decompositions can become numerically unstable if relatively small pivots are used. Relatively small pivots cause instability because they operate very similar to zeros during Gaussian elimination. Through the process of pivoting, we can greatly reduce this instability by ensuring that we use relatively large entries as our pivot elements. This prevents large factors from appearing in the computed L and U, which reduces roundoff errors during computa- tion.
    [Show full text]
  • Scalable Sparse Symbolic LU Factorization on Gpus
    JOURNAL OF LATEX CLASS FILES, VOL. 14, NO. 8, AUGUST 2015 1 GSOFA: Scalable Sparse Symbolic LU Factorization on GPUs Anil Gaihre, Xiaoye Sherry Li and Hang Liu Abstract—Decomposing a matrix A into a lower matrix L and an upper matrix U, which is also known as LU decomposition, is an essential operation in numerical linear algebra. For a sparse matrix, LU decomposition often introduces more nonzero entries in the L and U factors than in the original matrix. A symbolic factorization step is needed to identify the nonzero structures of L and U matrices. Attracted by the enormous potentials of the Graphics Processing Units (GPUs), an array of efforts have surged to deploy various LU factorization steps except for the symbolic factorization, to the best of our knowledge, on GPUs. This paper introduces GSOFA, the first GPU-based symbolic factorization design with the following three optimizations to enable scalable LU symbolic factorization for nonsymmetric pattern sparse matrices on GPUs. First, we introduce a novel fine-grained parallel symbolic factorization algorithm that is well suited for the Single Instruction Multiple Thread (SIMT) architecture of GPUs. Second, we tailor supernode detection into a SIMT friendly process and strive to balance the workload, minimize the communication and saturate the GPU computing resources during supernode detection. Third, we introduce a three-pronged optimization to reduce the excessive space consumption problem faced by multi-source concurrent symbolic factorization. Taken together, GSOFA achieves up to 31× speedup from 1 to 44 Summit nodes (6 to 264 GPUs) and outperforms the state-of-the-art CPU project, on average, by 5×.
    [Show full text]