PDL::Types#
Synopsis#
use PDL::Types;
my $type = PDL::Type->new(6); # double
print $type->symbol, "\n"; # PDL_D
print $type->realctype, "\n"; # double
my $a = zeroes(double, 10);
Mirrors PDL::Types.pm: exports type-name subs (e.g. byte, double) that
return PDL type codes, plus uppercase aliases (PDL_B, PDL_D, etc.).
Type codes match PdlDatatype discriminant values exactly.
Functions#
Other Functions#
type_stringify#
PDL::Type stringification: returns lowercase type name. PDL::Type is bless [$enum], ‘PDL::Type’.
type_new#
PDL::Type->new($code_or_name) — constructor. Handles: new($class, $code), new($class, "double"), new($class, $existing_type). If the argument is already a PDL::Type blessed ref, pass it through.
types_list#
PDL::Types::types() — return the list of all registered PDL::Type objects, ordered by numval. Mirrors PDL::Types.pm: my @CACHED_TYPES = map bless([$_->{numval}, $_], 'PDL::Type'), @HASHES; sub types { @CACHED_TYPES } Heavily used by Test::PDL (line 417) to iterate over available types when building per-type comparison subs; without it, every upstream test that uses Test::PDL fails at compile time.
type_eq#
PDL::Type eq comparison — stringify both sides and compare
type_ne#
PDL::Type ne comparison
type_spaceship#
PDL::Type <=> numeric comparison by enum/numval. Mirrors upstream PDL::Types.pm:578: “<=>” => sub { $_[2] ? $_[1][0] <=> $_[0][0] : $_[0][0] <=> $_[1][0] }, where $_[2] is the swap flag.
type_cmp#
PDL::Type cmp string comparison. Mirrors Types.pm:575-577.
type_nomethod#
PDL::Type overload marker (nomethod)
type_numify#
PDL::Type numification (0+) — returns the type code integer
type_howbig#
PDL::Type::howbig — returns byte size of the type.
type_enum#
enum($type) — numval, the slot-0 integer. Types.pm:531.
type_badvalue#
PDL::Type::badvalue — get or set the bad value for the type.
type_orig_badvalue#
PDL::Type::orig_badvalue — returns the ORIGINAL (hardcoded) bad value, ignoring any user-set override. Mirrors Bad.pd’s default_badvalue_int (pdl.h’s PDL_BADVAL* constants). Note: this is NOT the same as xs_type_badvalue, which reflects mutations made via byte->badvalue($v).
type_codederef#
PDL::Type &{} overload — allows calling a PDL::Type as a code reference. byte->() returns ‘byte’ (the type name string).