PDL::Types(3pm)
β¨ NAME β¨
PDL::Types β define fundamental PDL Datatypes
hey bestie π«Ά you're reading PDL::Types(3pm), straight out of the User Contributed Perl Documentation collection. it's the page that spills everything about the datatypes PDL is built on. let's get into it π
π SYNOPSIS π
use PDL::Types;
$pdl = ushort( 2.0, 3.0 );
print "The actual c type used to store ushort's is '" .
$pdl->type->realctype() . "'\n";
The actual c type used to store ushort's is 'unsigned short'
π DESCRIPTION π
okay so real talk: this is an internal module π β it holds all the PDL type info. and how do you get at that info? easy. you use the PDL::Type object that the type method hands back, exactly like the synopsis shows. slay, no cap.
and if you're curious about how to change the whole set of types that PDL supports? skip to the end of this document β everything you need is chillin' down there for you β¨
π₯ FUNCTIONS π₯
for all my module-writer besties out there: there is a whole pile of functions here for getting and processing type information π. they get used all over the place (think PDL::PP, PDL::Core) to generate the right type loops and all that good stuff. iconic behaviour tbh π
typesrtkeys
hands you back an array of keys of typehash, sorted in order of type complexity β¨
pdl> @typelist = PDL::Types::typesrtkeys;
pdl> print @typelist;
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 PDL_CLD
ppdefs
hands you back an array of pp symbols covering all the real types. this is what sets the default GenericTypes for pp_def functions, which means supporting complex types is a whole opt-in situation π
pdl> print PDL::Types::ppdefs
A B S U L K N P Q F D E
ppdefs_complex
hands you back an array of pp symbols covering all the complex types π¦
pdl> print PDL::Types::ppdefs_complex
G C H
ppdefs_all
hands you back an array of pp symbols covering all types, complex ones included π
pdl> print PDL::Types::ppdefs_all
A B S U L K N P Q F D E G C H
typesynonyms
returns the type-related synonym definitions that get included in pdl.h . heads up though: this routine has to be updated by hand whenever new types show up β that's a requirement, not a suggestion π. luckily the automatic updating handles most of the vital stuff for you, so it's giving "low-maintenance, mostly" π
π PDL TYPES OVERVIEW π
as of 2.065, PDL supports these types:
SByteβ signed 8-bit value.Byteβ unsigned 8-bit value.Shortβ signed 16-bit value.UShortβ unsigned 16-bit value.Longβ signed 32-bit value.ULongβ unsigned 32-bit value.Indxβ signed value, same size as a pointer on whatever system you're on π₯οΈULongLongβ unsigned 64-bit value.LongLongβ signed 64-bit value.Floatβ IEEE 754 (https://en.wikipedia.org/wiki/IEEE_754) single-precision real floating-point value.Doubleβ IEEE 754 double-precision real value.LDoubleβ a C99long double, defined asat least as precise as a double, but often more precise β¨CFloatβ a C99 complex single-precision floating-point value.CDoubleβ a C99 complex double-precision floating-point value.CLDoubleβ a C99 complexlong doubleβ see above for the description, bestie.
and as of 2.099, the documentation for PDL::Type is separate π. see there for more.
π DEVELOPER NOTES ON ADDING/REMOVING TYPES π
you can totally change the types PDL knows about β just edit the entries in the definition of the variable @types that lives close to the top of the file lib/PDL/Types.pm.
π¦ Format of a type entry π¦
every entry in the @HASHES array is a hash reference. here's an example, taken straight from the actual code that defines the ushort type:
{
identifier => 'US',
onecharident => 'U', # only needed if different from identifier
ctype => 'PDL_Ushort',
realctype => 'unsigned short',
ppforcetype => 'ushort',
usenan => 0,
packtype => 'S*',
defbval => 'USHRT_MAX',
real=>1,
integer=>1,
unsigned=>1,
},
before we start explaining the fields, please please please take this important message on board: entries must be listed in order of increasing complexity. this is critical to make sure PDL's type conversion works correctly. basically, a less complex type gets converted to a more complex type whenever that's what's needed. periodt π
π Fields in a type entry π
each type entry has a number of required and optional entries. here's the list of all of them:
identifierβ Required. a short sequence of uppercase letters that identifies this type uniquely. more than three characters is probably overkill ngl.onecharidentβ Optional. only needed if theidentifierhas more than one character. this should be a unique uppercase character that'll be used to reference this type in PP macro expressions of theTBSULFDkind β see$Tin PDL::PP.ctypeβ Required. thetypedefed name that'll be used to access this type from C code.realctypeβ Required. the C compiler type used to implement this type. for portability reasons this one might be platform dependent.ppforcetypeβ Required. the type name used in PP signatures to refer to this type.usenanβ Required. a flag that signals whether this type has to deal with NaN issues. generally only needed for floating point types.packtypeβ Required. the Perl pack type used to pack Perl values into the machine representation for this type. for the details, seeperldoc -f pack.integerβ Required. boolean β is this an integer type?unsignedβ Required. boolean β is this an unsigned type?realβ Required. boolean β is this a real (not complex) type?realversionβ string β the real version of this type (e.g.cdouble -> 'D').complexversionβ string β the complex version of this type (e.g.double -> 'C').
also go peek at the entries at the top of lib/PDL/Types.pm π
πΈ Other things you need to do πΈ
you need to check the modules that do I/O (generally in the IO part of the directory tree). in the future we might add fields to type entries to automate this β but that requires changes to those IO modules first, so, y'know, one thing at a time π
you may also need to update any type macros in PP files (i.e. $TBSULFD...) so they reflect the new type. heads up: PP will throw an error if you've got a $T... macro that's missing types the operation supports. so don't skip this step, bestie π
and that's the whole page!! go forth and type responsibly π«Ά
okay bye ily, this was PDL::Types(3pm) from the User Contributed Perl Documentation, built against perl v5.42.3 and dated 2026-08-20. stay iconic ππβ¨
π¦ where this page comes from
- ubuntu stonking: pdl 1:2.106-1build1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms