Computing the Complete CS Decomposition

Similar documents
Computation of eigenvalues and singular values Recall that your solutions to these questions will not be collected or evaluated.

Solving large scale eigenvalue problems

Bindel, Fall 2016 Matrix Computations (CS 6210) Notes for

Matrices, Moments and Quadrature, cont d

Orthogonal iteration to QR

Solving large scale eigenvalue problems

EIGENVALUE PROBLEMS. EIGENVALUE PROBLEMS p. 1/4

QR-decomposition. The QR-decomposition of an n k matrix A, k n, is an n n unitary matrix Q and an n k upper triangular matrix R for which A = QR

Index. for generalized eigenvalue problem, butterfly form, 211

This can be accomplished by left matrix multiplication as follows: I

Applied Numerical Linear Algebra. Lecture 8

Foundations of Matrix Analysis

EECS 275 Matrix Computation

Section 4.5 Eigenvalues of Symmetric Tridiagonal Matrices

Using semiseparable matrices to compute the SVD of a general matrix product/quotient

13-2 Text: 28-30; AB: 1.3.3, 3.2.3, 3.4.2, 3.5, 3.6.2; GvL Eigen2

Numerical Analysis Lecture Notes

Orthogonal iteration to QR

11.5 Reduction of a General Matrix to Hessenberg Form

11.3 Eigenvalues and Eigenvectors of a Tridiagonal Matrix

14.2 QR Factorization with Column Pivoting

AMS526: Numerical Analysis I (Numerical Linear Algebra for Computational and Data Sciences)

Begin accumulation of transformation matrices. This block skipped when i=1. Use u and u/h stored in a to form P Q.

Generalized interval arithmetic on compact matrix Lie groups

STAT 309: MATHEMATICAL COMPUTATIONS I FALL 2018 LECTURE 9

Solving linear equations with Gaussian Elimination (I)

Numerical Methods I Non-Square and Sparse Linear Systems

Math 411 Preliminaries

MULTISHIFT VARIANTS OF THE QZ ALGORITHM WITH AGGRESSIVE EARLY DEFLATION LAPACK WORKING NOTE 173

Applied Mathematics 205. Unit II: Numerical Linear Algebra. Lecturer: Dr. David Knezevic

A Review of Matrix Analysis

Linear algebra & Numerical Analysis

Using Godunov s Two-Sided Sturm Sequences to Accurately Compute Singular Vectors of Bidiagonal Matrices.

Notes on Householder QR Factorization

Review Questions REVIEW QUESTIONS 71

LAPACK-Style Codes for Pivoted Cholesky and QR Updating

4.8 Arnoldi Iteration, Krylov Subspaces and GMRES

Chasing the Bulge. Sebastian Gant 5/19/ The Reduction to Hessenberg Form 3

Numerical Methods - Numerical Linear Algebra

Eigenvalue Problems. Eigenvalue problems occur in many areas of science and engineering, such as structural analysis

Numerical Methods in Matrix Computations

Eigenvalue problems. Eigenvalue problems

Outline Background Schur-Horn Theorem Mirsky Theorem Sing-Thompson Theorem Weyl-Horn Theorem A Recursive Algorithm The Building Block Case The Origina

6.4 Krylov Subspaces and Conjugate Gradients

Scientific Computing: An Introductory Survey

Chapter 12 Block LU Factorization

LAPACK-Style Codes for Pivoted Cholesky and QR Updating. Hammarling, Sven and Higham, Nicholas J. and Lucas, Craig. MIMS EPrint: 2006.

11.2 Reduction of a Symmetric Matrix to Tridiagonal Form: Givens and Householder Reductions

Conceptual Questions for Review

Matrix Factorization and Analysis

The QR Algorithm. Chapter The basic QR algorithm

Eigenvalues and eigenvectors

Numerical Linear Algebra

A Review of Linear Algebra

Linear Algebra Review

EIGENVALUE PROBLEMS (EVP)

THE QR METHOD A = Q 1 R 1

Computing Eigenvalues and/or Eigenvectors;Part 2, The Power method and QR-algorithm

Vector and Matrix Norms. Vector and Matrix Norms

MAA507, Power method, QR-method and sparse matrix representation.

A fast randomized algorithm for overdetermined linear least-squares regression

11.0 Introduction. An N N matrix A is said to have an eigenvector x and corresponding eigenvalue λ if. A x = λx (11.0.1)

ON ORTHOGONAL REDUCTION TO HESSENBERG FORM WITH SMALL BANDWIDTH

TOPOLOGICAL COMPLEXITY OF 2-TORSION LENS SPACES AND ku-(co)homology

October 25, 2013 INNER PRODUCT SPACES

ON THE QR ITERATIONS OF REAL MATRICES

Matrix Algorithms. Volume II: Eigensystems. G. W. Stewart H1HJ1L. University of Maryland College Park, Maryland

AMS526: Numerical Analysis I (Numerical Linear Algebra) Lecture 23: GMRES and Other Krylov Subspace Methods; Preconditioning

Image Registration Lecture 2: Vectors and Matrices

Next topics: Solving systems of linear equations

Linear Algebra (part 1) : Vector Spaces (by Evan Dummit, 2017, v. 1.07) 1.1 The Formal Denition of a Vector Space

5.6. PSEUDOINVERSES 101. A H w.

11.6 The QR Algorithm for Real Hessenberg Matrices

Numerical Methods I Solving Square Linear Systems: GEM and LU factorization

Example: 2x y + 3z = 1 5y 6z = 0 x + 4z = 7. Definition: Elementary Row Operations. Example: Type I swap rows 1 and 3

Lecture 2 INF-MAT : , LU, symmetric LU, Positve (semi)definite, Cholesky, Semi-Cholesky

Eigenvalue Problems and Singular Value Decomposition

Review of matrices. Let m, n IN. A rectangle of numbers written like A =

Lecture 5 Singular value decomposition

Math 102, Winter Final Exam Review. Chapter 1. Matrices and Gaussian Elimination

arxiv: v1 [math.na] 5 May 2011

The Behavior of Algorithms in Practice 2/21/2002. Lecture 4. ɛ 1 x 1 y ɛ 1 x 1 1 = x y 1 1 = y 1 = 1 y 2 = 1 1 = 0 1 1

DS-GA 1002 Lecture notes 0 Fall Linear Algebra. These notes provide a review of basic concepts in linear algebra.

5.3 The Power Method Approximation of the Eigenvalue of Largest Module

Dense LU factorization and its error analysis

AMS 209, Fall 2015 Final Project Type A Numerical Linear Algebra: Gaussian Elimination with Pivoting for Solving Linear Systems

Math 504 (Fall 2011) 1. (*) Consider the matrices

SPARSE signal representations have gained popularity in recent

Block Bidiagonal Decomposition and Least Squares Problems

A Fast Implicit QR Eigenvalue Algorithm for Companion Matrices

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS. + + x 1 x 2. x n 8 (4) 3 4 2

Matrices. Chapter What is a Matrix? We review the basic matrix operations. An array of numbers a a 1n A = a m1...

Bindel, Spring 2016 Numerical Analysis (CS 4220) Notes for

Orthogonalization and least squares methods

Math 405: Numerical Methods for Differential Equations 2016 W1 Topics 10: Matrix Eigenvalues and the Symmetric QR Algorithm

Elementary linear algebra

Math 577 Assignment 7

Spectral inequalities and equalities involving products of matrices

Krylov Subspaces. Lab 1. The Arnoldi Iteration

Notes for CS542G (Iterative Solvers for Linear Systems)

Transcription:

Computing the Complete CS Decomposition Brian D Sutton May 0, 008 Abstract An algorithm for computing the complete CS decomposition of a partitioned unitary matrix is developed Although the existence of the CS decomposition (CSD) has been recognized since 19, prior algorithms compute only a reduced version This reduced version, which might be called a -by-1 CSD, is equivalent to two simultaneous singular value decompositions The algorithm presented in this article computes the complete -by- CSD, which requires the simultaneous diagonalization of all four blocks of a unitary matrix partitioned into a -by- block structure The algorithm appears to be the only fully specified algorithm available The computation occurs in two phases In the first phase, the unitary matrix is reduced to bidiagonal block form, as described by Sutton and Edelman In the second phase, the blocks are simultaneously diagonalized using techniques from bidiagonal SVD algorithms of Golub, Kahan, Reinsch, and Demmel The algorithm has a number of desirable numerical features 1 Introduction The complete CS decomposition (CSD) applies to any m-by-m matrix X from the unitary group U(m), viewed as a -by- block matrix,» p X 11 X 1 X = m p X 1 X q m q For convenience, we assume q p and p + q m A complete CS decomposition has the form» C S 0 0» U1 X = 0 0 I p q 0 V1 U S C 0 0, (11) V 0 0 0 I m p q C = diag(cos(θ 1),, cos(θ q)), S = diag(sin(θ 1),, sin(θ q)), in which θ 1,, θ q [0, π ], U1 U(p), U U(m p), V1 U(q), and V U(m q) The letters CS in the term CS decomposition come from cosine-sine The major contribution of this paper is an algorithm for computing (11) We believe this to be the only fully specified algorithm available for computing the complete CS decomposition Earlier algorithms compute only a reduced form, the -by-1 CSD, Department of Mathematics, Randolph-Macon College, PO Box 00, Ashland, VA 00 USA email: bsutton@rmcedu Supplementary material is available at the author s home page 1

Computing the Complete CS Decomposition, Brian D Sutton which is defined in the next section The algorithm developed in this article is based on well known bidiagonal SVD algorithms [, 8, 9] and has a number of desirable numerical properties The algorithm proceeds in two phases 1 Phase I: Bidiagonalization In the special case p = q = m, the decomposition is X =» P1 P " B (0) 11 B (0) 1 B (0) 1 B (0) #» Q1 Q, (1) in which B (0) 11 and B(0) 1 are upper bidiagonal, B(0) 1 and B(0) are lower bidiagonal, and P 1, P, Q 1, and Q are q-by-q unitary We say that the middle factor is a real orthogonal matrix in bidiagonal block form (See Definition 11)» B Phase II: Diagonalization The CSD of (0) 11 B(0) 1 is computed, " B (0) 11 B (0) 1 B (0) 1 B (0) # =» U1 U B (0) 1 B(0)» C S» S V1 C V Combining the factorizations gives the CSD of X,»»» P1U 1 C S Q1V 1 X = P U S C Q V (1) Phase I is a finite-time procedure first described in [18] and Phase II is an iterative procedure based on ideas from bidiagonal SVD algorithms [, 8, 9] Some of the earliest work related to the CSD was completed by Jordan, Davis, and Kahan [,, 1] The CSD as we know it today and the term CS decomposition first appeared in a pair of articles by Stewart [1, 1] Computational aspects of the -by-1 CSD are considered in [, 1, 1, 1, 19] and later articles A sketch of an algorithm for the complete CSD can be found in a paper by Hari [11], but few details are provided For general information and more references, see [, 10, 1] 11 Complete versus -by-1 CS decomposition Most commonly available CSD algorithms compute what we call the -by-1 CS decomposition of a matrix ˆX with orthonormal columns partitioned into a -by-1 block structure In the special case p = q = m, ˆX has the form ˆX = q q» q ˆX11 ˆX1, and the CSD is ˆX =» U1 U» C S V 1 A naive algorithm for computing the -by-1 CSD is to compute two SVD s, ( ˆX11 = U 1CV 1 ˆX 1 = ( U )SV 1, reordering rows and columns and adjusting signs as necessary to make sure that the two occurrences of V 1 are identical and that C + S = I This works in theory if no

Computing the Complete CS Decomposition, Brian D Sutton two singular values of ˆX 11 are repeated, but in practice it works poorly when there are clustered singular values Still, the basic idea can form the backbone of an effective algorithm for the -by-1 CSD [1, 19] Unfortunately, many algorithms for the -by-1 CSD do not extend easily to the complete -by- CSD The problem is the more extensive sharing of singular vectors evident below (still assuming p = q = m ): ( X11 = U 1CV1 X 1 = U 1SV X 1 = ( U )SV1 X = U CV (1) All four unitary matrices U 1, U, V 1, and V play dual roles, providing singular vectors for two different blocks of X Enforcing these identities has proven difficult over the years Our algorithm, unlike the naive algorithm, is designed to compute the four SVD s in (1) simultaneously, so that no discrepancies ever arise 1 Applications Unlike existing -by-1 CSD algorithms, the algorithm developed here fully solves Jordan s problem of angles between linear subspaces of R n [1] If the columns of matrices X and Y are orthonormal bases for two subspaces of R n, then the principal angles and principal vectors between the subspaces can be computed in terms of the SVD of X T Y [1] The complete CSD, equivalent to four SVD s, simultaneously provides principal vectors for these subspaces and their orthogonal complements In addition, our algorithm can be specialized to compute the -by-1 CSD and hence has application to the generalized singular value decomposition 1 Numerical properties The algorithm is designed for numerical stability All four blocks of the partitioned unitary matrix are treated simultaneously and with equal regard, and no cleanup procedure is necessary at the end of the algorithm In addition, a new representation for orthogonal matrices with a certain structure guarantees orthogonality, even on a floating-point architecture [18] 1 Efficiency As with popular bidiagonal SVD algorithms, Phase I (bidiagonalization) is often more expensive than Phase II (diagonalization) For the special case p = q = m, bidiagonalization requires about m flops about 8 q flops to bidiagonalize each block of ˆ X11 X 1 X 1 X and about q flops to accumulate each of P 1, P, Q 1, and Q, for a total of about ` q 8 + ` q = m flops 1 Overview of the algorithm 11 Bidiagonal block form During Phase I, the input unitary matrix is reduced to bidiagonal block form A matrix in this form is real orthogonal and has a specific sign pattern Bidiagonal block form was independently formulated by Sutton in 00 [18] Some similar results appear in a 199 paper by Watkins [0] The matrix structure and a related decomposition have already been applied to a problem in random matrix theory by Edelman and Sutton []

Computing the Complete CS Decomposition, Brian D Sutton Definition 11 Given θ = (θ 1,, θ q) [0, π ]q and φ = (φ 1,, φ q 1) [0, π ]q 1, let c i = cos θ i, s i = sin θ i, c i = cos φ i, and s i = sin φ i Define B ij(θ, φ), i, j = 1,, to be q-by-q bidiagonal matrices, as follows» B11(θ, φ) B 1(θ, φ) B 1(θ, φ) B (θ, φ) c 1 s 1s 1 s 1c 1 c c 1 cs 1 s c sq 1s q 1 c qc q 1 c qs q 1 s q = s 1 c 1s 1 c 1c 1 s c 1 ss 1 c c cq 1s q 1 (1) Any matrix of the form» B11(θ, φ) B 1(θ, φ) B 1(θ, φ) B (θ, φ) s qc q 1 s qs q 1 c q is said to be in bidiagonal block form and is necessarily real orthogonal To clarify (1), the (q 1, q 1) entry of B 1(θ, φ) is s q 1c q 1, and the (q 1, q 1) entry of B (θ, φ) is c q 1c q 1 Also, if q = 1, then the matrices are defined by» B11(θ, φ) B 1(θ, φ) B 1(θ, φ) B (θ, φ)» = c 1 s 1 s 1 c 1 As stated in the definition, any matrix whose entries satisfy the relations of (1) is necessarily real orthogonal The reverse is true as well any orthogonal matrix X with the bidiagonal structure and sign pattern of (1) is expressible in terms of some θ and φ (This is implicit in [, 18]) Furthermore, every unitary matrix is equivalent to a matrix in bidiagonal block form, as stated in the next theorem Theorem 1 Given any m-by-m unitary matrix X and integers p, q such that 0 q p and p + q m, there exist matrices P 1 U(p), P U(m p), Q 1 U(q), and Q U(m q) such that» B 11(θ, φ) B 1(θ, φ) 0 0» P1 X = 0 0 I p q 0 Q1 P B 1(θ, φ) B (θ, φ) 0 0 Q 0 0 0 I m p q for some θ = (θ 1,, θ q) [0, π ]q and φ = (φ 1,, φ q 1) [0, π ]q 1 A proof of the theorem has already been published in [, 18], along with an algorithm for computing the decomposition The algorithm applies pairs of Householder reflectors to the left and right of X, causing the structure to evolve as in Fig 1 This serves as Phase I of the CSD algorithm 1 Simultaneous SVD steps Phase II of the algorithm simultaneously applies the bidiagonal SVD algorithm of Golub and Reinsch [9, 10] to each of the four blocks of the matrix produced by Phase I

Computing the Complete CS Decomposition, Brian D Sutton unitary + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + real orthogonal Figure 1: Reduction to bidiagonal block form + + + + + The bidiagonal SVD algorithm is an iterative scheme Given an initial bidiagonal matrix B (0), the algorithm produces a sequence B (0) B (1) B () Σ converging to a diagonal matrix of singular values Implicitly, the step from B (n) to B (n+1) involves a QR factorization of (B (n) ) T B (n) σ I, for some appropriately chosen σ 0, but in practice the matrix (B (n) ) T B (n) is never explicitly formed Instead, the transformation from B (n) to B (n+1) is accomplished through a sequence of Givens rotations The first Givens rotation introduces a bulge, and the subsequent rotations chase the bulge away Our algorithm applies this idea simultaneously to all four blocks to execute a CSD step First, two bulges are introduced by a Givens rotation (Fig (a)), and then the bulges are chased away, also by Givens rotations (Fig (b)) The end result is a new matrix in bidiagonal block form whose blocks tend to be closer to diagonal than the original blocks 1 The driver routine The algorithm as a whole proceeds roughly as follows Execute Algorithm bidiagonalize to transform X to bidiagonal block form (See Fig 1) Until convergence, Execute Algorithm csd step to apply four simultaneous SVD steps (See Fig ) The algorithm as a whole is represented by Fig Matrices in bidiagonal block form may be represented implicitly in terms of θ and φ from Definition 11 In fact, the overall algorithm implicitly represents the sequence of Fig (b) as (θ (0), φ (0) ) (θ (1), φ (1) ) (θ (), φ () ) (θ (N), φ (N) ) The implicitly represented matrices are exactly orthogonal, even in floating-point The process stops when φ (N) is sufficiently close to (0,, 0); then the blocks of (1) are diagonal up to machine precision

Computing the Complete CS Decomposition, Brian D Sutton + + + + + + + + + + + (a) Bulges are introduced + + + + + + + + + + + (b) Bulges are chased Figure : CSD step» " X11 X 1 X = X 1 X B (0) 11 B (0) 1 B (0) 1 B (0) (a) Reduction to bidiagonal block form # " B (0) 11 B (0) 1 B (0) 1 B (0) # " B (1) 11 B (1) 1 B (1) 1 B (1) # " # B () 11 B () 1 B () 1 B () (b) Iteration of the CSD step " B (N) 11 B (N) 1 B (N) 1 B (N) #» C S = S C Figure : Computing the complete CSD

Computing the Complete CS Decomposition, Brian D Sutton 1 Overview of the article The remainder of the article is organized as follows Section Title Phase I: Algorithm bidiagonalize Reviewing and extending the SVD step Phase II: Algorithm csd step Algorithm csd On numerical stability The final section contains results of numerical tests on a BLAS/LAPACK-based implementation, which is available from the author s web site Phase I: Algorithm bidiagonalize Phase I of the CSD algorithm is to transform the partitioned unitary matrix X to bidiagonal block form Specification 1 Given an m-by-m unitary matrix X and integers p, q with 0 q p and p + q m, bidiagonalize(x, p, q) should compute θ (0) = (θ (0) 1,, θ(0) q ) [0, π ]q, φ (0) = (φ (0) 1,, φ(0) q 1 ) [0, π ]q 1, P 1 U(p), P U(m p), Q 1 U(q), and Q U(m q) such that X =» P1 P B (0) 11 B (0) 1 0 0 0 0 I p q 0 B (0) 1 B (0) 0 0 0 0 0 I m p q» Q1 Q, (1) in which B (0) ij = B ij(θ (0), φ (0) ), i, j = 1,, are bidiagonal matrices defined in (1) The algorithm is inspired by the bidiagonal reduction of Golub and Kahan [8] and has already appeared in [, 18] It is reproduced here Matlab-style indexing is used A(i, j) refers to the i, j entry of A; A(i : k, j : l) refers to the submatrix of A in rows i,, k and columns j,, l; A(i : k, :) refers to the submatrix of A in rows i,, k; and so on Also, house(x) constructs a Householder reflector F = ω(i βvv ) for which the first entry of F x is real and nonnegative and the remaining entries are zero (This is an abuse of common terminology F is not Hermitian if ω is not real) If given the empty vector (), house returns an identity matrix Finally, c i, s i, c i, and s i are shorthand for cos θ (0) i, sin θ (0) i, cos φ (0) i, and sin φ (0) i, respectively Algorithm (bidiagonalize) 1 Y := X; for i := 1,, q ( Y (1 : p, 1) if i = 1 u 1 := c i 1Y (i : p, i) + s i 1Y (i : p, q 1 + i) if i > 1; ( Y (p + 1 : m, 1) if i = 1 u := c i 1Y (p + i : m, i) s i 1Y (p + i : m, q 1 + i) if i > 1; θ (0) i 8 P (i) 1 := := atan( u, u 1 ); h Ii 1 house(u 1 ) i ; P (i) := h Ii 1 house(u ) i;

Computing the Complete CS Decomposition, Brian D Sutton 8 9 Y :=» P (i) 1 Y ; P (i) ( 11 v 1 := s iy (i, i + 1 : q) c iy (p + i, i + 1 : q) if i < q () if i = q; 1 v := s iy (i, q + i : m) + c iy (p + i, q + i : m); 1 if i < q, then 1 φ (0) i 1 Q (i) 1 := 1 else 1 Q (q) 1 := I q; 18 end if 19 Q (i) := 0 Y := Y end for := atan( v 1, v ); h Ii house(v i; 1 ) h Ii 1 house(v i;» ) Q (i) 1 ; Q (i) P 1 := P (1) 1 P (q) 1 ; P := P (1) P (q) ; Q 1 := Q (1) 1 Q (q 1) 1 ; Q := Q (1) Q (q) ; Using an LQ factorization, diagonalize the submatrix of Y lying in rows q +1,, p, p+ q + 1,, m and columns q + 1,, m, updating Q as necessary; Theorem Algorithm bidiagonalize satisfies Specification 1 The proof is available in [, 18] We illustrate the algorithm by concentrating on the case m =, p =, q = In the beginning, the matrix entries can have any signs, Y := X = To introduce zeros into column 1, two Householder reflectors, based on u 1 = Y (1 :, 1) and u = Y (:, 1), respectively, are applied» house(u1 ) Y := house(u ) Y = + 0 0 0 0 In fact, because Y is unitary, u 1 + u = 1, and θ (0) 1 is defined so that Y = c 1 0 0 s 1 0 0 Next, the algorithm focuses on rows 1 and Now something nonobvious happens Y (1, : ) and Y (, : ) are colinear (because Y (:, 1) is orthogonal to Y (:, ) and

Computing the Complete CS Decomposition, Brian D Sutton 9 Y (:, )), as are Y (1, : ) and Y (, : ) (By colinear, we mean that the absolute value of the inner product equals the product of norms) The row vectors v 1 and v are defined so that v 1 is colinear with Y (1, : ) and Y (, : ) and v is colinear with Y (1, : ) and Y (, : ) Computing φ (0) 1 and multiplying by Householder reflectors gives 1 Y := Y house(v 1 ) house(v ) = c 1 s 1 s 1 0 s 1 c 1 0 0 0 0 s 1 c 1 s 1 0 c 1 c 1 0 0 0 0 The algorithm proceeds in a similar fashion Now, Y ( :, ) and Y ( :, ) are colinear, as are Y (:, ) and Y (:, ) By computing θ (0) and applying Householder reflectors, we obtain Y := c 1 s 1 s 1 0 s 1 c 1 0 0 0 c c 1 c s 1 0 0 0 s 1 c 1 s 1 0 c 1 c 1 0 0 0 s c 1 s s 1 0 0 0 then another pair of Householder reflectors gives Y :=, c 1 s 1 s 1 0 s 1 c 1 0 0 0 c c 1 s s c s 1 s c 0 0 0 0 s 1 c 1 s 1 0 c 1 c 1 0 0 0 s c 1 c s s s 1 c c 0 0 0 0 and so on Note that the final matrix is represented implicitly by θ (0) 1,, θ(0) q and φ (0) 1,, φ(0) q 1, so that it is exactly orthogonal, even on a floating-point architecture The following theorem will be useful later A diagonal signature matrix is a diagonal matrix whose diagonal entries are ±1 Theorem If B 11 and B 1 are upper bidiagonal, B 1 and B are lower bidiagonal, and» B11 B 1 B 1 B is real orthogonal (but not necessarily having the sign pattern required for bidiagonal block form), then there exist diagonal signature matrices D 1, D, E 1, E such that»»» D1 B11 B 1 E1, D B 1 B E is a real orthogonal matrix in bidiagonal block form Proof Run bidiagonalize P 1, P, Q 1, and Q are products of Householder reflectors that are in fact diagonal signature matrices because the input matrix already has the correct zero/nonzero pattern Let D 1 = P 1, D = P, E 1 = Q 1, and E = Q Reviewing and extending the SVD step In [8, 9], Golub, Kahan, and Reinsch developed an SVD method based on implicit QR iteration The bulge-chasing method, as modified by Demmel and Kahan [], is

Computing the Complete CS Decomposition, Brian D Sutton 10 implemented as one of the most heavily used SVD routines in LAPACK Phase II of our CSD algorithm is based on this SVD method Given a real upper bidiagonal matrix B and a shift σ 0, the SVD step of Golub and Reinsch applies a unitary equivalence B = S T BT derived from QR iteration on B T B σ I The step is designed so that iteration will drive a superdiagonal entry of B to zero (especially quickly if the shifts lie near singular values of B) This section reviews the SVD step of Golub and Reinsch There are two notable aspects not present in most descriptions First, a certain left-right symmetry is emphasized not only is the SVD step equivalent to a QR step on B T B σ I; it is also equivalent to a QR step on BB T σ I Second, the SVD step is extended to handle any number of zeros on the bidiagonal band of B (The original SVD step of Golub and Reinsch requires special handling as soon as a zero appears The modification by Demmel and Kahan relaxes this, but only for zeros on the main diagonal and only when the shift is σ = 0) The modification is necessary in Section 1 QR step The SVD iterations of interest are derived from QR iteration for symmetric tridiagonal matrices Given a real symmetric tridiagonal matrix A and a shift λ R, a single QR step is accomplished by computing a QR factorization then reversing the factors and putting λi back, A λi = QR, (1) Ā := RQ + λi () Note that the resulting Ā is symmetric tridiagonal, because RQ = QT (A λi)q is upper Hessenberg and symmetric Note that if A is unreduced, ie, its subdiagonal entries are all nonzero, then Q and R are unique up to signs (Specifically, every QR factorization is of the form A λi = (QD)(DR) for some diagonal signature matrix D) However, if A has zero entries on its subdiagonal, then making the QR factorization unique requires extra care The following definition introduces a preferred QR factorization There are two important points: (1) the existence of the forthcoming CSD step relies on the uniqueness of the preferred QR factorization, and () the handling of noninvertible A supports the CSD deflation procedure Below, the notation A B refers to the block diagonal matrix [ A B ] Definition 1 Let A be an m-by-m real symmetric tridiagonal matrix Express A as A 1 A A =, in which each A i is either an unreduced tridiagonal matrix or 1-by-1 A preferred QR factorization for A is a QR factorization with a special form There are two cases A r

Computing the Complete CS Decomposition, Brian D Sutton 11 Case 1: A is invertible Then a preferred QR factorization has the form Q 1 Q A = and satisfies the following conditions: Q r R 1 R 1 every Q i has the same number of rows and columns as A i, is real orthogonal and upper Hessenberg, and has positive subdiagonal and determinant one (unless it is 1-by-1, in which case it equals the scalar 1), and every R i has the same number of rows and columns as A i and is upper triangular Case : A is not invertible Define Q 1,, Q r and R 1,, R r as in the first case, let k be the least index identifying a noninvertible A k, and let l be the index of this block s last row and column in the overall matrix A (Note that the first zero diagonal entry of R 1 R r must be in position (l, l)) Also, let P = I l 1 0 0 0 0 ±1 0 I m l 0 with the sign chosen so that det(p ) = 1 A preferred QR factorization for A is A = QR with Q = (Q 1 Q k I m l )P and R = P T (R 1 R k A k+1 A r) Theorem The terminology is valid: every preferred QR factorization really is a QR factorization Theorem If A is a real symmetric tridiagonal matrix, then a preferred QR factorization A = QR exists and is unique The proofs are straightforward Theorem Apply the QR step (1)() to a real symmetric tridiagonal matrix A using the preferred QR factorization If the shift λ is an eigenvalue of A, then deflation occurs immediately: the resulting Ā has the form " # Ā = Proof A λi is not invertible, so its preferred QR factorization satisfies Case of Definition 1 The rest of the proof uses the notation of that definition The last row of R k contains all zeros, so row l of R 1 R k (A k+1 λi) (A r λi) contains all zeros The permutation matrix P is designed to slide this row of all zeros to the bottom of R, and hence the last row of RQ also contains all zeros By symmetry, the last column of RQ also contains only zeros, and so RQ is block diagonal with a 1-by-1 block equaling zero in the bottom-right corner Adding λi to produce Ā = RQ + λi makes the bottom-right entry equal λ The orthogonal factor Q in a preferred QR factorization can be expressed as a product of Givens rotations in a particularly simple way A -by- Givens rotation with an angle of θ is a matrix [ s c s c ] in which c = cos θ and s = sin θ More generally, an m-by-m Givens rotation is an m-by-m real orthogonal matrix with a -by- principal submatrix that is a Givens rotation and whose principal submatrix lying in the other rows and columns is the (m )-by-(m ) identity matrix λ, R r

Computing the Complete CS Decomposition, Brian D Sutton 1 Theorem The orthogonal factor Q in a preferred QR factorization of an m-bym real symmetric tridiagonal matrix can be expressed uniquely as a product of Givens rotations G 1 G m 1 in which G j rotates columns j and j + 1 through an angle in [0, π) Proof Existence is proved by Algorithm below Uniqueness is guaranteed by the upper Hessenberg structure: inductively, the (j + 1, j) entry of Q determines G j Algorithm (givens) This algorithm computes a Givens rotation, with a corner case defined in a particularly important way 1 Given a nonzero -by-1 vector x, givens(m, i 1, i, x) constructs an m-by-m Givens rotation whose submatrix lying in rows and columns i 1 and i is a -by- Givens rotation G = [ c s s c ] with angle in [0, π) such that GT x = (± x, 0) T givens(m, i 1, i, (0, 0) T ) is defined to equal givens(m, i 1, i, (0, 1) T ) it rotates through an angle of π The choice to rotate through π when x = (0, 0)T allows the following algorithm to handle Cases 1 and of the preferred QR factorization in a uniform way Algorithm (qr step) Given an m-by-m real symmetric tridiagonal matrix A and a shift λ R, the following algorithm performs one QR step See Theorem 8 It is an extension of the idea on pp 180 of [10] 1 Ā := A λi; for i = 1,, m 1 (Ā(i : i + 1, i) v = Ā(i : i + 1, i 1) G i := givens(m, i, i + 1, v); Ā := G T i ĀG i; end for Ā := Ā + λi; if i = 1 or Ā(i : i + 1, i 1) is the zero vector otherwise; Theorem 8 Run Algorithm to compute G 1,, G m 1 and Ā, and define Q = G 1 G m 1 and R = Q T (A λi) Then A λi = QR is a preferred QR factorization and (1) and () are satisfied Proof The proof is broken into two cases Case 1: λ is not an eigenvalue of A The proof is by induction on r, the number of unreduced blocks of A The base case is r = 1 In this case, the algorithm executes the usual bulgechasing QR step See [10] For the inductive step, suppose r > 1 and assume that the theorem has been proved for smaller values of r Let s be the number of rows and columns in the final block A r The first m s 1 executions of the loop neither observe nor modify the final s rows or columns of Ā and by induction compute Q1,, Qr 1 and R 1,, R r 1 of the preferred QR factorization At the beginning of the loop with i = m s, the (m s, m s 1)-entry of Ā is nonzero because A λi is invertible, and the (m s + 1, m s 1)-entry of Ā is zero, so G m r is set to an identity matrix When the loop continues with i = m s + 1, the algorithm proceeds as in [10]

Computing the Complete CS Decomposition, Brian D Sutton 1 Case : λ is an eigenvalue of A Let l be the index of the first column of A that is a linear combination of the earlier columns The algorithm proceeds as in Case 1 until the loop with i = l At that point, the leading (l 1)-by-(l 1) principal submatrix of the new tridiagonal matrix is fixed (ignoring the addition of λi at the very end), and considering the proof of Theorem, the lth row of Ā is all zeros Therefore, G l is a rotation by π, which has the effect of swapping rows l and l + 1 of Ā Now, the (l + 1)st row of Ā is all zeros, so by induction, all remaining Givens rotations have angle π and the row of zeros is pushed to the bottom of Ā This constructs Q and R as in Case of Definition 1 SVD step To compute the SVD of a bidiagonal matrix B, we start with the idea of applying QR iteration to B T B σ I Because the formation of B T B is problematic in floatingpoint, each QR step must be executed implicitly, working directly with the entries of B The following definition of the SVD step is unconventional but equivalent to the usual definition Definition 9 Let B be a real bidiagonal matrix (either upper bidiagonal or lower bidiagonal) and σ a nonnegative real number Matrices B, S, and T are obtained from an SVD step if BB T σ I = SL T and B T B σ I = T R are preferred QR factorizations and Note that B = S T BT B B T = L T S + σ I and BT B = RT + σ I, ie, an SVD step on B implicitly computes QR steps for BB T and B T B Theorem 10 The SVD step exists and is uniquely defined Proof This follows immediately from the existence and uniqueness of the preferred QR factorization Theorem 11 If B is upper bidiagonal, then B is upper bidiagonal If B is lower bidiagonal, then B is lower bidiagonal The proof is presented after Lemma 1 below Before going any further with the SVD step, we need a utility routine Algorithm 1 (bulge start) Given a -by-1 vector x and a shift σ 0, bulge start computes a vector colinear with (x 1 σ, x 1x ) T If (x 1 σ, x 1x ) T is the zero vector, then bulge start returns the zero vector The implementation of bulge start is omitted LAPACK s DBDSQR provides guidance [1] The following algorithm computes an SVD step for an upper bidiagonal matrix It can also handle lower bidiagonal matrices by taking transposes as appropriate Algorithm 1 (svd step) Given an m-by-m upper bidiagonal matrix B and a shift σ 0, the following algorithm computes one SVD step See Theorem 1

Computing the Complete CS Decomposition, Brian D Sutton 1 1 B := B; for i := 1,, m 1 ( v := bulge start( B(i, i : i + 1) T, σ) if i = 1 or B(i 1, i : i + 1) = (0, 0) B(i 1, i : i + 1) T otherwise; T i := givens(m, i, i + 1, v); B := BTi; ( bulge start( 9 u := B(i : i + 1, i + 1), σ) B(i : i + 1, i) 10 S i := givens(m, i, i + 1, u); 11 B := S T i B; 1 end for 1 S := S 1 S m 1; T := T 1 T m 1; if B(i : i + 1, i) = (0, 0) T otherwise; Theorem 1 Given a real upper bidiagonal matrix B and a shift σ 0, 1 Algorithm 1 computes an SVD step B is real upper bidiagonal The proof follows immediately from Theorem 8 and the following three lemmas Lemma 1 Upon completion of line, B is upper bidiagonal, with the possible exception of a bulge at (i + 1, i) Upon completion of line 11, B is upper bidiagonal, with the possible exception of a bulge at (i, i + ) if i < m 1 Upon completion of the entire algorithm, B is upper bidiagonal The proof is omitted; the bulge-chasing nature of the algorithm is standard Lemma 1 Let B be an m-by-m real upper bidiagonal matrix and σ a nonnegative real number Run Algorithm 1 to produce T 1,, T m 1, and run Algorithm with A = B T B and λ = σ to produce G 1,, G m 1 Then T i = G i for i = 1,, m 1 The proof can be found in Appendix A Lemma 1 Let B be an m-by-m real upper bidiagonal matrix and σ a nonnegative real number Run Algorithm 1 to produce S 1,, S m 1, and run Algorithm with A = BB T and λ = σ to produce G 1,, G m 1 Then S i = G i for i = 1,, m 1 The proof can be found in Appendix A Proof of Theorem 11 If B is upper bidiagonal, then B can be obtained from Algorithm 1, which produces upper bidiagonal matrices If B is lower bidiagonal, then apply the same argument to B T Phase II: Algorithm csd step Now we can return to the CSD algorithm Phase I, which was already seen, transforms the original partitioned unitary matrix to bidiagonal block form Phase II, which is developed now, iteratively applies the SVD step to each of the four blocks of this matrix Algorithm csd step executes a single step in the iteration

Computing the Complete CS Decomposition, Brian D Sutton 1 1 Existence of the CSD step» B11 B Definition 1 Let 1 be a real orthogonal matrix in bidiagonal block B 1 B form and µ and ν nonnegative shifts satisfying µ + ν = 1 The matrix equation»» B11 B1 D1 = B 1 B effects a CSD step if D» S1 S T» B11 B 1 B 1 B» T1 1 B 11 S T 1 B 11T 1 and B S T B T are SVD steps with shift µ, B 1 S T 1 B 1T and B 1 S T B 1T 1 are SVD steps with shift ν, D 1, D, E 1, and E are diagonal signature matrices, and» B11 B1 is a matrix in bidiagonal block form B 1 B T» E1 The existence of the CSD step is not obvious at first glance It depends on several SVD steps being related in very specific ways, eg, B 11 and B 1 having the same right orthogonal factor T 1 The following theorem establishes that yes, indeed, the CSD step exists, and its proof makes clear the necessity of the restriction µ + ν = 1 Theorem The CSD step exists and the result» B11 B1 B 1 B is uniquely defined Proof Begin with the identities B T 11B 11 µ I = (B T 1B 1 ν I), (1) B T B µ I = (B T 1B 1 ν I), () B 11B T 11 µ I = (B 1B T 1 ν I), () B B T µ I = (B 1B T 1 ν I) () Each is proved using orthogonality and the relation µ + ν = 1 For example, the orthogonality of ˆ B 11 B 1 B 1 B implies B T 11 B 11 + B1B T 1 = I, and splitting the right-handside I into µ I + ν I and rearranging gives (1) Define B ij = S ijb ijt ij by an SVD step with the appropriate shift (µ if i = j or ν if i j) This produces a total of eight orthogonal factors S ij, T ij, but only four are required for the CSD step In fact, by uniqueness of the preferred QR factorization, T 11 = T 1, T 1 = T, S 11 = S 1, and S 1 = S (For example, T 11 is the orthogonal factor in the preferred QR factorization B11B T 11 µ I = T 11R 11, and T 1 is the orthogonal factor in the preferred QR factorization B1B T 1 ν I = T 1R 1 Considering (1) and the uniqueness of the preferred QR factorization, we must have T 1 = T 11 and R 1 = R 11) Hence, it is legal to define T 1 = T 11 = T 1, T = T 1 = T, S 1 = S 11 = S 1, and S = S 1 = S Finally, D 1, D, E 1, and E are designed to fix the sign pattern required for a matrix in bidiagonal block form Their existence is guaranteed by Theorem Regarding uniqueness, S 1, S, T 1, and T are uniquely defined by the preferred QR factorization, so Si T B ijt j, i, j = 1,, are uniquely defined This uniquely defines the absolute values of the entries of B ij, i, j = 1,, and the signs are specified by the definition of bidiagonal block form E

Computing the Complete CS Decomposition, Brian D Sutton 1 The obvious way to compute a CSD step is to compute four SVD steps and then to combine them together as in the proof Of course, when working in floating-point, the identities such as T 11 = T 1 typically will not hold exactly In fact, when singular values are clustered, the computed T 11 and T 1 may not even bear a close resemblance Our approach is to interleave the computation of the four SVD steps, taking care to compute S 1, S, T 1, and T once and only once We find that when one block of a matrix provides unreliable information (specifically, a very short vector whose direction is required for a Givens rotation), another block may come to the rescue, providing more reliable information Hence, the redundancy in the partitioned orthogonal matrix, rather than being a stumbling block, is actually an aid to stability Algorithm specification The following is a specification for Algorithm csd step, which accomplishes one step in Phase II of the CSD algorithm Specification The input to csd step should consist of 1 θ (n)» [0, π ]q and φ (n) [0, π ]q 1, implicitly defining a matrix in bidiagonal block B form (n) 11 B(n) 1, B (n) 1 B(n)» integers 1 i < i q identifying the current block in a partially deflated matrix B (n) 11 B(n) 1 must have the form B (n) 1 B(n) 0 0 B (n) 11 B (n) 1 (i : i, i : i) 0 0 B(n) 1 (i : i, i : i) 0 (i : i, i : i) 0 0 B(n) shifts 0 µ, ν 1 satisfying µ + ν = 1 (i : i, i : i) 0, () The algorithm should compute one CSD step with shifts µ and ν to effect " # B (n)» 11 (i : i, i : i) B(n) 1 (i : i, i : i) B11 B1 B (n) () 1 (i : i, i : i) B(n) (i : i, i : i) B 1 B B (n+1) 1 B (n+1) The output should» consist of θ (n+1) [0, π ]q and φ (n+1) [0, π ]q 1, implicitly defining the matrix (n+1) 11 B (n+1) 1 B that results from replacing the appropriate submatrices from () with the corresponding submatrices of (), and orthogonal matrices U (n+1) 1, U (n+1), V (n+1) 1, V (n+1) such that " B (n+1) 11 B (n+1) 1 B (n+1) 1 B (n+1) # = " U (n+1) 1 U (n+1) # " B (n) 11 B (n) 1 B (n) 1 B (n) # " V (n+1) 1 V (n+1) # ()

Computing the Complete CS Decomposition, Brian D Sutton 1 The algorithm The naive idea for implementing the above specification is to compute four SVD steps separately As mentioned in the proof of Theorem, this produces eight orthogonal factors when only four are needed In fact, in light of (1)() and Theorem, the Givens rotations defining S 1, S, T 1, and T come in identical pairs Of course, in floating-point, the paired Givens rotations would not actually be identical Hence, the naive algorithm suffers from the standpoints of efficiency (each Givens rotation is needlessly computed twice) and stability (what happens when two computed Givens rotations disagree?) Our solution, suggested by Fig, is to execute the four SVD steps simultaneously, computing each Givens rotation once and only once through a bulge-chasing procedure that treats all four blocks with equal regard The algorithm makes use of a routine called merge In the absence of roundoff error, merge is essentially a no-op; given two vectors in any one-dimensional subspace, it returns a vector in the same subspace (And merge((0, 0) T, (0, 0) T ) = (0, 0) T ) In the presence of roundoff error, merge is used to ameliorate small differences resulting from previous roundoff errors Algorithm (csd step) This algorithm performs one CSD step on a matrix in bidiagonal block form and satisfies Specification Its correctness is established in Theorem 1 Explicitly construct ˆ B 11 B 1 B 1 B from (θ (n), φ (n) ); Initialize h i B11 B1 B 1 B := ˆ B 11 B 1 B 1 B ; v 11 := bulge start( B 11(i, i : i + 1) T, µ); v 1 := bulge start( B 1(i, i : i + 1) T, ν); v 1 := merge(v 11, v 1); 8 T 1,i := givens (q, i, i + 1, v h i h i h 1); i B11 B1 9 := B11 B1 T1,i ; B 1 B B 1 B I ( B11(i : i + 1, i) if nonzero 10 u 11 := bulge start( B 11(i : i + 1, i + 1), µ) otherwise; 11 u 1 := bulge start( B 1(i : i + 1, i), ν); ( B1(i : i + 1, i) if nonzero 1 u 1 := bulge start( B 1(i : i + 1, i + 1), ν) otherwise; 1 u := bulge start( B (i : i + 1, i), µ); 1 u 1 := merge(u 11, u 1); u := merge(u 1, u ); 1 S 1,i := givens(q, i, i + 1, u 1); S,i := givens(q, i, i + 1, u ); 1 h i B11 B1 B 1 B := h S1,i 18 for i := i + 1,, i 1 S,i i T h B11 B1 i; B 1 B ( B11(i 1, i : i + 1) if nonzero 0 v 11 := bulge start( B 11(i, i : i + 1), µ) otherwise; ( B1(i 1, i : i + 1) if nonzero 1 v 1 := bulge start( B 1(i, i : i + 1), ν) otherwise;

Computing the Complete CS Decomposition, Brian D Sutton 18 ( B1(i 1, i 1 : i) if nonzero v 1 := bulge start( B 1(i, i 1 : i), ν) otherwise; ( B(i 1, i 1 : i) if nonzero v := bulge start( B (i, i 1 : i), µ) otherwise; v 1 := merge(v 11, v 1); v := merge(v 1, v ); T 1,i := givens(q, i, i + 1, v 1); T,i 1 := givens(q, i 1, i, v ); h i B11 B1 B 1 B := h B11 B1 B 1 B i h T1,i T,i 1 i; ( B11(i : i + 1, i) if nonzero 8 u 11 := bulge start( B 11(i : i + 1, i + 1), µ) otherwise; ( B1(i : i + 1, i 1) if nonzero 9 u 1 := bulge start( B 1(i : i + 1, i), ν) otherwise; ( B1(i : i + 1, i) if nonzero 0 u 1 := bulge start( B 1(i : i + 1, i + 1), ν) otherwise; ( B(i : i + 1, i 1) if nonzero 1 u := bulge start( B (i : i + 1, i), µ) otherwise; u 1 := merge(u 11, u 1); u := merge(u 1, u ); S 1,i := givens(q, i, i + 1, u 1); S,i := givens(q, i, i + 1, u ); end for h i B11 B1 B 1 B := h S1,i S,i i T h B11 B1 i; B 1 B ( B1(i 1, i 1 : i) if nonzero 8 v 1 := bulge start( B 1(i, i 1 : i), ν) otherwise; ( B(i 1, i 1 : i) if nonzero 9 v := bulge start( B (i, i 1 : i), µ) otherwise; 0 v := merge(v 1, v ); 1 T,i 1 := givens(q, i 1, i, v ); h i B11 B1 B 1 B := h B11 B1 B 1 B i h I T,i 1 i; U (n+1) 1 := S 1,i S 1,i 1 ; U (n+1) := S,i S,i 1 ; V (n+1) 1 := T 1,i T 1,i 1 ; V (n+1) := T,i T,i 1 ; Fix signs in h i B11 B1 B 1 B and V (n+1) as necessary; 9 Compute (θ (n+1), φ (n+1) ) to implicitly represent to match (1), negating columns of U (n+1) 1, U (n+1), V (n+1) 1, h B11 B1 i; B 1 B Note that it is possible and preferable to enforce signs and compute θ (n+1) and φ (n+1) as Givens rotations are applied, instead of waiting until the end of the algorithm Theorem If arithmetic operations are performed exactly, then Algorithm csd step satisfies Specification Proof The proof is organized into three parts First, it is shown that the algorithm

Computing the Complete CS Decomposition, Brian D Sutton 19 computes SVD steps for the top-left and bottom-right blocks Then, it is shown that the algorithm computes SVD steps for the top-right and bottom-left blocks Finally, utilizing the proof of Theorem, it is shown that the algorithm as stated simultaneously computes SVD steps of all four blocks and hence a CSD step for the entire matrix For the first part, temporarily delete lines, 11, 1, 1,, 9, 0, 8,, and 9 and make the following replacements: line original replacement v 1 := merge(v 11, v 1); v 1 := v 11; 1 u 1 := merge(u 11, u 1); u := merge(u 1, u ); u 1 := u 11; u := u ; v 1 := merge(v 11, v 1); v := merge(v 1, v ); v 1 := v 11; v := v ; u 1 := merge(u 11, u 1); u := merge(u 1, u ); u 1 := u 11; u := u ; 0 v := merge(v 1, v ); v := v ; All references to the top-right and bottom-left blocks have been removed, and the resulting algorithm is equivalent to running Algorithm svd step on the top-left and bottom-right blocks Hence, U (n+1) 1 and V (n+1) 1 are the outer factors from an SVD step on the top-left block, and U (n+1) and V (n+1) are the outer factors from an SVD step on the bottom-right block For the second part, revert back to the original algorithm but make the following changes, intended to focus attention on the top-right and bottom-left blocks: Delete lines, 10, 1, 0,, 8, 1, 9,, and 9 and make the following replacements: line original replacement v 1 := merge(v 11, v 1); v 1 := v 1; 1 u 1 := merge(u 11, u 1); u := merge(u 1, u ); u 1 := u 1; u := u 1; v 1 := merge(v 11, v 1); v := merge(v 1, v ); v 1 := v 1; v := v 1; u 1 := merge(u 11, u 1); u := merge(u 1, u ); u 1 := u 1; u := u 1; 0 v := merge(v 1, v ); v := v 1; This time, the algorithm is equivalent to running Algorithm svd step on the top-right are the outer factors from an SVD and bottom-left blocks, and so U (n+1) 1 and V (n+1) step on the top-right block and U (n+1) and V (n+1) 1 are the outer factors from an SVD step on the bottom-left block By the existence of the CSD step, the two versions of the algorithm discussed above produce identical U (n+1) 1, U (n+1), V (n+1) 1, and V (n+1) Hence, by Theorem, the two versions produce identical Givens rotations Therefore, in each invocation of merge in the final algorithm, one of the following holds: both vectors are nonzero and colinear, or one vector is the zero vector and the other vector points along the second coordinate axis, or both vectors equal the zero vector In any case, the call to merge is well defined Therefore, the final algorithm simultaneously computes SVD steps for all four blocks The final two lines of code could be implemented (inefficiently) with a single call to bidiagonalize It is straightforward to check that this would only change the signs of entries and would compute θ (n+1) and φ (n+1) Algorithm csd Algorithm csd is the driver algorithm, responsible for initiating Phase I and Phase II Given an m-by-m unitary matrix X and integers p, q with 0 q p and p+q m, csd(x, p, q) should compute θ = (θ 1,, θ q) [0, π ]q, U 1 U(p), U U(m p),

Computing the Complete CS Decomposition, Brian D Sutton 0 V 1 U(q), and V U(m q) satisfying» C S 0 0 U1 X 0 0 I p q 0 U S C 0 0 0 0 0 I m p q» V1 V, with C = diag(cos(θ 1),, cos(θ q)) and S = diag(sin(θ 1),, sin(θ q)) It would be preferable to replace the approximate equality with an error bound, but a formal stability analysis is left to the future csd s responsibility is to invoke bidiagonalize once and then csd step repeatedly The following code fleshes out this outline Algorithm 1 (csd) Given X, p, and q, the following algorithm computes the complete CS decomposition in terms of θ, U 1, U, V 1, and V 1 Find θ (0), φ (0), P 1, P, Q 1, and Q with bidiagonalize; If any θ (0) i or φ (0) i is negligibly different from 0 or π, then round; n := 0; Set i and i as in (1); 8 while i > 1 10 if some θ (n) i, i i i, is negligibly far from π, then 11 µ := 0; ν := 1; 1 elseif some θ (n) i, i i i, is negligibly far from 0, then 1 µ := 1; ν := 0; 1 else 1 Select shifts µ and ν satisfying µ + ν = 1; (* see discussion *) 1 end if 18 Compute θ (n+1), φ (n+1), U (n+1) 1, U (n+1), V (n+1) 1, V (n+1) with csd step; 0 n := n + 1; 1 If any θ (n) i or φ (n) i is negligibly different from 0 or π, then round; Set i and i as in (1); end while U 1 := P 1((U (1) 1 U () 1 U (n) 1 ) I p q); U := P ((U (1) U () U (n) ) I m p q); V 1 := Q 1(V (1) 1 V () 1 V (n) 1 ); V := Q ((V (1) V () V (n) ) I m q); As promised, the algorithm calls bidiagonalize once and csd step repeatedly The subtleties are the deflation procedure and the choice of shifts Deflation If the matrix obtained after n CSD steps, " # B (n) 11 B (n) 1 B (n) 1 B (n) =» B11(θ (n), φ (n) ) B 1(θ (n), φ (n) ) B 1(θ (n), φ (n) ) B (θ (n), φ (n) ),

Computing the Complete CS Decomposition, Brian D Sutton 1 has the form (), then the next CSD step can focus on just a principal submatrix The indices i and i are determined by φ (n) as follows 8 φ >< (n) = = φ (n) i q 1 = 0 none of φ (n) i,, φ (n) i 1 >: equal 0 (1) i is as small as possible Hence, deflation occurs when some φ (n) i transitions from nonzero to zero Note that some θ (n) i may equal 0 or π or some φ(n) i may equal π, producing zero entries in the matrix without satisfying (1) Fortunately, in this case one of the blocks has a zero on its diagonal, the appropriate shift is set to zero, and deflation occurs in the one block just as in the bidiagonal SVD algorithm of Demmel and Kahan [] (This is the reason for Case of the preferred QR factorization) It is easy to check that then one of the φ (n+1) i becomes zero Hence, as soon as a zero appears anywhere in any of the four bidiagonal bands, the entire matrix in bidiagonal block form deflates in at most one more step (assuming exact arithmetic) Choice of shift There are two natural possibilities for choosing shifts in line 1 One possibility is to let µ or ν be a Wilkinson shift (the smaller singular value of the trailing -by- submatrix of one of the blocks) from which the other shift follows by µ + ν = 1 This seems to give preference to one block over the other three, but as mentioned above, as soon as one block attains a zero, the other three blocks follow immediately Another possibility is to let µ and ν be singular values of appropriate blocks, ie, perfect shifts This keeps the number of CSD steps as small as possible [10, p 1] at the cost of extra singular value computations Based on what is known about the SVD problem and limited testing with the CSD algorithm, Wilkinson shifts appear to be the better choice, but more real world experience is desirable On numerical stability So far, the input matrix X has been assumed exactly unitary, and exact arithmetic has been assumed as well What happens in a more realistic environment? The algorithm is designed for numerical stability All four blocks are considered simultaneously and with equal regard Nearly every computation is based on information from two different sources, from which the algorithm can choose the more reliable source Below, some numerical issues and strategies are addressed Then results from numerical experiments are presented A BLAS/LAPACK-based implementation is available from the author s web site for further testing 1 Numerical issues and strategies The better of two vectors in bidiagonalize As mentioned in the discussion after Algorithm, most of the Householder reflectors used in the bidiagonalization procedure are determined by pairs of colinear vectors If the input matrix X is not exactly unitary, then some of the pairs of vectors will not be exactly colinear Each of the computations for u 1, u, v 1, and v in Algorithm performs an averaging of two different vectors in which the vector of greater norm is weighted more heavily (Vectors of greater norm tend to provide more reliable information about direction)

Computing the Complete CS Decomposition, Brian D Sutton Implementation of bulge start The implementation of bulge start (Algorithm 1) requires care to minimize roundoff error LAPACK s DBDSQR provides guidance [1] Implementation of merge In csd step, most Givens rotations can be constructed from either (or both) of two colinear vectors The function merge in the pseudocode is shorthand for a somewhat more complicated procedure in our implementation: If the Givens rotation is chasing an existing bulge in one block and introducing a new bulge in the other block, then base the Givens rotation entirely on the existing bulge (Maintaining bidiagonal block form is crucial) If the Givens rotation is chasing existing bulges in both blocks, then take a weighted average of the two vectors in the call to merge, waiting the longer vector more heavily (Vectors of greater norm provide more reliable information about direction) If the Givens rotation is introducing new bulges into both blocks, then base the computation solely on the block associated with the smaller shift, either µ or ν (In particular, when one shift is zero, this strategy avoids roundoff error in bulge start) Representation of θ (n) and φ (n) Angles of 0 and π play a special role in the deflation procedure Because common floating-point architectures represent angles near 0 more precisely than angles near π, it may be advisable to store any angle ψ as a pair (ψ, π ψ) This may provide a minor improvement but appears to be optional Rounding of θ (n) and φ (n) in csd To encourage fast termination, some angles in θ (n) and φ (n) may need to be rounded when they are negligibly far from 0 or π The best test for negligibility will be the subject of future work Disagreement of singular values when using perfect shifts If in csd, the shifts µ and ν are chosen to be perfect shifts, ie, singular values of appropriate blocks, then the computed shifts may not satisfy µ + ν = 1 exactly in the presence of roundoff error Empirically, satisfying µ + ν = 1 appears to be crucial Either µ or ν should be set to a singular value no greater than 1 and then the other shift computed from µ + ν = 1 Results of numerical experiments The sharing of singular vectors in (1) is often seen as a hindrance to numerical computation But in our algorithm, the redundancy appears to be a source of robustness when one block provides questionable information, a neighboring block may provide more reliable information Numerical tests support this claim Our criteria for a stable CSD computation, X» U1 U are the following: If X is nearly unitary, C S 0 0 0 0 I p q 0 S C 0 0 0 0 0 I m p q» V1 V, X X I m = ε, (1)

Computing the Complete CS Decomposition, Brian D Sutton then we desire θ = (θ 1,, θ q) and U 1, U, V 1, V such that C = diag(cos(θ 1),, cos(θ q)) S = diag(sin(θ 1),, sin(θ q)) Van Loan s example [19] Let X 11 = X 1 = X 1 = X = U 1 U 1 I p ε U U I m p ε V1 V 1 I q ε V V I m q ε» C = U1 T (X 0 11 + E 11)V 1, E 11 ε» S 0 0 = U1 T (X 0 I p q 0 1 + E 1)V, E 1 ε» S = U T (X 0 1 + E 1)V 1, E 1 ε» C 0 0 = U T (X 0 0 I + E )V, E ε m p q Our first test case is based on an example of Van Loan 000880 011098991 000110180 0091188808 0019980 0190 009018 01998 009919 0809 0110901 08099 00018081 0018990 008810 0100 0188188 0888 0810 00190 000919 0080198 0189881 0191081 0080819 099018 00 0189189 09191 0019011 00889 01 019900 0890989 08101900 0018909 0199 0091919 000998 099988 0188018 01081 01188 0001881 088990 001190 09888118 0110108 011889010 00090888 00808 01001990 01088 0189 0090 09988111 0019 008 018999 00999901 000 001898 011019991 01099098 and let X = [ X 11 X 1 ] [ X 1 X Van Loan considered the submatrix X11 ] X 1 X satisfies (1) with ε 10 1 Our implementation produces θ, U 1, U, V 1, and V for which U1 T U 1 I 1 10 1, U T U I 1 10 1, V T 1 V 1 I 8 10 1, V T V I 1 10 1, E 11 1 10 1, E 1 1 10 1, E 1 1 10 1, and E 9 10 1 The algorithm performs stably Haar measure Let X be a random 0-by-0 orthogonal matrix from Haar measure, let p = 18 and q = 1, and compute the CS decomposition of X using csd Actually, it is impossible to sample exactly from Haar measure in floating-point, so define X by the following Matlab code [X,R] = qr ( randn ( 0 ) ) ; X = X diag ( s i g n ( randn ( 0, 1 ) ) ) ;,

Computing the Complete CS Decomposition, Brian D Sutton Over 1000 trials of our implementation, U1 T U 1 I 18, U T U I, V1 T V 1 I 1, V T V I, E 11, E 1, E 1, and E were all less than ε, where ε was defined to be the greater of ten times machine epsilon or X T X I 0 Clusters of singular values Let δ 1, δ, δ,, δ 1 be independent and identically distributed random variables each with the same distribution as 10 18U(0,1), in which U(0, 1) is a random variable uniformly distributed on [0, 1] For i = 1,, 0, let θ i = π P i k=1 δ k P 1, and let C = diag(cos(θ k=1 δ 1 ),, cos(θ 0 )), S = k diag(sin(θ 1 ),, sin(θ 0 )), and X = [ U1 U ] [ C S ] [ ] T S V1, C V in which U 1, U, V 1, and V are random orthogonal matrices from Haar measure (These matrices can be sampled as X was sampled in the previous test case) The random matrix X is designed so that C and S have clustered singular values, as well as singular values close to 0 and 1 Such singular values break the naive CSD algorithm Compute the CSD of X with p = q = 0 using csd Over 1000 trials of our implementation, U1 T U 1 I 18, U T U I, V1 T V 1 I 1, V T V I, E 11, E 1, E 1, and E were all less than ε, with ε defined as in the previous test case θ (0) and φ (0) chosen uniformly from [ ] 0, π Choose θ 1,, θ 0 and φ 1,, φ 19 independently and uniformly from the interval [ ] 0, π, and let X = [ B11 (θ, φ) B 1 (θ, φ) B 1 (θ, φ) B (θ, φ) Compute the CSD of X with p = q = 0 using csd Over 1000 trials, U1 T U 1 I 18, U T U I, V1 T V 1 I 1, V T V I, E 11, E 1, E 1, and E were all less than ε, with ε defined as above θ (0) and φ (0) chosen randomly from { 0, π, } π Repeat the previous test case, but with θ 1,, θ 0 and φ 1,, φ 19 chosen uniformly from the threeelement set { 0, π, } π This produces test matrices with many zeros, which can tax the novel aspects of our extension of the SVD step Over 1000 trials, U1 T U 1 I 18, U T U I, V1 T V 1 I 1, V T V I, E 11, E 1, E 1, and E were all less than ε, with ε defined as above Acknowledgment The thoughtful comments of an anonymous referee are appreciated ] A Additional proofs A1 Proof of Lemma 1 Proof The proof is by induction on i