OSDN Git Service

new repo
[bytom/vapor.git] / vendor / gonum.org / v1 / gonum / blas / gonum / general_double.go
1 // Copyright ©2014 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         "math"
9 )
10
11 type general64 struct {
12         data       []float64
13         rows, cols int
14         stride     int
15 }
16
17 func (g general64) clone() general64 {
18         data := make([]float64, len(g.data))
19         copy(data, g.data)
20         return general64{
21                 data:   data,
22                 rows:   g.rows,
23                 cols:   g.cols,
24                 stride: g.stride,
25         }
26 }
27
28 func (g general64) equal(a general64) bool {
29         if g.rows != a.rows || g.cols != a.cols || g.stride != a.stride {
30                 return false
31         }
32         for i, v := range g.data {
33                 if a.data[i] != v {
34                         return false
35                 }
36         }
37         return true
38 }
39
40 func (g general64) equalWithinAbs(a general64, tol float64) bool {
41         if g.rows != a.rows || g.cols != a.cols || g.stride != a.stride {
42                 return false
43         }
44         for i, v := range g.data {
45                 if math.Abs(a.data[i]-v) > tol {
46                         return false
47                 }
48         }
49         return true
50 }