Forum: Ruby Re: Calling plotutils from xemacs using Ruby GSL

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
unknown (Guest)
on 2006-03-12 01:34
(Received via mailing list)
Just guessing ...
Maybe plotutils cannot be found because its path is not visible ?
What happens if you run the example from

_http://ruby-gsl.sourceforge.net/rnd3.html_
(http://ruby-gsl.sourceforge.net/rnd3.html)  .

If that works out ok, you could execute the graph command
as an external command, eg. by including it in backticks or
by calling the system command ...

Best regards,

Axel
Ruby M. (Guest)
on 2006-03-12 04:39
(Received via mailing list)
Thanks Axel:

This was my output, leaving me to believe I have bigger problems, or I'm
just using IRB incorrectly:  Why would it see GSL okay but barf on the
include for GSL::Random?

Thanks for your time.

#!/usr/local/bin/ruby

require "GSL"
true
include GSL::Random
NameError: uninitialized constant GSL::Random
    from (irb):5

# Test random number distributions
# generate output suitable for graph(1) from GNU plotutils:
# ruby test/rnd3.rb | graph -Tps > g.ps

STDERR.puts "Running tests for RND(3)..."
Running tests for RND(3)...
nil

x = y = 0
0
a = []
[]
r = RNG.new
NameError: uninitialized constant RNG
    from (irb):15
puts "#m=1,S=2"
#m=1,S=2
nil
printf "%g %g\n", x, y
0 0
nil
10.times do
  a = RND::dir_2d(r)
  x += a[0]
  y += a[1]
  printf "%g %g\n", x, y
end
NameError: uninitialized constant RND
    from (irb):19
    from (irb):18

STDERR.puts "\ndone.SyntaxError: compile error
(irb):25: unterminated string meets end of file
    from (irb):25
G.Durga P. (Guest)
on 2006-03-12 20:55
(Received via mailing list)
On 3/12/06, Ruby M. <removed_email_address@domain.invalid> wrote:
> require "GSL"
> Running tests for RND(3)...
> #m=1,S=2
> NameError: uninitialized constant RND
> > Just guessing ...
> > Best regards,
> >
> > Axel
> >
> >
>
>
In Linux , after some modifications to rnd3.rb
ruby rnd3.rb | graph -Tps > g.ps
works and I can see the graph using Evince Document Viewer after
ps2pdfwr g.ps to covert it to g.pdf.

Modified rnd3.rb:
#!/usr/local/bin/ruby


#require "GSL"
require "gsl"
require 'rbgsl'
#include GSL::Random
include GSL
#include RBGSL
# Test random number distributions
# generate output suitable for graph(1) from GNU plotutils:
# ruby test/rnd3.rb | graph -Tps > g.ps

STDERR.puts "Running tests for RND(3)..."
x = y = 0
a = []
r = Rng.new
#r = RND.new
puts "#m=1,S=2"
printf "%g %g\n", x, y
10.times do
#  a = RND::dir_2d(r)
  a = Ran::dir_2d(r)
  x += a[0]
  y += a[1]
  printf "%g %g\n", x, y
end

Thanks for the education ,because of you
Prasad
This topic is locked and can not be replied to.