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.
11 var sizeOfFloat64 = int(reflect.TypeOf(float64(0)).Size())
13 // offset returns the number of float64 values b[0] is after a[0].
14 func offset(a, b []float64) int {
15 va0 := reflect.ValueOf(a).Index(0)
16 vb0 := reflect.ValueOf(b).Index(0)
17 if va0.Addr() == vb0.Addr() {
20 // This expression must be atomic with respect to GC moves.
21 // At this stage this is true, because the GC does not
22 // move. See https://golang.org/issue/12445.
23 return int(vb0.UnsafeAddr()-va0.UnsafeAddr()) / sizeOfFloat64