PDL::Type(3pm)

PDL::Type ๐Ÿ’– (from the User Contributed Perl Documentation, bestie)

okay so welcome to PDL::Type, the little class that holds all the datatype tea for your PDL ndarrays. it's giving "type info but make it an object." ๐ŸŽ€


โœจ NAME โœจ

PDL::Type โ€” objects that encapsulate datatypes for PDL transformations. periodt. ๐Ÿ’…

๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

$p = pdl('1 2 3');
print $p->type;
# double

๐ŸŒธ DESCRIPTION ๐ŸŒธ

so like, this class is literally the type-info holder for PDL ndarrays. when you call the type method on an ndarray, it hands you back a PDL::Type object. want more examples? go peek at the type method again, it ate. ๐Ÿ”ฅ

comparison and stringification are overloaded, which means you can compare and print type objects like it's nothing, e.g.

$nofloat = 1 if $pdl->type < float;
die "must be double" if $type != double;

and yeah, it's got methods to get at all that type info. let's go. ๐Ÿ‘‘

๐Ÿ’œ METHODS ๐Ÿ’œ

enum

returns the number that represents this datatype (check get_datatype for the deets). ๐Ÿ”ข

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'. ๐Ÿท๏ธ

ctype

returns the macro used to represent this type in C code (eg 'PDL_Long'). ๐Ÿ’ป

convertfunc

lower-case version of the "shortctype". ๐Ÿ”ก

ppsym

the letter used to represent this type in PP code (eg 'U' for ushort). โœจ

realctype

the actual C type used to store this type. ๐Ÿ“ฆ

shortctype

the value that "ctype" returns, but with the 'PDL_' prefix stripped off. โœ‚๏ธ

badvalue

the special numerical value used to represent bad values for this type. see "badvalue" in PDL::Bad for more. ๐Ÿ˜ญ

isnan

give it a string representing a C value, and it'll return a C expression for this type that says whether that value is NaN (for complex values, it's true if either one is NaN). ๐Ÿ™ˆ

isfinite

give it a string representing a C value, and it'll return a C expression for this type that says whether that value is finite (for complex values, it's true if both are finite). ๐ŸŒˆ

floatsuffix

the string that gets appended to floating-point functions for this floating-point type. returns "INVALID" if you call it on a non-floating-point type. โš ๏ธ

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 while it's running, no biggie.) see the orig_badvalue routine in PDL::Bad for more. ๐Ÿ’ซ

bswap

returns the appropriate "bswap*" from PDL::IO::Misc for the size of this type, and it even includes a no-op for types of size 1. heads up tho: this means for a one-line construction you have to call the return value:

$pdl->type->bswap->($pdl);

don't forget the call, bestie. ๐Ÿซถ

real

returns whether the type is real-only (true) or can hold complex values (false).

die "Real data only!" if !$pdl->type->real;

unsigned

returns whether the type can hold signed values (false) or not (true). ๐Ÿ”„

integer

returns whether the type can hold non-integer, aka floating-point, values (false) or not (true). ๐Ÿงฎ


and that's the whole vibe check, bestie ๐ŸŽ€ this was perl v5.42.3, dated 2026-08-20, straight from the User Contributed Perl Documentation โ€” slay, go type something cute ๐Ÿ’–๐Ÿ‘‘

๐Ÿ“ฆ where this page comes from