Class | Array |
In: |
lib/gsl/gnuplot.rb
|
Parent: | Object |
# File lib/gsl/gnuplot.rb, line 4 4: def to_gplot 5: if ( self[0].kind_of? Array ) then 6: tmp = self[0].zip( *self[1..-1] ) 7: tmp.collect { |a| a.join(" ") }.join("\n") + "\ne" 8: elsif ( self[0].kind_of? Numeric ) then 9: s = "" 10: self.length.times { |i| s << "#{self[i]}\n" } 11: s 12: elsif ( self[0].kind_of? GSL::Vector ) then 13: tmp = self[0].zip( *self[1..-1] ) 14: tmp.collect { |a| a.join(" ") }.join("\n") + "\ne" 15: else 16: self[0].zip( *self[1..-1] ).to_gplot 17: end 18: end
# File lib/gsl/gnuplot.rb, line 19 19: def to_gsplot 20: f = "" 21: 22: if ( self[0].kind_of? Array ) then 23: x = self[0] 24: y = self[1] 25: d = self[2] 26: 27: x.each_with_index do |xv, i| 28: y.each_with_index do |yv, j| 29: f << [ xv, yv, d[i][j] ].join(" ") << "\n" 30: end 31: # f << "\n" 32: end 33: elsif ( self[0].kind_of? Numeric ) then 34: self.length.times do |i| f << "#{self[i]}\n" end 35: else 36: self[0].zip( *self[1..-1] ).to_gsplot 37: end 38: 39: f 40: end