Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
NArray help
Joe Lovick
10/16/2008 7:32:00 PM
Hi,
Could someone please tell me how the syntax works for the narray, max
and min methods.
if i use @values.max i get the max of the entire array, after reading
the narray documentation
http://narray.rubyforge.o...
it looks
like i can get the max of a particular dimension at an orthogonal index,
however, i am at a loss to work out how this should be specified
syntatically.
to put it another way, i have a 2D array, and i would like to find the
max and the min, of each of the columns 1..n.
Cheers
Joe
--
Posted via
http://www.ruby-...
.
2 Answers
Joel VanderWerf
10/16/2008 7:38:00 PM
0
Joe Lovick wrote:
> Hi,
>
> Could someone please tell me how the syntax works for the narray, max
> and min methods.
>
> if i use @values.max i get the max of the entire array, after reading
> the narray documentation
http://narray.rubyforge.o...
it looks
> like i can get the max of a particular dimension at an orthogonal index,
> however, i am at a loss to work out how this should be specified
> syntatically.
>
> to put it another way, i have a 2D array, and i would like to find the
> max and the min, of each of the columns 1..n.
This maybe?
irb(main):006:0> a = NArray[ [1,2,3], [4,5,6] ]
=> NArray.int(3,2):
[ [ 1, 2, 3 ],
[ 4, 5, 6 ] ]
irb(main):007:0> a.max(0)
=> NArray.int(2):
[ 3, 6 ]
irb(main):008:0> a.max(1)
=> NArray.int(3):
[ 4, 5, 6 ]
So I guess 0 means "max over each row", and 1 means "max over each column".
--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407
Joe Lovick
10/16/2008 7:55:00 PM
0
> This maybe?
>
> irb(main):006:0> a = NArray[ [1,2,3], [4,5,6] ]
> => NArray.int(3,2):
> [ [ 1, 2, 3 ],
> [ 4, 5, 6 ] ]
> irb(main):007:0> a.max(0)
> => NArray.int(2):
> [ 3, 6 ]
> irb(main):008:0> a.max(1)
> => NArray.int(3):
> [ 4, 5, 6 ]
>
> So I guess 0 means "max over each row", and 1 means "max over each
> column".
Thanks,
my own stupidity even takes me by surprise
Cheers
Joe
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
NArray help
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