github.com/egonelbre/exp@v0.0.0-20240430123955-ed1d3aa93911/vector/define/scal.go (about) 1 package define 2 3 import . "github.com/egonelbre/exp/vector/vector" 4 5 func ScalUnitary[T float32 | float64 | complex64 | complex128](alpha T, xs []T, n uintptr) { 6 Apply1( 7 Vector[T]{Values: xs, Offset: 0, Inc: 1}, 8 n, func(x T) T { 9 return x * alpha 10 }) 11 } 12 13 func ScalUnitaryTo[T float32 | float64 | complex64 | complex128](dst []T, alpha T, xs []T, n uintptr) { 14 Apply1To( 15 Vector[T]{Values: dst, Offset: 0, Inc: 1}, 16 Vector[T]{Values: xs, Offset: 0, Inc: 1}, 17 n, func(x T) T { 18 return x * alpha 19 }) 20 } 21 22 func ScalIncUnitary[T float32 | float64 | complex64 | complex128](alpha T, xs []T, n, incx uintptr) { 23 Apply1( 24 Vector[T]{Values: xs, Offset: 0, Inc: incx}, 25 n, func(x T) T { 26 return x * alpha 27 }) 28 } 29 30 func ScalIncUnitaryTo[T float32 | float64 | complex64 | complex128](dst []T, incdst uintptr, alpha T, xs []T, n, incx uintptr) { 31 Apply1To( 32 Vector[T]{Values: dst, Offset: 0, Inc: incdst}, 33 Vector[T]{Values: xs, Offset: 0, Inc: incx}, 34 n, func(x T) T { 35 return x * alpha 36 }) 37 }