Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Re: Premature Optimization
Gavin Kistner
10/25/2006 9:15:00 PM
From: poopdeville@gmail.com [mailto:poopdeville@gmail.com]
> first = [1,0,0,0,0]
> second = [1,1,0,0,0]
> third = [0,0,0,1,0]
>
> I would end up with
> count = [2,1,0,1,0]
Built into Ruby:
irb(main):001:0> require 'matrix'
=> true
irb(main):002:0> first = Vector[1,0,0,0,0]
=> Vector[1, 0, 0, 0, 0]
irb(main):003:0> second = Vector[1,1,0,0,0]
=> Vector[1, 1, 0, 0, 0]
irb(main):004:0> third = Vector[0,0,0,1,0]
=> Vector[0, 0, 0, 1, 0]
irb(main):005:0> count = first + second + third
=> Vector[2, 1, 0, 1, 0]
However, I believe that's a pure-ruby implementation of matrices and
vectors. A quick bit of Googling looks ike RNum[1] might be crazy fast
and do what you need. I've never used it. I've also never used
NArray[2], but it might do what you need.
[1]
http://rnum.ruby...
[2]
http://narray.ruby...
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: Premature Optimization
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password