00001
00002
00003
00004 #ifndef STACK_SCI
00005 #define STACK_SCI
00006
00007 #include <string.h>
00008
00009 #if ( !(defined __MATH__) || (defined __APPLE__) || (defined aix) )
00010 #include "core_math.h"
00011 #else
00012 #include "machine.h"
00013 #endif
00014
00015 #include "stack-def.h"
00016
00017
00018
00019
00020
00021
00022 typedef enum {
00023 sci_matrix= 1 ,
00024 sci_poly= 2 ,
00025 sci_boolean= 4 ,
00026 sci_sparse= 5 ,
00027 sci_boolean_sparse= 6,
00028 sci_ints= 8,
00029 sci_handles=9,
00030 sci_strings= 10,
00031 sci_u_function= 11,
00032 sci_c_function= 13 ,
00033 sci_lib= 14,
00034 sci_list= 15,
00035 sci_tlist= 16,
00036 sci_mlist= 17
00037 } sci_types;
00038
00039
00043 typedef struct scisparse {
00044 integer m;
00045 integer n;
00046 integer it;
00047 integer nel;
00048 integer *mnel;
00049 integer *icol;
00050 double *R;
00051 double *I ;
00052 } SciSparse ;
00053
00054
00055
00056
00057
00058
00059
00060 #define I_CHAR 1
00061 #define I_INT16 2
00062 #define I_INT32 4
00063 #define I_UCHAR 11
00064 #define I_UINT16 12
00065 #define I_UINT32 14
00066
00067
00068
00069 #define IC_CHAR(x) ((char *) (x))
00070 #define IC_INT16(x) ((short int *) (x))
00071 #define IC_INT32(x) ((int *) (x))
00072 #define IC_UCHAR(x) ((unsigned char *) (x))
00073 #define IC_UINT16(x) ((unsigned short int *) (x))
00074 #define IC_UINT32(x) ((unsigned int *) (x))
00075
00079 typedef struct sciintmat {
00080 integer m,n;
00081 integer it ;
00082 integer l;
00083 void *D;
00084 } SciIntMat ;
00085
00086
00087 #include "stack1.h"
00088 #include "stack2.h"
00089 #include "stack3.h"
00090
00091
00092
00093
00094
00095
00096 static int c1_local=0;
00097 static int c_local=0;
00098
00099 static void initial_c1_local(void);
00100 static void initial_c_local(void);
00101
00102
00103
00104 static void initial_c_local()
00105 {
00106 initial_c1_local();
00107 c_local=0;
00108 }
00109
00110
00111 static void initial_c1_local()
00112 {
00113 initial_c_local();
00114 c1_local=0;
00115 }
00116
00117
00118 #define TRUE_ 1
00119 #define FALSE_ 0
00120
00121 #define iadr(l) ((l)+(l)-1)
00122 #define sadr(l) (((l)/2)+1)
00123 #define cadr(l) ((l)+(l)+(l)+(l)-3)
00124
00125 #define Top C2F(vstk).top
00126 #define Fin C2F(com).fin
00127 #define Rhs C2F(com).rhs
00128 #define Lhs C2F(com).lhs
00129 #define Bot C2F(vstk).bot
00130 #define Err C2F(iop).err
00131 #define Leps_sci *stk(C2F(vstk).leps)
00132
00133 #define stk(x) ( C2F(stack).Stk + x-1 )
00134 #define istk(x) (((int *) C2F(stack).Stk) + x-1 )
00135 #define sstk(x) (((float *) C2F(stack).Stk) + x-1 )
00136 #define cstk(x) (((char *) C2F(stack).Stk) + x-1 )
00137 typedef struct { double r, i; } doublecomplex;
00138 #define zstk(x) (((doublecomplex *) C2F(stack).Stk) + x-1 )
00139
00140
00141 #define Lstk(x) (((integer *) C2F(vstk).lstk) + x-1 )
00142 #define Infstk(x) (((integer *) C2F(vstk).infstk) + x-1 )
00143
00144
00145 #ifdef _MSC_VER
00146 #define hstk(x) (((long long *) C2F(stack).Stk) + x-1 )
00147 #else
00148 #define hstk(x) (((long long *) C2F(stack).Stk) + x-1 )
00149 #endif
00150
00151
00152 #ifndef FTable_H
00153 extern void * GetFuncPtr __PARAMS((char *,int,void *,void (*f)(),int *,int*,int*));
00154 #endif
00155 #define CheckOpt(first) if ( C2F(checkopt)(first) ) {return 0;}
00156
00157 #define FirstOpt() C2F(firstopt)()
00158
00159 #define FindOpt(str,opts) C2F(findopt)(str,opts)
00160
00161 #define NumOpt() C2F(numopt)()
00162
00163 #define IsOpt(k,name) C2F(isopt)((c_local=k,&c_local),name,nlgh)
00164
00165 #define Maxvol(n,ct) C2F(maxvol)((c_local=n,&c_local),ct,1L)
00166
00167 #define CreateVarFromPtr(n,ct,mx,nx,lx) if ( ! C2F(createvarfromptr)((c_local=n,&c_local),ct,mx,nx,(double *)lx,1L)) \
00168 { return 0;}
00169
00170 #define CreateCVarFromPtr(n,ct,it,mx,nx,lrx,lcx) if ( ! C2F(createcvarfromptr)((c_local=n,&c_local),ct,it,mx,nx,(double *)lrx,(double *) lcx,1L)) \
00171 { return 0;}
00172 #define CreateRefFromName(n,nx) if(! C2F(createreffromname)(n,nx)){return 0;}
00173
00174 #define CreateRef(num, point) if(! C2F(createreference)(num,point)){return 0;}
00175
00176 #define ChangeToRef(num, point) C2F(changetoref)(num,point)
00177
00178 #define FreePtr(lx) C2F(freeptr)((double **) lx)
00179
00180 #define GetType(n) C2F(gettype)((c_local = n +Top - Rhs, &c_local))
00181
00182 #define VarType(n) C2F(vartype)((c_local=n,&c_local))
00183 #define ElementType(n,m) C2F(elementtype)((c_local=n,&c_local),(c1_local=m,&c1_local))
00184
00185 #define OverLoad(n) C2F(overload)((c_local = n +Top - Rhs, &c_local),fname,strlen(fname))
00186
00187 #define GetRhsVar(n,ct,mx,nx,lx) if (! C2F(getrhsvar)((c_local=n,&c_local),ct,mx,nx,(integer *) lx,1L))\
00188 { return 0; }
00189
00190 #define CreateVar(n,ct,mx,nx,lx) if(! C2F(createvar)((c_local=n,&c_local),ct,mx,nx,(void *)lx, 1L))\
00191 { return 0; }
00192
00193 #define CreateWork(n,mx,lx) if(! C2F(creatework)((c_local=n,&c_local),mx,(void *)lx))\
00194 { return 0; }
00195
00196 #define SetWorkSize(n,mx) if(! C2F(setworksize)((c_local=n,&c_local),mx))\
00197 { return 0; }
00198
00199 #define CreateData(n,nx) if(! C2F(createdata)((c_local=n,&c_local),nx))\
00200 { return 0; }
00201
00202 #define GetRhsCVar(n,ct,it,mx,nx,lrx,lcx) if (! C2F(getrhscvar)((c_local=n,&c_local),ct,it,mx,nx,lrx,lcx,1L))\
00203 { return 0; }
00204
00205 #define CreateCVar(n,ct,it,mx,nx,lrx,lcx) if(! C2F(createcvar)((c_local=n,&c_local),ct,it,mx,nx,lrx,lcx, 1L))\
00206 { return 0; }
00207
00208 #define Error(x) C2F(error)((c_local=x,&c_local))
00209
00210 #define Errorinfo(routinename,info) C2F(errorinfo)(routinename,(c_local=info, &c_local), strlen(routinename));
00211
00212 #define PutLhsVar() if (! C2F(putlhsvar)()) { return 0; }
00213
00214 #define ReadMatrix(ct,mx,nx,w) if (! C2F(creadmat)(ct,mx,nx,w,(unsigned long)strlen(ct) )) { return 0; }
00215
00216 #define WriteMatrix(ct,mx,nx,w) if (! C2F(cwritemat)(ct,mx,nx,w,strlen(ct) )) { return 0; }
00217
00218 #define PutVar(num, nam) if (! C2F(putvar)( (c_local=num, &c_local), nam, strlen(nam) )) { return 0; }
00219
00220 #define ReadString(ct,mx,w) if (! C2F(creadchain)(ct,mx,w,strlen(ct),strlen(w) )) { return 0; }
00221
00222 #define WriteString(ct,mx,w) if (! C2F(cwritechain)(ct,mx,w,strlen(ct),strlen(w) )) { return 0; }
00223
00224 #define GetMatrixptr(ct,mx,nx,lx) if (! C2F(cmatptr)(ct,mx,nx,lx,(unsigned long)strlen(ct) )) { return 0; }
00225
00226 #define GetMatrixdims(n,mx,nx) if (! C2F(getmatdims)((c_local=n,&c_local),mx,nx)) { return 0; }
00227
00228 #define CreateVarFrom(n,ct,mx,nx,lx,lx1) if (!C2F(createvarfrom)((c_local=n,&c_local),ct,mx,nx,lx,lx1,1L)) { return 0;}
00229 #define CreateCVarFrom(n,ct,it,mx,nx,lx,lc,lx1,lc1) if (!C2F(createcvarfrom)((c_local=n,&c_local),ct,it,mx,nx,lx,lc,lx1,lc1,1L)) { return 0;}
00230
00231 #define Createlist(m,n) C2F(createlist)((c_local=m,&c_local),(c1_local=n,&c1_local))
00232
00233 #define CreateListVarFrom(n,m,ct,mx,nx,lx,lx1) if (!C2F(createlistvarfrom)((c_local=n,&c_local),(c1_local=m,&c1_local),ct,mx,nx,(void *)lx,(void *) lx1,1L)) { return 0;}
00234
00235 #define CreateListCVarFrom(n,m,ct,it,mx,nx,lx,lc,lx1,lc1) if (!C2F(createlistcvarfrom)((c_local=n,&c_local),(c1_local=m,&c1_local),ct,it,mx,nx,(void *)lx,(void *) lc,(void *) lx1,(void *)lc1,1L)) { return 0;}
00236
00237 #define CreateListVarFromPtr(n,m,ct,mx,nx,lx1) if (!C2F(createlistvarfromptr)((c_local=n,&c_local),(c1_local=m,&c1_local),ct,mx,nx,(void *) lx1,1L)) { return 0;}
00238
00239 #define CreateListCVarFromPtr(n,m,ct,it,mx,nx,lx1,lc1) if (!C2F(createlistcvarfromptr)((c_local=n,&c_local),(c1_local=m,&c1_local),ct,it,mx,nx,(void *) lx1,(void *) lc1,1L)) { return 0;}
00240
00241
00242
00243 #define GetListRhsVar(n,m,ct,m1e1,n1e1,l1e1) if(!C2F(getlistrhsvar)((c_local=n,&c_local),(c1_local=m,&c1_local),ct,m1e1,n1e1,(integer *) l1e1,1L)) {return 0;}
00244
00245 #define GetListRhsCVar(n,m,ct,it,m1e1,n1e1,l1e1,l1e2) if(!C2F(getlistrhscvar)((c_local=n,&c_local),(c1_local=m,&c1_local),ct,it,m1e1,n1e1,(integer *) l1e1,(integer *) l1e2,1L)) {return 0;}
00246
00247 #ifdef _MSC_VER
00248 #define CheckRhs(minrhs,maxrhs) \
00249 if (! C2F(checkrhs)(fname,(c_local = minrhs,&c_local),(c1_local=maxrhs,&c1_local),\
00250 (unsigned long)strlen(fname))) { \
00251 return 0;\
00252 }
00253
00254 #define CheckLhs(minlhs,maxlhs) \
00255 if (! C2F(checklhs)(fname,(c_local = minlhs,&c_local),(c1_local=maxlhs,&c1_local),\
00256 (unsigned long)strlen(fname))) { \
00257 return 0;\
00258 }
00259 #else
00260 #define CheckRhs(minrhs,maxrhs) \
00261 if (! C2F(checkrhs)(fname,(c_local = minrhs,&c_local),(c1_local=maxrhs,&c1_local),\
00262 strlen(fname))) { \
00263 return 0;\
00264 }
00265
00266 #define CheckLhs(minlhs,maxlhs) \
00267 if (! C2F(checklhs)(fname,(c_local = minlhs,&c_local),(c1_local=maxlhs,&c1_local),\
00268 strlen(fname))) { \
00269 return 0;\
00270 }
00271
00272 #endif
00273
00276 #define Convert2Sci(x) C2F(convert2sci)((c_local=x,&c_local))
00277
00278
00281 #define SciString(ibegin,name,mlhs,mrhs) \
00282 if( ! C2F(scistring)(ibegin,name,mlhs,mrhs,(unsigned long)strlen(name))) return 0;
00283
00286 #define SciFunction(ibegin,lf,mlhs,mrhs) \
00287 if( ! C2F(scifunction)(ibegin,lf,mlhs,mrhs)) return 0;
00288
00291 #define PExecSciFunction(n,mx,nx,lx,name,fsqpenv) \
00292 if(! C2F(scifunction)((c_local=n,&c_local),mx,nx,lx))\
00293 { sciprint("Error in function %s\r\n",name); longjmp(fsqpenv,-1); }
00294
00295 #define Nbvars C2F(intersci).nbvars
00296
00297 #define LhsVar(x) C2F(intersci).lhsvar[x-1]
00298
00299
00300
00301
00302
00303
00304 #define VarPtr(x) C2F(intersci).lad[x-1]
00305
00306 typedef int (*interfun) __PARAMS((char *fname,unsigned long l));
00307
00308 typedef struct tagTabF {
00309 interfun f;
00310 char *name;
00311 } TabF;
00312
00313
00314
00315
00316
00317
00318 #define CheckSquare(pos,m,n) if (! check_square(pos,m,n)) return 0;
00319 #define CheckVector(pos,m,n) if (! check_vector(pos,m,n)) return 0;
00320 #define CheckRow(pos,m,n) if (! check_row(pos,m,n)) return 0;
00321 #define CheckColumn(pos,m,n) if (! check_col(pos,m,n)) return 0;
00322 #define CheckScalar(pos,m,n) if (! check_scalar(pos,m,n)) return 0;
00323 #define CheckDims(pos,m,n,m1,n1) if (! check_dims(pos,m,n,m1,n1)) return 0;
00324 #define CheckLength(pos,m,m1) if (! check_length(pos,m,m1)) return 0;
00325 #define CheckSameDims(pos,pos1,m,n,m1,n1) if (! check_same_dims(pos,pos1,m,n,m1,n1)) return 0;
00326 #define CheckDimProp(pos,pos1,m) if (! check_dim_prop(pos,pos1,m)) return 0;
00327 #define CheckOneDim(pos,dim,val,valref) if (! check_one_dim(pos,dim,val,valref)) return 0;
00328
00329 #define CheckListSquare(lpos,pos,m,n) if (! check_list_square(lpos,pos,m,n)) return 0;
00330 #define CheckListVector(lpos,pos,m,n) if (! check_list_vector(lpos,pos,m,n)) return 0;
00331 #define CheckListRow(lpos,pos,m,n) if (! check_list_row(lpos,pos,m,n)) return 0;
00332 #define CheckListColumn(lpos,pos,m,n) if (! check_list_column(lpos,pos,m,n)) return 0;
00333 #define CheckListScalar(lpos,pos,m,n) if (! check_list_scalar(lpos,pos,m,n)) return 0;
00334 #define CheckListOneDim(lpos,pos,dim,val,valref) if (! check_list_one_dim(lpos,pos,dim,val,valref)) return 0;
00335
00336
00337
00338
00339
00340 typedef struct rhs_opts__ {
00341 int position ;
00342 char *name ;
00343 char *type;
00344 int m,n;
00345 unsigned long int l;
00346 } rhs_opts;
00347
00348 int get_optionals __PARAMS((char *name,rhs_opts opts[]));
00349
00350
00351
00352
00353
00354 extern int C2F(error) __PARAMS((int *));
00355
00356 extern int C2F(firstopt) __PARAMS((void));
00357 extern int C2F(findopt) __PARAMS((char *, rhs_opts *));
00358
00359 extern int C2F(numopt) __PARAMS((void));
00360 extern int C2F(isopt) __PARAMS((integer *,char *,unsigned long));
00361 extern int C2F(gettype) __PARAMS((integer *pos));
00362
00363 extern int C2F(checkrhs) __PARAMS((char *fname, integer *imin, integer *imax, unsigned long fname_len));
00364 extern int C2F(checklhs) __PARAMS((char *fname, integer *imin, integer *imax, unsigned long fname_len));
00365
00366 extern void C2F(freeptr) __PARAMS((double *ip[]));
00367
00368 #endif
00369
00370