github.com/jingcheng-WU/gonum@v0.9.1-0.20210323123734-f1a2a11a8f7b/blas/gonum/level1float32_sdot.go (about)

     1  // Code generated by "go generate github.com/jingcheng-WU/gonum/blas/gonum”; DO NOT EDIT.
     2  
     3  // Copyright ©2015 The Gonum Authors. All rights reserved.
     4  // Use of this source code is governed by a BSD-style
     5  // license that can be found in the LICENSE file.
     6  
     7  package gonum
     8  
     9  import (
    10  	"github.com/jingcheng-WU/gonum/internal/asm/f32"
    11  )
    12  
    13  // Sdot computes the dot product of the two vectors
    14  //  \sum_i x[i]*y[i]
    15  //
    16  // Float32 implementations are autogenerated and not directly tested.
    17  func (Implementation) Sdot(n int, x []float32, incX int, y []float32, incY int) float32 {
    18  	if incX == 0 {
    19  		panic(zeroIncX)
    20  	}
    21  	if incY == 0 {
    22  		panic(zeroIncY)
    23  	}
    24  	if n <= 0 {
    25  		if n == 0 {
    26  			return 0
    27  		}
    28  		panic(nLT0)
    29  	}
    30  	if incX == 1 && incY == 1 {
    31  		if len(x) < n {
    32  			panic(shortX)
    33  		}
    34  		if len(y) < n {
    35  			panic(shortY)
    36  		}
    37  		return f32.DotUnitary(x[:n], y[:n])
    38  	}
    39  	var ix, iy int
    40  	if incX < 0 {
    41  		ix = (-n + 1) * incX
    42  	}
    43  	if incY < 0 {
    44  		iy = (-n + 1) * incY
    45  	}
    46  	if ix >= len(x) || ix+(n-1)*incX >= len(x) {
    47  		panic(shortX)
    48  	}
    49  	if iy >= len(y) || iy+(n-1)*incY >= len(y) {
    50  		panic(shortY)
    51  	}
    52  	return f32.DotInc(x, y, uintptr(n), uintptr(incX), uintptr(incY), uintptr(ix), uintptr(iy))
    53  }