Types.pm.PL (PDL-2.080) | : | Types.pm.PL (PDL-2.081) | ||
---|---|---|---|---|
skipping to change at line 205 | skipping to change at line 205 | |||
real=>1, | real=>1, | |||
complexversion=> 'CLD', | complexversion=> 'CLD', | |||
integer=>0, | integer=>0, | |||
unsigned=>0, | unsigned=>0, | |||
isnan=>'isnan(%1$s)', | isnan=>'isnan(%1$s)', | |||
isfinite=>'isfinite(%1$s)', | isfinite=>'isfinite(%1$s)', | |||
floatsuffix=>'l', | floatsuffix=>'l', | |||
}, | }, | |||
# the complex types need to be in the same order as their real | # the complex types need to be in the same order as their real | |||
# counterparts, because the "real" ppforcetype relies on a fixed interval | # counterparts, because the "real" ppforcetype relies on a fixed interval | |||
# between real and complex versions | # between each real and complex version | |||
# they also need to occur at the end of the types, as a < PDL_CF | # they also need to occur at the end of the types, as a < PDL_CF | |||
# comparison is done at C level to see if a type is real, analogous to | # comparison is done at C level to see if a type is real, analogous to | |||
# the < PDL_F above | # the < PDL_F above | |||
{ | { | |||
identifier => 'CF', | identifier => 'CF', | |||
onecharident => 'G', # only needed if different from identifi er | onecharident => 'G', # only needed if different from identifi er | |||
pdlctype => 'PDL_CFloat', | pdlctype => 'PDL_CFloat', | |||
realctype => 'complex float', | realctype => 'complex float', | |||
ppforcetype => 'cfloat', | ppforcetype => 'cfloat', | |||
usenan => 1, | usenan => 1, | |||
skipping to change at line 669 | skipping to change at line 669 | |||
=item symbol | =item symbol | |||
Returns one of 'PDL_B', 'PDL_S', 'PDL_US', 'PDL_L', 'PDL_IND', 'PDL_LL', | Returns one of 'PDL_B', 'PDL_S', 'PDL_US', 'PDL_L', 'PDL_IND', 'PDL_LL', | |||
'PDL_F' or 'PDL_D'. | 'PDL_F' or 'PDL_D'. | |||
=item ctype | =item ctype | |||
Returns the macro used to represent this type in C code (eg 'PDL_Long'). | Returns the macro used to represent this type in C code (eg 'PDL_Long'). | |||
=item convertfunc | ||||
Synonym for C<ctype>. | ||||
=item ppsym | =item ppsym | |||
The letter used to represent this type in PP code (eg 'U' for L<ushort|PDL::Core /ushort>). | The letter used to represent this type in PP code (eg 'U' for L<ushort|PDL::Core /ushort>). | |||
=item realctype | =item realctype | |||
The actual C type used to store this type. | The actual C type used to store this type. | |||
=item shortctype | =item shortctype | |||
skipping to change at line 718 | skipping to change at line 722 | |||
L<orig_badvalue routine in PDL::Bad|PDL::Bad/orig_badvalue> for more details. | L<orig_badvalue routine in PDL::Bad|PDL::Bad/orig_badvalue> for more details. | |||
=item bswap | =item bswap | |||
Returns the appropriate C<bswap*> from L<PDL::IO::Misc> for the size of | Returns the appropriate C<bswap*> from L<PDL::IO::Misc> for the size of | |||
this type, including a no-op for types of size 1. Note this means a | this type, including a no-op for types of size 1. Note this means a | |||
one-line construction means you must call the return value: | one-line construction means you must call the return value: | |||
$pdl->type->bswap->($pdl); | $pdl->type->bswap->($pdl); | |||
=item real | ||||
Returns whether the type is real-only (true) or can hold complex values | ||||
(false). | ||||
die "Real data only!" if !$pdl->type->real; | ||||
=item unsigned | ||||
Returns whether the type can hold signed values (false) or not (true). | ||||
=item integer | ||||
Returns whether the type can hold non-integer, a.k.a. floating-point, | ||||
values (false) or not (true). | ||||
=back | =back | |||
=cut | =cut | |||
my @CACHED_TYPES = map bless([$_->{numval}, $_], 'PDL::Type'), @HASHES; | my @CACHED_TYPES = map bless([$_->{numval}, $_], 'PDL::Type'), @HASHES; | |||
# return all known types as type objects | # return all known types as type objects | |||
sub types { @CACHED_TYPES } | sub types { @CACHED_TYPES } | |||
{ | { | |||
package PDL::Type; | package PDL::Type; | |||
skipping to change at line 811 | skipping to change at line 831 | |||
}, | }, | |||
"<=>" => sub { $_[2] ? $_[1][0] <=> $_[0][0] : $_[0][0] <=> $_[1][0] }, | "<=>" => sub { $_[2] ? $_[1][0] <=> $_[0][0] : $_[0][0] <=> $_[1][0] }, | |||
); | ); | |||
} # package: PDL::Type | } # package: PDL::Type | |||
# Return | # Return | |||
1; | 1; | |||
__END__ | __END__ | |||
=head1 DEVELOPER NOTES ON ADDING/REMOVING TYPEs | =head1 DEVELOPER NOTES ON ADDING/REMOVING TYPES | |||
You can change the types that PDL knows about by editing entries in | You can change the types that PDL knows about by editing entries in | |||
the definition of the variable C<@types> that appears close to the | the definition of the variable C<@types> that appears close to the | |||
top of the file F<Types.pm.PL> (i.e. the file from which this module | top of the file F<Types.pm.PL> (i.e. the file from which this module | |||
was generated). | was generated). | |||
=head2 Format of a type entry | =head2 Format of a type entry | |||
Each entry in the C<@types> array is a hash reference. Here is an example | Each entry in the C<@types> array is a hash reference. Here is an example | |||
taken from the actual code that defines the C<ushort> type: | taken from the actual code that defines the C<ushort> type: | |||
End of changes. 4 change blocks. | ||||
2 lines changed or deleted | 22 lines changed or added |