github.com/jingcheng-WU/gonum@v0.9.1-0.20210323123734-f1a2a11a8f7b/internal/asm/f64/scal.go (about) 1 // Copyright ©2016 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. 4 5 // +build !amd64 noasm gccgo safe 6 7 package f64 8 9 // ScalUnitary is 10 // for i := range x { 11 // x[i] *= alpha 12 // } 13 func ScalUnitary(alpha float64, x []float64) { 14 for i := range x { 15 x[i] *= alpha 16 } 17 } 18 19 // ScalUnitaryTo is 20 // for i, v := range x { 21 // dst[i] = alpha * v 22 // } 23 func ScalUnitaryTo(dst []float64, alpha float64, x []float64) { 24 for i, v := range x { 25 dst[i] = alpha * v 26 } 27 } 28 29 // ScalInc is 30 // var ix uintptr 31 // for i := 0; i < int(n); i++ { 32 // x[ix] *= alpha 33 // ix += incX 34 // } 35 func ScalInc(alpha float64, x []float64, n, incX uintptr) { 36 var ix uintptr 37 for i := 0; i < int(n); i++ { 38 x[ix] *= alpha 39 ix += incX 40 } 41 } 42 43 // ScalIncTo is 44 // var idst, ix uintptr 45 // for i := 0; i < int(n); i++ { 46 // dst[idst] = alpha * x[ix] 47 // ix += incX 48 // idst += incDst 49 // } 50 func ScalIncTo(dst []float64, incDst uintptr, alpha float64, x []float64, n, incX uintptr) { 51 var idst, ix uintptr 52 for i := 0; i < int(n); i++ { 53 dst[idst] = alpha * x[ix] 54 ix += incX 55 idst += incDst 56 } 57 }