github.com/gopherd/gonum@v0.0.4/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  //  for i, v := range x {
    12  //  	sum += y[i] * v
    13  //  }
    14  //  return sum
    15  func DotUnitary(x, y []float64) (sum float64) {
    16  	for i, v := range x {
    17  		sum += y[i] * v
    18  	}
    19  	return sum
    20  }
    21  
    22  // DotInc is
    23  //  for i := 0; i < int(n); i++ {
    24  //  	sum += y[iy] * x[ix]
    25  //  	ix += incX
    26  //  	iy += incY
    27  //  }
    28  //  return sum
    29  func DotInc(x, y []float64, n, incX, incY, ix, iy uintptr) (sum float64) {
    30  	for i := 0; i < int(n); i++ {
    31  		sum += y[iy] * x[ix]
    32  		ix += incX
    33  		iy += incY
    34  	}
    35  	return sum
    36  }