2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 1998-2000 - ENPC - Jean-Philippe CHANCELIER
4 * Copyright (C) 1998-2008 - INRIA - Allan CORNET
5 * Copyright (C) 1998-2008 - INRIA - Serge STEER
6 * Copyright (C) 1998-2008 - INRIA - Sylvestre LEDRU
7 * Copyright (C) 1998-2008 - INRIA - Bruno JOFRET
8 * Copyright (C) 2011 - DIGITEO - Allan CORNET
10 * This file must be used under the terms of the CeCILL.
11 * This source file is licensed as described in the file COPYING, which
12 * you should have received as part of this distribution. The terms
13 * are also available at
14 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
16 * Please note that piece of code will be rewrited for the Scilab 6 family
18 /*------------------------------------------------------------------------
19 * Scilab Memory Management library (Stack API)
20 --------------------------------------------------------------------------*/
22 /*---------------------------------------------------------------------
23 * Interface Library: ilib
24 *---------------------------------------------------------------------*/
30 #include "strdup_windows.h"
39 #include "men_Sutils.h"
43 #include "localization.h"
44 #include "callinterf.h"
45 #include "call_scilab.h"
46 #include "recursionFunction.h"
47 #include "doublecomplex.h"
51 #define abs(x) ((x) >= 0 ? (x) : -(x)) /* pour abs C2F(mvfromto) line 2689 */
54 /* Table of constant values */
58 static char *Get_Iname(void);
59 static int C2F(mvfromto) (int *itopl, int *);
61 static int rhs_opt_find(char *name, rhs_opts opts[]);
62 static void rhs_opt_print_names(rhs_opts opts[]);
63 extern int C2F(isbyref) (int *fun);
65 /*------------------------------------------------*/
66 void strcpy_tws(char *str1, char *str2, int len);
67 int C2F(copyvarfromsciptr) (int lw, int n, int l);
68 static int intersci_push(void);
69 static void intersci_pop(void);
70 static int C2F(getopcode) (char *string, unsigned long string_len);
72 static void ConvertData(unsigned char *type, int size, int l);
74 /*------------------------------------------------
75 * checkrhs: checks right hand side arguments
76 *-----------------------------------------------*/
78 int C2F(checkrhs) (char *fname, int *iMin, int *iMax, unsigned long fname_len)
81 * store the name in recu array, fname can be a non null terminated char array
82 * Get_Iname() can be used in other function to get the interface name
85 C2F(cvname) (&C2F(recu).ids[(C2F(recu).pt + 1) * nsiz - nsiz], fname, &cx0, fname_len);
87 if (Rhs < *iMin || Rhs > *iMax)
91 /* No optional argument */
92 Scierror(77, _("%s: Wrong number of input argument(s): %d expected.\n"), get_fname(fname, fname_len), *iMax);
96 Scierror(77, _("%s: Wrong number of input argument(s): %d to %d expected.\n"), get_fname(fname, fname_len), *iMin, *iMax);
103 /*------------------------------------------------
104 * checkrhs: checks left hand side arguments
105 *-----------------------------------------------*/
107 int C2F(checklhs) (char *fname, int *iMin, int *iMax, unsigned long fname_len)
109 if (Lhs < *iMin || Lhs > *iMax)
113 /* No optional argument */
114 Scierror(78, _("%s: Wrong number of output argument(s): %d expected.\n"), get_fname(fname, fname_len), *iMax);
118 Scierror(78, _("%s: Wrong number of output argument(s): %d to %d expected.\n"), get_fname(fname, fname_len), *iMin, *iMax);
125 /*---------------------------------------------------------------------
127 * returns the status of the variable number k
128 * if its an optional variable f(x=...)
129 * returns .true. and variable name in namex
130 * namex must have a size of nlgh + 1
131 *---------------------------------------------------------------------*/
133 int C2F(isopt) (int *k, char *namex, unsigned long name_len)
135 int i1 = *k + Top - Rhs;
137 if (C2F(isoptlw) (&Top, &i1, namex, name_len) == FALSE)
141 /* add a '\0' at the end of the string removing trailing blanks */
142 for (i1 = nlgh - 1; i1 >= 0; i1--)
144 if (namex[i1] != ' ')
149 namex[i1 + 1] = '\0';
153 /*--------------------------------------------------------------
154 * freeptr : free ip pointer
155 *--------------------------------------------------------------*/
157 void C2F(freeptr) (double *ip[])
165 /*---------------------------------------
167 * returns the status of the variable at position lw in the stack
168 * if its an optional variable f(x=...)
169 * returns .true. and variable name in namex
170 *--------------------------------------- */
172 int C2F(isoptlw) (int *topk, int *lw, char *namex, unsigned long name_len)
174 if (*Infstk(*lw) != 1)
178 C2F(cvname) (&C2F(vstk).idstk[(*lw) * nsiz - nsiz], namex, &cx1, name_len);
182 /*---------------------------------------
184 * return the position of the first optionnal argument
185 * given as xx=val in the calling sequence.
186 * If no such argument it returns Rhs+1.
187 *--------------------------------------- */
188 int C2F(firstopt) (void)
192 for (k = 1; k <= Rhs; ++k)
193 if (*Infstk(k + Top - Rhs) == 1)
200 /*---------------------------------------
202 * checks if option str has been passed.
203 * If yes returns the position of the variable
205 *--------------------------------------- */
207 int C2F(findopt) (char *str, rhs_opts opts[])
211 i = rhs_opt_find(str, opts);
213 if (opts[i].iPos > 0)
222 /*---------------------------------------
224 * returns the number of optional variables
225 * given as xx=val in the caling sequence
226 * top must have a correct value when using this function
227 *--------------------------------------- */
229 int C2F(numopt) (void)
233 for (k = 1; k <= Rhs; ++k)
234 if (*Infstk(k + Top - Rhs) == 1)
241 /*---------------------------------------------------------------------
243 * type of variable number number in the stack
244 *---------------------------------------------------------------------*/
246 int C2F(vartype) (int *number)
248 int ix1 = *number + Top - Rhs;
250 return C2F(gettype) (&ix1);
253 /*------------------------------------------------
255 * returns the type of object at position lw in the stack
256 *------------------------------------------------*/
258 int C2F(gettype) (int *lw)
262 il = iadr(*Lstk(*lw));
265 il = iadr(*istk(il + 1));
270 /*------------------------------------------------
272 * set mechanism to overloaded function fname if object type
273 * does not fit given type
274 *------------------------------------------------*/
276 static int overloadtype(int *lw, char *fname, unsigned char *typ)
281 il = iadr(*Lstk(*lw));
284 il = iadr(*istk(il + 1));
288 case 'c': /* string */
289 case 'S': /* string Matrix */
295 case 'z': /* numeric */
298 case 'b': /* boolean */
301 case 'h': /* handle */
307 case 't': /* tlist */
310 case 'm': /* mlist */
313 case 'f': /* external */
314 ityp = sci_c_function;
316 case 'p': /* pointer */
317 ityp = sci_pointer; /* used to be sci_lufact_pointer before Scilab 5.2 */
319 case 's': /* sparse */
322 case 'I': /* int matrix */
325 case 'x': /* polynomial matrix */
330 if (*istk(il) != ityp)
332 return C2F(overload) (lw, fname, (unsigned long)strlen(fname));
337 /*------------------------------------------------
339 * set mechanism to overloaded function fname for object lw
340 *------------------------------------------------*/
342 int C2F(overload) (int *lw, char *fname, unsigned long l)
344 C2F(putfunnam) (fname, lw, l);
349 /*------------------------------------------------
351 *------------------------------------------------*/
352 int C2F(ogettype) (int *lw)
354 return *istk(iadr(*Lstk(*lw)));
357 /*----------------------------------------------------
358 * Optional arguments f(....., arg =val,...)
360 * function get_optionals : example is provided in
361 * examples/addinter-examples/intex2c.c
362 *----------------------------------------------------*/
364 int get_optionals(char *fname, rhs_opts opts[])
368 int nopt = NumOpt(); /* optional arguments on the stack */
370 /* reset first field since opts is declared static in calling function */
371 /* this could be avoided with ansi compilers by removing static in the
372 * opts declaration */
374 while (opts[i].pstName != NULL)
380 /* Walking through last arguments */
382 for (k = Rhs - nopt + 1; k <= Rhs; k++)
384 if (IsOpt(k, name) == 0)
386 Scierror(999, _("%s: Optional arguments name=val must be at the end.\n"), fname);
391 int isopt = rhs_opt_find(name, opts);
395 rhs_opts *ro = &opts[isopt];
397 if (ro->iType != '?')
399 GetRhsVar(ro->iPos, ro->iType, &ro->iRows, &ro->iCols, &ro->piAddr);
404 sciprint(_("%s: Unrecognized optional arguments %s.\n"), fname, name);
405 rhs_opt_print_names(opts);
414 /* Is name in opts */
416 int rhs_opt_find(char *name, rhs_opts opts[])
420 while (opts[i].pstName != NULL)
424 /* name is terminated by white space and we want to ignore them */
425 if ((cmp = strcmp(name, opts[i].pstName)) == 0)
442 void rhs_opt_print_names(rhs_opts opts[])
443 /* array of optinal names (in alphabetical order)
444 * the array is null terminated */
448 if (opts[i].pstName == NULL)
450 sciprint(_("Optional argument list is empty.\n"));
453 sciprint(_("Optional arguments list: \n"));
454 while (opts[i + 1].pstName != NULL)
456 sciprint("%s, ", opts[i].pstName);
459 sciprint(_("and %s.\n"), opts[i].pstName);
462 /*---------------------------------------------------------------------
464 * checks if variable number lw is on the stack
465 * or is just a reference to a variable on the stack
466 *---------------------------------------------------------------------*/
468 int IsRef(int number)
470 return C2F(isref) (&number);
473 int C2F(isref) (int *number)
477 lw = *number + Top - Rhs;
480 Scierror(999, _("%s: bad call to %s! (1rst argument).\n"), "isref", "isref");
483 il = iadr(*Lstk(lw));
494 /*---------------------------------------------------------------------
495 * create a variable number lw in the stack of type
497 * the argument must be of type type ('c','d','r','i','l','b')
498 * return values m,n,lr
499 * c : string (m-> number of characters and n->1)
500 * d,r,i : matrix of double,float or integer
502 * l : a list (m-> number of elements and n->1)
503 * for each element of the list an other function
504 * must be used to <<get>> them
505 * side effects : arguments in the common intersci are modified
506 * see examples in addinter-examples
507 *---------------------------------------------------------------------*/
509 int C2F(createvar) (int *lw, char *typex, int *m, int *n, int *lr, unsigned long type_len)
511 int ix1, ix, it = 0, lw1, lcs, IT;
512 unsigned char Type = *typex;
513 char *fname = Get_Iname();
517 Scierror(999, _("%s: (%s) too many arguments in the stack edit stack.h and enlarge intersiz.\n"), fname, "createvar");
520 Nbvars = Max(*lw, Nbvars);
521 lw1 = *lw + Top - Rhs;
524 Scierror(999, _("%s: bad call to %s! (1rst argument).\n"), fname, "createvar");
531 if (!C2F(cresmat2) (fname, &lw1, &ix1, lr, nlgh))
536 // Fill the string with spaces
537 for (ix = 0; ix < (*m) * (*n); ++ix)
539 *cstk(*lr + ix) = ' ';
541 *cstk(*lr + (*m) * (*n)) = '\0';
542 C2F(intersci).ntypes[*lw - 1] = Type;
543 C2F(intersci).iwhere[*lw - 1] = *Lstk(lw1);
544 C2F(intersci).lad[*lw - 1] = *lr;
547 if (!C2F(cremat) (fname, &lw1, &it, m, n, lr, &lcs, nlgh))
551 C2F(intersci).ntypes[*lw - 1] = Type;
552 C2F(intersci).iwhere[*lw - 1] = *Lstk(lw1);
553 C2F(intersci).lad[*lw - 1] = *lr;
557 if (!(*Lstk(lw1) % 2))
559 *Lstk(lw1) = *Lstk(lw1) + 1;
561 if (!C2F(cremat) (fname, &lw1, &IT, m, n, lr, &lcs, nlgh))
565 C2F(intersci).ntypes[*lw - 1] = Type;
566 C2F(intersci).iwhere[*lw - 1] = *Lstk(lw1);
567 C2F(intersci).lad[*lw - 1] = *lr;
571 C2F(crelist) (&lw1, m, lr);
572 C2F(intersci).ntypes[*lw - 1] = '$';
573 C2F(intersci).iwhere[*lw - 1] = *Lstk(lw1);
574 C2F(intersci).lad[*lw - 1] = *lr;
577 C2F(cretlist) (&lw1, m, lr);
578 C2F(intersci).ntypes[*lw - 1] = '$';
579 C2F(intersci).iwhere[*lw - 1] = *Lstk(lw1);
580 C2F(intersci).lad[*lw - 1] = *lr;
583 C2F(cremlist) (&lw1, m, lr);
584 C2F(intersci).ntypes[*lw - 1] = '$';
585 C2F(intersci).iwhere[*lw - 1] = *Lstk(lw1);
586 C2F(intersci).lad[*lw - 1] = *lr;
589 if (!C2F(cremat) (fname, &lw1, &it, m, n, lr, &lcs, nlgh))
594 C2F(intersci).ntypes[*lw - 1] = Type;
595 C2F(intersci).iwhere[*lw - 1] = *Lstk(lw1);
596 C2F(intersci).lad[*lw - 1] = *lr;
599 if (!C2F(cremat) (fname, &lw1, &it, m, n, lr, &lcs, nlgh))
604 C2F(intersci).ntypes[*lw - 1] = Type;
605 C2F(intersci).iwhere[*lw - 1] = *Lstk(lw1);
606 C2F(intersci).lad[*lw - 1] = *lr;
609 if (!C2F(crebmat) (fname, &lw1, m, n, lr, nlgh))
613 C2F(intersci).ntypes[*lw - 1] = Type;
614 C2F(intersci).iwhere[*lw - 1] = *Lstk(lw1);
615 C2F(intersci).lad[*lw - 1] = *lr;
618 if (!C2F(crepointer) (fname, &lw1, lr, nlgh))
622 C2F(intersci).ntypes[*lw - 1] = '$';
623 C2F(intersci).iwhere[*lw - 1] = *Lstk(lw1);
624 C2F(intersci).lad[*lw - 1] = *lr;
627 it = *lr; /* on entry lr gives the int type */
628 if (!C2F(creimat) (fname, &lw1, &it, m, n, lr, nlgh))
632 C2F(intersci).ntypes[*lw - 1] = '$';
633 C2F(intersci).iwhere[*lw - 1] = *Lstk(lw1);
634 C2F(intersci).lad[*lw - 1] = *lr;
637 if (!C2F(crehmat) (fname, &lw1, m, n, lr, nlgh))
641 C2F(intersci).ntypes[*lw - 1] = Type;
642 C2F(intersci).iwhere[*lw - 1] = *Lstk(lw1);
643 C2F(intersci).lad[*lw - 1] = *lr;
645 // TODO : add a default case
650 /*---------------------------------------------------------------------
651 * create a variable number lw in the stack of type
653 * the argument must be of type type ('d','r','i')
654 * return values m,n,lr
655 * d,r,i : matrix of double,float or integer
656 * side effects : arguments in the common intersci are modified
657 * see examples in addinter-examples
658 * Like createvar but for complex matrices
659 *---------------------------------------------------------------------*/
661 int C2F(createcvar) (int *lw, char *typex, int *it, int *m, int *n, int *lr, int *lc, unsigned long type_len)
663 unsigned char Type = *typex;
665 char *fname = Get_Iname();
669 Scierror(999, _("%s: (%s) too many arguments in the stack edit stack.h and enlarge intersiz.\n"), fname, "createcvar");
672 Nbvars = Max(*lw, Nbvars);
673 lw1 = *lw + Top - Rhs;
676 Scierror(999, _("%s: bad call to %s! (1rst argument).\n"), fname, "createcvar");
682 if (!C2F(cremat) (fname, &lw1, it, m, n, lr, lc, nlgh))
686 C2F(intersci).ntypes[*lw - 1] = Type;
687 C2F(intersci).iwhere[*lw - 1] = *Lstk(lw1);
688 C2F(intersci).lad[*lw - 1] = *lr;
691 if (!C2F(cremat) (fname, &lw1, it, m, n, lr, lc, nlgh))
697 C2F(intersci).ntypes[*lw - 1] = Type;
698 C2F(intersci).iwhere[*lw - 1] = *Lstk(lw1);
699 C2F(intersci).lad[*lw - 1] = *lr;
702 if (!C2F(cremat) (fname, &lw1, it, m, n, lr, lc, nlgh))
708 C2F(intersci).ntypes[*lw - 1] = Type;
709 C2F(intersci).iwhere[*lw - 1] = *Lstk(lw1);
710 C2F(intersci).lad[*lw - 1] = *lr;
716 /*---------------------------------------------------------------------
717 * create a variable number lw on the stack of type
718 * list with nel elements
719 *---------------------------------------------------------------------*/
721 int C2F(createlist) (int *lw, int *nel)
723 char *fname = Get_Iname();
728 Scierror(999, _("%s: (%s) too many arguments in the stack edit stack.h and enlarge intersiz.\n"), fname, "createlist");
731 Nbvars = Max(*lw, Nbvars);
732 lw1 = *lw + Top - Rhs;
735 Scierror(999, _("%s: bad call to %s! (1rst argument).\n"), fname, "createlist");
738 C2F(crelist) (&lw1, nel, &lr);
739 C2F(intersci).ntypes[*lw - 1] = '$';
740 C2F(intersci).iwhere[*lw - 1] = *Lstk(lw1);
741 C2F(intersci).lad[*lw - 1] = lr;
745 /*---------------------------------------------------------------------
746 * create a variable number lw on the stack of type
748 * the argument must be of type type ('c','d','r','i','b')
749 * return values m,n,lr,lar
750 * lar is also an input value
751 * if lar != -1 var is filled with data stored at lar
752 *---------------------------------------------------------------------*/
754 int C2F(createvarfrom) (int *lw, char *typex, int *m, int *n, int *lr, int *lar, unsigned long type_len)
756 int M = *m, N = *n, MN = M * N;
757 unsigned char Type = *typex;
759 int it = 0, lw1, lcs;
760 char *fname = Get_Iname();
764 Scierror(999, _("%s: (%s) too many arguments in the stack edit stack.h and enlarge intersiz.\n"), fname, "createvarfrom");
767 Nbvars = Max(*lw, Nbvars);
768 lw1 = *lw + Top - Rhs;
771 Scierror(999, _("%s: bad call to %s! (1rst argument).\n"), fname, "createvarfrom");
777 if (!C2F(cresmat2) (fname, &lw1, &MN, lr, nlgh))
783 C2F(cvstr1) (&MN, istk(*lr), cstk(*lar), &cx0, MN + 1);
789 if (!C2F(cremat) (fname, &lw1, &it, m, n, lr, &lcs, nlgh))
795 C2F(dcopy) (&MN, stk(*lar), &cx1, stk(*lr), &cx1);
800 if (!C2F(cremat) (fname, &lw1, &it, m, n, lr, &lcs, nlgh))
806 C2F(rea2db) (&MN, sstk(*lar), &cx1, stk(*lr), &cx1);
812 if (!C2F(cremat) (fname, &lw1, &it, m, n, lr, &lcs, nlgh))
818 C2F(int2db) (&MN, istk(*lar), &cx1, stk(*lr), &cx1);
824 if (!C2F(crebmat) (fname, &lw1, m, n, lr, nlgh))
830 C2F(icopy) (&MN, istk(*lar), &cx1, istk(*lr), &cx1);
836 if (!C2F(creimat) (fname, &lw1, &it, m, n, lr, nlgh))
842 C2F(tpconv) (&it, &it, &MN, istk(*lar), &inc, istk(*lr), &inc);
848 if (!C2F(crepointer) (fname, &lw1, lr, nlgh))
854 C2F(dcopy) (&MN, stk(*lar), &cx1, stk(*lr), &cx1);
859 if (!C2F(crehmat) (fname, &lw1, m, n, lr, nlgh))
865 C2F(dcopy) (&MN, stk(*lar), &cx1, stk(*lr), &cx1);
870 C2F(intersci).ntypes[*lw - 1] = '$';
871 C2F(intersci).iwhere[*lw - 1] = *Lstk(lw1);
872 C2F(intersci).lad[*lw - 1] = *lr;
876 /*---------------------------------------------------------------------
877 * create a variable number lw on the stack of type
879 * the argument must be of type type ('d','r','i')
880 * return values it,m,n,lr,lc,lar,lac
881 * lar is also an input value
882 * if lar != -1 var is filled with data stored at lar
884 * ==> like createvarfrom for complex matrices
885 *---------------------------------------------------------------------*/
887 int C2F(createcvarfrom) (int *lw, char *typex, int *it, int *m, int *n, int *lr, int *lc, int *lar, int *lac, unsigned long type_len)
889 unsigned char Type = *typex;
892 char *fname = Get_Iname();
896 Scierror(999, _("%s: (%s) too many arguments in the stack edit stack.h and enlarge intersiz.\n"), fname, "createcvarfrom");
899 Nbvars = Max(*lw, Nbvars);
900 lw1 = *lw + Top - Rhs;
904 Scierror(999, _("%s: bad call to %s! (1rst argument).\n"), fname, "createcvarfrom");
910 if (!C2F(cremat) (fname, &lw1, it, m, n, lr, lc, nlgh))
916 C2F(dcopy) (&MN, stk(*lar), &cx1, stk(*lr), &cx1);
918 if (*lac != -1 && *it == 1)
920 C2F(dcopy) (&MN, stk(*lac), &cx1, stk(*lc), &cx1);
926 if (!C2F(cremat) (fname, &lw1, it, m, n, lr, lc, nlgh))
932 C2F(rea2db) (&MN, sstk(*lar), &cx1, stk(*lr), &cx1);
934 if (*lac != -1 && *it == 1)
936 C2F(rea2db) (&MN, sstk(*lac), &cx1, stk(*lc), &cx1);
944 if (!C2F(cremat) (fname, &lw1, it, m, n, lr, &lcs, nlgh))
950 C2F(int2db) (&MN, istk(*lar), &cx1, stk(*lr), &cx1);
952 if (*lac != -1 && (*it == 1))
954 C2F(int2db) (&MN, istk(*lac), &cx1, stk(*lc), &cx1);
962 C2F(intersci).ntypes[*lw - 1] = '$';
963 C2F(intersci).iwhere[*lw - 1] = *Lstk(lw1);
964 C2F(intersci).lad[*lw - 1] = *lr;
968 /*---------------------------------------------------------------------
969 * This function must be called after createvar(lnumber,'l',...)
970 * Argument lnumber is a list
971 * we want here to get its argument number number
972 * the argument must be of type type ('c','d','r','i','b')
973 * input values lnumber,number,type,lar
974 * lar : input value ( -1 or the adress of an object which is used
975 * to fill the new variable data slot.
976 * lar must be a variable since it is used as input and output
977 * return values m,n,lr,lar
978 * (lar --> data is coded at stk(lar)
979 * lr --> data is coded at istk(lr) or stk(lr) or sstk(lr)
981 * c : string (m-> number of characters and n->1)
982 * d,r,i : matrix of double,float or integer
983 *---------------------------------------------------------------------*/
985 int C2F(createlistvarfrom) (int *lnumber, int *number, char *typex, int *m, int *n, int *lr, int *lar, unsigned long type_len)
987 unsigned Type = *typex;
988 int lc, ix1, it = 0, mn = (*m) * (*n), inc = 1;
989 char *fname = Get_Iname();
991 if (*lnumber > intersiz)
993 Scierror(999, _("%s: (%s) too many arguments in the stack edit stack.h and enlarge intersiz.\n"), fname, "createlistvar");
1000 ix1 = *lnumber + Top - Rhs;
1001 if (!C2F(listcrestring) (fname, &ix1, number, &C2F(intersci).lad[*lnumber - 1], m, lr, nlgh))
1007 C2F(cvstr1) (m, istk(*lr), cstk(*lar), &cx0, *m **n + 1);
1013 ix1 = *lnumber + Top - Rhs;
1014 if (!C2F(listcremat) (fname, &ix1, number, &C2F(intersci).lad[*lnumber - 1], &it, m, n, lr, &lc, nlgh))
1020 C2F(dcopy) (&mn, stk(*lar), &cx1, stk(*lr), &cx1);
1025 ix1 = *lnumber + Top - Rhs;
1026 if (!C2F(listcremat) (fname, &ix1, number, &C2F(intersci).lad[*lnumber - 1], &it, m, n, lr, &lc, nlgh))
1032 C2F(rea2db) (&mn, sstk(*lar), &cx1, stk(*lr), &cx1);
1038 ix1 = *lnumber + Top - Rhs;
1039 if (!C2F(listcremat) (fname, &ix1, number, &C2F(intersci).lad[*lnumber - 1], &it, m, n, lr, &lc, nlgh))
1045 C2F(int2db) (&mn, istk(*lar), &cx1, stk(*lr), &cx1);
1051 ix1 = *lnumber + Top - Rhs;
1052 if (!C2F(listcrebmat) (fname, &ix1, number, &C2F(intersci).lad[*lnumber - 1], m, n, lr, nlgh))
1058 C2F(icopy) (&mn, istk(*lar), &cx1, istk(*lr), &cx1);
1063 it = *lr; /* it gives the type on entry */
1064 ix1 = *lnumber + Top - Rhs;
1065 if (!C2F(listcreimat) (fname, &ix1, number, &C2F(intersci).lad[*lnumber - 1], &it, m, n, lr, nlgh))
1071 C2F(tpconv) (&it, &it, &mn, istk(*lar), &inc, istk(*lr), &inc);
1076 ix1 = *lnumber + Top - Rhs;
1077 if (!C2F(listcrepointer) (fname, &ix1, number, &C2F(intersci).lad[*lnumber - 1], lr, nlgh))
1083 *stk(*lr) = *stk(*lar);
1088 ix1 = *lnumber + Top - Rhs;
1089 if (!C2F(listcrehmat) (fname, &ix1, number, &C2F(intersci).lad[*lnumber - 1], m, n, lr, nlgh))
1095 C2F(dcopy) (&mn, stk(*lar), &cx1, stk(*lr), &cx1);
1100 Scierror(999, _("%s: (%s) bad third argument!\n"), fname, "createlistvar");
1107 /*---------------------------------------------------------------------
1108 * create a complex list variable from data
1109 *---------------------------------------------------------------------*/
1111 int C2F(createlistcvarfrom) (int *lnumber, int *number, char *typex, int *it, int *m, int *n, int *lr, int *lc, int *lar, int *lac,
1112 unsigned long type_len)
1115 int mn = (*m) * (*n);
1116 unsigned char Type = *typex;
1117 char *fname = Get_Iname();
1119 if (*lnumber > intersiz)
1121 Scierror(999, _("%s: (%s) too many arguments in the stack edit stack.h and enlarge intersiz.\n"), fname, "createlistcvar");
1128 ix1 = *lnumber + Top - Rhs;
1129 if (!C2F(listcremat) (fname, &ix1, number, &C2F(intersci).lad[*lnumber - 1], it, m, n, lr, lc, nlgh))
1135 C2F(dcopy) (&mn, stk(*lar), &cx1, stk(*lr), &cx1);
1137 if (*lac != -1 && *it == 1)
1139 C2F(dcopy) (&mn, stk(*lac), &cx1, stk(*lc), &cx1);
1145 ix1 = *lnumber + Top - Rhs;
1146 if (!C2F(listcremat) (fname, &ix1, number, &C2F(intersci).lad[*lnumber - 1], it, m, n, lr, lc, nlgh))
1152 C2F(rea2db) (&mn, sstk(*lar), &cx1, stk(*lr), &cx1);
1154 if (*lac != -1 && *it == 1)
1156 C2F(rea2db) (&mn, sstk(*lac), &cx1, stk(*lc), &cx1);
1164 ix1 = *lnumber + Top - Rhs;
1165 if (!C2F(listcremat) (fname, &ix1, number, &C2F(intersci).lad[*lnumber - 1], it, m, n, lr, lc, nlgh))
1171 C2F(int2db) (&mn, istk(*lar), &cx1, stk(*lr), &cx1);
1173 if (*lac != -1 && *it == 1)
1175 C2F(int2db) (&mn, istk(*lac), &cx1, stk(*lc), &cx1);
1183 Scierror(999, _("%s: (%s) bad third argument!\n"), fname, "createlistcvar");
1189 /*---------------------------------------------------------------------
1190 * This function must be called after createvar(lnumber,'l',...)
1191 * Argument lnumber is a list
1192 * we want here to get its argument number number
1193 * the argument must be of type type ('c','d','r','i','b')
1194 * input values lnumber,number,type,lar
1195 * lar : input value ( -1 or the adress of an object which is used
1196 * to fill the new variable data slot.
1197 * lar must be a variable since it is used as input and output
1198 * return values m,n,lr,lar
1199 * (lar --> data is coded at stk(lar)
1200 * lr --> data is coded at istk(lr) or stk(lr) or sstk(lr)
1202 * c : string (m-> number of characters and n->1)
1203 * d,r,i : matrix of double,float or integer
1204 *---------------------------------------------------------------------*/
1206 int C2F(createlistvarfromptr) (int *lnumber, int *number, char *typex, int *m, int *n, void *iptr, unsigned long type_len)
1208 unsigned Type = *typex;
1209 int lc, ix1, it = 0, lr, inc = 1;
1210 char *fname = Get_Iname();
1212 if (*lnumber > intersiz)
1214 Scierror(999, _("%s: (%s) too many arguments in the stack edit stack.h and enlarge intersiz.\n"), fname, "createlistvarfromptr");
1218 ix1 = *lnumber + Top - Rhs; /* factorization of this term (Bruno 9 march 2005, bugfix ) */
1223 if (!C2F(listcrestring) (fname, &ix1, number, &C2F(intersci).lad[*lnumber - 1], m, &lr, nlgh))
1227 C2F(cchar) (m, (char **)iptr, istk(lr));
1230 if (!C2F(listcremat) (fname, &ix1, number, &C2F(intersci).lad[*lnumber - 1], &it, m, n, &lr, &lc, nlgh))
1235 C2F(cdouble) (&ix1, (double **)iptr, stk(lr));
1238 if (!C2F(listcremat) (fname, &ix1, number, &C2F(intersci).lad[*lnumber - 1], &it, m, n, &lr, &lc, nlgh))
1243 C2F(cfloat) (&ix1, (float **)iptr, stk(lr));
1246 if (!C2F(listcremat) (fname, &ix1, number, &C2F(intersci).lad[*lnumber - 1], &it, m, n, &lr, &lc, nlgh))
1251 C2F(cint) (&ix1, (int **)iptr, stk(lr));
1254 if (!C2F(listcrebmat) (fname, &ix1, number, &C2F(intersci).lad[*lnumber - 1], m, n, &lr, nlgh))
1259 C2F(cbool) (&ix1, (int **)iptr, istk(lr));
1262 if (!cre_listsmat_from_str(fname, &ix1, number, &C2F(intersci).lad[*lnumber - 1], m, n, (char **)iptr, nlgh)) /* XXX */
1268 if (!cre_listsparse_from_ptr(fname, &ix1, number, &C2F(intersci).lad[*lnumber - 1], m, n, (SciSparse *) iptr, nlgh))
1274 it = ((SciIntMat *) iptr)->it;
1275 if (!C2F(listcreimat) (fname, &ix1, number, &C2F(intersci).lad[*lnumber - 1], &it, m, n, &lr, nlgh))
1280 C2F(tpconv) (&it, &it, &ix1, ((SciIntMat *) iptr)->D, &inc, istk(lr), &inc);
1283 if (!C2F(listcrepointer) (fname, &ix1, number, &C2F(intersci).lad[*lnumber - 1], &lr, nlgh))
1287 *stk(lr) = (double)((unsigned long int)iptr);
1290 Scierror(999, _("%s: (%s) bad third argument!\n"), fname, "createlistcvar");
1297 /*---------------------------------------------------------------------
1298 * This function must be called after createvar(lnumber,'l',...)
1299 * Argument lnumber is a list
1300 * we want here to get its argument number number
1301 * the argument must be of type type ('c','d','r','i','b')
1302 * input values lnumber,number,type,lar
1303 * lar : input value ( -1 or the adress of an object which is used
1304 * to fill the new variable data slot.
1305 * lar must be a variable since it is used as input and output
1306 * return values m,n,lr,lar
1307 * (lar --> data is coded at stk(lar)
1308 * lr --> data is coded at istk(lr) or stk(lr) or sstk(lr)
1310 * c : string (m-> number of characters and n->1)
1311 * d,r,i : matrix of double,float or integer
1312 *---------------------------------------------------------------------*/
1314 int C2F(createlistcvarfromptr) (int *lnumber, int *number, char *typex, int *it, int *m, int *n, void *iptr, void *iptc, unsigned long type_len)
1316 unsigned Type = *typex;
1318 char *fname = Get_Iname();
1320 if (*lnumber > intersiz)
1322 Scierror(999, _("%s: (%s) too many arguments in the stack edit stack.h and enlarge intersiz.\n"), fname, "createlistvarfromptr");
1328 ix1 = *lnumber + Top - Rhs;
1329 if (!C2F(listcremat) (fname, &ix1, number, &C2F(intersci).lad[*lnumber - 1], it, m, n, &lr, &lc, nlgh))
1334 C2F(cdouble) (&ix1, (double **)iptr, stk(lr));
1337 C2F(cdouble) (&ix1, (double **)iptc, stk(lc));
1341 ix1 = *lnumber + Top - Rhs;
1342 if (!C2F(listcremat) (fname, &ix1, number, &C2F(intersci).lad[*lnumber - 1], it, m, n, &lr, &lc, nlgh))
1347 C2F(cfloat) (&ix1, (float **)iptr, stk(lr));
1350 C2F(cfloat) (&ix1, (float **)iptc, stk(lc));
1354 ix1 = *lnumber + Top - Rhs;
1355 if (!C2F(listcremat) (fname, &ix1, number, &C2F(intersci).lad[*lnumber - 1], it, m, n, &lr, &lc, nlgh))
1360 C2F(cint) (&ix1, (int **)iptr, stk(lr));
1363 C2F(cint) (&ix1, (int **)iptc, stk(lc));
1367 Scierror(999, _("%s: (%s) bad third argument!\n"), fname, "createlistcvarfromptr");
1374 /*---------------------------------------------------------------------
1375 * use the rest of the stack as working area
1376 * the allowed size (in double) is returned in m
1377 *---------------------------------------------------------------------*/
1379 int C2F(creatework) (int *number, int *m, int *lr)
1381 int n, it = 0, lw1, lcs, il;
1382 char *fname = Get_Iname();
1384 if (*number > intersiz)
1387 Scierror(999, _("%s: (%s) too many arguments in the stack edit stack.h and enlarge intersiz.\n"), fname, "creatework");
1390 Nbvars = Max(*number, Nbvars);
1391 lw1 = *number + Top - Rhs;
1394 Scierror(999, _("%s: bad call to %s! (1rst argument).\n"), fname, "creatework");
1397 il = iadr(*Lstk(lw1));
1398 *m = *Lstk(Bot) - sadr(il + 4);
1400 if (!C2F(cremat) (fname, &lw1, &it, m, &n, lr, &lcs, nlgh))
1407 /*---------------------------------------------------------------------
1408 * This can be used with creatework to
1409 * set the size of object which was intialy sized to the whole
1410 * remaining space with creatework
1411 * Moreover information the objet is recorded
1412 *---------------------------------------------------------------------*/
1414 int C2F(setworksize) (int *number, int *size)
1417 char *fname = Get_Iname();
1419 if (*number > intersiz)
1421 Scierror(999, _("%s: (%s) too many arguments in the stack edit stack.h and enlarge intersiz.\n"), fname, "creatework");
1424 Nbvars = Max(*number, Nbvars);
1425 lw1 = *number + Top - Rhs;
1428 Scierror(999, _("%s: bad call to %s! (1rst argument).\n"), fname, "setworksize");
1431 *Lstk(lw1 + 1) = *Lstk(lw1) + *size;
1432 C2F(intersci).ntypes[*number - 1] = '$';
1433 C2F(intersci).iwhere[*number - 1] = *Lstk(lw1);
1434 C2F(intersci).lad[*number - 1] = 0; /* not to be used XXXX */
1438 /*---------------------------------------------------------------------
1440 * check if argument number <<number>> is a matrix and
1441 * returns its dimensions
1442 *---------------------------------------------------------------------*/
1444 int C2F(getmatdims) (int *number, int *m, int *n)
1446 char *fname = Get_Iname();
1449 lw = *number + Top - Rhs;
1452 Scierror(999, _("%s: bad call to %s! (1rst argument).\n"), fname, "getmatdims");
1456 il = iadr(*Lstk(lw));
1459 il = iadr(*istk(il + 1));
1462 if (typ > sci_strings)
1464 Scierror(199, _("%s: Wrong type for argument #%d: Matrix expected.\n"), fname, *number);
1472 /*---------------------------------------------------------------------
1474 * get the argument number <<number>>
1475 * the argument must be of type type ('c','d','r','i','f','l','b')
1476 * return values m,n,lr
1477 * c : string (m-> number of characters and n->1)
1478 * d,r,i : matrix of double,float or integer
1479 * f : external (function)
1480 * b : boolean matrix
1481 * l : a list (m-> number of elements and n->1)
1482 * for each element of the list an other function
1483 * must be used to <<get>> them
1484 * side effects : arguments in the common intersci are modified
1485 * see examples in addinter-examples
1486 *---------------------------------------------------------------------*/
1488 int C2F(getrhsvar) (int *number, char *typex, int *m, int *n, int *lr, unsigned long type_len)
1490 int ierr = 0, il1 = 0, ild1 = 0, nn = 0;
1492 char *fname = Get_Iname();
1493 char **items = NULL, namex[nlgh + 1];
1494 unsigned char Type = *(unsigned char *)typex;
1495 int topk = 0, ltype = 0, m1 = 0, n1 = 0, lc = 0, lr1 = 0, it = 0, lw = 0, ile = 0, ils = 0, ix1 = 0, ix2 = 0;
1496 int mnel = 0, icol = 0;
1497 SciSparse *Sp = NULL;
1498 SciIntMat *Im = NULL;
1500 /* we accept a call to getrhsvar after a createvarfromptr call */
1501 if (*number > Rhs && *number > Nbvars)
1503 Scierror(999, _("%s: bad call to %s! (1rst argument).\n"), fname, "getrhsvar");
1507 Nbvars = Max(Nbvars, *number);
1508 lw = *number + Top - Rhs;
1510 if (*number > intersiz)
1512 Scierror(999, _("%s: (%s) too many arguments in the stack edit stack.h and enlarge intersiz.\n"), fname, "getrhsvar");
1516 if (overloadtype(&lw, fname, &Type) == 0)
1526 if (!C2F(getsmat) (fname, &topk, &lw, &m1, &n1, &cx1, &cx1, lr, m, nlgh))
1531 if ((m1 != 1) || (n1 != 1))
1533 /* bug 8768 check dimensions */
1534 Scierror(999, _("%s: Wrong size for input argument #%d: A string expected.\n"), fname, *number);
1539 /* in case where ix2 is 0 in2str adds the \0 char after the end of
1540 * the storage of the variable, so it writes over the next variable
1541 * tp avoid this pb we shift up by one the location where the
1542 * data is written */
1549 C2F(in2str) (&ix2, istk(*lr), cstk(cadr(*lr)), ix2 + 1);
1551 C2F(intersci).ntypes[*number - 1] = Type;
1552 C2F(intersci).iwhere[*number - 1] = *Lstk(lw);
1553 C2F(intersci).lad[*number - 1] = *lr;
1557 if (!C2F(getmat) (fname, &topk, &lw, &it, m, n, lr, &lc, nlgh))
1561 C2F(intersci).ntypes[*number - 1] = Type;
1562 C2F(intersci).iwhere[*number - 1] = *Lstk(lw);
1563 C2F(intersci).lad[*number - 1] = *lr;
1566 if (!C2F(getmat) (fname, &topk, &lw, &it, m, n, lr, &lc, nlgh))
1571 if ((it != 1) && (ix2 != 0))
1573 Scierror(999, _("%s: Wrong type for argument: Complex expected.\n"), fname);
1578 /* bad adress (lr is even) shift up the stack */
1579 double2z(stk(*lr), stk(*lr) - 1, ix2, ix2);
1580 *istk(iadr(*lr) - 4) = 133;
1581 *istk(iadr(*lr) - 3) = iadr(*lr + 2 * ix2 - 1);
1582 *istk(iadr(*lr + 2 * ix2 - 1)) = *m;
1583 *istk(iadr(*lr + 2 * ix2 - 1) + 1) = *n;
1584 C2F(intersci).ntypes[*number - 1] = Type;
1585 C2F(intersci).iwhere[*number - 1] = *Lstk(lw);
1586 C2F(intersci).lad[*number - 1] = *lr - 1;
1587 *lr = sadr(*lr - 1);
1591 SciToF77(stk(*lr), ix2, ix2);
1592 C2F(intersci).ntypes[*number - 1] = Type;
1593 C2F(intersci).iwhere[*number - 1] = *Lstk(lw);
1594 C2F(intersci).lad[*number - 1] = *lr;
1599 if (!C2F(getmat) (fname, &topk, &lw, &it, m, n, lr, &lc, nlgh))
1604 C2F(simple) (&ix1, stk(*lr), sstk(iadr(*lr)));
1606 C2F(intersci).ntypes[*number - 1] = Type;
1607 C2F(intersci).iwhere[*number - 1] = *Lstk(lw);
1608 C2F(intersci).lad[*number - 1] = *lr;
1611 if (!C2F(getmat) (fname, &topk, &lw, &it, m, n, lr, &lc, nlgh))
1616 C2F(entier) (&ix1, stk(*lr), istk(iadr(*lr)));
1618 C2F(intersci).ntypes[*number - 1] = Type;
1619 C2F(intersci).iwhere[*number - 1] = *Lstk(lw);
1620 C2F(intersci).lad[*number - 1] = *lr;
1623 if (!C2F(getbmat) (fname, &topk, &lw, m, n, lr, nlgh))
1627 C2F(intersci).ntypes[*number - 1] = Type;
1628 C2F(intersci).iwhere[*number - 1] = *Lstk(lw);
1629 C2F(intersci).lad[*number - 1] = *lr;
1635 if (!C2F(getilist) (fname, &topk, &lw, m, n, lr, nlgh))
1639 /* No data conversion for list members ichar(type)='$' */
1641 C2F(intersci).ntypes[*number - 1] = Type;
1642 C2F(intersci).iwhere[*number - 1] = *Lstk(lw);
1643 C2F(intersci).lad[*number - 1] = *lr;
1646 /** getwsmat : must be back in stack1.c from xawelm.f */
1647 if (!C2F(getwsmat) (fname, &topk, &lw, m, n, &il1, &ild1, nlgh))
1652 ScilabMStr2CM(istk(il1), &nn, istk(ild1), &items, &ierr);
1659 * Warning : lr must have the proper size when calling getrhsvar
1660 * char **Str1; .... GetRhsVar(...., &lr)
1662 *((char ***)lr) = items;
1663 C2F(intersci).ntypes[*number - 1] = Type;
1664 C2F(intersci).iwhere[*number - 1] = *Lstk(lw);
1665 C2F(intersci).lad[*number - 1] = *lr;
1668 /* sparse matrices */
1669 Sp = (SciSparse *) lr;
1670 if (!C2F(getsparse) (fname, &topk, &lw, &it, m, n, &(Sp->nel), &mnel, &icol, &lr1, &lc, nlgh))
1677 Sp->mnel = istk(mnel);
1678 Sp->icol = istk(icol);
1680 Sp->I = (it == 1) ? stk(lc) : NULL;
1682 C2F(intersci).ntypes[*number - 1] = Type;
1683 C2F(intersci).iwhere[*number - 1] = *Lstk(lw);
1684 C2F(intersci).lad[*number - 1] = *lr;
1688 Im = (SciIntMat *) lr;
1689 if (!C2F(getimat) (fname, &topk, &lw, &it, m, n, &lr1, nlgh))
1699 C2F(intersci).ntypes[*number - 1] = Type;
1700 C2F(intersci).iwhere[*number - 1] = *Lstk(lw);
1701 C2F(intersci).lad[*number - 1] = *lr;
1704 /* XXXXXX : gros bug ici car getexternal a besoin de savoir
1705 * pour quelle fonction on recupere un external
1706 * or ici on presuppose que c'est setfeval
1707 * de plus on ne sait pas exactement de quel type d'external il s'agit
1710 /* int function getrhsvar(number,type,m,n,lr) */
1712 ils = iadr(*lr) + 1;
1714 ile = ils + *m * nsiz + 1;
1716 if (!C2F(getexternal) (fname, &topk, &lw, namex, <ype, C2F(setfeval), nlgh, nlgh))
1721 C2F(intersci).ntypes[*number - 1] = Type;
1722 C2F(intersci).iwhere[*number - 1] = *Lstk(lw);
1723 C2F(intersci).lad[*number - 1] = *lr;
1726 if (!C2F(getpointer) (fname, &topk, &lw, lr, nlgh))
1730 C2F(intersci).ntypes[*number - 1] = Type;
1731 C2F(intersci).iwhere[*number - 1] = *Lstk(lw);
1732 C2F(intersci).lad[*number - 1] = *lr;
1735 if (!C2F(gethmat) (fname, &topk, &lw, m, n, lr, nlgh))
1739 C2F(intersci).ntypes[*number - 1] = Type;
1740 C2F(intersci).iwhere[*number - 1] = *Lstk(lw);
1741 C2F(intersci).lad[*number - 1] = *lr;
1747 /*---------------------------------------------------------------------
1749 * get the argument number <<number>>
1750 * the argument must be of type type ('d','r','i')
1751 * like getrhsvar but for complex matrices
1752 *---------------------------------------------------------------------*/
1754 int C2F(getrhscvar) (int *number, char *typex, int *it, int *m, int *n, int *lr, int *lc, unsigned long type_len)
1757 unsigned char Type = *typex;
1758 char *fname = Get_Iname();
1760 Nbvars = Max(Nbvars, *number);
1761 lw = *number + Top - Rhs;
1764 Scierror(999, _("%s: bad call to %s! (1rst argument).\n"), fname, "getrhscvar");
1767 if (*number > intersiz)
1769 Scierror(999, _("%s: (%s) too many arguments in the stack edit stack.h and enlarge intersiz.\n"), fname, "getrhscvar");
1776 if (!C2F(getmat) (fname, &topk, &lw, it, m, n, lr, lc, nlgh))
1782 if (!C2F(getmat) (fname, &topk, &lw, it, m, n, lr, lc, nlgh))
1786 ix1 = *m **n * (*it + 1);
1787 C2F(simple) (&ix1, stk(*lr), sstk(iadr(*lr)));
1792 if (!C2F(getmat) (fname, &topk, &lw, it, m, n, lr, lc, nlgh))
1796 ix1 = *m **n * (*it + 1);
1797 C2F(entier) (&ix1, stk(*lr), istk(iadr(*lr)));
1802 C2F(intersci).ntypes[*number - 1] = Type;
1803 C2F(intersci).iwhere[*number - 1] = *Lstk(lw);
1804 C2F(intersci).lad[*number - 1] = *lr;
1808 /*---------------------------------------------------------------------
1810 * returns the type of the element indexed by *number in the list
1811 * whose variable number is *lnumber. If the indexed element does not exist
1812 * the function returns 0.
1813 *---------------------------------------------------------------------*/
1815 int C2F(elementtype) (int *lnumber, int *number)
1817 int il, lw, itype, n, ix, ili;
1818 char *fname = Get_Iname();
1822 Scierror(999, _("%s: bad call to %s!\n"), fname, "elementtype");
1826 lw = *lnumber + Top - Rhs; /*index of the variable numbered *lnumber in the stack */
1827 il = iadr(*Lstk(lw));
1830 il = iadr(*istk(il + 1));
1832 itype = *istk(il); /* type of the variable numbered *lnumber */
1833 if (itype < sci_list || itype > sci_mlist)
1835 /* check if it is really a list */
1836 Scierror(210, _("%s: Wrong type for argument #%d: List expected.\n"), fname, *lnumber);
1839 n = *istk(il + 1); /* number of elements in the list */
1840 itype = 0; /*default answer if *number is not a valid element index */
1841 if (*number <= n && *number > 0)
1843 ix = sadr(il + 3 + n); /* adress of the first list element */
1844 if (*istk(il + 1 + *number) < *istk(il + *number + 2))
1846 /* the required element is defined */
1847 ili = iadr(ix + *istk(il + 1 + *number) - 1); /* adress of the required element */
1854 /*---------------------------------------------------------------------
1855 * This function must be called after getrhsvar(lnumber,'l',...)
1856 * Argument lnumber is a list
1857 * we want here to get its argument number number
1858 * the argument must be of type type ('c','d','r','i','b')
1859 * return values m,n,lr,lar
1860 * (lar --> data is coded at stk(lar)
1861 * lr --> data is coded at istk(lr) or stk(lr) or sstk(lr)
1863 * c : string (m-> number of characters and n->1)
1864 * d,r,i : matrix of double,float or integer
1865 *---------------------------------------------------------------------*/
1867 int C2F(getlistrhsvar) (int *lnumber, int *number, char *typex, int *m, int *n, int *lr, unsigned long type_len)
1871 int il1, ild1, nn, ierr = 0;
1872 char *fname = Get_Iname();
1873 int m1, n1, lc, it, lw, topk = Top, ix1, ix2;
1874 unsigned char Type = *typex;
1879 Nbvars = Max(Nbvars, *lnumber);
1880 lw = *lnumber + Top - Rhs;
1883 Scierror(999, _("%s: bad call to %s! (1rst argument).\n"), fname, "getlistrhsvar");
1886 if (*lnumber > intersiz)
1888 Scierror(999, _("%s: (%s) too many arguments in the stack edit stack.h and enlarge intersiz.\n"), fname, "getlistrhsvar");
1896 if (!C2F(getlistsimat) (fname, &topk, &lw, number, &m1, &n1, &cx1, &cx1, lr, m, nlgh))
1901 C2F(in2str) (&ix2, istk(*lr), cstk(cadr(*lr)), ix2 + 1);
1905 if (!C2F(getlistmat) (fname, &topk, &lw, number, &it, m, n, lr, &lc, nlgh))
1911 if (!C2F(getlistmat) (fname, &topk, &lw, number, &it, m, n, lr, &lc, nlgh))
1916 C2F(simple) (&ix1, stk(*lr), sstk(iadr(*lr)));
1920 if (!C2F(getlistmat) (fname, &topk, &lw, number, &it, m, n, lr, &lc, nlgh))
1925 C2F(entier) (&ix1, stk(*lr), istk(iadr(*lr)));
1929 if (!C2F(getlistbmat) (fname, &topk, &lw, number, m, n, lr, nlgh))
1936 if (!C2F(getlistmat) (fname, &topk, &lw, number, &it, m, n, lr, &lc, nlgh))
1941 if ((it != 1) && (ix2 != 0))
1943 Scierror(999, _("%s: argument %d > (%d) should be a complex matrix.\n"), fname, Rhs + (lw - topk), *number);
1948 /* bad adress (lr is even) shift up the stack */
1949 double2z(stk(*lr), stk(*lr) - 1, ix2, ix2);
1951 *istk(iadr(*lr) - 4) = 133;
1952 *istk(iadr(*lr) - 3) = iadr(*lr + ix2);
1953 *istk(iadr(*lr + ix2)) = *m;
1954 *istk(iadr(*lr + ix2) + 1) = *n;
1955 *lr = sadr(*lr - 1);
1959 SciToF77(stk(*lr), ix2, ix2);
1964 /** getwsmat : must be back in stack1.c from xawelm.f */
1965 if (!C2F(getlistwsmat) (fname, &topk, &lw, number, m, n, &il1, &ild1, nlgh))
1970 ScilabMStr2CM(istk(il1), &nn, istk(ild1), &items, &ierr);
1976 * Warning : lr must have the proper size when calling getrhsvar
1977 * char **Str1; .... GetRhsVar(...., &lr)
1979 *((char ***)lr) = items;
1982 /* sparse matrices */
1983 Sp = (SciSparse *) lr;
1984 if (!C2F(getlistsparse) (fname, &topk, &lw, number, &it, m, n, &(Sp->nel), &mnel, &icol, &lr1, &lc, nlgh))
1991 Sp->mnel = istk(mnel);
1992 Sp->icol = istk(icol);
1998 Im = (SciIntMat *) lr;
1999 if (!C2F(getlistimat) (fname, &topk, &lw, number, &it, m, n, &lr1, nlgh))
2010 if (!C2F(getlistpointer) (fname, &topk, &lw, number, lr, nlgh))
2016 Scierror(999, _("%s: bad call to %s (third argument %c).\n"), fname, "getlistrhsvar", Type);
2019 /* can't perform back data conversion with lists */
2020 C2F(intersci).ntypes[*number - 1] = '$';
2024 /*---------------------------------------------------------------------
2026 *---------------------------------------------------------------------*/
2028 int C2F(getlistrhscvar) (int *lnumber, int *number, char *typex, int *it, int *m, int *n, int *lr, int *lc, unsigned long type_len)
2030 int ix1, topk = Top, lw;
2031 char *fname = Get_Iname();
2032 unsigned char Type = *typex;
2034 Nbvars = Max(Nbvars, *lnumber);
2035 lw = *lnumber + Top - Rhs;
2038 Scierror(999, _("%s: bad call to %s! (1rst argument).\n"), fname, "getlistrhscvar");
2041 if (*lnumber > intersiz)
2043 Scierror(999, _("%s: (%s) too many arguments in the stack edit stack.h and enlarge intersiz.\n"), fname, "getlistrhscvar");
2049 if (!C2F(getlistmat) (fname, &topk, &lw, number, it, m, n, lr, lc, nlgh))
2055 if (!C2F(getlistmat) (fname, &topk, &lw, number, it, m, n, lr, lc, nlgh))
2059 ix1 = *m **n * (*it + 1);
2060 C2F(simple) (&ix1, stk(*lr), sstk(iadr(*lr)));
2065 if (!C2F(getlistmat) (fname, &topk, &lw, number, it, m, n, lr, lc, nlgh))
2069 ix1 = *m **n * (*it + 1);
2070 C2F(entier) (&ix1, stk(*lr), istk(iadr(*lr)));
2075 Scierror(999, _("%s: (%s) bad third argument!\n"), fname, "getlistrhscvar");
2079 /* can't perform back data conversion with lists */
2080 C2F(intersci).ntypes[*number - 1] = '$';
2084 /*---------------------------------------------------------------------
2085 * creates variable number number of type "type" and dims m,n
2088 *---------------------------------------------------------------------*/
2090 int C2F(createvarfromptr) (int *number, char *typex, int *m, int *n, void *iptr, unsigned long type_len)
2093 unsigned char Type = *typex;
2094 int MN = (*m) * (*n), lr, it, lw1;
2095 char *fname = Get_Iname();
2097 lw1 = *number + Top - Rhs;
2101 if (C2F(createvar) (number, typex, m, n, &lr, type_len) == FALSE)
2105 C2F(dcopy) (&MN, *((double **)iptr), &un, stk(lr), &un);
2109 if (C2F(createvar) (number, typex, m, n, &lr, type_len) == FALSE)
2113 C2F(icopy) (&MN, *((int **)iptr), &un, istk(lr), &un);
2116 if (C2F(createvar) (number, typex, m, n, &lr, type_len) == FALSE)
2120 C2F(rcopy) (&MN, *((float **)iptr), &un, sstk(lr), &un);
2123 if (C2F(createvar) (number, typex, m, n, &lr, type_len) == FALSE)
2127 strcpy(cstk(lr), *((char **)iptr));
2130 /* on entry lr must gives the int type */
2131 it = lr = ((SciIntMat *) iptr)->it;
2132 if (C2F(createvar) (number, typex, m, n, &lr, type_len) == FALSE)
2136 C2F(tpconv) (&it, &it, &MN, ((SciIntMat *) iptr)->D, &un, istk(lr), &un);
2139 if (C2F(createvar) (number, typex, m, n, &lr, type_len) == FALSE)
2143 *stk(lr) = (double)((unsigned long int)iptr);
2146 /* special case: not taken into account in createvar */
2147 Nbvars = Max(*number, Nbvars);
2148 if (!cre_smat_from_str(fname, &lw1, m, n, (char **)iptr, nlgh))
2152 C2F(intersci).iwhere[*number - 1] = *Lstk(lw1);
2153 C2F(intersci).ntypes[*number - 1] = '$';
2156 /* special case: not taken into account in createvar */
2157 Nbvars = Max(*number, Nbvars);
2158 if (!cre_sparse_from_ptr(fname, &lw1, m, n, (SciSparse *) iptr, nlgh))
2162 C2F(intersci).iwhere[*number - 1] = *Lstk(lw1);
2163 C2F(intersci).ntypes[*number - 1] = '$';
2166 Scierror(999, _("%s: (%s) bad second argument!\n"), fname, "createvarfromptr");
2170 /* this object will be copied with a vcopyobj in putlhsvar */
2174 /*---------------------------------------------------------------------
2176 *---------------------------------------------------------------------*/
2178 int C2F(createcvarfromptr) (int *number, char *typex, int *it, int *m, int *n, double *iptr, double *iptc, unsigned long type_len)
2180 unsigned char Type = *typex;
2181 char *fname = Get_Iname();
2182 int lw1, lcs, lrs, ix1;
2184 Nbvars = Max(Nbvars, *number);
2185 if (*number > intersiz)
2187 Scierror(999, _("%s: createcvarfromptr: too many arguments on the stack, enlarge intersiz.\n"), fname);
2190 lw1 = *number + Top - Rhs;
2194 if (!C2F(cremat) (fname, &lw1, it, m, n, &lrs, &lcs, nlgh))
2199 C2F(cdouble) (&ix1, (double **)iptr, stk(lrs));
2203 C2F(cdouble) (&ix1, (double **)iptc, stk(lcs));
2207 if (!C2F(cremat) (fname, &lw1, it, m, n, &lrs, &lcs, nlgh))
2212 C2F(cint) (&ix1, (int **)iptr, stk(lrs));
2216 C2F(cint) (&ix1, (int **)iptc, stk(lcs));
2220 Scierror(999, _("%s: (%s) bad second argument!\n"), fname, "createcvarfromptr");
2224 /* this object will be copied with a vcopyobj in putlhsvar */
2225 C2F(intersci).ntypes[*number - 1] = '$';
2229 /*---------------------------------------------------------------------
2231 * replace the last n variables created at postions pos:pos-1+n
2232 * by a list of these variables at position pos
2233 *---------------------------------------------------------------------*/
2235 int C2F(mklistfromvars) (int *pos, int *n)
2240 for (k = *pos; k < *pos + *n; k++)
2242 C2F(convert2sci) (&k);
2244 Top = Top - Rhs + *pos - 1 + *n;
2247 C2F(intersci).ntypes[*pos - 1] = '$';
2251 /*---------------------------------------------------------------------
2253 * similar to mklistfromvars but create a tlist
2254 *---------------------------------------------------------------------*/
2256 int C2F(mktlistfromvars) (int *pos, int *n)
2262 for (k = *pos; k < *pos + *n; k++)
2264 C2F(convert2sci) (&k);
2266 Top = Top - Rhs + *pos - 1 + *n;
2267 C2F(mklistt) (n, &type);
2269 C2F(intersci).ntypes[*pos - 1] = '$';
2273 /*---------------------------------------------------------------------
2275 * similar to mklistfromvars but create a mlist
2276 *---------------------------------------------------------------------*/
2278 int C2F(mkmlistfromvars) (int *pos, int *n)
2280 int type = sci_mlist;
2284 for (k = *pos; k < *pos + *n; k++)
2286 C2F(convert2sci) (&k);
2288 Top = Top - Rhs + *pos - 1 + *n;
2289 C2F(mklistt) (n, &type);
2291 C2F(intersci).ntypes[*pos - 1] = '$';
2295 /*---------------------------------------------------------------------
2296 * call a Scilab function given its name
2297 *---------------------------------------------------------------------*/
2299 int C2F(callscifun) (char *string, unsigned long string_len)
2303 C2F(cvname) (id, string, &cx0, string_len);
2304 C2F(putid) (&C2F(recu).ids[(C2F(recu).pt + 1) * nsiz - nsiz], id);
2309 /*---------------------------------------------------------------------
2310 * scifunction(number,ptr,mlhs,mrhs) >
2311 * execute scilab function with mrhs input args and mlhs output
2313 * input args are supposed to be stored in the top of the stack
2314 * at positions top-mrhs+1:top
2315 *---------------------------------------------------------------------*/
2317 int C2F(scifunction) (int *number, int *ptr, int *mlhs, int *mrhs)
2320 int ix1, ix, k, intop, lw;
2323 if (intersci_push() == 0)
2325 Scierror(999, _("%s: No more memory.\n"), "scifunction");
2329 /* macro execution inside a builtin gateway */
2331 Top = Top - Rhs + *number + *mrhs - 1;
2333 if (C2F(recu).pt > psiz)
2338 C2F(recu).ids[C2F(recu).pt * nsiz - nsiz] = Lhs;
2339 C2F(recu).ids[C2F(recu).pt * nsiz - (nsiz - 1)] = Rhs;
2340 C2F(recu).rstk[C2F(recu).pt - 1] = 1001;
2345 C2F(com).fin = *ptr;
2346 C2F(recu).icall = 5;
2347 C2F(recu).krec = -1;
2348 /* ************************** copied from callinter.h */
2351 /* parse has exited for a built-in evaluation */
2353 if (C2F(com).fun == 99)
2355 if (Err > 0 || C2F(errgst).err1 > 0)
2357 imode = abs(C2F(errgst).errct) / 100000 % 8;
2371 if (isRecursionCallToFunction())
2373 int gw = getRecursionGatewayToCall();
2375 if (gw == END_OVERLOAD)
2379 else if (gw == ERROR_GW_ID)
2389 if (isRecursionCallToFunction())
2391 int gw = getRecursionGatewayToCall();
2393 if (gw == END_OVERLOAD)
2397 else if (gw == ERROR_GW_ID)
2411 Scierror(22, _("%s: Recursion problems. Sorry ...\n"), "scifunction");
2414 if (Top - Rhs + Lhs + 1 >= Bot)
2416 Scierror(18, _("%s: Too many names.\n"), "scifunction");
2419 /* ireftop used to reset top if an error occurs during
2420 * the function evaluation */
2421 ireftop = Top - Max(0, Rhs);
2433 if (k == C2F(recu).krec)
2435 Scierror(22, _("%s: Recursion problems. Sorry ...\n"), "scifunction");
2438 C2F(recu).krec = -1;
2444 if (!C2F(allowptr) (&k))
2449 C2F(callinterf) (&k);
2451 C2F(recu).krec = -1;
2452 if (C2F(com).fun >= 0)
2454 if (Top - Lhs + 1 > 0)
2456 C2F(iset) (&Rhs, &cx0, &C2F(vstk).infstk[Top - Lhs], &cx1);
2458 if (C2F(recu).paus > 0)
2462 if (C2F(errgst).err1 > 0)
2468 /* called interface ask for a scilab function to perform the function (fun=-1)
2469 * the function name is given in ids(1,pt+1)
2471 /* call ref2val removed here because if forces overloading function to
2472 * be called by value
2475 C2F(funs) (&C2F(recu).ids[(C2F(recu).pt + 1) * nsiz - nsiz]);
2481 if (C2F(com).fun > 0)
2483 if (C2F(isbyref) (&C2F(com).fun) == 0)
2499 Fin = *Lstk(C2F(com).fin);
2500 C2F(recu).rstk[C2F(recu).pt - 1] = 910;
2501 C2F(recu).icall = 5;
2509 L97: /* error handling */
2510 if ((C2F(recu).niv > 0) && (C2F(recu).paus > 0))
2516 /* ************************** end of copy */
2518 Lhs = C2F(recu).ids[C2F(recu).pt * nsiz - nsiz];
2519 Rhs = C2F(recu).ids[C2F(recu).pt * nsiz - (nsiz - 1)];
2526 for (ix = 1; ix <= ix1; ++ix)
2528 lw = Top - Rhs + *number + ix - 1;
2529 C2F(intersci).ntypes[lw - 1] = '$';
2536 if (C2F(errgst).err1 > 0)
2538 Lhs = C2F(recu).ids[C2F(recu).pt * nsiz - nsiz];
2539 Rhs = C2F(recu).ids[C2F(recu).pt * nsiz - (nsiz - 1)];
2547 /*---------------------------------------------------------------------
2549 * executes scilab string (name of a scilab function) with mrhs
2550 * input args and mlhs output variables
2551 * input args are supposed to be indexed by ifirst,ifirst+1,...
2552 * thestring= string made of the name of a Scilab function
2553 * mlhs,mlhs = number of lhs and rhs parameters of the function
2554 * ifirst,thestring,mlhs and mrhs are input parameters.
2555 *---------------------------------------------------------------------*/
2557 int C2F(scistring) (int *ifirst, char *thestring, int *mlhs, int *mrhs, unsigned long thestring_len)
2560 int ifin = 0, ifun = 0, tops = 0;
2562 int lf = 0, op = 0, ils = 0, nnn = thestring_len;
2566 op = C2F(getopcode) (thestring, thestring_len);
2571 C2F(cvname) (id, thestring, &cx0, nnn);
2574 Top = Top - Rhs + *ifirst + *mrhs - 1;
2580 Scierror(999, _("%s: %s is not a Scilab function.\n"), "scistring", get_fname(thestring, thestring_len));
2584 if (C2F(com).fun <= 0)
2587 ret = C2F(scifunction) (ifirst, &lf, mlhs, mrhs);
2592 ifun = C2F(com).fun;
2593 ret = C2F(scibuiltin) (ifirst, &ifun, &ifin, mlhs, mrhs);
2598 ret = C2F(sciops) (ifirst, &op, mlhs, mrhs);
2603 int C2F(getopcode) (char *string, unsigned long string_len)
2605 unsigned char ch = string[0];
2608 if (string_len >= 2)
2648 /*---------------------------------------------------------------------
2649 * same as scifunction: executes scilab built-in function (ifin,ifun)
2651 * =(interface-number, function-nmber-in-interface)
2652 * for the input parameters located at number, number+1, ....
2653 * mlhs,mrhs = # of lhs and rhs parameters of the function.
2654 *---------------------------------------------------------------------*/
2656 int C2F(scibuiltin) (int *number, int *ifun, int *ifin, int *mlhs, int *mrhs)
2658 int srhs = 0, slhs = 0;
2659 int ix = 0, k = 0, intop = 0, lw = 0, pt0 = C2F(recu).pt;
2660 int imode = 0, ireftop = 0;
2664 if (intersci_push() == 0)
2666 Scierror(999, _("%s: No more memory.\n"), "scifunction");
2670 Top = Top - Rhs + *number + *mrhs - 1;
2675 C2F(recu).krec = -1;
2678 /* ***************************** copied from callinter.h */
2682 if (C2F(com).fun == 99)
2684 if (Err > 0 || C2F(errgst).err1 > 0)
2686 imode = abs(C2F(errgst).errct) / 100000 % 8;
2700 if (isRecursionCallToFunction())
2702 int gw = getRecursionGatewayToCall();
2704 if (gw == END_OVERLOAD)
2708 else if (gw == ERROR_GW_ID)
2722 Scierror(22, _("%s: Recursion problems. Sorry ...\n"), _("built in"));
2725 if (Top - Rhs + Lhs + 1 >= Bot)
2727 Scierror(18, _("%s: Too many names.\n"), "");
2730 /* ireftop used to reset top if an error occurs during
2731 * the function evaluation */
2732 ireftop = Top - Max(0, Rhs);
2744 if (k == C2F(recu).krec)
2746 Scierror(22, _("%s: Recursion problems. Sorry ...\n"), _("built in"));
2749 C2F(recu).krec = -1;
2753 if (C2F(recu).pt > pt0)
2761 if (!C2F(allowptr) (&k))
2766 C2F(callinterf) (&k);
2767 C2F(recu).krec = -1;
2768 if (C2F(com).fun >= 0)
2770 if (Top - Lhs + 1 > 0)
2772 C2F(iset) (&Lhs, &cx0, &C2F(vstk).infstk[Top - Lhs], &cx1);
2774 if (C2F(recu).paus > 0)
2778 if (C2F(errgst).err1 > 0)
2784 /* called interface ask for a sci function to perform the function (fun=-1) */
2785 /* the function name is given in ids(1,pt+1) */
2788 C2F(funs) (&C2F(recu).ids[(C2F(recu).pt + 1) * nsiz - nsiz]);
2793 if (C2F(com).fun > 0)
2795 if (C2F(isbyref) (&C2F(com).fun) == 0)
2811 Fin = *Lstk(C2F(com).fin);
2812 C2F(recu).rstk[C2F(recu).pt - 1] = 910;
2813 C2F(recu).icall = 5;
2821 L97: /* error handling */
2822 if ((C2F(recu).niv > 0) && (C2F(recu).paus > 0))
2827 /* ************************** end of copy */
2834 for (ix = 0; ix < *mlhs; ++ix)
2836 lw = Top - Rhs + *number + ix;
2837 C2F(intersci).ntypes[lw - 1] = '$';
2847 /*---------------------------------------------------------------------
2848 * same as scibuiltin: executes scilab operation op
2849 * for the input parameters located at number, number+1, ....
2850 * mlhs,mrhs = # of lhs and rhs parameters of the operation.
2851 *---------------------------------------------------------------------*/
2853 int C2F(sciops) (int *number, int *op, int *mlhs, int *mrhs)
2855 int ifin, ifun, srhs = Rhs, slhs = Lhs, ix, intop = Top, lw;
2858 Top = Top - Rhs + *number + *mrhs - 1;
2869 if (C2F(com).fun == 0)
2874 ifun = C2F(com).fun;
2876 if (!C2F(scibuiltin) (number, &ifun, &ifin, mlhs, mrhs))
2889 for (ix = 1; ix <= *mlhs; ++ix)
2891 lw = Top - Rhs + *number + ix - 1;
2892 C2F(intersci).ntypes[lw - 1] = '$';
2896 C2F(recu).icall = 0;
2900 /*-------------------------------------------------------------
2901 * test and return linear system (syslin tlist)
2902 * inputs: lw = variable number
2904 * N=size of A matrix (square)
2905 * M=number of inputs = col. dim B matrix
2906 * P=number of outputs = row. dim of C matrix
2907 * ptr(A,B,C,D,X0) adresses of A,B,C,D,X0 in stk
2908 * h=type h=0.0 continuous system
2909 * h=1.0 discrete time system
2910 * h=h sampled system h=sampling period
2911 -------------------------------------------------------------*/
2913 int C2F(getrhssys) (int *lw, int *n, int *m, int *p, int *ptra, int *ptrb, int *ptrc, int *ptrd, int *ptrx0, double *hx)
2915 int cx2 = 2, cx3 = 3, cx4 = 4, cx5 = 5, cx6 = 6;
2916 int ix1, junk, msys, nsys, ix, icord;
2917 int ma, na, mb, nb, mc, nc, il, md, nd;
2918 int mx0, nx0, ptrsys, itimedomain;
2920 static int iwork[23] = { 10, 1, 7, 0, 1, 4, 5, 6, 7, 8, 10, 12, 21, 28, 28, -10, -11,
2921 -12, -13, -33, 0, 13, 29
2923 if (!C2F(getrhsvar) (lw, "t", &msys, &nsys, &ptrsys, 1L))
2927 il = iadr(ptrsys) - msys - 1;
2928 /* syslin tlist=[ chain, (A,B,C,D,X0) ,chain or scalar ]
2931 junk = il + msys + iadr(*istk(il));
2932 if (*istk(junk) != 10)
2936 if (*istk(il + msys + iadr(*istk(il + 1))) != 1)
2940 if (*istk(il + msys + iadr(*istk(il + 2))) != 1)
2944 if (*istk(il + msys + iadr(*istk(il + 3))) != 1)
2948 if (*istk(il + msys + iadr(*istk(il + 4))) != 1)
2952 if (*istk(il + msys + iadr(*istk(il + 5))) != 1)
2956 itimedomain = *istk(il + msys + iadr(*istk(il + 6)));
2957 switch (itimedomain)
2960 /* Sys(7)='c' or 'd' */
2961 icord = *istk(il + msys + iadr(*istk(il + 6)) + 6);
2971 Scierror(999, _("Invalid time domain.\n"));
2977 ix1 = il + msys + iadr(*istk(il + 6)) + 4;
2978 *hx = *stk(sadr(ix1));
2981 Scierror(999, _("Invalid time domain.\n"));
2984 for (ix = 0; ix < 23; ++ix) /* @TODO : what is 23 ? */
2986 if (iwork[ix] != *istk(junk + ix))
2988 Scierror(999, _("Invalid system.\n"));
2992 if (!C2F(getlistrhsvar) (lw, &cx2, "d", &ma, &na, ptra, 1L))
2996 if (!C2F(getlistrhsvar) (lw, &cx3, "d", &mb, &nb, ptrb, 1L))
3000 if (!C2F(getlistrhsvar) (lw, &cx4, "d", &mc, &nc, ptrc, 1L))
3004 if (!C2F(getlistrhsvar) (lw, &cx5, "d", &md, &nd, ptrd, 1L))
3008 if (!C2F(getlistrhsvar) (lw, &cx6, "d", &mx0, &nx0, ptrx0, 1L))
3014 Scierror(999, _("A non square matrix!\n"));
3017 if (ma != mb && mb != 0)
3019 Scierror(999, _("Invalid %c,%c matrices.\n"), 'A', 'B');
3022 if (ma != nc && nc != 0)
3024 Scierror(999, _("Invalid %c,%c matrices.\n"), 'A', 'C');
3027 if (mc != md && md != 0)
3029 Scierror(999, _("Invalid %c,%c matrices.\n"), 'C', 'D');
3032 if (nb != nd && nd != 0)
3034 Scierror(999, _("Invalid %c,%c matrices.\n"), 'B', 'D');
3043 /*---------------------------------------------------
3044 * call Scilab error function (for Fortran use)
3045 *---------------------------------------------------*/
3047 int C2F(errorinfo) (char *fname, int *info, unsigned long fname_len)
3049 Scierror(998, _("%s: internal error, info=%d.\n"), get_fname(fname, fname_len), *info);
3053 /*-------------------------------------------------------------
3054 * returns Maximal available size in scilab stack
3055 * for variable <<number>> lw
3058 * type= 'd','r','i','c'
3059 * type_len is here for C/Fortran calling conventions
3060 * This function is used for creating a working array of Maximal dimension
3062 * lwork=Maxvol(nb,'d')
3063 * if(.not.createvar(nb,'d',lwork,1,idwork)) return
3064 * call pipo( ,stk(idwork),[lwork],...)
3065 *-------------------------------------------------------------*/
3067 int C2F(maxvol) (int *lw, char *lw_type, unsigned long type_len)
3069 unsigned char Type = *(unsigned char *)lw_type;
3071 /* I like this one a lot: a kind of free jazz pattern */
3072 int m = *Lstk(Bot) - sadr(iadr(*Lstk(*lw + Top - Rhs)) + 4);
3092 /* should never get there */
3096 /*---------------------------------------------
3097 * This function checks all the variables which
3098 * where references and restore their contents
3100 *---------------------------------------------*/
3102 static int Check_references()
3106 for (ivar = 1; ivar <= Rhs; ++ivar)
3108 unsigned char Type = (unsigned char)C2F(intersci).ntypes[ivar - 1];
3112 int lw = ivar + Top - Rhs;
3113 int il = iadr(*Lstk(lw));
3119 /* back conversion if necessary of a reference */
3122 il = iadr(*istk(il + 1));
3132 size = m * n * (it + 1);
3136 break; /* size is unsued for 'z' in ConvertData; */
3138 size = *istk(il + 4 + 1) - *istk(il + 4);
3146 ConvertData(&Type, size, C2F(intersci).lad[ivar - 1]);
3147 C2F(intersci).ntypes[ivar - 1] = '$';
3157 /*---------------------------------------------------------------------
3158 * int C2F(putlhsvar)()
3159 * This function put on the stack the lhs
3160 * variables which are at position lhsvar(i)
3161 * on the calling stack
3162 * Warning : this function supposes that the last
3163 * variable on the stack is at position top-rhs+nbvars
3164 *---------------------------------------------------------------------*/
3166 int C2F(putlhsvar) ()
3168 int ix2, ivar, ibufprec, ix, k, lcres, nbvars1;
3173 for (k = 1; k <= Lhs; k++)
3177 plhsk = *Lstk(LhsVar(k) + Top - Rhs);
3178 if (*istk(iadr(plhsk)) < 0)
3180 if (*Lstk(Bot) > *Lstk(*istk(iadr(plhsk) + 2)))
3182 LhsVar(k) = *istk(iadr(plhsk) + 2);
3189 if (Err > 0 || C2F(errgst).err1 > 0)
3193 if (C2F(com).fun == -1)
3196 } /* execution continue with an
3197 * overloaded function */
3200 Top = Top - Rhs + Lhs;
3201 C2F(objvide) (" ", &Top, 1L);
3206 for (k = 1; k <= Lhs; ++k)
3208 nbvars1 = Max(nbvars1, LhsVar(k));
3210 /* check if output variabe are in increasing order in the stack */
3213 for (ix = 1; ix <= Lhs; ++ix)
3215 if (LhsVar(ix) < ibufprec)
3222 ibufprec = LhsVar(ix);
3227 /* First pass if output variables are not
3228 * in increasing order
3230 for (ivar = 1; ivar <= Lhs; ++ivar)
3232 ix2 = Top - Rhs + nbvars1 + ivar;
3233 if (!C2F(mvfromto) (&ix2, &LhsVar(ivar)))
3237 LhsVar(ivar) = nbvars1 + ivar;
3238 /* I change type of variable nbvars1 + ivar
3239 * in order to just perform a dcopy at next pass
3241 if (nbvars1 + ivar > intersiz)
3243 Scierror(999, _("%s: intersiz is too small.\n"), "putlhsvar");
3246 C2F(intersci).ntypes[nbvars1 + ivar - 1] = '$';
3250 for (ivar = 1; ivar <= Lhs; ++ivar)
3252 ix2 = Top - Rhs + ivar;
3253 if (!C2F(mvfromto) (&ix2, &LhsVar(ivar)))
3258 Top = Top - Rhs + Lhs;
3264 /*---------------------------------------------------------------------
3266 * this routines copies the variable number i
3267 * (created by getrhsvar or createvar or by mvfromto itself in a precedent call)
3268 * from its position on the stack to position itopl
3269 * returns false if there's no more stack space available
3270 * - if type(i) # '$' : This variable is at
3271 * position lad(i) on the stack )
3272 * and itopl must be the first free position
3274 * copy is performed + type conversion (type(i))
3275 * - if type(i) == '$': then it means that object at position i
3276 * is the result of a previous call to mvfromto
3277 * a copyobj is performed and itopl can
3278 * can be any used position on the stack
3279 * the object which was at position itopl
3280 * is replaced by object at position i
3281 * (and access to object itopl+1 can be lost if
3282 * the object at position i is <> from object at
3284 *---------------------------------------------------------------------*/
3286 static int C2F(mvfromto) (int *itopl, int *ix)
3297 unsigned long int ilp = 0;
3301 Type = (unsigned char)C2F(intersci).ntypes[*ix - 1];
3304 /* int iwh = *ix + Top - Rhs;
3305 * ilp = iadr(*Lstk(iwh)); */
3306 int iwh = C2F(intersci).iwhere[*ix - 1];
3311 ilp = iadr(*istk(ilp + 1));
3315 it = *istk(ilp + 3);
3321 if (!C2F(cremat) ("mvfromto", itopl, &it, &m, &n, &lrs, &lcs, 8L))
3325 ix1 = m * n * (it + 1);
3326 C2F(stacki2d) (&ix1, &C2F(intersci).lad[*ix - 1], &lrs);
3327 C2F(intersci).lad[*ix - 1] = iadr(lrs);
3330 if (!C2F(cremat) ("mvfromto", itopl, &it, &m, &n, &lrs, &lcs, 8L))
3334 ix1 = m * n * (it + 1);
3335 C2F(stackr2d) (&ix1, &C2F(intersci).lad[*ix - 1], &lrs);
3336 C2F(intersci).lad[*ix - 1] = iadr(lrs);
3339 if (!C2F(cremat) ("mvfromto", itopl, &it, &m, &n, &lrs, &lcs, 8L))
3343 /* no copy if the two objects are the same
3344 * the cremat above is kept to deal with possible size changes
3346 if (C2F(intersci).lad[*ix - 1] != lrs)
3348 ix1 = m * n * (it + 1);
3349 l = C2F(intersci).lad[*ix - 1];
3350 if (abs(l - lrs) < ix1)
3352 C2F(unsfdcopy) (&ix1, stk(l), &cx1, stk(lrs), &cx1);
3356 C2F(dcopy) (&ix1, stk(l), &cx1, stk(lrs), &cx1);
3358 C2F(intersci).lad[*ix - 1] = lrs;
3362 if (*istk(ilp) == 133)
3364 wsave = *stk(C2F(intersci).lad[*ix - 1]);
3368 if (!C2F(cremat) ("mvfromto", itopl, &it, &m, &n, &lrs, &lcs, 8L))
3372 z2double(stk(C2F(intersci).lad[*ix - 1]), stk(lrs), m * n, m * n);
3374 C2F(intersci).lad[*ix - 1] = lrs;
3378 if (!C2F(cremat) ("mvfromto", itopl, &it, &m, &n, &lrs, &lcs, 8L))
3382 z2double(stk(C2F(intersci).lad[*ix - 1]), stk(lrs), m * n, m * n);
3383 C2F(intersci).lad[*ix - 1] = lrs;
3387 m = *istk(ilp + 4 + 1) - *istk(ilp + 4);
3390 if (!C2F(cresmat2) ("mvfromto", itopl, &ix1, &lrs, 8L))
3394 C2F(stackc2i) (&ix1, &C2F(intersci).lad[*ix - 1], &lrs);
3395 C2F(intersci).lad[*ix - 1] = cadr(lrs);
3399 if (!C2F(crebmat) ("mvfromto", itopl, &m, &n, &lrs, 8L))
3404 C2F(icopy) (&ix1, istk(C2F(intersci).lad[*ix - 1]), &cx1, istk(lrs), &cx1);
3405 C2F(intersci).lad[*ix - 1] = lrs;
3408 /* reference '-' = ascii(45) */
3409 ilp = iadr(*Lstk(*ix));
3410 size = *istk(ilp + 3);
3411 pointed = *istk(ilp + 2);
3412 if (!C2F(cremat) ("mvfromto", itopl, (it = 0, &it), (m = 1, &m), &size, &lrs, &lcs, 8L))
3416 if (C2F(vcopyobj) ("mvfromto", &pointed, itopl, 8L) == FALSE)
3422 if (!C2F(crehmat) ("mvfromto", itopl, &m, &n, &lrs, 8L))
3426 /* no copy if the two objects are the same
3427 * the cremat above is kept to deal with possible size changes
3429 if (C2F(intersci).lad[*ix - 1] != lrs)
3432 l = C2F(intersci).lad[*ix - 1];
3433 if (abs(l - lrs) < ix1)
3435 C2F(unsfdcopy) (&ix1, stk(l), &cx1, stk(lrs), &cx1);
3439 C2F(dcopy) (&ix1, stk(l), &cx1, stk(lrs), &cx1);
3441 C2F(intersci).lad[*ix - 1] = lrs;
3447 if (Top - Rhs + *ix != *itopl)
3449 ix1 = Top - Rhs + *ix;
3450 if (C2F(vcopyobj) ("mvfromto", &ix1, itopl, 8L) == FALSE)
3459 /*---------------------------------------------------------------------
3461 * copy object at position from to position to
3462 * without changing data.
3463 * The copy is only performed if object is a reference
3464 * and ref object is replaced by its value
3465 *---------------------------------------------------------------------*/
3467 int Ref2val(int from, int to)
3471 lw = from + Top - Rhs;
3474 Scierror(999, _("%s: bad call to %s! (1rst argument).\n"), "copyref", "isref");
3477 il = iadr(*Lstk(lw));
3482 /* from contains a reference */
3484 lwd = to + Top - Rhs;
3485 C2F(copyobj) ("copyref", &lw, &lwd, (unsigned long)strlen("copyref"));
3490 /*---------------------------------------------------------------------
3492 * this routine converts data of variable number num
3493 * to scilab standard data code
3494 * see how it is used in matdes.c
3495 *---------------------------------------------------------------------*/
3497 int C2F(convert2sci) (int *ix)
3499 int ix1 = Top - Rhs + *ix;
3501 if (!C2F(mvfromto) (&ix1, ix))
3505 C2F(intersci).ntypes[*ix - 1] = '$';
3509 /*-----------------------------------------------------------
3510 * strcpy_tws : fname[0:nlgh-2]=' '
3511 * fname[nlgh-1] = '\0'
3512 * then second string is copied into first one
3513 * ------------------------------------------------------------*/
3515 void strcpy_tws(char *str1, char *str2, int len)
3519 for (i = 0; i < (int)strlen(str2); i++)
3523 for (i = (int)strlen(str2); i < len; i++)
3527 str1[len - 1] = '\0';
3530 /*---------------------------------------------------------------------
3531 * conversion from Scilab code --> ascii
3532 * + add a 0 at end of string
3533 *---------------------------------------------------------------------*/
3535 int C2F(in2str) (int *n, int *line, char *str, unsigned long str_len)
3537 C2F(codetoascii) (n, line, str, str_len);
3542 /*---------------------------------------------------------------------
3544 * Get the name (interfcae name) which was stored in ids while in checkrhs
3545 *---------------------------------------------------------------------*/
3547 static char Fname[nlgh + 1];
3549 static char *Get_Iname()
3553 C2F(cvname) (&C2F(recu).ids[(C2F(recu).pt + 1) * nsiz - nsiz], Fname, &cx1, nlgh);
3554 /** remove trailing blanks **/
3555 for (i = 0; i < nlgh; i++)
3556 if (Fname[i] == ' ')
3565 /*---------------------------------------------------------------------
3566 * Utility for error message
3567 *---------------------------------------------------------------------*/
3569 static char arg_position[56]; /* @TODO WTF is 56 ? */
3571 char *CharPosition(int i)
3573 char *tmp_buffer = NULL;
3578 tmp_buffer = strdup(_("first"));
3581 tmp_buffer = strdup(_("second"));
3584 tmp_buffer = strdup(_("third"));
3587 tmp_buffer = strdup(_("fourth"));
3590 tmp_buffer = strdup(" ");
3596 char *ArgPosition(int i)
3598 char *tmp_buffer = NULL;
3600 if (i > 0 && i <= 4)
3602 tmp_buffer = CharPosition(i - 1);
3603 sprintf(arg_position, _("%s argument"), tmp_buffer);
3608 sprintf(arg_position, _("argument #%d"), i);
3610 return arg_position;
3613 char *ArgsPosition(int i, int j)
3615 char *tmp_buffer_1 = NULL, *tmp_buffer_2 = NULL;
3617 if (i > 0 && i <= 4)
3619 if (j > 0 && j <= 4)
3621 tmp_buffer_1 = CharPosition(i - 1);
3622 tmp_buffer_2 = CharPosition(j - 1);
3623 sprintf(arg_position, _("%s and %s arguments"), tmp_buffer_1, tmp_buffer_2);
3629 tmp_buffer_1 = CharPosition(i - 1);
3630 sprintf(arg_position, _("%s argument and argument #%d"), tmp_buffer_1, j);
3636 if (j > 0 && j <= 4)
3638 tmp_buffer_1 = CharPosition(j - 1);
3639 sprintf(arg_position, _("%s argument and argument #%d"), tmp_buffer_1, i);
3644 sprintf(arg_position, _("arguments #%d and #%d"), i, j);
3647 return arg_position;
3650 /*---------------------------------------------------------------------
3651 * Utility for back convertion to Scilab format
3652 * (can be used with GetListRhsVar )
3653 *---------------------------------------------------------------------*/
3655 static void ConvertData(unsigned char *type, int size, int l)
3657 int zero = 0, mu = -1;
3665 C2F(cvstr1) (&size, (int *)cstk(l), cstk(l), &zero, size);
3668 C2F(rea2db) (&size, sstk(l), &mu, (double *)sstk(l), &mu);
3671 C2F(int2db) (&size, istk(l), &mu, (double *)istk(l), &mu);
3674 if (*istk(iadr(iadr(l)) - 2) == 133)
3676 /* values @ even adress */
3677 prov = *istk(iadr(iadr(l)) - 1);
3679 n = *istk(prov + 1);
3682 wsave = *stk(laddr);
3684 *istk(iadr(iadr(l)) - 2) = 1;
3685 *istk(iadr(iadr(l)) - 1) = m;
3686 *istk(iadr(iadr(l))) = n;
3687 *istk(iadr(iadr(l)) + 1) = it;
3688 /* convert values */
3689 z2double(stk(laddr), stk(laddr + 1), m * n, m * n);
3690 *stk(laddr + 1) = wsave;
3694 F77ToSci((double *)zstk(l), size, size);
3699 /*---------------------------------------------------------------------
3700 * Utility for checking properties
3701 *---------------------------------------------------------------------*/
3703 static int check_prop(char *mes, int posi, int m)
3707 /* XXXX moduler 999 en fn des messages */
3708 Scierror(999, "%s: %s %s\n", Get_Iname(), ArgPosition(posi), mes);
3714 int check_square(int posi, int m, int n)
3716 return check_prop(_("should be square"), posi, m != n);
3719 int check_vector(int posi, int m, int n)
3721 return check_prop(_("should be a vector"), posi, m != 1 && n != 1);
3724 int check_row(int posi, int m, int n)
3726 return check_prop(_("should be a row vector"), posi, m != 1);
3729 int check_col(int posi, int m, int n)
3731 return check_prop(_("should be a column vector"), posi, n != 1);
3734 int check_scalar(int posi, int m, int n)
3736 return check_prop(_("should be a scalar"), posi, n != 1 || m != 1);
3739 int check_dims(int posi, int m, int n, int m1, int n1)
3741 if (m != m1 || n != n1)
3743 Scierror(999, _("%s: %s has wrong dimensions (%d,%d), expecting (%d,%d).\n"), Get_Iname(), ArgPosition(posi), m, n, m1, n1);
3749 int check_one_dim(int posi, int dim, int val, int valref)
3753 Scierror(999, _("%s: %s has wrong %s dimension (%d), expecting (%d).\n"), Get_Iname(), ArgPosition(posi),
3754 (dim == 1) ? _("first") : _("second"), val, valref);
3760 int check_length(int posi, int m, int m1)
3764 Scierror(999, _("%s: %s has wrong length %d, expecting (%d).\n"), Get_Iname(), ArgPosition(posi), m, m1);
3770 int check_same_dims(int i, int j, int m1, int n1, int m2, int n2)
3772 if (m1 == m2 && n1 == n2)
3776 Scierror(999, _("%s: %s have incompatible dimensions (%dx%d) # (%dx%d)\n"), Get_Iname(), ArgsPosition(i, j), m1, n1, m2, n2);
3780 int check_dim_prop(int i, int j, int flag)
3784 Scierror(999, _("%s: %s have incompatible dimensions.\n"), Get_Iname(), ArgsPosition(i, j));
3790 static int check_list_prop(char *mes, int lpos, int posi, int m)
3794 Scierror(999, _("%s: %s should be a list with %d-element being %s.\n"), Get_Iname(), ArgPosition(posi), posi, mes);
3800 int check_list_square(int lpos, int posi, int m, int n)
3802 return check_list_prop(_("square"), lpos, posi, (m != n));
3805 int check_list_vector(int lpos, int posi, int m, int n)
3807 return check_list_prop(_("a vector"), lpos, posi, m != 1 && n != 1);
3810 int check_list_row(int lpos, int posi, int m, int n)
3812 return check_list_prop(_("a row vector"), lpos, posi, m != 1);
3815 int check_list_col(int lpos, int posi, int m, int n)
3817 return check_list_prop(_("a column vector"), lpos, posi, n != 1);
3820 int check_list_scalar(int lpos, int posi, int m, int n)
3822 return check_list_prop(_("a scalar"), lpos, posi, n != 1 || m != 1);
3825 int check_list_one_dim(int lpos, int posi, int dim, int val, int valref)
3829 Scierror(999, _("%s: argument %d(%d) has wrong %s dimension (%d), expecting (%d).\n"), Get_Iname(), lpos, posi,
3830 (dim == 1) ? _("first") : _("second"), val, valref);
3836 /*---------------------------------------------------------------------
3837 * Utility for hand writen data extraction or creation
3838 *---------------------------------------------------------------------*/
3840 int C2F(createdata) (int *lw, int n)
3843 char *fname = Get_Iname();
3847 Scierror(999, _("%s: (%s) too many arguments in the stack edit stack.h and enlarge intersiz.\n"), fname, "createdata");
3850 Nbvars = Max(*lw, Nbvars);
3851 lw1 = *lw + Top - Rhs;
3854 Scierror(999, _("%s: bad call to %s! (1rst argument).\n"), fname, "createdata");
3857 if (!C2F(credata) (fname, &lw1, n, nlgh))
3861 C2F(intersci).ntypes[*lw - 1] = '$';
3862 C2F(intersci).iwhere[*lw - 1] = *Lstk(lw1);
3863 C2F(intersci).lad[*lw - 1] = *Lstk(lw1);
3867 /*---------------------------------------------------------------------
3869 * copy a Scilab variable given by
3870 * - its first adress l in stk
3872 * to the variable position lw
3873 *----------------------------------------------------------------------*/
3874 int C2F(copyvarfromsciptr) (int lw, int n, int l)
3878 if ((ret = C2F(createdata) (&lw, n)) == FALSE)
3882 C2F(unsfdcopy) (&n, stk(l), &un, stk(*Lstk(lw + Top - Rhs)), &un);
3886 void *GetVarPtr(int n)
3887 /* return the pointer on the first int of the n th variable data structure */
3889 int l1 = *Lstk(n + Top - Rhs);
3890 int *loci = (int *)stk(l1);
3895 void *GetData(int lw)
3896 /* Usage: header = (int *) GetData(lw); header[0] = type of variable lw etc */
3898 int lw1 = lw + Top - Rhs;
3899 int l1 = *Lstk(lw1);
3900 int *loci = (int *)stk(l1);
3905 loci = (int *)stk(l1);
3907 C2F(intersci).ntypes[lw - 1] = '$';
3908 C2F(intersci).iwhere[lw - 1] = l1;
3909 C2F(intersci).lad[lw - 1] = l1;
3913 int GetDataSize(int lw)
3914 /* get memory used by the argument lw in double world etc */
3916 int lw1 = lw + Top - Rhs;
3917 int l1 = *Lstk(lw1);
3918 int *loci = (int *)stk(l1);
3919 int n = *Lstk(lw1 + 1) - *Lstk(lw1);
3924 loci = (int *)stk(l1);
3930 void *GetRawData(int lw)
3931 /* same as GetData BUT does not go to the pointed variable if lw is a reference */
3933 int lw1 = lw + Top - Rhs;
3934 int l1 = *Lstk(lw1);
3935 int *loci = (int *)stk(l1);
3937 C2F(intersci).ntypes[lw - 1] = '$';
3938 C2F(intersci).iwhere[lw - 1] = l1;
3939 /* C2F(intersci).lad[lw - 1] = l1; to be checked */
3943 void *GetDataFromName(char *name)
3944 /* usage: header = (int *) GetDataFromName("pipo"); header[0] = type of variable pipo etc... */
3950 if (C2F(objptr) (name, &lw, &fin, (unsigned long)strlen(name)))
3952 header = istk(iadr(*Lstk(fin)));
3953 return (void *)header;
3957 Scierror(999, _("GetDataFromName: variable %s not found.\n"), name);
3962 int C2F(createreference) (int number, int pointed)
3963 /* variable number is created as a reference to variable pointed */
3969 CreateData(number, 4 * sizeof(int));
3970 header = GetRawData(number);
3972 point_ed = offset + pointed;
3973 header[0] = -*istk(iadr(*Lstk(point_ed))); /* reference : 1st entry (type) is opposite */
3974 header[1] = *Lstk(point_ed); /* pointed adress */
3975 header[2] = point_ed; /* pointed variable */
3976 header[3] = *Lstk(point_ed + 1) - *Lstk(point_ed); /* size of pointed variable */
3977 C2F(intersci).ntypes[number - 1] = '-';
3981 int C2F(changetoref) (int number, int pointed)
3982 /* variable number is changed as a reference to variable pointed */
3988 header = GetRawData(number);
3990 point_ed = offset + pointed;
3991 header[0] = -*istk(iadr(*Lstk(point_ed))); /* reference : 1st entry (type) is opposite */
3992 header[1] = *Lstk(point_ed); /* pointed adress */
3993 header[2] = pointed; /* pointed variable */
3994 header[3] = *Lstk(point_ed + 1) - *Lstk(point_ed); /* size of pointed variable */
3995 C2F(intersci).ntypes[number - 1] = '-';
3999 int C2F(createreffromname) (int number, char *name)
4000 /* variable number is created as a reference pointing to variable "name" */
4001 /* name must be an existing Scilab variable */
4007 CreateData(number, 4 * sizeof(int));
4008 header = (int *)GetData(number);
4009 if (C2F(objptr) (name, &lw, &fin, (unsigned long)strlen(name)))
4011 header[0] = -*istk(iadr(*Lstk(fin))); /* type of reference = - type of pointed variable */
4012 header[1] = lw; /* pointed adress */
4013 header[2] = fin; /* pointed variable */
4014 header[3] = *Lstk(fin + 1) - *Lstk(fin); /*size of pointed variable */
4019 Scierror(999, _("%s: Variable %s not found.\n"), "CreateRefFromName", name);
4024 /*-------------------------------------------------------
4025 * protect the intersci common during recursive calls
4026 *-------------------------------------------------------*/
4028 typedef struct inter_s_
4030 int iwhere, nbrows, nbcols, itflag, ntypes, lad, ladc, lhsvar;
4033 typedef struct inter_l
4035 intersci_state *state;
4037 struct inter_l *next;
4040 static intersci_list *L_intersci;
4042 static int intersci_push(void)
4046 intersci_state *new = NULL;
4050 new = MALLOC(Nbvars * sizeof(intersci_state));
4057 loc = MALLOC(sizeof(intersci_list));
4062 loc->next = L_intersci;
4064 loc->nbvars = Nbvars;
4065 for (i = 0; i < Nbvars; i++)
4067 loc->state[i].iwhere = C2F(intersci).iwhere[i];
4068 loc->state[i].ntypes = C2F(intersci).ntypes[i];
4069 loc->state[i].lad = C2F(intersci).lad[i];
4070 loc->state[i].lhsvar = C2F(intersci).lhsvar[i];
4076 static void intersci_pop(void)
4079 intersci_list *loc = L_intersci;
4085 Nbvars = loc->nbvars;
4086 for (i = 0; i < Nbvars; i++)
4088 C2F(intersci).iwhere[i] = loc->state[i].iwhere;
4089 C2F(intersci).ntypes[i] = loc->state[i].ntypes;
4090 C2F(intersci).lad[i] = loc->state[i].lad;
4091 C2F(intersci).lhsvar[i] = loc->state[i].lhsvar;
4093 L_intersci = loc->next;
4106 static void intersci_show()
4109 fprintf(stderr,"======================\n");
4110 for ( i = 0 ; i < C2F(intersci).nbvars ; i++ )
4112 fprintf(stderr,"%d %d %d\n",i,
4113 C2F(intersci).iwhere[i],
4114 C2F(intersci).ntypes[i]);
4116 fprintf(stderr,"======================\n");