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