in reply to Manipulating columns of PDL data using slice() method
I recommend you to have a look at the following nodes for information on PDL
- RFC: Getting Started with PDL (the Perl Data Language)
- The Perl Data Language (PDL): A Quick Reference Guide
- RFC: PDL Cheat Sheet
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
In Section
Seekers of Perl Wisdom