1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
package PDL::Type;
=head1 NAME
PDL::Type - Objects encapsulating datatypes for PDL transformations
=head1 SYNOPSIS
$p = pdl('1 2 3');
print $p->type;
# double
=head1 DESCRIPTION
This module declares one class - of this class The L<type|PDL::Core/type>
method of an ndarray returns a C<PDL::Type> object.
For further examples check again the L<type|PDL::Core/type> method.
Comparison and stringification are overloaded so that
you can compare and print type objects, e.g.
$nofloat = 1 if $pdl->type < float;
die "must be double" if $type != double;
It has methods to access type information.
=head1 METHODS
=head2 enum
Returns the number representing this datatype (see L<get_datatype|PDL::Core/PDL::get_datatype>).
=head2 symbol
Returns one of 'PDL_SB', 'PDL_B', 'PDL_S', 'PDL_US', 'PDL_L',
'PDL_UL', 'PDL_IND', 'PDL_ULL', 'PDL_LL', 'PDL_F', 'PDL_D', 'PDL_LD',
'PDL_CF', 'PDL_CD', or 'PDL_CLD'.
=head2 ctype
Returns the macro used to represent this type in C code (eg 'PDL_Long').
=head2 convertfunc
Lower-case version of the C<shortctype>.
=head2 ppsym
The letter used to represent this type in PP code (eg 'U' for L<ushort|PDL::Core/ushort>).
=head2 realctype
The actual C type used to store this type.
=head2 shortctype
The value returned by C<ctype> without the 'PDL_' prefix.
=head2 badvalue
The special numerical value used to represent bad values for this type.
See L<PDL::Bad/badvalue> for more details.
=head2 isnan
Given a string representing a C value, will return a C expression for
this type that indicates whether that value is NaN (for complex values,
if I<either> is NaN).
=head2 isfinite
Given a string representing a C value, will return a C expression for
this type that indicates whether that value is finite (for complex values,
if I<both> are finite).
=head2 floatsuffix
The string appended to floating-point functions for this floating-point
type. Returns C<INVALID> if called on non-floating-point type.
=head2 orig_badvalue
The default special numerical value used to represent bad values for this
type. (You can change the value that represents bad values for each type
during runtime.) See the
L<orig_badvalue routine in PDL::Bad|PDL::Bad/orig_badvalue> for more details.
=head2 bswap
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
one-line construction means you must call the return value:
$pdl->type->bswap->($pdl);
=head2 real
Returns whether the type is real-only (true) or can hold complex values
(false).
die "Real data only!" if !$pdl->type->real;
=head2 unsigned
Returns whether the type can hold signed values (false) or not (true).
=head2 integer
Returns whether the type can hold non-integer, a.k.a. floating-point,
values (false) or not (true).
|