Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Manipulating columns of PDL data using slice() method

by lin0 (Curate)
on Jul 02, 2007 at 22:38 UTC ( #624562=note: print w/ replies, xml ) Need Help??


in reply to Manipulating columns of PDL data using slice() method

Hi Anonymous Monk

I recommend you to have a look at the following nodes for information on PDL

Now, answering your question, you could use the function minimum together with xchg as in the following example:

#!/usr/bin/perl use warnings; use strict; use PDL; my ( @data, @tmp ); while (defined(my $line = <DATA>)) { chomp ($line); @tmp = split /\s+/, $line; push @data, [ @tmp ]; } my $patterns = pdl(@data); my $minimum = minimum($patterns->xchg(0,1)); print "minimum: $minimum\n"; __DATA__ 2.0 4.0 4.0 5.0 5.0 4.0 5.5 6.0 5.0 5.0 4.5 4.5 5.0 5.5 5.5 5.0 5.0 4.5 4.5 5.0 9.5 -1.0 9.0 9.5 8.0 8.0 7.0 8.0 8.0 7.0 8.5 7.0 7.0 8.5 7.0 7.0 7.5 7.0 6.5 8.0 8.0 6.5 6.5 7.0 10.0 10.0 10.0 9.0 10.0 9.0 9.5 10.0 8.0 10.0 9.5 9.5 9.0 9.0 9.0 10.0

The output is:

minimum: [2 -1]

Cheers,

lin0


Comment on Re: Manipulating columns of PDL data using slice() method
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://624562]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2014-12-28 17:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (182 votes), past polls