ssa
57 строк · 2.0 Кб
1package blackmanharris_test2
3import (4"math"5"testing"6
7"github.com/RB-PRO/ssa/pkg/blackmanharris"8)
9
10func TestBlackmanharris(t *testing.T) {11N := 3212blackman := blackmanharris.Blackmanharris(N, blackmanharris.Koef4_92db)13
14// Результат15MatLabBlackman := make([]float64, N)16MatLabBlackman[0] = 0.023420000000000017MatLabBlackman[1] = 0.020079620856794918MatLabBlackman[2] = 0.011998651606123519MatLabBlackman[3] = 0.0045385633721817120MatLabBlackman[4] = 0.0052178226101618621MatLabBlackman[5] = 0.021949523519208822MatLabBlackman[6] = 0.061198547824683023MatLabBlackman[7] = 0.12647458598788124MatLabBlackman[8] = 0.21747000000000025MatLabBlackman[9] = 0.32997401330573026MatLabBlackman[10] = 0.45650136008324627MatLabBlackman[11] = 0.58741944583171128MatLabBlackman[12] = 0.71228217738983829MatLabBlackman[13] = 0.82109246727689830MatLabBlackman[14] = 0.90530144048594731MatLabBlackman[15] = 0.95847177984959432MatLabBlackman[16] = 0.97664000000000033MatLabBlackman[17] = 0.95847177984959434MatLabBlackman[18] = 0.90530144048594735MatLabBlackman[19] = 0.82109246727689836MatLabBlackman[20] = 0.71228217738983837MatLabBlackman[21] = 0.58741944583171238MatLabBlackman[22] = 0.45650136008324739MatLabBlackman[23] = 0.32997401330573040MatLabBlackman[24] = 0.21747000000000041MatLabBlackman[25] = 0.12647458598788142MatLabBlackman[26] = 0.061198547824683043MatLabBlackman[27] = 0.021949523519208944MatLabBlackman[28] = 0.0052178226101619045MatLabBlackman[29] = 0.0045385633721816846MatLabBlackman[30] = 0.011998651606123447MatLabBlackman[31] = 0.020079620856794948
49// Циклом идём по всему массиву и сравниваем данные50for index := range blackman {51if int(math.Abs(blackman[index]-MatLabBlackman[index])) > 3 {52t.Errorf("Blackmanharris: Элемент с индексом %v не соответствует рассчитанному. Должно было быть %v, а получено %v.",53index, int(MatLabBlackman[index]*1000000), int(blackman[index]*1000000))54}55}56
57}
58