Loading the rest of this comparison.

misc.pd diff

Created Diff never expires
35 removals
772 lines
35 additions
772 lines

# check for bad value support
use PDL::Config;
my $bvalflag = $PDL::Config{WITH_BADVAL} || 0;

# and endian-ness of machine
# and endian-ness of machine
require PDL::Core::Dev;
require PDL::Core::Dev;
my $isbigendian = PDL::Core::Dev::isbigendian();
my $isbigendian = PDL::Core::Dev::isbigendian();


use strict;
use warnings;
pp_addpm({At=>'Top'},<<'EOD');
pp_addpm({At=>'Top'},<<'EOD');
use strict;
use warnings;


=head1 NAME
=head1 NAME


PDL::IO::Misc - misc IO routines for PDL
PDL::IO::Misc - misc IO routines for PDL


=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


EOD
EOD


pp_addpm({At=>'Bot'},<<'EOD');
pp_addpm({At=>'Bot'},<<'EOD');


=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


EOD
EOD


pp_add_exported('',"rcols wcols swcols rgrep rdsa");
pp_add_exported('',"rcols wcols swcols rgrep");


############################## PM CODE ########################################
############################## PM CODE ########################################


pp_addpm(<<'!NO!SUBS!');
pp_addpm(<<'!NO!SUBS!');


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;


!NO!SUBS!
!NO!SUBS!


defpdl(
defpdl(
'bswap2',
'bswap2',
'x(); ',
'x(); ',
'',
'',
'
'
int i;
int i;
PDL_Short *aa; PDL_Short bb;
PDL_Short *aa; PDL_Short bb;
PDL_Byte *a,*b;
PDL_Byte *a,*b;


int n = sizeof($x()) / sizeof(PDL_Short);
int n = sizeof($x()) / sizeof(PDL_Short);
aa = (PDL_Short*) &$x();
aa = (PDL_Short*) &$x();


for(i=0;i<n; i++) {
for(i=0;i<n; i++) {
bb = aa[i]; a = (PDL_Byte*) (void*) (aa+i);
bb = aa[i]; a = (PDL_Byte*) (void*) (aa+i);
b = (PDL_Byte*) &bb;
b = (PDL_Byte*) &bb;
*a = *(b+1); *(a+1) = *b;
*a = *(b+1); *(a+1) = *b;
}',
}',
"Swaps pairs of bytes in argument x()"
"Swaps pairs of bytes in argument x()"
);
);




defpdl(
defpdl(
'bswap4',
'bswap4',
'x(); ',
'x(); ',
'',
'',
'
'
int i;
int i;
PDL_Long *aa; PDL_Long bb;
PDL_Long *aa; PDL_Long bb;
PDL_Byte *a,*b;
PDL_Byte *a,*b;


int n = sizeof($x()) / sizeof(PDL_Long);
int n = sizeof($x()) / sizeof(PDL_Long);
aa = (PDL_Long*) &$x();
aa = (PDL_Long*) &$x();


for(i=0;i<n; i++) {
for(i=0;i<n; i++) {
bb = aa[i]; a = (PDL_Byte*) (void*) (aa+i);
bb = aa[i]; a = (PDL_Byte*) (void*) (aa+i);
b = (PDL_Byte*) &bb;
b = (PDL_Byte*) &bb;