#! /usr/bin/perl
use Math::Matrix;
$a = new Math::Matrix ([1], [2], [3]);
$x = new Math::Matrix ([4], [5], [6]);
$a->print("A\n");
$x->print("X\n");
$f = $a->cross_product( $x );
print "output of a->cross_product( x ) is: '$f'\n\n";
if( defined( $f ) ) { $f->print( "Cross product is \n" ) };
$f = $a->cross_product( $a, $x );
print "output of a->cross_product( a, x ) is: '$f'\n\n";
if( defined( $f ) ) { $f->print( "Cross product is \n" ) };
$ mathtest.pl A 1.00000 2.00000 3.00000 X 4.00000 5.00000 6.00000 output of a->cross_product( x ) is: '' output of a->cross_product( a, x ) is: ''
#!/usr/bin/perl
use warnings;
use strict;
use Math::VectorReal;
my $a = vector( 1, 2, 3 );
my $b = vector( 4, 5, 6 );
print "Vector as string (MatrixReal default format)\n\$a => ", $a;
print $a->stringify( "Formated Output \$a => { %g, %g, %g }\n" );
print "Vector as string (MatrixReal default format)\n\$b => ", $b;
print $b->stringify( "Formated Output \$b => { %g, %g, %g }\n" );
print 'dot product $a . $b =', $a . $b, "\n\n";
print 'cross product $a x $b =', $a x $b, "\n\n";
You do realize that you have full access to the source code, right?
sub cross_product {
my $vectors = shift;
my $class = ref($vectors);
my $dimensions = @{$vectors->[0]};
return undef
unless $dimensions == @$vectors + 1;
indicates that cross_product() expects to receive a single (blessed) matrix that contains the vectors to be productizedmultiplied.
I'm not saying that this access excuses unclear documentation, of course. But I suspect you can use the source to answer your own questions faster then you'll get answers from someone else. Producing a patch for the module might be a good result of your investigation.
- [tye]
perlmonks.org content © perlmonks.org and dirving, GeoBoater, tye, zentara
prlmnks.org © 2006 edmund von der burg (eccles & toad)
v 0.03