#!/usr/bin/env ruby
require("gsl")

n = 128
data = Vector.new(n)

data[0] = 1.0
for i in 1..10 do
  data[i] = 1.0
  data[n-i] = 1.0
end

file0 = "testrealradix2-0.dat"
file1 = "testrealradix2-1.dat"

File.open(file0, "w") do |f|
  for i in 0...n do
    f.printf("%d %e\n", i, data[i])
  end
end

#data.radix2_transform()
#FFT::Real.radix2_transform(data)
FFT::Real::Radix2.transform(data)
sqrtn = Math::sqrt(n)
File.open(file1, "w") do |f|
  for i in 0...n do
    f.printf("%d %e\n", i, data[i]/sqrtn)
  end
end

#puts("Data files #{file0} and #{file1} are created.")
#puts("Try \"gnuplot -persist realradix2.gp\"")
system("gnuplot -persist realradix2.gp")
File.delete(file0)
File.delete(file1)

