Matrix addition - Perl - PDL

Hi All,

I have a question. I need to add 3 matrices of size 2000 x 2000. (i.e) 2000 rows and 2000 columns using Perl::PDL module. I used the following perl script

#!/usr/bin/perl -w
use strict;
use warnings;

use PDL;
use PDL::Matrix;

if ( @ARGV != 3 ) {
    die 'Two matrix files are required as arguments';
}

my $index = 0;
my @matrices;
while (<>) {
    push @{ $matrices[$index] }, [ split /\s+/ ];
}
continue { $index++ if eof }

my $matrix_1 = PDL::Matrix->pdl( @{ $matrices[0] } );
my $matrix_2 = PDL::Matrix->pdl( @{ $matrices[1] } );
my $matrix_3 = PDL::Matrix->pdl( @{ $matrices[2] } );

print $matrix_1 + $matrix_2 + $matrix_3;

but I got - "TOO LONG TO PRINT" - in the output.

Can anyone help me, how to solve this problem?

Your replies are highly appreciated.

Warm regards
Fredrick.

One online hint said write it to a file. If you can write it to a file, you can write it to /dev/stdout on many systems. Of course, it might not be readable. JAVA says all objects must know how to render themselves to strings. This error comes from PDL::String, so you can look there to see what it is up to and how to make a more robust string generator: http://cpansearch.perl.org/src/CSOE/PDL-2.4.3/Basic/Core/Core.pm.PL Maybe send it sub-matrices sized less than 10000 elements in x dimension order.

    if($self->nelem > 10000) {
    	return "TOO LONG TO PRINT";
    }