ref: ããã³ãã³åç»ããã¯ãPCã®åçé³ã«åããã¦èªåã§è¸ããã¦ã¿ã âã«è§¦çºããã¦æ³¢ã®å¦çãããããªã£ãã®ã§ãRuby 㧠FFT (é«éãã¼ãªã¨å¤æ) ãæ¸ãã¦ã¿ã¾ããã FFT ã¨ã¯ãæ³¢ã®å½¢ãè¦ã¦å¨æ³¢æ°ã¨ããè¦æãéæ³ã®ãã¨ã§ããæ°å¼ã¨ãèããããªãã®ã§ãã¨ã«ãã Ruby ã§æ¸ãã¦ã¿ã¾ãã *1 ã def fft(a) n = a.size return a if n == 1 w = Complex.polar(1, -2 * Math::PI / n) a1 = fft((0 .. n / 2 - 1).map {|i| a[i] + a[i + n / 2] }) a2 = fft((0 .. n / 2 - 1).map {|i| (a[i] - a[i + n / 2]) * (w ** i) }) a1.zip(a2).flatten end ããã ãã§ããçãã§
{{#tags}}- {{label}}
{{/tags}}