gonum.org/v1/gonum@v0.14.0/mathext/airy_test.go (about)

     1  // Copyright ©2016 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  package mathext
     6  
     7  import (
     8  	"math"
     9  	"testing"
    10  )
    11  
    12  func TestAiry(t *testing.T) {
    13  	t.Parallel()
    14  	for _, test := range []struct {
    15  		z, ans complex128
    16  	}{
    17  		// Results computed using Octave.
    18  		{5, 1.08344428136074e-04},
    19  		{5i, 29.9014823980070 + 21.6778315987835i},
    20  	} {
    21  		ans := AiryAi(test.z)
    22  		if math.Abs(real(ans)-real(test.ans)) > 1e-10 {
    23  			t.Errorf("Real part mismatch. Got %v, want %v", real(ans), real(test.ans))
    24  		}
    25  		if math.Abs(imag(ans)-imag(test.ans)) > 1e-10 {
    26  			t.Errorf("Imaginary part mismatch. Got %v, want %v", imag(ans), imag(test.ans))
    27  		}
    28  	}
    29  }