1 // Copyright ©2017 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 "golang.org/x/exp/rand"
14 type Zcopyer interface {
15 Zcopy(n int, x []complex128, incX int, y []complex128, incY int)
18 func ZcopyTest(t *testing.T, impl Zcopyer) {
19 rnd := rand.New(rand.NewSource(1))
20 for n := 0; n <= 20; n++ {
21 for _, inc := range allPairs([]int{-7, -3, 1, 13}, []int{-11, -5, 1, 17}) {
29 x = make([]complex128, (n-1)*aincX+1)
34 for i := 0; i < n; i++ {
35 x[i*aincX] = complex(rnd.NormFloat64(), rnd.NormFloat64())
37 xCopy := make([]complex128, len(x))
42 y = make([]complex128, (n-1)*aincY+1)
48 want := make([]complex128, len(y))
53 for i := 0; i < n; i++ {
54 want[i*aincY] = x[i*aincX]
57 for i := 0; i < n; i++ {
58 want[i*aincY] = x[(n-1-i)*aincX]
62 impl.Zcopy(n, x, incX, y, incY)
64 prefix := fmt.Sprintf("Case n=%v,incX=%v,incY=%v:", n, incX, incY)
67 t.Errorf("%v: unexpected modification of x", prefix)
70 t.Errorf("%v: unexpected y:\nwant %v\ngot %v", prefix, want, y)