PDL::Type(3)

NAME
PDL::Type - Objects encapsulating datatypes for PDL transformations

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

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

METHODS

  enum
Returns the number representing this datatype (see get_datatype).

  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 returned by "ctype" without the 'PDL_' prefix.

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

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

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

  floatsuffix
The string appended to floating-point functions for this floating-point type. Returns "INVALID" if called on 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 during runtime.) See the orig_badvalue routine in PDL::Bad for more details.

  bswap
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);

  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, a.k.a. floating-point, values (false) or not (true).