package expl8m; # expl8m.m package for expl8.pl use strict; use Exporter qw(import); our $VERSION = 1.00; our @ISA = qw(Exporter); our @EXPORT_OK = qw(matadd matsub); # see matrix.pm for many subroutines sub matadd { my ($mat1, $mat2, $sum) = @_; # parameters my $r1 = @$mat1; my $c1 = @{$mat1->[0]}; my $r2 = @$mat2; my $c2 = @{$mat2->[0]}; print "in matadd r1=$r1, c1=$c1, r2=$r2, c2=$c2 \n"; for (my $i = 0; $i < $r1; $i++) { for (my $j = 0; $j < $c1; $j++) { $sum->[$i][$j] = $mat1->[$i][$j] + $mat2->[$i][$j]; } } } # end matadd sub matsub { my ($mat1, $mat2, $sum) = @_; # parameters my $r1 = @$mat1; my $c1 = @{$mat1->[0]}; my $r2 = @$mat2; my $c2 = @{$mat2->[0]}; print "in matsub r1=$r1, c1=$c1, r2=$r2, c2=$c2 \n"; for (my $i = 0; $i < $r1; $i++) { for (my $j = 0; $j < $c1; $j++) { $sum->[$i][$j] = $mat1->[$i][$j] - $mat2->[$i][$j]; } } } # end matsub 1;