Chris Marshall
2013-12-10 19:42:57 UTC
This is a quick summary of my planned fix for the
implicit double<->longlong conversion which is causing
problems with the new PDL_Indx type when it is a
64bit integer. I believe this fix would work as the
basis for general type support planned for PDL3.
NOTE: The new type support could probably be
shoehorned into our PDL-2.x development sequence
but to simplify development, a clean break with the
legacy kitchen-sink of code needs to be made.
As it is, there are large sections of the PDL-2.x
source that are not well known by any current PDL
developers. Cleaning that out should enable a more
robust core and stable base for the new functionality.
ASSUMPTIONS for PDL type support:
- based on C to avoid C++ compiler/link problems
- as simple as possible
- keep types modular and efficient
- data should be able to be processed at the C level
The current PDL-2.x types are based on single,
atomic types which are a subset of the standard C
data types *and* which all can be cast into a double
without loss of precision. As a result, the generic
PDL type is implicitly 'double' which is why the
problems with 64bit integer index support. An IEEE
double only has a 52bit mantissa.
THE PROPOSED FIX:
Replace the hidden, container type of 'double' by a
union type large enough to hold the set of desired
atomic types *and* a pointer. The idea is that the
atomic types could be passed by copy but the
pointer type would support arbitrarily complex types
at the expense of an additional indirection. Conveniently,
perl SVs are pointers (which give us perl references,
object, code,...)
This idea seems to work directly for PDL3 where the
atomic types would be all C integer types 64bits or
less, all floating point types 64bit or less, and the
corresponding complex float types with components
64bits or less.
In addition to the union, we would need to pass around
information on what the type is. I'm not sure where the
best place to stash it. Seems likely that having the
value perl-piddle would be efficient and similar to what
we have now. If a type were needed per-element, then
that would involve using one of the pointer types at
which point full generality is available.
Thoughts and/or comments?
Chris
implicit double<->longlong conversion which is causing
problems with the new PDL_Indx type when it is a
64bit integer. I believe this fix would work as the
basis for general type support planned for PDL3.
NOTE: The new type support could probably be
shoehorned into our PDL-2.x development sequence
but to simplify development, a clean break with the
legacy kitchen-sink of code needs to be made.
As it is, there are large sections of the PDL-2.x
source that are not well known by any current PDL
developers. Cleaning that out should enable a more
robust core and stable base for the new functionality.
ASSUMPTIONS for PDL type support:
- based on C to avoid C++ compiler/link problems
- as simple as possible
- keep types modular and efficient
- data should be able to be processed at the C level
The current PDL-2.x types are based on single,
atomic types which are a subset of the standard C
data types *and* which all can be cast into a double
without loss of precision. As a result, the generic
PDL type is implicitly 'double' which is why the
problems with 64bit integer index support. An IEEE
double only has a 52bit mantissa.
THE PROPOSED FIX:
Replace the hidden, container type of 'double' by a
union type large enough to hold the set of desired
atomic types *and* a pointer. The idea is that the
atomic types could be passed by copy but the
pointer type would support arbitrarily complex types
at the expense of an additional indirection. Conveniently,
perl SVs are pointers (which give us perl references,
object, code,...)
This idea seems to work directly for PDL3 where the
atomic types would be all C integer types 64bits or
less, all floating point types 64bit or less, and the
corresponding complex float types with components
64bits or less.
In addition to the union, we would need to pass around
information on what the type is. I'm not sure where the
best place to stash it. Seems likely that having the
value perl-piddle would be efficient and similar to what
we have now. If a type were needed per-element, then
that would involve using one of the pointer types at
which point full generality is available.
Thoughts and/or comments?
Chris