MCPcopy Create free account
hub / github.com/breeze-sys/Label-Only-MIA-Go / VectorAdd

Function VectorAdd

pkg/mathutils/basic.go:18–28  ·  view source on GitHub ↗

VectorAdd 两个向量对应元素相加 对应 Python: a + b (用于叠加噪声)

(a, b []float32)

Source from the content-addressed store, hash-verified

16// VectorAdd 两个向量对应元素相加
17// 对应 Python: a + b (用于叠加噪声)
18func VectorAdd(a, b []float32) []float32 {
19 if len(a) != len(b) {
20 panic("VectorAdd: vectors must have the same length")
21 }
22
23 result := make([]float32, len(a))
24 for i := 0; i < len(a); i++ {
25 result[i] = a[i] + b[i]
26 }
27 return result
28}
29
30// VectorSub 两个向量对应元素相减
31// 对应 Python: a - b (用于计算差异向量)

Callers 2

AttackMethod · 0.92
approximateGradientMethod · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected