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.
10 "golang.org/x/exp/rand"
13 type Izamaxer interface {
14 Izamax(n int, x []complex128, incX int) int
17 func IzamaxTest(t *testing.T, impl Izamaxer) {
18 rnd := rand.New(rand.NewSource(1))
19 for _, n := range []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 50, 100} {
20 for _, incX := range []int{-5, 1, 2, 10} {
24 x = make([]complex128, (n-1)*aincX+1)
29 for i := 0; i < n; i++ {
30 re := 2*rnd.Float64() - 1
31 im := 2*rnd.Float64() - 1
32 x[i*aincX] = complex(re, im)
36 if incX > 0 && n > 0 {
38 x[want*incX] = 10 + 10i
40 got := impl.Izamax(n, x, incX)
43 t.Errorf("Case n=%v,incX=%v: unexpected result. want %v, got %v", n, incX, want, got)