"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "Basic/Pod/Internals.pod" between
PDL-2.074.tar.gz and PDL-2.075.tar.gz

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

Internals.pod  (PDL-2.074):Internals.pod  (PDL-2.075)
skipping to change at line 89 skipping to change at line 89
never get destroyed */ never get destroyed */
void *datasv; /* Pointer to SV containing data. Refcnt inced */ void *datasv; /* Pointer to SV containing data. Refcnt inced */
void *data; /* Null: no data alloced for this one */ void *data; /* Null: no data alloced for this one */
PDL_Indx nvals; /* How many values allocated */ PDL_Indx nvals; /* How many values allocated */
int datatype; int datatype;
PDL_Indx *dims; /* Array of data dimensions */ PDL_Indx *dims; /* Array of data dimensions */
PDL_Indx *dimincs; /* Array of data default increments */ PDL_Indx *dimincs; /* Array of data default increments */
short ndims; /* Number of data dimensions */ short ndims; /* Number of data dimensions */
unsigned char *threadids; /* Starting index of the thread index set n unsigned char *broadcastids; /* Starting index of the broadcast index
*/ set n */
unsigned char nthreadids; unsigned char nbroadcastids;
pdl_trans_children trans_children; pdl_trans_children trans_children;
PDL_Indx def_dims[PDL_NDIMS]; /* Preallocated space for efficiency */ PDL_Indx def_dims[PDL_NDIMS]; /* Preallocated space for efficiency */
PDL_Indx def_dimincs[PDL_NDIMS]; /* Preallocated space for efficie ncy */ PDL_Indx def_dimincs[PDL_NDIMS]; /* Preallocated space for efficie ncy */
unsigned char def_threadids[PDL_NTHREADIDS]; unsigned char def_broadcastids[PDL_NBROADCASTIDS];
struct pdl_magic *magic; struct pdl_magic *magic;
void *hdrsv; /* "header", settable from outside */ void *hdrsv; /* "header", settable from outside */
}; };
This is quite a structure for just storing some data in - what is going on? This is quite a structure for just storing some data in - what is going on?
=head3 Data storage =head3 Data storage
skipping to change at line 188 skipping to change at line 188
Since the vast majority of ndarrays don't have more than 6 dimensions, Since the vast majority of ndarrays don't have more than 6 dimensions,
it is more efficient to have default storage for the dimensions and dimincs it is more efficient to have default storage for the dimensions and dimincs
inside the PDL struct. inside the PDL struct.
PDL_Indx def_dims[PDL_NDIMS]; PDL_Indx def_dims[PDL_NDIMS];
PDL_Indx def_dimincs[PDL_NDIMS]; PDL_Indx def_dimincs[PDL_NDIMS];
The C<dims> and C<dimincs> may be set to point to the beginning of these The C<dims> and C<dimincs> may be set to point to the beginning of these
arrays if C<ndims> is smaller than or equal to the compile-time constant arrays if C<ndims> is smaller than or equal to the compile-time constant
C<PDL_NDIMS>. This is important to note when freeing an ndarray struct. C<PDL_NDIMS>. This is important to note when freeing an ndarray struct.
The same applies for the threadids: The same applies for the broadcastids:
unsigned char def_threadids[PDL_NTHREADIDS]; unsigned char def_broadcastids[PDL_NBROADCASTIDS];
=head3 Magic =head3 Magic
It is possible to attach magic to ndarrays, much like Perl's own magic It is possible to attach magic to ndarrays, much like Perl's own magic
mechanism. If the member pointer mechanism. If the member pointer
struct pdl_magic *magic; struct pdl_magic *magic;
is nonzero, the PDL has some magic attached to it. The implementation is nonzero, the PDL has some magic attached to it. The implementation
of magic can be gleaned from the file F<pdlmagic.c> in the distribution. of magic can be gleaned from the file F<pdlmagic.c> in the distribution.
skipping to change at line 458 skipping to change at line 458
functions (e.g., C<slice>, C<xchg>) belong to this class. functions (e.g., C<slice>, C<xchg>) belong to this class.
The basic trick is that parent and child of such a transformation work The basic trick is that parent and child of such a transformation work
on the same (shared) block of data which they just choose on the same (shared) block of data which they just choose
to interpret differently (by using different C<dims>, C<dimincs> and to interpret differently (by using different C<dims>, C<dimincs> and
C<offs> on the same data, compare the C<pdl> structure above). C<offs> on the same data, compare the C<pdl> structure above).
Each operation on an ndarray sharing Each operation on an ndarray sharing
data with another one in this way is therefore automatically flowed data with another one in this way is therefore automatically flowed
from child to parent and back -- after all they are reading and writing from child to parent and back -- after all they are reading and writing
the same block of memory. This is currently not Perl thread safe -- the same block of memory. This is currently not Perl thread safe --
no big loss since the whole PDL core is not reentrant no big loss since the whole PDL core is not reentrant.
(Perl threading C<!=> PDL threading!).
=head2 Callback functions =head2 Callback functions
=head3 redodims =head3 redodims
Works out the dimensions of ndarrays that need Works out the dimensions of ndarrays that need
to be created and is called from within the API function that to be created and is called from within the API function that
should be called to ensure that the dimensions of an ndarray are should be called to ensure that the dimensions of an ndarray are
accessible (F<pdlapi.c>): accessible (F<pdlapi.c>):
skipping to change at line 499 skipping to change at line 498
=head3 freetrans =head3 freetrans
Frees dynamically allocated memory associated with the trans as needed. Frees dynamically allocated memory associated with the trans as needed.
If C<redodims> has previously been called, it will free any If C<redodims> has previously been called, it will free any
vaffine-associated memory. If the C<destroy> parameter is true, it will vaffine-associated memory. If the C<destroy> parameter is true, it will
also free any bespoke C<params>-connected memory - this will not be the also free any bespoke C<params>-connected memory - this will not be the
case if called before doing another C<redodims>. case if called before doing another C<redodims>.
Again, functions built with L<PDL::PP> make sure that Again, functions built with L<PDL::PP> make sure that
freeing via these callbacks happens at the right times. freeing via these callbacks happens at the right times.
=head2 Signatures: threading over elementary operations =head2 Signatures: broadcasting over elementary operations
Most of that functionality of PDL threading (automatic iteration Most of that functionality of PDL broadcasting (automatic iteration
of elementary operations over multi-dim ndarrays) is implemented in the of elementary operations over multi-dim ndarrays) is implemented in the
file F<pdlthread.c>. file F<pdlbroadcast.c>.
The L<PDL::PP> generated functions (in particular the The L<PDL::PP> generated functions (in particular the
C<readdata> and C<writebackdata> callbacks) use this infrastructure to C<readdata> and C<writebackdata> callbacks) use this infrastructure to
make sure that the fundamental operation implemented by the make sure that the fundamental operation implemented by the
trans is performed in agreement with PDL's threading semantics. trans is performed in agreement with PDL's broadcasting semantics.
=head2 Defining new PDL functions -- Glue code generation =head2 Defining new PDL functions -- Glue code generation
Please, see L<PDL::PP> and examples in the PDL distribution. Implementation Please, see L<PDL::PP> and examples in the PDL distribution. Implementation
and syntax are currently far from perfect but it does a good job! and syntax are currently far from perfect but it does a good job!
=head2 The Core struct =head2 The Core struct
As discussed in L<PDL::API>, PDL uses a pointer to a structure As discussed in L<PDL::API>, PDL uses a pointer to a structure
to allow PDL modules access to its core routines. The definition of this to allow PDL modules access to its core routines. The definition of this
 End of changes. 9 change blocks. 
12 lines changed or deleted 11 lines changed or added

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