From aca21d339e81d8b30744a39d34e4fffbd6ddf42e Mon Sep 17 00:00:00 2001 From: Vladimir Chalupecky Date: Fri, 23 Sep 2016 10:53:54 +0900 Subject: [PATCH] testlapack: add rootsOfUnity help function --- testlapack/general.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/testlapack/general.go b/testlapack/general.go index 7479cdea..2f1db614 100644 --- a/testlapack/general.go +++ b/testlapack/general.go @@ -1170,3 +1170,13 @@ func isLeftEigenvectorOf(a blas64.General, yRe, yIm []float64, lambda complex128 } return true } + +// rootsOfUnity returns the n complex numbers whose n-th power is equal to 1. +func rootsOfUnity(n int) []complex128 { + w := make([]complex128, n) + for i := 0; i < n; i++ { + angle := math.Pi * float64(2*i) / float64(n) + w[i] = complex(math.Cos(angle), math.Sin(angle)) + } + return w +}