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 // Dlas2 computes the singular values of the 2×2 matrix defined by
12 // The smaller and larger singular values are returned in that order.
14 // Dlas2 is an internal routine. It is exported for testing purposes.
15 func (impl Implementation) Dlas2(f, g, h float64) (ssmin, ssmax float64) {
19 fhmin := math.Min(fa, ha)
20 fhmax := math.Max(fa, ha)
25 v := math.Min(fhmax, ga) / math.Max(fhmax, ga)
26 return 0, math.Max(fhmax, ga) * math.Sqrt(1+v*v)
30 at := (fhmax - fhmin) / fhmax
31 au := (ga / fhmax) * (ga / fhmax)
32 c := 2 / (math.Sqrt(as*as+au) + math.Sqrt(at*at+au))
33 return fhmin * c, fhmax / c
37 return fhmin * fhmax / ga, ga
40 at := (fhmax - fhmin) / fhmax
41 c := 1 / (math.Sqrt(1+(as*au)*(as*au)) + math.Sqrt(1+(at*au)*(at*au)))
42 return 2 * (fhmin * c) * au, ga / (c + c)