Annotation of OpenXM_contrib/pari-2.2/src/gp/gp_init.c, Revision 1.2
1.2 ! noro 1: /* $Id: gp_init.c,v 1.17 2002/09/07 21:52:27 cvsadmin Exp $
1.1 noro 2:
3: Copyright (C) 2000 The PARI group.
4:
5: This file is part of the PARI/GP package.
6:
7: PARI/GP is free software; you can redistribute it and/or modify it under the
8: terms of the GNU General Public License as published by the Free Software
9: Foundation. It is distributed in the hope that it will be useful, but WITHOUT
10: ANY WARRANTY WHATSOEVER.
11:
12: Check the License for details. You should have received a copy of it, along
13: with the package; see the file 'COPYING'. If not, write to the Free Software
14: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
15:
16: /*******************************************************************/
17: /* */
18: /* GP-SPECIFIC FUNCTIONS */
19: /* */
20: /*******************************************************************/
21: #include "pari.h"
22: #include "../graph/rect.h"
1.2 ! noro 23: #include "../language/anal.h"
! 24: #include "gp.h"
1.1 noro 25:
1.2 ! noro 26: extern void allocatemem0(size_t newsize);
1.1 noro 27: extern GEN default0(char *a, char *b, long flag);
28: extern void error0(GEN *g);
29: extern GEN extern0(char *cmd);
30: extern void gp_quit(void);
1.2 ! noro 31: extern GEN input0(void);
1.1 noro 32: extern void kill0(entree *ep);
33: extern void print0(GEN *g,long flag);
34: extern GEN read0(char *s);
35: extern void system0(char *cmd);
36: extern GEN trap0(char *e, char *f, char *r);
37: extern int whatnow(char *s, int silent);
38:
1.2 ! noro 39: static void whatnow0(char *s) { whatnow(s,0); }
1.1 noro 40:
41: entree functions_gp[]={
42: {"allocatemem",0,(void*)allocatemem0,11,"vD0,L,"},
43: {"default",0,(void*)default0,11,"D\"\",r,D\"\",s,D0,L,"},
44: {"error",0,(void*)error0,11,"vs*"},
45: {"extern",1,(void*)extern0,11,"s"},
46: {"input",0,(void*)input0,11,""},
47: {"global",88,NULL,11,NULL},
1.2 ! noro 48: {"print",0,(void*)print,11,"vs*"},
! 49: {"print1",0,(void*)print1,11,"vs*"},
! 50: {"printp",0,(void*)printp,11,"vs*"},
! 51: {"printp1",0,(void*)printp1,11,"vs*"},
! 52: {"printtex",0,(void*)printtex,11,"vs*"},
1.1 noro 53: {"quit",0,(void*)gp_quit,11,"v"},
54: {"read",0,(void*)read0,11,"D\"\",s,"},
55: {"system",70,(void*)system0,11,"vs"},
1.2 ! noro 56: {"trap",0,(void*)trap0,11,"D\"\",r,DIDI"},
1.1 noro 57: {"whatnow",1,(void*)whatnow0,11,"vr"},
1.2 ! noro 58: {"write",99,(void*)write0,11,"vss*"},
! 59: {"write1",99,(void*)write1,11,"vss*"},
1.1 noro 60: {"writebin",99,(void*)gpwritebin,11,"vsDG"},
1.2 ! noro 61: {"writetex",99,(void*)writetex,11,"vss*"},
1.1 noro 62:
63: {NULL,0,NULL,0,NULL} /* sentinel */
64: };
65:
66: char *helpmessages_gp[]={
67: "allocatemem({s=0}): allocates a new stack of s bytes. doubles the stack if s is omitted",
68: "default({opt},{v},{flag}): set the default opt to v. If v is omitted, print the current default for opt. If no argument is given, print a list of all defaults as well as their values. If flag is non-zero, return the result instead of printing it on screen. See manual for details",
69: "error(\"msg\"): abort script with error message msg",
70: "extern(cmd): execute shell command cmd, and feeds the result to GP (as if loading from file)",
71: "input(): read an expression from the input file or standard input",
72: "global(x): declare x to be a global variable",
73: "print(a): outputs a (in raw format) ending with newline",
74: "print1(a): outputs a (in raw format) without ending with newline",
75: "printp(a): outputs a (in beautified format) ending with newline",
76: "printp1(a): outputs a (in beautified format) without ending with newline",
77: "printtex(a): outputs a in TeX format",
78: "quit(): quits GP and return to the system",
79: "read({filename}): read from the input file filename. If filename is omitted, reread last input file (be it from readfile or \\r)",
80: "system(a): a being a string, execute the system command a (not valid on every machine)",
81: "trap({err}, {rec}, {seq}): try to execute seq, trapping error err (all of them if err ommitted); sequence rec is executed if the error occurs and is the result of the command. When seq is omitted, define rec as a default handler for error err (a break loop will be started if rec omitted). If rec is the empty string \"\" pop out the last default handler",
82: "whatnow(fun): if f was present in GP version 1.39.15 or lower, gives the new function name",
83: "write(filename,a): write the string expression a (same output as print) to filename",
84: "write1(filename,a): write the string expression a (same output as print1) to filename",
85: "writebin(filename,{x}): write x as a binary object to file filename. If x is omitted, write all session variables",
86: "writetex(filename,a): write the string expression a (same format as print) to filename, in TeX format",
87: };
88:
89: /* Backward Compatibility */
90:
91: static GEN
92: gtype(GEN x)
93: {
94: return stoi(typ(x));
95: }
96:
97: static GEN
98: gsettype(GEN x,long t)
99: {
100: x=gcopy(x); settyp(x,t); return x;
101: }
102:
103: static long
104: setserieslength(long n)
105: {
106: long m=precdl;
107: if(n>0) precdl=n;
108: return m;
109: }
110:
1.2 ! noro 111: static long
! 112: setprecr(long n)
! 113: {
! 114: long m = GP_DATA->fmt->sigd;
! 115: if (n > 0) { GP_DATA->fmt->sigd = n; prec = (long)(n*pariK1 + 3); }
! 116: return m;
! 117: }
! 118:
1.1 noro 119: entree functions_oldgp[] = {
120: {"allocatemem",11,(void *)allocatemem0,2,"vLp"},
121: {"box",35,(void *)rectbox,10,"vLGG"},
122: {"color",2,(void *)rectcolor,2,"vLL"},
123: {"cursor",11,(void*)rectcursor,10,"vLp"},
124: {"default",0,(void*)default0,11,"D\"\",r,D\"\",s,D0,L,"},
125: {"draw",1,(void*)rectdraw,10,"vGp"},
126: {"initrect",34,(void*)initrect,10,"vLLL"},
127: {"kill",85,(void*)kill0,11,"vS"},
128: {"killrect",11,(void *)killrect,10,"vL"},
129: {"line",35,(void *)rectline,10,"vLGG"},
130: {"lines",35,(void *)rectlines,10,"vLGG"},
131: {"move",35,(void*)rectmove,10,"vLGG"},
132: {"plot",99,(void *)plot,10,"vV=GGIDGDGp"},
133: {"ploth",37,(void *)ploth,10,"V=GGIp"},
134: {"ploth2",37,(void *)ploth2,10,"V=GGIp"},
135: {"plothmult",37,(void *)plothmult,10,"V=GGIp"},
136: {"plothraw",2,(void *)plothraw,10,"GGp"},
137: {"point",35,(void *)rectpoint,10,"vLGG"},
138: {"points",35,(void *)rectpoints,10,"vLGG"},
139: {"postdraw",1,(void *)postdraw,10,"vG"},
140: {"postploth",37,(void *)postploth,10,"V=GGIpD0,L,D0,L,"},
141: {"postploth2",37,(void *)postploth2,10,"V=GGIpD0,L,"},
142: {"postplothraw",2,(void *)postplothraw,10,"GGD0,L,"},
1.2 ! noro 143: {"pprint",0,(void*)printp,11,"vs*"},
! 144: {"pprint1",0,(void*)printp1,11,"vs*"},
! 145: {"print",0,(void*)print,11,"vs*"},
! 146: {"print1",0,(void*)print1,11,"vs*"},
1.1 noro 147: {"rbox",35,(void *)rectrbox,10,"vLGG"},
148: {"read",0,(void *)input0,11,""},
149: {"rline",35,(void *)rectrline,10,"vLGG"},
150: {"rlines",35,(void *)rectlines,10,"vLGG"},
151: {"rmove",35,(void *)rectrmove,10,"vLGG"},
152: {"rpoint",35,(void *)rectrpoint,10,"vLGG"},
153: {"rpoints",35,(void *)rectpoints,10,"vLGG"},
154: {"scale",59,(void *)rectscale,10,"vLGGGG"},
155: {"setprecision",15,(void *)setprecr,2,"lL"},
156: {"setserieslength",15,(void *)setserieslength,2,"lL"},
157: {"settype",21,(void *)gsettype,2,"GL"},
158: {"string",57,(void*)rectstring,10,"vLs"},
159: {"system",70,(void*) system0,11,"vs"},
1.2 ! noro 160: {"texprint",0,(void*)printtex,11,"vs*"},
1.1 noro 161: {"type",1,(void *)gtype,2,"Gp"},
162:
163: {NULL,0,NULL,0,NULL} /* sentinel */
164: };
165:
166: char *helpmessages_oldgp[] = {
167: "allocatemem(s)=allocates a new stack of s bytes, or doubles the stack if size is 0",
168: "box(w,x2,y2)=if the cursor is at position (x1,y1), draw a box with diagonal (x1,y1) and (x2,y2) in rectwindow w (cursor does not move)",
169: "color(w,c)=set default color to c in rectwindow. Possible values for c are 1=sienna, 2=cornsilk, 3=red, 4=black, 5=grey, 6=blue, 7=gainsborough",
170: "cursor(w)=current position of cursor in rectwindow w",
171: "default({opt},{v},{flag}): set the default opt to v. If v is omitted, print the current default for opt. If no argument is given, print a list of all defaults as well as their values. If flag is non-zero, return the result instead of printing it on screen. See manual for details",
172: "draw(list)=draw vector of rectwindows list at indicated x,y positions; list is a vector w1,x1,y1,w2,x2,y2,etc...",
173: "initrect(w,x,y)=initialize rectwindow w to size x,y",
174: "kill(x)= kills the present value of the variable or function x. Returns new value or 0",
175: "killrect(w)=erase the rectwindow w",
176: "line(w,x2,y2)=if cursor is at position (x1,y1), draw a line from (x1,y1) to (x2,y2) (and move the cursor) in the rectwindow w",
177: "lines(w,listx,listy)=draws an open polygon in rectwindow w where listx and listy contain the x (resp. y) coordinates of the vertices",
178: "move(w,x,y)=move cursor to position x,y in rectwindow w",
179: "plot(X=a,b,expr)=crude plot of expression expr, X goes from a to b",
180: "ploth(X=a,b,expr)=plot of expression expr, X goes from a to b in high resolution",
181: "ploth2(X=a,b,[expr1,expr2])=plot of points [expr1,expr2], X goes from a to b in high resolution",
182: "plothmult(X=a,b,[expr1,...])=plot of expressions expr1,..., X goes from a to b in high resolution",
183: "plothraw(listx,listy)=plot in high resolution points whose x (resp. y) coordinates are in listx (resp. listy)",
184: "point(w,x,y)=draw a point (and move cursor) at position x,y in rectwindow w",
185: "points(w,listx,listy)=draws in rectwindow w the points whose x (resp y) coordinates are in listx (resp listy)",
186: "postdraw(list)=same as plotdraw, except that the output is a PostScript program in file \"pari.ps\"",
187: "postploth(X=a,b,expr)=same as ploth, except that the output is a PostScript program in the file \"pari.ps\"",
188: "postploth2(X=a,b,[expr1,expr2])=same as ploth2, except that the output is a PostScript program in the file \"pari.ps\"",
189: "postplothraw(listx,listy)=same as plothraw, except that the output is a PostScript program in the file \"pari.ps\"",
190: "pprint(a)=outputs a in beautified format ending with newline",
191: "pprint1(a)=outputs a in beautified format without ending with newline",
192: "print(a)=outputs a in raw format ending with newline",
193: "print1(a)=outputs a in raw format without ending with newline",
194: "rbox(w,dx,dy)=if the cursor is at (x1,y1), draw a box with diagonal (x1,y1)-(x1+dx,y1+dy) in rectwindow w (cursor does not move)",
195: "read()=read an expression from the input file or standard input",
196: "rline(w,dx,dy)=if the cursor is at (x1,y1), draw a line from (x1,y1) to (x1+dx,y1+dy) (and move the cursor) in the rectwindow w",
197: "rlines(w,dx,dy)=draw in rectwindow w the points given by vector of first coordinates xsand vector of second coordinates, connect them by lines",
198: "rmove(w,dx,dy)=move cursor to position (dx,dy) relative to the present position in the rectwindow w",
199: "rpoint(w,dx,dy)=draw a point (and move cursor) at position dx,dy relative to present position of the cursor in rectwindow w",
200: "rpoints(w,xs,ys)=draw in rectwindow w the points given by vector of first coordinates xs and vector of second coordinates ys",
201: "scale(w,x1,x2,y1,y2)=scale the coordinates in rectwindow w so that x goes from x1 to x2 and y from y1 to y2 (y2<y1 is allowed)",
202: "setprecision(n)=set the current precision to n decimal digits if n>0, or return the current precision if n<=0",
203: "setserieslength(n)=set the default length of power series to n if n>0, or return the current default length if n<=0",
204: "settype(x,t)=make a copy of x with type t (to use with extreme care)",
205: "string(w,x)=draw in rectwindow w the string corresponding to x, where x is either a string, or a number in R, written in format 9.3",
206: "system(a): a being a string, execute the system command a (not valid on every machine)",
207: "texprint(a)=outputs a in TeX format",
208: "type(x)=internal type number of the GEN x"
209: };
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>