OSDN Git Service

test (#52)
[bytom/vapor.git] / vendor / gonum.org / v1 / gonum / blas / gonum / level1double_ddot.go
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 package gonum
6
7 import (
8         "gonum.org/v1/gonum/internal/asm/f64"
9 )
10
11 // Ddot computes the dot product of the two vectors
12 //  \sum_i x[i]*y[i]
13 func (Implementation) Ddot(n int, x []float64, incX int, y []float64, incY int) float64 {
14         if incX == 0 {
15                 panic(zeroIncX)
16         }
17         if incY == 0 {
18                 panic(zeroIncY)
19         }
20         if n <= 0 {
21                 if n == 0 {
22                         return 0
23                 }
24                 panic(negativeN)
25         }
26         if incX == 1 && incY == 1 {
27                 if len(x) < n {
28                         panic(badLenX)
29                 }
30                 if len(y) < n {
31                         panic(badLenY)
32                 }
33                 return f64.DotUnitary(x[:n], y)
34         }
35         var ix, iy int
36         if incX < 0 {
37                 ix = (-n + 1) * incX
38         }
39         if incY < 0 {
40                 iy = (-n + 1) * incY
41         }
42         if ix >= len(x) || ix+(n-1)*incX >= len(x) {
43                 panic(badLenX)
44         }
45         if iy >= len(y) || iy+(n-1)*incY >= len(y) {
46                 panic(badLenY)
47         }
48         return f64.DotInc(x, y, uintptr(n), uintptr(incX), uintptr(incY), uintptr(ix), uintptr(iy))
49 }