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 // Dlassq updates a sum of squares in scaled form. The input parameters scale and
10 // sumsq represent the current scale and total sum of squares. These values are
11 // updated with the information in the first n elements of the vector specified
14 // Dlassq is an internal routine. It is exported for testing purposes.
15 func (impl Implementation) Dlassq(n int, x []float64, incx int, scale float64, sumsq float64) (scl, smsq float64) {
19 for ix := 0; ix <= (n-1)*incx; ix += incx {
20 absxi := math.Abs(x[ix])
21 if absxi > 0 || math.IsNaN(absxi) {
23 sumsq = 1 + sumsq*(scale/absxi)*(scale/absxi)
26 sumsq += (absxi / scale) * (absxi / scale)