Here is an interesting tidbit for people just learning. You always want to print your piddles to see what you are doing wrong, but PDL has a limit set of 30000 elements, and if your piddles exceed that, you get the dreaded 'TOO LONG TO PRINT' error message. Fortunately the PDL modules have easy-to-override subs, so you can use this module to print any size piddle.
Include this somewhere in your PERL5LIB, and
use pdldump;
# file pdldump.pm
package PDL::Core;
my $max_elem = 10000000; # set your max here
sub PDL::Core::string {
my ( $self, $format ) = @_;
if ( $PDL::_STRINGIZING ) {
return "ALREADY_STRINGIZING_NO_LOOPS";
}
local $PDL::_STRINGIZING = 1;
my $ndims = $self->getndims;
if ( $self->nelem > $max_elem ) {
return "TOO LONG TO PRINT";
}
if ( $ndims == 0 ) {
if ( $self->badflag() and $self->isbad() ) {
return "BAD";
}
else {
my @x = $self->at();
return ( $format ? sprintf( $format, $x[ 0 ] ) : "$x[0]" );
}
}
return "Null" if $self->isnull;
return "Empty" if $self->isempty; # Empty piddle
local $PDL::Core::sep = $PDL::use_commas ? "," : " ";
local $PDL::Core::sep2 = $PDL::use_commas ? "," : "";
if ( $ndims == 1 ) {
return PDL::Core::str1D( $self, $format );
}
else {
return PDL::Core::strND( $self, $format, 0 );
}
}
1;
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.