On Fri, 8 Jul 2005, none wrote:

> How do you get the singular value decomposition of a matrix in Narray
> into a [u,x,v] triple of matrices?

i'll leave this one as an exercise because i'm pressed for time and it sounds
like math.  ;-)

> Then I want to grab the first column of u (u(:,1) in matlab).

   harp:~ > cat a.rb
   require 'narray'

   u = NArray::int 2, 3
   u[true, 0] = 42
   c = u[true, 0]
   p c

   harp:~ > ruby a.rb
   NArray.int(2):
   [ 42, 42 ]

> I am also interested in stacking a bunch of data matrices with various
> lags:
>
> c = column dimension of m
> stacked_m = [m(:, 1:c-2); m(:, 2:c-1); m(:,3:c)]

not sure exactly what you are looking for here, but it can easily be done:

   harp:~ > cat a.rb
   require 'narray'

   c = 3
   r = 2
   m = NArray::int c, r
   s = true

   m[s, 0] = [0,1,2]
   m[s, 1] = [3,4,5]
   p m

   stacked_m = NArray::to_na [ m[0..c-2, s], m[1..c-1, s] ]
   p stacked_m

   harp:~ > ruby a.rb
   NArray.int(3,2):
   [ [ 0, 1, 2 ],
     [ 3, 4, 5 ] ]
   NArray.int(2,2,2):
   [ [ [ 0, 1 ],
       [ 3, 4 ] ],
     [ [ 1, 2 ],
       [ 4, 5 ] ] ]


> Finally, just for grins, I want to assign 1 to all the elements of a
> matrix if which are less than 1:
>
> m(m<1) = 1

again this is trivial:

   harp:~ > cat a.rb
   require 'narray'
   na = NArray::to_na [42, -1, -42, 0]
   na[na < 1] = 1
   p na

   harp:~ > ruby a.rb
   NArray.int(4):
   [ 42, 1, 1, 1 ]



> I think there is a *lot* of work, in various bits and pieces.  (And I don't
> write Japanese, unfortunately.)

english:

   http://www.ir.isas.ac.jp/~masa/ruby/index-e.html
   http://www.ir.isas.ac.jp/~masa/ruby/na/SPEC.en


> However, it seems to be all over
> the place.  (I was never very fond of the CPAN haphazard approach to
> "library" development.)

it's either here:

   http://raa.ruby-lang.org/

or here:

   http://rubyforge.org/

> I don't want to complain--I would be quite happy to help with a
> project.  I just think we need a push to come up with a use-case based
> integration of all the tools, like scipy in Python (really like scipy +
> matplotlib), all in one coherent package.

here:

   http://www.gfd-dennou.org/library/ruby/index.htm

all there stuff can be found by:

   http://raa.ruby-lang.org/search.rhtml?search=dennou

hth.

-a
-- 
===============================================================================
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| My religion is very simple.  My religion is kindness.
| --Tenzin Gyatso
===============================================================================