OSDN Git Service

test (#52)
[bytom/vapor.git] / vendor / gonum.org / v1 / gonum / mat / offset.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 //+build !appengine
6
7 package mat
8
9 import "unsafe"
10
11 // offset returns the number of float64 values b[0] is after a[0].
12 func offset(a, b []float64) int {
13         if &a[0] == &b[0] {
14                 return 0
15         }
16         // This expression must be atomic with respect to GC moves.
17         // At this stage this is true, because the GC does not
18         // move. See https://golang.org/issue/12445.
19         return int(uintptr(unsafe.Pointer(&b[0]))-uintptr(unsafe.Pointer(&a[0]))) / int(unsafe.Sizeof(float64(0)))
20 }