Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

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

by lin0 (Curate)
on Jul 02, 2007 at 22:38 UTC ( [id://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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2024-03-19 10:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found