[Tioga-users] Tioga and NArray

David MacMahon davidm at astro.berkeley.edu
Mon Apr 28 03:21:11 EDT 2008


Thanks for the reply, Bill!

> Concerning NArray -- we are currently going through a reworking of
> the tioga implementation prompted by Taro Sato's project to make a
> Python version.  Taro's version of tioga doesn't use Dvectors -- it
> uses the standard python analog of NArray.

That sounds interesting, though I'm not sure what that means for the  
future of Ruby Tioga.


> So, if you're willing to help Taro get some new software working, you
> might want to give "PyTioga" a try!

Thanks for the info, but switching to Python is not a palatable option.

> For the ruby Tioga, the NArray to Array to Dvector hack is probably
> the best work around for the short term.

I've had some initial success (very initial) using NArray with the  
sine.rb sample.  Perhaps it was automatically doing the NArray->Array- 
 >Dvector conversion under the covers, but here's a diff of the  
changes I made...

$ diff -U0 sine.rb na_sine.rb
--- sine.rb     2008-04-23 12:28:55.000000000 -0700
+++ na_sine.rb  2008-04-27 22:40:21.000000000 -0700
@@ -10,0 +11 @@
+require 'narray'
@@ -34,2 +35,2 @@
-    xAxis = Dvector.new(num) {|i| 2*PI*i/(num-1) }
-    yAxis = xAxis.sin
+    xAxis = NArray.float(num).indgen!.mul!(2*PI/(num-1))
+    yAxis = NMath.sin(xAxis)

If needed, I can monkey-patch a "from_na" method into the Dvector  
class...

module Dobjects
   class Dvector
     def self.from_na(na)
       _load([1, na.length, na.to_s].pack('CIa*'))
     end
   end
end

I think I can do something similar for Dtable, too.

Dave



More information about the Tioga-users mailing list