1Types(3)              User Contributed Perl Documentation             Types(3)
2
3
4

NAME

6       PDL::Types - define fundamental PDL Datatypes
7

SYNOPSIS

9        use PDL::Types;
10
11        $pdl = ushort( 2.0, 3.0 );
12        print "The actual c type used to store ushort's is '" .
13           $pdl->type->realctype() . "'\n";
14        The actual c type used to store ushort's is 'unsigned short'
15

DESCRIPTION

17       Internal module - holds all the PDL Type info.  The type info can be
18       accessed easily using the "PDL::Type" object returned by the type
19       method.
20
21       Skip to the end of this document to find out how to change the set of
22       types supported by PDL.
23

Support functions

25       A number of functions are available for module writers to get/process
26       type information. These are used in various places (e.g. "PDL::PP",
27       "PDL::Core") to generate the appropriate type loops, etc.
28
29       typesrtkeys
30
31       return array of keys of typehash sorted in order of type complexity
32
33       ppdefs
34
35       return array of pp symbols for all known types
36
37       typefld
38
39       return specified field ($fld) for specified type ($type) by querying
40       type hash
41
42       mapfld
43
44       map a given source field to the corresponding target field by querying
45       the type hash
46
47       typesynonyms
48
49       return type related synonym definitions to be included in pdl.h .  This
50       routine must be updated to include new types as required.  Mostly the
51       automatic updating should take care of the vital things.
52

PDL::Type OBJECTS

54       This module declares one class - "PDL::Type" - objects of this class
55       are returned by the type method of a piddle.  It has several methods,
56       listed below, which provide an easy way to access type information:
57
58       Additionally, comparison and stringification are overloaded so that you
59       can compare and print type objects, e.g.
60
61         $nofloat = 1 if $pdl->type < float;
62         die "must be double" if $type != double;
63
64       For further examples check again the type method.
65
66       enum
67           Returns the number representing this datatype (see get_datatype).
68
69       symbol
70           Returns one of 'PDL_B', 'PDL_S', 'PDL_US', 'PDL_L', 'PDL_LL',
71           'PDL_F' or 'PDL_D'.
72
73       ctype
74           Returns the macro used to represent this type in C code (eg
75           'PDL_Long').
76
77       ppsym
78           The letter used to represent this type in PP code code (eg 'U' for
79           ushort).
80
81       realctype
82           The actual C type used to store this type.
83
84       shortctype
85           The value returned by "ctype" without the 'PDL_' prefix.
86
87       badvalue
88           Since PDL was compiled without support for 'bad' values, this rou‐
89           tine returns undef.
90
91       orig_badvalue
92           Since PDL was compiled without support for 'bad' values, this rou‐
93           tine returns undef.
94

Adding/removing types

96       You can change the types that PDL knows about by editing entries in the
97       definition of the variable @types that appears close to the top of the
98       file Types.pm.PL (i.e. the file from which this module was generated).
99
100       Format of a type entry
101
102       Each entry in the @types array is a hash reference. Here is an example
103       taken from the actual code that defines the "ushort" type:
104
105                    {
106                     identifier => 'US',
107                     onecharident => 'U',   # only needed if different from identifier
108                     pdlctype => 'PDL_Ushort',
109                     realctype => 'unsigned short',
110                     ppforcetype => 'ushort',
111                     usenan => 0,
112                     packtype => 'S*',
113                    },
114
115       Before we start to explain the fields please take this important mes‐
116       sage on board: entries must be listed in order of increasing complex‐
117       ity. This is critical to ensure that PDL"s type conversion works cor‐
118       rectly.  Basically, a less complex type will be converted to a more
119       complex type as required.
120
121       Fields in a type entry
122
123       Each type entry has a number of required and optional entry.
124
125       A list of all the entries:
126
127       ·   identifier
128
129           Required. A short sequence of upercase letters that identifies this
130           type uniquely. More than three characters is probably overkill.
131
132       ·   onecharident
133
134           Optional. Only required if the "identifier" has more than one char‐
135           acter.  This should be a unique uppercase character that will be
136           used to reference this type in PP macro expressions of the
137           "TBSULFD" type. If you don't know what I am talking about read the
138           PP manpage or ask on the mailing list.
139
140       ·   pdlctype
141
142           Required. The "typedefed" name that will be used to access this
143           type from C code.
144
145       ·   realctype
146
147           Required. The C compiler type that is used to implement this type.
148           For portability reasons this one might be platform dependent.
149
150       ·   ppforcetype
151
152           Required. The type name used in PP signatures to refer to this
153           type.
154
155       ·   usenan
156
157           Required. Flag that signals if this type has to deal with NaN
158           issues.  Generally only required for floating point types.
159
160       ·   packtype
161
162           Required. The Perl pack type used to pack Perl values into the
163           machine representation for this type. For details see "perldoc -f
164           pack".
165
166       Also have a look at the entries at the top of Types.pm.PL.
167
168       The syntax is not written into stone yet and might change as the con‐
169       cept matures.
170
171       Other things you need to do
172
173       You need to check modules that do I/O (generally in the IO part of the
174       directory tree). In the future we might add fields to type entries to
175       automate this. This requires changes to those IO modules first though.
176
177       You should also make sure that any type macros in PP files (i.e.
178       "$TBSULFD...") are updated to reflect the new type. PDL::PP::Dump has a
179       mode to check for type macros requiring updating. Do something like
180
181           find . -name \*.pd -exec perl -Mblib=. -M'PDL::PP::Dump=typecheck' {} \;
182
183       from the PDL root directory after updating Types.pm.PL to check for
184       such places.
185
186
187
188perl v5.8.8                       2002-05-21                          Types(3)
Impressum