問題描述
Tài liệu trực tuyến Ruby / GSL cho phiên bản sai? (Ruby/GSL online documentation for wrong version?)
After successfuly installing Ruby/GSL library on my Debian (via *deb), with Ruby 1.9.3, I am having troubles running most of the GSL methods. Specifically, this webpage shows several code samples, but (in Arrays), right from the top line, require "GSL"
is obsolete, it is require "gsl"
today. The remaining methods also do not work.
For another example of my problem, consider another online reference to Ruby/GSL.
GSL::VERSION
#=> 1.15
GSL::pow_2( 4 )
#=> 16
But when I flip the page,
GSL::Complex.new( 0.9, 1.1 )
#=> ArgumentError: wrong number of arguments(2 for 0)
The simplest explanation to me would be that Ruby/GSL has more than one version hanging online, and the documentation I found is for the old one. For example, there is this abandoned version (https://github.com/codahale/ruby‑gsl), so perhaps the version history is a bit complicated? Which is the authoritative version, and where can I finde the up‑to‑date documentation?
參考解法
方法 1:
Following methods do work for the Complex module:
> c = GSL::Complex[0.9, 1.1]
=> GSL::Complex
[ 9.000e‑01 1.100e+00 ]
> c.real
=> 0.9
> c.imag
=> 1.1
> c.pow 2
=> GSL::Complex
[ ‑4.000e‑01 1.980e+00 ]
(by Boris Stitnicky、David Unric)