Files
external-snapshotter/vendor/gonum.org/v1/gonum/lapack/gonum/dlae2.go
xiangqian 728e29aa7e 1. update clientset, deepcopy using code-generator
2. add a dummy file tools.go to force "go mod vendor" to see
code-generator as dependencies
3. add a script to update CRD
4. add a README to document CRD updating steps
run go mod tidy
update README
2019-12-04 14:40:46 -08:00

50 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Copyright ©2016 The Gonum Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package gonum
import "math"
// Dlae2 computes the eigenvalues of a 2×2 symmetric matrix
// [a b]
// [b c]
// and returns the eigenvalue with the larger absolute value as rt1 and the
// smaller as rt2.
//
// Dlae2 is an internal routine. It is exported for testing purposes.
func (impl Implementation) Dlae2(a, b, c float64) (rt1, rt2 float64) {
sm := a + c
df := a - c
adf := math.Abs(df)
tb := b + b
ab := math.Abs(tb)
acmx := c
acmn := a
if math.Abs(a) > math.Abs(c) {
acmx = a
acmn = c
}
var rt float64
if adf > ab {
rt = adf * math.Sqrt(1+(ab/adf)*(ab/adf))
} else if adf < ab {
rt = ab * math.Sqrt(1+(adf/ab)*(adf/ab))
} else {
rt = ab * math.Sqrt2
}
if sm < 0 {
rt1 = 0.5 * (sm - rt)
rt2 = (acmx/rt1)*acmn - (b/rt1)*b
return rt1, rt2
}
if sm > 0 {
rt1 = 0.5 * (sm + rt)
rt2 = (acmx/rt1)*acmn - (b/rt1)*b
return rt1, rt2
}
rt1 = 0.5 * rt
rt2 = -0.5 * rt
return rt1, rt2
}