First and foremost, I highly recommend looking at the Perl Data Language module on CPAN. It is large, but it covers a wide range of scientific and numeric programming tools, including various vector and matrix operations.
That said, you make no effort to ensure that any two arrays passed to your functions are the same length. Nor do you check for possible division-by-zero errors in adiv. For that matter, the classic definitions of vector-multiple and vector-divide require that one of the operands be a scalar. In fact, it's more complex even than that, but this isn't a good forum for this (it isn't really Perl-specific).
For now, I would be more concerned about getting a potential div-by-zero from adiv, as that will stop program execution cold. Mismatched-length arrays will just result in undefined elements being accessed, which will mean that Perl will grow the arrays on your behalf, behind the scenes.
Seriously, look at PDL.
--rjray
| [reply] |