in reply to array add/sub/mult/div

Well, if you wanted to admit modules, you could have some fun with the PDL module:

#!/usr/bin/perl -w use strict; use PDL; my $v1 = pdl reverse 1..10; my $v2 = pdl 0..9; my $v3 = pdl ((2)x10); my $add = $v1 + $v2; my $mult = $v1 * $add; my $div = $mult / $v3; my $sub = $div - $v1; print "add: $add\nmult: $mult\ndiv: $div\nsub: $sub\n"; # we didn't stomp the original vectors either... # and of course, we can work with matrices too my $matA = pdl [0,0,0],[1,1,1],[2,2,2]; # 2d 3x3 $matA++; # add one across the board $matA *= 2; # and scale up by factor of 2 print "A: $matA\n"; $matA *= $matA; # scale it by itself print "B: $matA\n"; $matA x= $matA; # matrix multiply print "C: $matA\n"; # and say, did you ever want to know the eigenvalues and # eigenvectors of a 4 x 4 matrix of a fibonacci sequence??? use PDL::Slatec; # Fortran never dies :-) my $fibo = fibonacci(4,4); my($eigvals, $eigvecs) = eigsys($fibo); print <<EOF; Fibo matrix: $fibo Eigenvalues: $eigvals Eigenvectors:$eigvecs EOF __END__ add: [10 10 10 10 10 10 10 10 10 10] mult: [100 90 80 70 60 50 40 30 20 10] div: [50 45 40 35 30 25 20 15 10 5] sub: [40 36 32 28 24 20 16 12 8 4] A: [ [2 2 2] [4 4 4] [6 6 6] ] B: [ [ 4 4 4] [16 16 16] [36 36 36] ] C: [ [ 224 224 224] [ 896 896 896] [2016 2016 2016] ] Fibo matrix: [ [ 1 1 2 3] [ 5 8 13 21] [ 34 55 89 144] [233 377 610 987] ] Eigenvalues: [0.859383 6.05138 68.0353 1010.05] Eigenvectors: [ [ 0.99101 -0.13375 -0.00326739 0.00031052] [ -0.131501 -0.97827 0.160279 -0.00218367] [ -0.0244236 -0.156787 -0.974861 0.156421] [ 0.0032657 0.0227098 0.154745 0.987688] ]