Hello,
I posted this on Perlguru but, i have not gotten a reply yet.
I' just hoping to get one here.
Anyway, i have data (numbers) in a file data.txt.
I would like to import it and use it as a matrix.
ie: be able to use a matematical operation on only one row, or only one column. And Or on only one element.
I have tried a few things:
1) I know you can create a matrix like this:
my @matrix1 = (
[qw(0 0 0 0)],
[qw(0 0 1 0)],
[qw(0 1 0 0)],
[qw(1 0 0 0)],
);
But i can only access one element at a time. eg: $matrix1[0][0]
2) I have tried to use the PDL::Matrix module. It has given me errors, of which i have not found the solution on Google.
I included it like this:
use PDL::Matrix;
That line gave me no error. (I did install it, using CPAN)
When i tried to use it like this:
my $matrix2 = mpdl[[1,2,3],[4,5,6],[7,8,9]];
#or like this:
my $matrix2 = pdl[[1,2,3],[4,5,6],[7,8,9]];
#or even like this:
my $matrix2 = PDL::Matrix->pdl[[1,2,3],[4,5,6],[7,8,9]];
All of them gave me the error below:
Can't locate object method "pdl" via package "PDL::Matrix" at /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/PDL/Matrix.pm line 134.
I have been doing the two examples for practice but, what i want to do it import my file and be able to do all the operations i described above. I still have to figure out how i will use the above method on my file handler.
The only thing that works so far is importing the file and reading one line at a time :(
Thank you for your help