Sha256: 98640db8040cad95571e2ddfe9a311ac8826c301b345d193a553fe933ec840c9

Contents?: true

Size: 985 Bytes

Versions: 14

Compression:

Stored size: 985 Bytes

Contents

require("gnuplot")

class Array
  def to_gplot
    if ( self[0].kind_of? Array ) then
      tmp = self[0].zip( *self[1..-1] )
      tmp.collect { |a| a.join(" ") }.join("\n") + "\ne"
    elsif ( self[0].kind_of? Numeric ) then
      s = ""
      self.length.times { |i| s << "#{self[i]}\n" }
      s
    elsif ( self[0].kind_of? GSL::Vector ) then
      tmp = self[0].zip( *self[1..-1] )
      tmp.collect { |a| a.join(" ") }.join("\n") + "\ne"
    else
      self[0].zip( *self[1..-1] ).to_gplot
    end
  end
  def to_gsplot
    f = ""
    
    if ( self[0].kind_of? Array ) then
      x = self[0]
      y = self[1]
      d = self[2]

      x.each_with_index do |xv, i|
        y.each_with_index do |yv, j|
          f << [ xv, yv, d[i][j] ].join(" ") << "\n"
        end
        # f << "\n"
      end
    elsif ( self[0].kind_of? Numeric ) then
      self.length.times do |i| f << "#{self[i]}\n" end
    else
      self[0].zip( *self[1..-1] ).to_gsplot
    end
    
    f
  end
end

Version data entries

14 entries across 14 versions & 5 rubygems

Version Path
gsl-nmatrix-1.15.3.2 lib/gsl/gnuplot.rb
romanbsd-gsl-1.11.2.2 lib/gsl/gnuplot.rb
gsl-nmatrix-1.15.3.1 lib/gsl/gnuplot.rb
rb-gsl-1.16.0 lib/gsl/gnuplot.rb
rb-gsl-1.15.3.2 lib/gsl/gnuplot.rb
rb-gsl-1.15.3.1 lib/gsl/gnuplot.rb
blackwinter-gsl-1.15.3.2 lib/gsl/gnuplot.rb
gsl-nmatrix-1.15.3.0 lib/gsl/gnuplot.rb
gsl-1.15.3 lib/gsl/gnuplot.rb
gsl-1.14.7 lib/gsl/gnuplot.rb
gsl-1.14.6 lib/gsl/gnuplot.rb
gsl-1.14.5 lib/gsl/gnuplot.rb
gsl-1.12.109 lib/gsl/gnuplot.rb
gsl-1.12.108 lib/gsl/gnuplot.rb