This is the mail archive of the gsl-discuss@sources.redhat.com mailing list for the GSL project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[ANN] Ruby/GSL 1.5.4 released


  Ruby/GSL, a Ruby binding of GSL, has been 
updated to version 1.5.4. The source code is 
available at 
  http://rubyforge.org/projects/rb-gsl/.

# Ruby is an object-oriented script language.
# http://www.ruby-lang.org/en

  The new version supports all the functionalities 
of GSL-1.5, and some of GSL-1.6 features as 
discrete wavelet transforms. The two GSL add-on 
packages, rngextra by Brian and gsl_tensor by 
J. Burguet are also supported. The tarball 
includes html reference and many sample scripts. 
Enjoy easy computing with GSL and the light-weight 
language. 

  I list some examples:

  * LU/QR/SV decomposition

      m = GSL::Matrix.alloc([3, 5, 6], [2, 3, 4], [7, 1, 4])
      b = GSL::Vector.alloc([6, 1, 4])
      lu, perm, sign = m.LU_decomp  # gsl_linalg_LU_decomp()
      x = lu.solve(perm, b)         # gsl_linalg_LU_solve()

      qr, tau = m.QR_decomp
      q, r = qr.unpack(tau)
      a = q*q.trans      # Unit matrix (q is orthonormal)
      b = q*r            # Reconstruct matrix m

      u, v, s = m.SV_decomp
      c = u*GSL::Matrix.diagonal(s)*v.trans # Reconstruct m

  * Numerical integration

      f = GSL::Function.alloc { |x| Math::sin(x)/x }
      f.integration_qng(0, 2.0*M_PI)  
        ---> [1.41815157613263, 2.52463969828182e-14, 21, 0]

  * Special functions
      x = GSL::Vector.linspace(0, 20, 100) # mimics GNU Octave
      y = GSL::Sf::bessel_J0(x)
      GSL::graph(x, y, "-T X -C")   # uses GNU graph interface

  * Histograms
      # 100 divisions in [-8, 8)
	  h = GSL::Histogram.alloc(100, [-8, 8]) 
      rng = GSL::Rng.alloc          # Random number generator
      for i in 0..10000 do
        r = Ran::gaussian(rng, 1.5) + 2 # mean=2, sigma=1.5
        h.increment(r)
      end
      GSL::graph(h, "-T X -C -g 3")

  * Wavelet transform:

      n = 256; nc = 20
      data = GSL::Vector.alloc(n)
      data.fscanf("ecg.dat")
      datasave = data.duplicate
      w = GSL::Wavelet.alloc("daubechies", 4)
      work = GSL::Wavelet::Workspace.alloc(n)

      w.transform(data, Wavelet::FORWARD, work)

      perm = data.abs.sort_index
      i = 0
      while (i + nc) < n
        data[perm[i]] = 0.0
        i += 1  
      end
      w.transform(data, Wavelet::BACKWARD, work)
      GSL::graph(nil, datasave, data) 



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]