gonum.org/v1/gonum@v0.14.0/internal/asm/f64/dot.go (about) 1 // Copyright ©2015 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 // DotUnitary is 11 // 12 // for i, v := range x { 13 // sum += y[i] * v 14 // } 15 // return sum 16 func DotUnitary(x, y []float64) (sum float64) { 17 for i, v := range x { 18 sum += y[i] * v 19 } 20 return sum 21 } 22 23 // DotInc is 24 // 25 // for i := 0; i < int(n); i++ { 26 // sum += y[iy] * x[ix] 27 // ix += incX 28 // iy += incY 29 // } 30 // return sum 31 func DotInc(x, y []float64, n, incX, incY, ix, iy uintptr) (sum float64) { 32 for i := 0; i < int(n); i++ { 33 sum += y[iy] * x[ix] 34 ix += incX 35 iy += incY 36 } 37 return sum 38 }