[Israel.pm] PDL - simple vector and matrix operation
Gabor Szabo
szabgab at gmail.com
Wed Nov 11 00:07:00 PST 2009
I am still not sure where *I* might need to use PDL but it
is still fun to play with it. It has a command line utility in
which I can play with it interactively.
Let's see an example:
perldl> $x = pdl(1,2,3,4)
perldl> p $x
[1 2 3 4]
perldl> p $x + 1 # add one to each value
[2 3 4 5]
perldl> p $x + $x # add the values pair wise
[2 4 6 8]
perldl> p $x * $x # multiply the values pair wise
[1 4 9 16]
perldl> p transpose $x # from horizontal vector make a vertical vector
[
[1]
[2]
[3]
[4]
]
perldl> p $x * transpose($x) # then multiply the two vectors
[
[ 1 2 3 4]
[ 2 4 6 8]
[ 3 6 9 12]
[ 4 8 12 16]
]
Gabor
More information about the Perl
mailing list