"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "Basic/Core/Types.pm.PL" between
PDL-2.075.tar.gz and PDL-2.076.tar.gz

About: PDL (Perl Data Language) aims to turn perl into an efficient numerical language for scientific computing (similar to IDL and MatLab).

Types.pm.PL  (PDL-2.075):Types.pm.PL  (PDL-2.076)
skipping to change at line 455 skipping to change at line 455
$pdl = ushort( 2.0, 3.0 ); $pdl = ushort( 2.0, 3.0 );
print "The actual c type used to store ushort's is '" . print "The actual c type used to store ushort's is '" .
$pdl->type->realctype() . "'\n"; $pdl->type->realctype() . "'\n";
The actual c type used to store ushort's is 'unsigned short' The actual c type used to store ushort's is 'unsigned short'
=head1 DESCRIPTION =head1 DESCRIPTION
Internal module - holds all the PDL Type info. The type info can be Internal module - holds all the PDL Type info. The type info can be
accessed easily using the C<PDL::Type> object returned by accessed easily using the C<PDL::Type> object returned by
the L<type|PDL::Core/type> method. the L<type|PDL::Core/type> method as shown in the synopsis.
Skip to the end of this document to find out how to change Skip to the end of this document to find out how to change
the set of types supported by PDL. the set of types supported by PDL.
=head1 FUNCTIONS =head1 FUNCTIONS
A number of functions are available for module writers A number of functions are available for module writers
to get/process type information. These are used in various to get/process type information. These are used in various
places (e.g. C<PDL::PP>, C<PDL::Core>) to generate the places (e.g. C<PDL::PP>, C<PDL::Core>) to generate the
appropriate type loops, etc. appropriate type loops, etc.
skipping to change at line 533 skipping to change at line 533
=for example =for example
pdl> print PDL::Types::ppdefs_all pdl> print PDL::Types::ppdefs_all
B S U L N Q F D G C B S U L N Q F D G C
=cut =cut
my @PPDEFS_ALL = map $_->{ppsym}, @HASHES; my @PPDEFS_ALL = map $_->{ppsym}, @HASHES;
sub ppdefs_all { @PPDEFS_ALL } sub ppdefs_all { @PPDEFS_ALL }
=head2 typefld
=for ref
Returns specified field (C<$fld>) for specified type (C<$type>)
by querying type hash
=for usage
PDL::Types::typefld($type,$fld);
=for example
pdl> print PDL::Types::typefld('PDL_IND',realctype)
long
=cut
sub typefld { sub typefld {
my ($type,$fld) = @_; my ($type,$fld) = @_;
croak "unknown type $type" unless exists $typehash{$type}; croak "unknown type $type" unless exists $typehash{$type};
croak "unknown field $fld in type $type" croak "unknown field $fld in type $type"
unless exists $typehash{$type}->{$fld}; unless exists $typehash{$type}->{$fld};
return $typehash{$type}->{$fld}; return $typehash{$type}->{$fld};
} }
=head2 mapfld
Map a given source field to the corresponding target field by
querying the type hash. This gives you a way to say, "Find the type
whose C<$in_key> is equal to C<$value>, and return that type's value
for C<$out_key>. For example:
# Does byte type use nan?
$uses_nan = PDL::Types::mapfld(byte => 'ppforcetype', 'usenan');
# Equivalent:
$uses_nan = byte->usenan;
# What is the actual C type for the value that we call 'long'?
$type_name = PDL::Types::mapfld(long => 'convertfunc', 'realctype');
# Equivalent:
$type_name = long->realctype;
As you can see, the equivalent examples are much shorter and legible, so you
should only use mapfld if you were given the type index (in which case the
actual type is not immediately obvious):
$type_index = 4;
$type_name = PDL::Types::mapfld($type_index => numval, 'realctype');
=cut
sub mapfld { sub mapfld {
my ($type,$src,$trg) = @_; my ($type,$src,$trg) = @_;
my @keys = grep {$typehash{$_}->{$src} eq $type} typesrtkeys; my @keys = grep {$typehash{$_}->{$src} eq $type} typesrtkeys;
return @keys > 0 ? $typehash{$keys[0]}->{$trg} : undef; return @keys > 0 ? $typehash{$keys[0]}->{$trg} : undef;
} }
=head2 typesynonyms =head2 typesynonyms
=for ref =for ref
skipping to change at line 609 skipping to change at line 565
=cut =cut
sub typesynonyms { sub typesynonyms {
my $add = join "\n", my $add = join "\n",
map {"#define PDL_".typefld($_,'ppsym')." ".typefld($_,'sym')} map {"#define PDL_".typefld($_,'ppsym')." ".typefld($_,'sym')}
grep {"PDL_".typefld($_,'ppsym') ne typefld($_,'sym')} typesrtkeys; grep {"PDL_".typefld($_,'ppsym') ne typefld($_,'sym')} typesrtkeys;
return "$add\n"; return "$add\n";
} }
=head1 PDL TYPES OVERVIEW
As of 2.065, PDL supports these types:
=over
=item SByte
Signed 8-bit value.
=item Byte
Unsigned 8-bit value.
=item Short
Signed 16-bit value.
=item UShort
Unsigned 16-bit value.
=item Long
Signed 32-bit value.
=item ULong
Unsigned 32-bit value.
=item Indx
Signed value, same size as a pointer on the system in use.
=item LongLong
Signed 64-bit value.
=item ULongLong
Unsigned 64-bit value.
=item Float
L<IEEE 754|https://en.wikipedia.org/wiki/IEEE_754> single-precision real
floating-point value.
=item Double
IEEE 754 double-precision real value.
=item LDouble
A C99 "long double", defined as "at least as precise as a double",
but often more precise.
=item CFloat
A C99 complex single-precision floating-point value.
=item CDouble
A C99 complex double-precision floating-point value.
=item CLDouble
A C99 complex "long double" - see above for description.
=back
=head1 PDL::Type OBJECTS =head1 PDL::Type OBJECTS
This module declares one class - C<PDL::Type> - objects of this class This module declares one class - C<PDL::Type> - objects of this class
are returned by the L<type|PDL::Core/type> method of an ndarray. It has are returned by the L<type|PDL::Core/type> method of an ndarray. It has
several methods, listed below, which provide an easy way to access several methods, listed below, which provide an easy way to access
type information: type information:
Additionally, comparison and stringification are overloaded so that Additionally, comparison and stringification are overloaded so that
you can compare and print type objects, e.g. you can compare and print type objects, e.g.
skipping to change at line 781 skipping to change at line 807
}, },
"<=>" => sub { $_[2] ? $_[1][0] <=> $_[0][0] : $_[0][0] <=> $_[1][0] }, "<=>" => sub { $_[2] ? $_[1][0] <=> $_[0][0] : $_[0][0] <=> $_[1][0] },
); );
} # package: PDL::Type } # package: PDL::Type
# Return # Return
1; 1;
__END__ __END__
=head1 Adding/removing types =head1 DEVELOPER NOTES ON ADDING/REMOVING TYPEs
You can change the types that PDL knows about by editing entries in You can change the types that PDL knows about by editing entries in
the definition of the variable C<@types> that appears close to the the definition of the variable C<@types> that appears close to the
top of the file F<Types.pm.PL> (i.e. the file from which this module top of the file F<Types.pm.PL> (i.e. the file from which this module
was generated). was generated).
=head2 Format of a type entry =head2 Format of a type entry
Each entry in the C<@types> array is a hash reference. Here is an example Each entry in the C<@types> array is a hash reference. Here is an example
taken from the actual code that defines the C<ushort> type: taken from the actual code that defines the C<ushort> type:
skipping to change at line 835 skipping to change at line 861
I<Required>. A short sequence of upercase letters that identifies this I<Required>. A short sequence of upercase letters that identifies this
type uniquely. More than three characters is probably overkill. type uniquely. More than three characters is probably overkill.
=item * =item *
onecharident onecharident
I<Optional>. Only required if the C<identifier> has more than one character. I<Optional>. Only required if the C<identifier> has more than one character.
This should be a unique uppercase character that will be used to reference This should be a unique uppercase character that will be used to reference
this type in PP macro expressions of the C<TBSULFD> type. If you don't this type in PP macro expressions of the C<TBSULFD> type - see L<PDL::PP/$T>.
know what I am talking about read the PP manpage or ask on the mailing list.
=item * =item *
pdlctype pdlctype
I<Required>. The C<typedefed> name that will be used to access this type I<Required>. The C<typedef>ed name that will be used to access this type
from C code. from C code.
=item * =item *
realctype realctype
I<Required>. The C compiler type that is used to implement this type. I<Required>. The C compiler type that is used to implement this type.
For portability reasons this one might be platform dependent. For portability reasons this one might be platform dependent.
=item * =item *
 End of changes. 7 change blocks. 
49 lines changed or deleted 74 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)