1 // Copyright ©2015 The Gonum Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
9 // Dlaev2 computes the Eigen decomposition of a symmetric 2×2 matrix.
10 // The matrix is given by
13 // Dlaev2 returns rt1 and rt2, the eigenvalues of the matrix where |RT1| > |RT2|,
14 // and [cs1, sn1] which is the unit right eigenvalue for RT1.
15 // [ cs1 sn1] [a b] [cs1 -sn1] = [rt1 0]
16 // [-sn1 cs1] [b c] [sn1 cs1] [ 0 rt2]
18 // Dlaev2 is an internal routine. It is exported for testing purposes.
19 func (impl Implementation) Dlaev2(a, b, c float64) (rt1, rt2, cs1, sn1 float64) {
27 if math.Abs(a) > math.Abs(c) {
33 rt = adf * math.Sqrt(1+(ab/adf)*(ab/adf))
35 rt = ab * math.Sqrt(1+(adf/ab)*(adf/ab))
37 rt = ab * math.Sqrt(2)
43 rt2 = (acmx/rt1)*acmn - (b/rt1)*b
47 rt2 = (acmx/rt1)*acmn - (b/rt1)*b
64 sn1 = 1 / math.Sqrt(1+ct*ct)
72 cs1 = 1 / math.Sqrt(1+tn*tn)
81 return rt1, rt2, cs1, sn1