PDL::Type(3pm) User Contributed Perl Documentation PDL::Type(3pm)

PDL::Type - Objects encapsulating datatypes for PDL transformations

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

This module declares one class - of this class The type method of an ndarray returns a "PDL::Type" object. For further examples check again the 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.

Returns the number representing this datatype (see get_datatype).

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'.

Returns the macro used to represent this type in C code (eg 'PDL_Long').

Lower-case version of the "shortctype".

The letter used to represent this type in PP code (eg 'U' for ushort).

The actual C type used to store this type.

The value returned by "ctype" without the 'PDL_' prefix.

The special numerical value used to represent bad values for this type. See "badvalue" in PDL::Bad for more details.

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 either is NaN).

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 both are finite).

The string appended to floating-point functions for this floating-point type. Returns "INVALID" if called on non-floating-point type.

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 orig_badvalue routine in PDL::Bad for more details.

Returns the appropriate "bswap*" from 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);

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

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

Returns whether the type can hold signed values (false) or not (true).

Returns whether the type can hold non-integer, a.k.a. floating-point, values (false) or not (true).

2025-01-23 perl v5.40.0