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 // Dlartg generates a plane rotation so that
10 // [ cs sn] * [f] = [r]
12 // This is a more accurate version of BLAS drotg, with the other differences that
13 // if g = 0, then cs = 1 and sn = 0, and if f = 0 and g != 0, then cs = 0 and sn = 1.
14 // If abs(f) > abs(g), cs will be positive.
16 // Dlartg is an internal routine. It is exported for testing purposes.
17 func (impl Implementation) Dlartg(f, g float64) (cs, sn, r float64) {
18 safmn2 := math.Pow(dlamchB, math.Trunc(math.Log(dlamchS/dlamchE)/math.Log(dlamchB)/2))
34 scale := math.Max(math.Abs(f1), math.Abs(g1))
41 scale = math.Max(math.Abs(f1), math.Abs(g1))
46 r = math.Sqrt(f1*f1 + g1*g1)
49 for i := 0; i < count; i++ {
52 } else if scale <= safmn2 {
58 scale = math.Max(math.Abs(f1), math.Abs(g1))
63 r = math.Sqrt(f1*f1 + g1*g1)
66 for i := 0; i < count; i++ {
70 r = math.Sqrt(f1*f1 + g1*g1)
74 if math.Abs(f) > math.Abs(g) && cs < 0 {