spatial/r3: use array conversion in safe code

This commit is contained in:
Dan Kortschak
2022-03-10 22:56:08 +10:30
parent 1a8a607b3c
commit 92bbdcdd97
3 changed files with 2 additions and 9 deletions

2
go.mod
View File

@@ -1,6 +1,6 @@
module gonum.org/v1/gonum
go 1.14
go 1.17
require (
github.com/google/go-cmp v0.5.7

View File

@@ -127,14 +127,8 @@ func (m *Mat) RawMatrix() blas64.General {
return blas64.General{Rows: 3, Cols: 3, Data: m.data[:], Stride: 3}
}
// BUG(kortschak): Implementing NewMat without unsafe conversion or slice to
// array pointer conversion leaves it with semantics that do not match the
// sharing semantics that exist in the mat package.
func arrayFrom(vals []float64) *array {
// TODO(kortschak): Use array conversion when go1.16 is no longer supported.
var a array
copy(a[:], vals)
return &a
return (*array)(vals)
}
// Mat returns a 3×3 rotation matrix corresponding to the receiver. It

View File

@@ -140,7 +140,6 @@ func (r Rotation) Mat() *Mat {
}
func arrayFrom(vals []float64) *array {
// TODO(kortschak): Use array conversion when go1.16 is no longer supported.
return (*array)(unsafe.Pointer(&vals[0]))
}