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