Misc.pm (PDL-2.082) | : | Misc.pm (PDL-2.083) | ||
---|---|---|---|---|
skipping to change at line 35 | skipping to change at line 35 | |||
=head1 DESCRIPTION | =head1 DESCRIPTION | |||
Some basic I/O functionality: FITS, tables, byte-swapping | Some basic I/O functionality: FITS, tables, byte-swapping | |||
=head1 SYNOPSIS | =head1 SYNOPSIS | |||
use PDL::IO::Misc; | use PDL::IO::Misc; | |||
=cut | =cut | |||
#line 43 "Misc.pm" | #line 44 "Misc.pm" | |||
=head1 FUNCTIONS | =head1 FUNCTIONS | |||
=cut | =cut | |||
#line 47 "misc.pd" | #line 47 "misc.pd" | |||
use PDL::Primitive; | use PDL::Primitive; | |||
use PDL::Types; | use PDL::Types; | |||
use PDL::Options; | use PDL::Options; | |||
use PDL::Bad; | use PDL::Bad; | |||
use Carp; | use Carp; | |||
use Symbol qw/ gensym /; | use Symbol qw/ gensym /; | |||
use List::Util; | use List::Util; | |||
use strict; | use strict; | |||
#line 68 "Misc.pm" | #line 64 "Misc.pm" | |||
#line 958 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm" | ||||
=head2 bswap2 | =head2 bswap2 | |||
=for sig | =for sig | |||
Signature: (x(); ) | Signature: (x(); ) | |||
=for ref | =for ref | |||
Swaps pairs of bytes in argument x() | Swaps pairs of bytes in argument x() | |||
=for bad | =for bad | |||
bswap2 does not process bad values. | bswap2 does not process bad values. | |||
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. | It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. | |||
=cut | =cut | |||
#line 93 "Misc.pm" | ||||
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm" | ||||
*bswap2 = \&PDL::bswap2; | *bswap2 = \&PDL::bswap2; | |||
#line 100 "Misc.pm" | ||||
#line 958 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm" | ||||
=head2 bswap4 | =head2 bswap4 | |||
=for sig | =for sig | |||
Signature: (x(); ) | Signature: (x(); ) | |||
=for ref | =for ref | |||
Swaps quads of bytes in argument x() | Swaps quads of bytes in argument x() | |||
=for bad | =for bad | |||
bswap4 does not process bad values. | bswap4 does not process bad values. | |||
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. | It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. | |||
=cut | =cut | |||
#line 125 "Misc.pm" | ||||
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm" | ||||
*bswap4 = \&PDL::bswap4; | *bswap4 = \&PDL::bswap4; | |||
#line 132 "Misc.pm" | ||||
#line 958 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm" | ||||
=head2 bswap8 | =head2 bswap8 | |||
=for sig | =for sig | |||
Signature: (x(); ) | Signature: (x(); ) | |||
=for ref | =for ref | |||
Swaps octets of bytes in argument x() | Swaps octets of bytes in argument x() | |||
=for bad | =for bad | |||
bswap8 does not process bad values. | bswap8 does not process bad values. | |||
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. | It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. | |||
=cut | =cut | |||
#line 157 "Misc.pm" | ||||
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm" | ||||
*bswap8 = \&PDL::bswap8; | *bswap8 = \&PDL::bswap8; | |||
#line 164 "Misc.pm" | ||||
#line 124 "misc.pd" | #line 124 "misc.pd" | |||
# Internal routine to extend PDL array by size $n along last dimension | # Internal routine to extend PDL array by size $n along last dimension | |||
# - Would be nice to have a proper extend function rather than hack | # - Would be nice to have a proper extend function rather than hack | |||
# - Is a NO-OP when handed a perl ARRAY ref rather than an ndarray arg | # - Is a NO-OP when handed a perl ARRAY ref rather than an ndarray arg | |||
sub _ext_lastD { # Called by rcols and rgrep | sub _ext_lastD { # Called by rcols and rgrep | |||
my ($x,$n) = @_; | my ($x,$n) = @_; | |||
if (ref($_[0]) ne 'ARRAY') { | if (ref($_[0]) ne 'ARRAY') { | |||
my @nold = $x->dims; | my @nold = $x->dims; | |||
skipping to change at line 391 | skipping to change at line 373 | |||
my $class = shift; | my $class = shift; | |||
barf 'Usage ($x,$y,...) = rcols( *HANDLE|"filename", ["/pattern/" or \%option s], $col1, $col2, ..., [ \%options] )' | barf 'Usage ($x,$y,...) = rcols( *HANDLE|"filename", ["/pattern/" or \%option s], $col1, $col2, ..., [ \%options] )' | |||
if $#_<0; | if $#_<0; | |||
my $is_handle = _is_io_handle $_[0]; | my $is_handle = _is_io_handle $_[0]; | |||
my $fh = $is_handle ? $_[0] : gensym; | my $fh = $is_handle ? $_[0] : gensym; | |||
open $fh, $_[0] or die "File $_[0] not found\n" unless $is_handle; | open $fh, $_[0] or die "File $_[0] not found\n" unless $is_handle; | |||
shift; | shift; | |||
# set up default options | # set up default options | |||
my $opt = new PDL::Options( { | my $opt = PDL::Options->new( { | |||
CHUNKSIZE => undef, | CHUNKSIZE => undef, | |||
COLIDS => undef, | COLIDS => undef, | |||
COLSEP => undef, | COLSEP => undef, | |||
DEFTYPE => $deftype, | DEFTYPE => $deftype, | |||
EXCLUDE => '/^#/', | EXCLUDE => '/^#/', | |||
INCLUDE => undef, | INCLUDE => undef, | |||
LINES => '', | LINES => '', | |||
PERLCOLS => undef, | PERLCOLS => undef, | |||
TYPES => [], | TYPES => [], | |||
VERBOSE=> $PDL::verbose, | VERBOSE=> $PDL::verbose, | |||
skipping to change at line 1100 | skipping to change at line 1082 | |||
my $is_handle = _is_io_handle $_[0]; | my $is_handle = _is_io_handle $_[0]; | |||
my $fh = $is_handle ? $_[0] : gensym; | my $fh = $is_handle ? $_[0] : gensym; | |||
open $fh, $_[0] or die "File $_[0] not found\n" unless $is_handle; | open $fh, $_[0] or die "File $_[0] not found\n" unless $is_handle; | |||
if (ref($pattern) ne "CODE") { | if (ref($pattern) ne "CODE") { | |||
die "Got a ".ref($pattern)." for rgrep?!"; | die "Got a ".ref($pattern)." for rgrep?!"; | |||
} | } | |||
# set up default options | # set up default options | |||
my $opt = new PDL::Options( { | my $opt = PDL::Options->new( { | |||
DEFTYPE => $deftype, | DEFTYPE => $deftype, | |||
TYPES => [], | TYPES => [], | |||
UNDEFINED => $PDL::undefval, | UNDEFINED => $PDL::undefval, | |||
BUFFERSIZE => 10000 | BUFFERSIZE => 10000 | |||
} ); | } ); | |||
# Check if the user specified options | # Check if the user specified options | |||
my $u_opt = $_[1] || {}; | my $u_opt = $_[1] || {}; | |||
$opt->options( $u_opt); | $opt->options( $u_opt); | |||
my $options = $opt->current(); | my $options = $opt->current(); | |||
skipping to change at line 1171 | skipping to change at line 1153 | |||
wantarray ? return(@ret) : return $ret[0]; | wantarray ? return(@ret) : return $ret[0]; | |||
} | } | |||
=head2 isbigendian | =head2 isbigendian | |||
=for ref | =for ref | |||
Determine endianness of machine - returns 0 or 1 accordingly | Determine endianness of machine - returns 0 or 1 accordingly | |||
=cut | =cut | |||
#line 1221 "Misc.pm" | ||||
#line 1180 "misc.pd" | #line 1180 "misc.pd" | |||
sub PDL::isbigendian { return 0; }; | sub PDL::isbigendian { return 0; }; | |||
*isbigendian = \&PDL::isbigendian; | *isbigendian = \&PDL::isbigendian; | |||
#line 1229 "Misc.pm" | ||||
#line 1202 "misc.pd" | #line 1202 "misc.pd" | |||
=head2 rasc | =head2 rasc | |||
=for ref | =for ref | |||
Simple function to slurp in ASCII numbers quite quickly, | Simple function to slurp in ASCII numbers quite quickly, | |||
although error handling is marginal (to nonexistent). | although error handling is marginal (to nonexistent). | |||
=for usage | =for usage | |||
$pdl->rasc("filename"|FILEHANDLE [,$noElements]); | $pdl->rasc("filename"|FILEHANDLE [,$noElements]); | |||
skipping to change at line 1284 | skipping to change at line 1262 | |||
$im->getdim(0) != $nx or $im->getdim(1) != $ny ; | $im->getdim(0) != $nx or $im->getdim(1) != $ny ; | |||
} | } | |||
$tmp = $cube->slice(":,:,($k)"); | $tmp = $cube->slice(":,:,($k)"); | |||
$tmp .= $im; | $tmp .= $im; | |||
$k++; | $k++; | |||
} | } | |||
return $cube; | return $cube; | |||
} | } | |||
#line 1340 "Misc.pm" | #line 1300 "Misc.pm" | |||
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm" | ||||
*_rasc = \&PDL::_rasc; | *_rasc = \&PDL::_rasc; | |||
#line 1347 "Misc.pm" | ||||
#line 27 "misc.pd" | #line 27 "misc.pd" | |||
=head1 AUTHOR | =head1 AUTHOR | |||
Copyright (C) Karl Glazebrook 1997, Craig DeForest 2001, | Copyright (C) Karl Glazebrook 1997, Craig DeForest 2001, | |||
2003, and Chris Marshall 2010. All rights reserved. There is | 2003, and Chris Marshall 2010. All rights reserved. There is | |||
no warranty. You are allowed to redistribute this software | no warranty. You are allowed to redistribute this software | |||
/ documentation under certain conditions. For details, see | / documentation under certain conditions. For details, see | |||
the file COPYING in the PDL distribution. If this file is | the file COPYING in the PDL distribution. If this file is | |||
separated from the PDL distribution, the copyright notice | separated from the PDL distribution, the copyright notice | |||
should be included in the file. | should be included in the file. | |||
=cut | =cut | |||
#line 1367 "Misc.pm" | #line 1323 "Misc.pm" | |||
# Exit with OK status | # Exit with OK status | |||
1; | 1; | |||
End of changes. 17 change blocks. | ||||
31 lines changed or deleted | 6 lines changed or added |