标签:os ar for sp bs as return class oo
func dst(in []float64) []float64 { out := make([]float64, len(in)) nr := len(in) for i := 0; i < nr; i++ { for j := 0; j < nr; j++ { tmp := (float64(i) + 0.5) * (float64(j) + 0.5) / float64(nr) out[i] += in[j] * math.Sin(tmp*math.Pi) } } return out } func idst(in []float64) []float64 { out := dst(in) for i, v := range out { out[i] = v * 2 / float64(len(in)) } return out } func dct(in []float64) []float64 { out := make([]float64, len(in)) nr := len(in) for i := 0; i < nr; i++ { for j := 0; j < nr; j++ { tmp := float64(i) * (float64(j) + 0.5) / float64(nr) out[i] += in[j] * math.Cos(tmp*math.Pi) } } return out } func idct(in []float64) []float64 { out := make([]float64, len(in)) nr := len(in) for i := 0; i < nr; i++ { out[i] = in[i] / 2 for j := 0; j < nr; j++ { tmp := float64(j) * (float64(i) + 0.5) / float64(nr) out[i] += in[j] * math.Cos(tmp*math.Pi) } out[i] = out[i] * 2 / float64(nr) } return out }
标签:os ar for sp bs as return class oo
原文地址:http://my.oschina.net/promi/blog/325824