Sha256: 55251ea397b2bf633c1510f12e3adba45d4eb6004432724903d48c4d8f6293f4
Contents?: true
Size: 1.68 KB
Versions: 4
Compression:
Stored size: 1.68 KB
Contents
#!/usr/bin/env ruby require("gsl") n = 256 nc = 20 data = GSL::Vector.alloc(n) File.new(File.dirname(__FILE__) + '/ecg.dat').each_with_index do |l, i| data[i] = l.to_f end w = GSL::Wavelet.alloc("daubechies", 4) work = GSL::Wavelet::Workspace.alloc(n) # Choose as you like... data2 = w.transform(data, GSL::Wavelet::FORWARD, work) #data2 = data.wavelet_transform(w, GSL::Wavelet::FORWARD, work) #data2 = data.wavelet_transform_forward(w, work) #data2 = w.transform(data, work) #data2 = w.transform(data) #data2 = w.transform(data, GSL::Wavelet::FORWARD) #data2 = w.transform_forward(data, work) #data2 = w.transform_forward(data) #data2 = GSL::Wavelet.transform(w, data, GSL::Wavelet::FORWARD, work) #data2 = GSL::Wavelet.transform(w, data, GSL::Wavelet::FORWARD) #data2 = GSL::Wavelet.transform(w, data, work) #data2 = GSL::Wavelet.transform(w, data) #data2 = GSL::Wavelet.transform_forward(w, data, work) #data2 = GSL::Wavelet.transform_forward(w, data) perm = data2.abs.sort_index i = 0 while (i + nc) < n data2[perm[i]] = 0.0 i += 1 end # Choose as you like... data3 = w.transform(data2, GSL::Wavelet::BACKWARD, work) #data3 = data2.wavelet_transform(w, GSL::Wavelet::BACKWARD, work) #data3 = data2.wavelet_transform_inverse(w, work) #data3 = w.transform(data2, GSL::Wavelet::BACKWARD) #data3 = w.transform_inverse(data2, work) #data3 = w.transform_inverse(data2) #data3 = GSL::Wavelet.transform(w, data2, GSL::Wavelet::BACKWARD, work) #data3 = GSL::Wavelet.transform(w, data2, GSL::Wavelet::BACKWARD) #data3 = GSL::Wavelet.transform_inverse(w, data2, work) #data3 = GSL::Wavelet.transform_inverse(w, data2) # GSL::graph(nil, data, data3, "-T X -C -g 3 -x 0 #{data.size} -L 'Red: data, Green: DWT'")
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
gsl-2.1.0.3 | examples/wavelet/wavelet1.rb |
gsl-2.1.0.2 | examples/wavelet/wavelet1.rb |
gsl-2.1.0.1 | examples/wavelet/wavelet1.rb |
gsl-2.1.0 | examples/wavelet/wavelet1.rb |