From:

Date:

August 29, 2000 19:56Subject:

Re: RFC 169 (v1) Proposed syntax for matrix element access and slicing.Message ID:

002901c0122d$48453fa0$26f1af80@phil.edu----- Original Message ----- From: "Perl6 RFC Librarian" <perl6-rfc@perl.org> To: <perl6-announce@perl.org> Cc: <perl6-language-data@perl.org> Sent: Tuesday, August 29, 2000 10:06 PM Subject: RFC 169 (v1) Proposed syntax for matrix element access and slicing. > I propose the use of ';' as a separator for index terms when accessing > multi-dimensional arrays (matrices). The syntax > "$matrix[$w;$x;$y;$z];" is clearer and more flexible than other > proposed alternatives. The flexibility is mainly in the possibility > of a robust slicing syntax. > > Although I know of no RFC's that recommend the implementation of > matrices, I expect such a proposal to be made, and this RFC does not > make such a suggestion. > > =head1 DESCRIPTION > > Several suggestions have been made for matrix element accessors, > including: > > $matrix[$x][$y][$z] # aka "(Lo)*L" notation ( (lists of)* lists) > $matrix[$x,$y,$z] # aka "[,,]" notation > $matrix{"$x,$y,$z"} # aka hash notation Perhaps I missed some discussion earlier, but I don't really see the value in defining a seperate type of matrix. Your first method $m[$x][$y][$z] is obviously already taken and isn't going to work too well if it's adapted. I can only assume that your goal is to optimize the following: my @matrix; $#matrix = $DIM1 * $DIM2 * $DIM3; for my $i ( 0 .. $DIM1 ) { for my $j ( 0 .. $DIM2 ) { for my $k ( 0 .. $DIM3 ) { op $matrix[ $i * $DIM1 + $j * $DIM2 + $k * $DIM3 ]; }}} Hence C-like matrixes. But apply various matlab like functionality to it. If you go there, then you're really asking for trouble, since you might as well ask for more and more. Though I think matlab is cool, and if we have enough mathematicians in the house, I'd love to add some more libraries to CPAN, I don't think this is the answer. The closest I would whole-heartedly advocate is a bunch of C-functions with perl wrappers. use Math::Matrix ':all'; my Math::Matrix $mat1 = new Math::Matrix dim => [ $dim1, $dim2, $dim3 ]; my Math::Matrix $mat2 = $mat1->slice( [ 0 .. 5 ], [ 0 .. 2 ], [ 3 .. 8 ] ); You can optimize this to your heart's content. And do so with complete perl5 capability. Maybe I'm wrong and this sort of activity solves a wide verity of problems. However, this added complexity is only going to enlarge the core, and make it harder for newbies to learn arrays (not that that's bad in and of itself). -MichaelThread Next

**Re: RFC 169 (v1) Proposed syntax for matrix element access and slicing.**by Michael Maraist- Re: RFC 169 (v1) Proposed syntax for matrix element access and slicing. by Karl Glazebrook

nntp.perl.org: Perl Programming lists via nntp and http.

Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About