Class: GSL::Vector
- Inherits:
-
Object
- Object
- GSL::Vector
- Defined in:
- lib/gsl_extras.rb,
lib/gsl_extras.rb,
lib/gsl_extras.rb
Overview
Means that #inspect, eval, Marshal.dump etc all work in the expected way
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
- #_dump(depth) ⇒ Object
- #gaussian_smooth(sigma) ⇒ Object
- #gaussian_smooth!(sigma) ⇒ Object
- #inspect ⇒ Object
- #join(*args) ⇒ Object
- #mean_no_outliers(nstd = 1.0) ⇒ Object
- #rectangular_smooth ⇒ Object
-
#to_gslv ⇒ Object
aliold :join.
Class Method Details
._load(string) ⇒ Object
31 32 33 |
# File 'lib/gsl_extras.rb', line 31 def self._load(string) return self.alloc(Marshal.load(string)) end |
Instance Method Details
#_dump(depth) ⇒ Object
28 29 30 |
# File 'lib/gsl_extras.rb', line 28 def _dump(depth) return Marshal.dump(self.to_a) end |
#gaussian_smooth(sigma) ⇒ Object
1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 |
# File 'lib/gsl_extras.rb', line 1100 def gaussian_smooth(sigma) npix = (3.0*sigma).floor smooth = dup smooth.set_all(0.0) kernel = GaussianSmoothKernel.alloc(sigma)# gaussian_smooth_kernel(sigma) # p kernel for i in 0...smooth.size range = [([i - npix, 0].max), ([i + npix, smooth.size - 1].min)] ke = kernel.subvector(range[0] - i + npix, range[1] - range[0] + 1) ke = kernel / ke.sum for j in range[0]..range[1] smooth[i] += self[j] * ke[j - i + npix] end end smooth end |
#gaussian_smooth!(sigma) ⇒ Object
1093 1094 1095 1096 1097 1098 1099 |
# File 'lib/gsl_extras.rb', line 1093 def gaussian_smooth!(sigma) new = gaussian_smooth(sigma) for i in 0...size do i self[i] = new[i] end return nil end |
#inspect ⇒ Object
23 24 25 |
# File 'lib/gsl_extras.rb', line 23 def inspect "GSL::Vector.alloc(#{to_a.inspect})" end |
#join(*args) ⇒ Object
20 21 22 |
# File 'lib/gsl_extras.rb', line 20 def join(*args) to_a.join(*args) end |
#mean_no_outliers(nstd = 1.0) ⇒ Object
1118 1119 1120 1121 1122 |
# File 'lib/gsl_extras.rb', line 1118 def mean_no_outliers(nstd=1.0) av = mean std = sd self.dup.delete_if{|val| (val - mean).abs > nstd * std}.mean end |
#rectangular_smooth ⇒ Object
1083 1084 1085 1086 1087 1088 1089 |
# File 'lib/gsl_extras.rb', line 1083 def rectangular_smooth smooth = dup for i in 1...(self.size-1) smooth[i] = (self[i-1] + self[i] + self[i+1]) / 3.0 end smooth end |
#to_gslv ⇒ Object
aliold :join
17 18 19 |
# File 'lib/gsl_extras.rb', line 17 def to_gslv self end |