代码拉取完成,页面将自动刷新
package functions
import (
"gitee.com/quant1x/num/internal/constraints"
"gitee.com/quant1x/num/vectors"
)
type Number interface {
constraints.Float | constraints.Integer
}
func Zeros_Go[T constraints.Float](x []T, n int) {
Repeat_Go(x, 0, n)
}
func Ones_Go[T constraints.Float](x []T, n int) {
Repeat_Go(x, 1, n)
}
func Repeat_Go[T constraints.Float](x []T, a T, n int) {
vectors.Repeat(x, a, n)
}
func v1Repeat_Go[T constraints.Float](x []T, a T, n int) {
for i := 0; i < n; i++ {
x[i] = a
}
}
func Range_Go[T constraints.Float](x []T, a T, n int) {
for i := 0; i < n; i++ {
x[i] = a
a += 1
}
}
func Gather_Go[T constraints.Float](dst, x []T, idx []int) {
for i := 0; i < len(idx); i++ {
dst[i] = x[idx[i]]
}
}
func Scatter_Go[T constraints.Float](dst, x []T, idx []int) {
for i := 0; i < len(idx); i++ {
dst[idx[i]] = x[i]
}
}
func Clone_Go[T constraints.Float](x, y []T) {
copy(x, y)
}
func Clone_Go_Loop[T constraints.Float](x, y []T) {
for i := 0; i < len(x); i++ {
x[i] = y[i]
}
}
func FromNumber_Go[T constraints.Float, F Number](x []T, y []F) {
for i := 0; i < len(y); i++ {
x[i] = T(y[i])
}
}
func ToNumber_Go[T Number, F constraints.Float](x []T, y []F) {
for i := 0; i < len(y); i++ {
x[i] = T(y[i])
}
}
func FromBool_Go[T constraints.Float](x []T, y []bool) {
for i := 0; i < len(y); i++ {
if y[i] {
x[i] = 1
} else {
x[i] = 0
}
}
}
func ToBool_Go[F constraints.Float](x []bool, y []F) {
for i := 0; i < len(y); i++ {
if y[i] != 0 {
x[i] = true
} else {
x[i] = false
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。