~ubuntu-branches/ubuntu/lucid/pdl/lucid

« back to all changes in this revision

Viewing changes to Basic/Core/pdlcore.h.PL

  • Committer: Bazaar Package Importer
  • Author(s): Ben Gertzfield
  • Date: 2002-04-08 18:47:16 UTC
  • Revision ID: james.westby@ubuntu.com-20020408184716-0hf64dc96kin3htp
Tags: upstream-2.3.2
ImportĀ upstreamĀ versionĀ 2.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*-perl-*-
 
2
 
 
3
use strict;
 
4
use Config;
 
5
use File::Basename qw(&basename &dirname);
 
6
 
 
7
# version 2 is for versions after PDL 2.1.1
 
8
use vars qw( $pdl_core_version );
 
9
$pdl_core_version = 3;  
 
10
 
 
11
# List explicitly here the variables you want Configure to
 
12
# generate.  Metaconfig only looks for shell variables, so you
 
13
# have to mention them as if they were shell variables, not
 
14
# %Config entries.  Thus you write
 
15
#  $startperl
 
16
# to ensure Configure will look for $Config{startperl}.
 
17
 
 
18
# This forces PL files to create target in same directory as PL file.
 
19
# This is so that make depend always knows where to find PL derivatives.
 
20
chdir(dirname($0));
 
21
my $file;
 
22
($file = basename($0)) =~ s/\.PL$//;
 
23
$file =~ s/\.pl$//
 
24
        if ($Config{'osname'} eq 'VMS' or
 
25
            $Config{'osname'} eq 'OS2');  # "case-forgiving"
 
26
 
 
27
print "Extracting $file\n";
 
28
open OUT,">$file" or die "Can't create $file: $!";
 
29
chmod 0644, $file;
 
30
 
 
31
# In this section, perl variables will be expanded during extraction.
 
32
# You can use $Config{...} to use Configure variables.
 
33
 
 
34
 
 
35
print OUT <<'!NO!SUBS!';
 
36
/*
 
37
 * THIS FILE IS GENERATED FROM pdlcore.h.PL! Do NOT edit!
 
38
 */
 
39
 
 
40
#include "EXTERN.h"   /* std perl include */
 
41
#include "perl.h"     /* std perl include */
 
42
#include "ppport.h"
 
43
#include "XSUB.h"  /* for the win32 perlCAPI crap */
 
44
 
 
45
#if defined(CONTEXT) && defined(__osf__)
 
46
#undef CONTEXT
 
47
#endif
 
48
 
 
49
#include "pdl.h"
 
50
#include "pdlthread.h"
 
51
/* the next one causes trouble in c++ compiles - exclude for now */
 
52
#ifndef __cplusplus
 
53
#include "pdlmagic.h"
 
54
#endif
 
55
 
 
56
!NO!SUBS!
 
57
 
 
58
    print OUT "#define PDL_CORE_VERSION $pdl_core_version\n";
 
59
 
 
60
print OUT <<'!NO!SUBS!' if ($^O =~ /MSWin/);
 
61
 
 
62
#define finite _finite
 
63
#include <float.h>
 
64
 
 
65
!NO!SUBS!
 
66
 
 
67
print OUT <<'!NO!SUBS!';
 
68
 
 
69
#define PDL_TMP  0        /* Flags */
 
70
#define PDL_PERM 1
 
71
 
 
72
#define BIGGESTOF(a,b) ( a->nvals>b->nvals ? a->nvals : b->nvals )
 
73
 
 
74
/* for the moment we go back to the original croak
 
75
 * since there seem to be quite a few problems with maintaining
 
76
 * our own barf version
 
77
 */
 
78
 
 
79
#define barf croak
 
80
 
 
81
typedef int Logical;
 
82
 
 
83
/*************** Function prototypes *********************/
 
84
 
 
85
 
 
86
/* pdlcore.c */
 
87
 
 
88
int     pdl_howbig (int datatype);           /* Size of data type (bytes) */
 
89
pdl*    SvPDLV ( SV* sv );                   /* Map SV* to pdl struct */
 
90
void    SetSV_PDL( SV *sv, pdl *it );        /* Outputting a pdl from.. */
 
91
SV*     pdl_copy( pdl* a, char* option );     /* call copy method */
 
92
PDL_Long *    pdl_packdims ( SV* sv, int*ndims ); /* Pack dims[] into SV aref */
 
93
void    pdl_unpackdims ( SV* sv, PDL_Long *dims,  /* Unpack */
 
94
                         int ndims );
 
95
void*   pdl_malloc ( int nbytes );           /* malloc memory - auto free()*/
 
96
 
 
97
void pdl_makescratchhash(pdl *ret,double data, int datatype);
 
98
PDL_Long pdl_safe_indterm(PDL_Long dsz, PDL_Long at, char *file, int lineno);
 
99
void pdl_barf(const char* pat,...); /* General croaking utility */
 
100
 
 
101
/* pdlapi.c */
 
102
 
 
103
void pdl_vaffinechanged(pdl *it, int what);
 
104
void pdl_trans_mallocfreeproc(struct pdl_trans *tr);
 
105
void pdl_make_trans_mutual(pdl_trans *trans);
 
106
void pdl_destroytransform_nonmutual(pdl_trans *trans,int ensure);
 
107
 
 
108
void pdl_vafftrans_free(pdl *it);
 
109
void pdl_vafftrans_remove(pdl * it);
 
110
void pdl_make_physvaffine(pdl *it);
 
111
void pdl_vafftrans_alloc(pdl *it);
 
112
 
 
113
pdl *pdl_null();
 
114
pdl *pdl_get_convertedpdl(pdl *pdl,int type);
 
115
 
 
116
void pdl_destroytransform(pdl_trans *trans,int ensure);
 
117
pdl *pdl_make_now(pdl *it);
 
118
 
 
119
pdl *pdl_hard_copy(pdl *src);
 
120
 
 
121
#define pdl_new() pdl_create(PDL_PERM)
 
122
#define pdl_tmp() pdl_create(PDL_TMP)
 
123
pdl* pdl_external_new();
 
124
pdl* pdl_external_tmp();
 
125
pdl* pdl_create(int type);
 
126
void pdl_destroy(pdl *it);
 
127
void pdl_setdims(pdl* it, PDL_Long* dims, int ndims);
 
128
void pdl_reallocdims ( pdl *it,int ndims );  /* reallocate dims and incs */
 
129
void pdl_reallocthreadids ( pdl *it,int ndims );  /* reallocate threadids */
 
130
void pdl_resize_defaultincs ( pdl *it );     /* Make incs out of dims */
 
131
void pdl_unpackarray ( HV* hash, char *key, int *dims, int ndims );
 
132
void pdl_print(pdl *it);
 
133
void pdl_dump(pdl *it);
 
134
void pdl_allocdata(pdl *it);
 
135
 
 
136
int *pdl_get_threadoffsp(pdl_thread *thread); /* For pthreading */
 
137
void pdl_thread_copy(pdl_thread *from,pdl_thread *to);
 
138
void pdl_clearthreadstruct(pdl_thread *it);
 
139
void pdl_initthreadstruct(int nobl,pdl **pdls,int *realdims,int *creating,int npdls,
 
140
        pdl_errorinfo *info,pdl_thread *thread,char *flags);
 
141
int pdl_startthreadloop(pdl_thread *thread,void (*func)(pdl_trans *),pdl_trans *);
 
142
int pdl_iterthreadloop(pdl_thread *thread,int which);
 
143
void pdl_freethreadloop(pdl_thread *thread);
 
144
void pdl_thread_create_parameter(pdl_thread *thread,int j,int *dims,
 
145
                                 int temp);
 
146
void pdl_croak_param(pdl_errorinfo *info,int j, char *pat, ...);
 
147
 
 
148
void pdl_setdims_careful(pdl *pdl);
 
149
void pdl_put_offs(pdl *pdl,PDL_Long offs, double val);
 
150
double pdl_get_offs(pdl *pdl,PDL_Long offs);
 
151
double pdl_get(pdl *pdl,int *inds);
 
152
void pdl_set_trans(pdl *it, pdl *parent, pdl_transvtable *vtable);
 
153
 
 
154
void pdl_make_physical(pdl *it);
 
155
void pdl_make_physdims(pdl *it);
 
156
 
 
157
void pdl_children_changesoon(pdl *it, int what);
 
158
void pdl_changed(pdl *it, int what, int recursing);
 
159
void pdl_separatefromparent(pdl *it);
 
160
 
 
161
void pdl_trans_changesoon(pdl_trans *trans,int what);
 
162
void pdl_trans_changed(pdl_trans *trans,int what);
 
163
 
 
164
void pdl_set_trans_childtrans(pdl *it, pdl_trans *trans,int nth);
 
165
void pdl_set_trans_parenttrans(pdl *it, pdl_trans *trans,int nth);
 
166
 
 
167
/* pdlhash.c */
 
168
 
 
169
pdl*    pdl_getcache( HV* hash );       /* Retrieve address of $$x{PDL} */
 
170
pdl*    pdl_fillcache( HV* hash, SV* ref);       /* Fill/create $$x{PDL} cache */
 
171
void    pdl_fillcache_partial( HV *hash, pdl *thepdl ) ;
 
172
SV*     pdl_getKey( HV* hash, char* key );  /* Get $$x{Key} SV* with deref */
 
173
void pdl_flushcache( pdl *thepdl );          /* flush cache */
 
174
 
 
175
/* pdlfamily.c */
 
176
 
 
177
void pdl_family_create(pdl *from,pdl_trans *trans,int ind1,int ind2);
 
178
pdl *pdl_family_clone2now(pdl *from); /* Use pdl_make_now instead */
 
179
 
 
180
 
 
181
/* pdlconv.c */
 
182
 
 
183
void pdl_writebackdata_vaffine(pdl *it);
 
184
void pdl_readdata_vaffine(pdl *it);
 
185
 
 
186
void   pdl_swap(pdl** a, pdl** b);             /* Swap two pdl ptrs */
 
187
void   pdl_converttype( pdl** a, int targtype, /* Change type of a pdl */
 
188
                        Logical changePerl );
 
189
void   pdl_coercetypes( pdl** a, pdl **b, Logical changePerl ); /* Two types to same */
 
190
void   pdl_grow  ( pdl* a, int newsize);      /* Change pdl 'Data' size */
 
191
void   pdl_retype( pdl* a, int newtype);      /* Change pdl 'Datatype' value */
 
192
void** pdl_twod( pdl* x );                    /* Return 2D pointer to data array */
 
193
 
 
194
/* pdlsections.c */
 
195
 
 
196
int  pdl_get_offset(PDL_Long* pos, PDL_Long* dims, PDL_Long *incs, PDL_Long offset, int ndims);      /* Offset of pixel x,y,z... */
 
197
int  pdl_validate_section( int* sec, int* dims,           /* Check section */
 
198
                           int ndims );
 
199
void pdl_row_plusplus ( int* pos, int* dims,              /* Move down one row */
 
200
                        int ndims );
 
201
void pdl_subsection( char *y, char*x, int datatype,      /* Take subsection */
 
202
                 int* sec, int* dims, int *incs, int offset, int* ndims);
 
203
void pdl_insertin( char*y, int* ydims, int nydims,        /* Insert pdl in pdl */
 
204
                   char*x, int* xdims, int nxdims,
 
205
                   int datatype, int* pos);
 
206
double pdl_at( void* x, int datatype, PDL_Long* pos, PDL_Long* dims, /* Value at x,y,z,... */
 
207
             PDL_Long *incs, PDL_Long offset, int ndims);
 
208
void  pdl_set( void* x, int datatype, PDL_Long* pos, PDL_Long* dims, /* Set value at x,y,z... */
 
209
                PDL_Long *incs, PDL_Long offs, int ndims, double value);
 
210
void pdl_axisvals( pdl* a, int axis );               /* Fill with axis values */
 
211
 
 
212
/* Structure to hold pointers core PDL routines so as to be used by many modules */
 
213
 
 
214
struct Core {
 
215
    I32    Version;
 
216
    pdl*   (*SvPDLV)      ( SV*  );
 
217
    void   (*SetSV_PDL)   ( SV *sv, pdl *it );
 
218
#if defined(PDL_clean_namespace) || defined(PDL_OLD_API)
 
219
    pdl*   (*new)      ( );     /* make it work with gimp-perl */
 
220
#else
 
221
    pdl*   (*pdlnew)      ( );  /* renamed because of C++ clash */
 
222
#endif
 
223
    pdl*   (*tmp)         ( );
 
224
    pdl*   (*create)      (int type);
 
225
    void   (*destroy)     (pdl *it);
 
226
    pdl*   (*null)        ();
 
227
    SV*    (*copy)        ( pdl*, char* );
 
228
    void   (*converttype) ( pdl**, int, Logical );
 
229
    void** (*twod)        ( pdl* );
 
230
    void*  (*smalloc)      ( int );
 
231
    int    (*howbig)      ( int );
 
232
    PDL_Long*   (*packdims)    ( SV* sv, int *ndims ); /* Pack dims[] into SV aref */
 
233
    void   (*setdims)     ( pdl* it, PDL_Long* dims, int ndims );
 
234
    void   (*unpackdims)  ( SV* sv, PDL_Long *dims,    /* Unpack */
 
235
                            int ndims );
 
236
    void   (*grow)        ( pdl* a, int newsize); /* Change pdl 'Data' size */
 
237
    void (*flushcache)( pdl *thepdl );       /* flush cache */
 
238
    void (*reallocdims) ( pdl *it,int ndims );  /* reallocate dims and incs */
 
239
    void (*reallocthreadids) ( pdl *it,int ndims );
 
240
    void (*resize_defaultincs) ( pdl *it );     /* Make incs out of dims */
 
241
 
 
242
void (*thread_copy)(pdl_thread *from,pdl_thread *to);
 
243
void (*clearthreadstruct)(pdl_thread *it);
 
244
void (*initthreadstruct)(int nobl,pdl **pdls,int *realdims,int *creating,int npdls,
 
245
        pdl_errorinfo *info,pdl_thread *thread,char *flags);
 
246
int (*startthreadloop)(pdl_thread *thread,void (*func)(pdl_trans *),pdl_trans *);
 
247
int *(*get_threadoffsp)(pdl_thread *thread); /* For pthreading */
 
248
int (*iterthreadloop)(pdl_thread *thread,int which);
 
249
void (*freethreadloop)(pdl_thread *thread);
 
250
void (*thread_create_parameter)(pdl_thread *thread,int j,int *dims,
 
251
                                int temp);
 
252
void (*add_deletedata_magic) (pdl *it,void (*func)(pdl *, int param), int param); /* Automagic destructor */
 
253
 
 
254
/* XXX NOT YET IMPLEMENTED */
 
255
void (*setdims_careful)(pdl *pdl);
 
256
void (*put_offs)(pdl *pdl,PDL_Long offs, double val);
 
257
double (*get_offs)(pdl *pdl,PDL_Long offs);
 
258
double (*get)(pdl *pdl,int *inds);
 
259
void (*set_trans_childtrans)(pdl *it, pdl_trans *trans,int nth);
 
260
void (*set_trans_parenttrans)(pdl *it, pdl_trans *trans,int nth);
 
261
pdl *(*make_now)(pdl *it);
 
262
 
 
263
pdl *(*get_convertedpdl)(pdl *pdl,int type);
 
264
 
 
265
void (*make_trans_mutual)(pdl_trans *trans);
 
266
 
 
267
/* Affine trans. THESE ARE SET IN ONE OF THE OTHER Basic MODULES
 
268
   and not in Core.xs ! */
 
269
void (*readdata_affine)(pdl_trans *tr);
 
270
void (*writebackdata_affine)(pdl_trans *tr);
 
271
void (*affine_new)(pdl *par,pdl *child,int offs,SV *dims,SV *incs);
 
272
 
 
273
/* Converttype. Similar */
 
274
void (*converttypei_new)(pdl *par,pdl *child,int type);
 
275
 
 
276
void (*trans_mallocfreeproc)(struct pdl_trans *tr);
 
277
 
 
278
void (*make_physical)(pdl *it);
 
279
void (*make_physdims)(pdl *it);
 
280
void (*pdl_barf) (const char* pat,...); /* Not plain 'barf' as this
 
281
                                  is a macro - KGB */
 
282
void (*make_physvaffine)(pdl *it);
 
283
void (*allocdata) (pdl *it);
 
284
  PDL_Long (*safe_indterm)(PDL_Long dsz, PDL_Long at, char *file, int lineno);
 
285
 
 
286
!NO!SUBS!
 
287
 
 
288
# set up the qsort routines
 
289
 
 
290
    # fortunately it looks like Types.pm.PL is processed before this
 
291
    # file
 
292
    require "Types.pm";  # ie PDL::Types
 
293
 
 
294
for (keys %PDL::Types::typehash) {
 
295
   my $ctype = $PDL::Types::typehash{$_}{ctype};
 
296
   my $ppsym = $PDL::Types::typehash{$_}{ppsym};
 
297
 
 
298
   print OUT "void (*qsort_${ppsym}) (${ctype} *xx, int a, int b );\n";
 
299
   print OUT "void (*qsort_ind_${ppsym}) (${ctype} *xx, int *ix, int a, int b );\n";
 
300
}
 
301
 
 
302
# storage space for bad values
 
303
 
 
304
print OUT <<'!NO!SUBS!';
 
305
 
 
306
  badvals bvals;  /* store the default bad values */
 
307
  void (*propogate_badflag) (pdl *it, int newval );  /* defined in bad.pd */
 
308
 
 
309
};
 
310
 
 
311
typedef struct Core Core;
 
312
 
 
313
Core *pdl__Core_get_Core(); /* INTERNAL TO CORE! DON'T CALL FROM OUTSIDE */
 
314
 
 
315
!NO!SUBS!
 
316