[b6b6153] | 1 | /////////////////////////////////////////////////////////////////////////////// |
---|
[341696] | 2 | version="$Id$"; |
---|
[f5254ec] | 3 | category="Visualization"; |
---|
[651b46] | 4 | info=" |
---|
[5bc214c] | 5 | LIBRARY: latex.lib Typesetting of Singular-Objects in LaTeX2e |
---|
[f34c37c] | 6 | AUTHOR: Christian Gorzel, gorzelc@math.uni-muenster.de |
---|
| 7 | |
---|
[1057ab5] | 8 | GLOBAL VARIABLES: |
---|
| 9 | TeXwidth, TeXnofrac, TeXbrack, TeXproj, TeXaligned, TeXreplace, NoDollars |
---|
| 10 | are used to control the typesetting. |
---|
| 11 | Call @code{texdemo();} to obtain a LaTeX2e file @code{texlibdemo.tex} |
---|
| 12 | explaining the features of @code{latex.lib} and its global variables. |
---|
| 13 | @format |
---|
| 14 | @code{TeXwidth} (int) -1, 0, 1..9, >9: controls breaking of long polynomials |
---|
| 15 | @code{TeXnofrac} (int) flag: write 1/2 instead of \\frac@{1@}@{2@} |
---|
| 16 | @code{TeXbrack} (string) \"@{\", \"(\", \"<\", \"|\", empty string: |
---|
| 17 | controls brackets around ideals and matrices |
---|
| 18 | @code{TeXproj} (int) flag: write \":\" instead of \",\" in vectors |
---|
| 19 | @code{TeXaligned} (int) flag: write maps (and ideals) aligned |
---|
| 20 | @code{TeXreplace} (list) list entries = 2 strings: replacing symbols |
---|
| 21 | @code{NoDollars} (int) flag: suppresses surrounding $ signs |
---|
| 22 | @end format |
---|
[f34c37c] | 23 | PROCEDURES: |
---|
[1a3911] | 24 | closetex(fnm) writes closing line for LaTeX-document |
---|
| 25 | opentex(fnm) writes header for LaTeX-file fnm |
---|
| 26 | tex(fnm) calls LaTeX2e for LaTeX-file fnm |
---|
| 27 | texdemo([n]) produces a file explaining the features of this lib |
---|
[3754ca] | 28 | texfactorize(fnm,f) creates string in LaTeX-format for factors of polynomial f |
---|
[1a3911] | 29 | texmap(fnm,m,r1,r2) creates string in LaTeX-format for map m:r1->r2 |
---|
| 30 | texname(fnm,s) creates string in LaTeX-format for identifier |
---|
| 31 | texobj(l) creates string in LaTeX-format for any (basic) type |
---|
| 32 | texpoly(f,n[,l]) creates string in LaTeX-format for poly |
---|
| 33 | texproc(fnm,p) creates string in LaTeX-format of text from proc p |
---|
| 34 | texring(fnm,r[,l]) creates string in LaTeX-format for ring/qring |
---|
| 35 | rmx(s) removes .aux and .log files of LaTeX-files |
---|
| 36 | xdvi(s) calls xdvi for dvi-files |
---|
| 37 | (parameters in square brackets [] are optional) |
---|
| 38 | (Procedures with file output assume sufficient write permissions |
---|
| 39 | when trying to append existing or create new files.) |
---|
[917fb5] | 40 | |
---|
[651b46] | 41 | "; |
---|
[ae4196] | 42 | |
---|
[1057ab5] | 43 | LIB "inout.lib"; // only needed for pause(); |
---|
[5bc214c] | 44 | |
---|
[ae4196] | 45 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 46 | |
---|
[917fb5] | 47 | proc closetex(string fname, list #) |
---|
[5bc214c] | 48 | "USAGE: closetex(fname); fname string |
---|
| 49 | RETURN: nothing; writes a LaTeX2e closing line into file @code{<fname>}. |
---|
[11dddeb] | 50 | NOTE: preceding \">>\" are deleted and suffix \".tex\" (if not given) |
---|
[5bc214c] | 51 | is added to @code{fname}. |
---|
[ae4196] | 52 | EXAMPLE: example closetex; shows an example |
---|
[651b46] | 53 | " |
---|
[ae4196] | 54 | { |
---|
[917fb5] | 55 | string default = "latex2e"; |
---|
[ae4196] | 56 | string s; |
---|
| 57 | int i = 1; |
---|
| 58 | int flag; |
---|
| 59 | |
---|
| 60 | if (size(#)) { default = #[1];} |
---|
| 61 | |
---|
[917fb5] | 62 | if (default=="latex2e" or default == "latex") |
---|
[ae4196] | 63 | { s = "\\end{document}"; flag = 1;} |
---|
| 64 | if (default=="amstex") {s = "\\enddocument"; flag = 1;} |
---|
| 65 | if (default=="tex") {s = "\\bye"; flag = 1;} |
---|
[917fb5] | 66 | if (not(flag)) { s = "";} |
---|
[ae4196] | 67 | |
---|
[917fb5] | 68 | if (size(fname)) |
---|
[ae4196] | 69 | { |
---|
| 70 | while (fname[i]==">"){i++;} |
---|
| 71 | fname = fname[i,size(fname)-i+1]; |
---|
[917fb5] | 72 | |
---|
[ae4196] | 73 | if (size(fname)>=4) // check if filename is ending with ".tex" |
---|
| 74 | { if(fname[size(fname)-3,4]!=".tex") {fname = fname +".tex"; } |
---|
| 75 | } |
---|
| 76 | else {fname = fname + ".tex";} |
---|
| 77 | write(fname, s); |
---|
[1057ab5] | 78 | write(fname," % - Thanks latex.lib and Singular - "); |
---|
[ae4196] | 79 | } |
---|
[917fb5] | 80 | else {return(s);} |
---|
[ae4196] | 81 | } |
---|
| 82 | example |
---|
| 83 | { "EXAMPLE:"; echo=2; |
---|
| 84 | opentex("exmpl"); |
---|
| 85 | texobj("exmpl","{\\large \\bf hello}"); |
---|
| 86 | closetex("exmpl"); |
---|
[5bc214c] | 87 | echo=0; |
---|
[ae4196] | 88 | } |
---|
| 89 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 90 | |
---|
| 91 | proc tex(string fname, list #) |
---|
[5bc214c] | 92 | "USAGE: tex(fname); fname string |
---|
| 93 | RETURN: nothing; calls latex (LaTeX2e) for compiling the file fname |
---|
[11dddeb] | 94 | NOTE: preceding \">>\" are deleted and suffix \".tex\" (if not given) |
---|
[5bc214c] | 95 | is added to @code{fname}. |
---|
[ae4196] | 96 | EXAMPLE: example tex; shows an example |
---|
[651b46] | 97 | " |
---|
[917fb5] | 98 | { |
---|
[ae4196] | 99 | string default = "latex2e"; |
---|
[917fb5] | 100 | int retval; |
---|
[ae4196] | 101 | int i=1; |
---|
| 102 | if (size(#)) {default = string(#[1]);} |
---|
| 103 | if (size(fname)) |
---|
| 104 | { |
---|
| 105 | while (fname[i]==">"){i++;} |
---|
| 106 | fname = fname[i,size(fname)-i+1]; |
---|
[917fb5] | 107 | |
---|
[5bc214c] | 108 | if (size(fname)>=4) // check if filename is ending with ".tex" |
---|
[ae4196] | 109 | { if(fname[size(fname)-3,4]!=".tex") {fname = fname +".tex"; } |
---|
| 110 | } |
---|
| 111 | else {fname = fname + ".tex";} |
---|
[1057ab5] | 112 | "calling "+default+" for:",fname,newline; |
---|
[917fb5] | 113 | |
---|
[0e6c7f] | 114 | if (default=="latex2e") |
---|
| 115 | { |
---|
| 116 | retval = system("sh","latex " + fname); |
---|
| 117 | } |
---|
| 118 | else |
---|
| 119 | { |
---|
| 120 | retval = system("sh",default + " " + fname); |
---|
| 121 | } |
---|
[ae4196] | 122 | } |
---|
| 123 | else |
---|
[1057ab5] | 124 | { " // -- Need a filename "; |
---|
[ae4196] | 125 | return(); |
---|
| 126 | } |
---|
| 127 | } |
---|
| 128 | example |
---|
| 129 | { "EXAMPLE:"; echo =2; |
---|
| 130 | ring r; |
---|
| 131 | ideal I = maxideal(7); |
---|
[5bc214c] | 132 | opentex("exp001"); // open latex2e document |
---|
[ae4196] | 133 | texobj("exp001","An ideal ",I); |
---|
| 134 | closetex("exp001"); |
---|
[3c4dcc] | 135 | tex("exp001"); |
---|
[5bc214c] | 136 | echo=0; |
---|
[917fb5] | 137 | pause("the created files will be deleted after pressing <RETURN>"); |
---|
[5bc214c] | 138 | system("sh","rm exp001.*"); |
---|
[ae4196] | 139 | } |
---|
| 140 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 141 | |
---|
[917fb5] | 142 | proc opentex(string fname, list #) |
---|
[5bc214c] | 143 | "USAGE: opentex(fname); fname string |
---|
| 144 | RETURN: nothing; writes a LaTeX2e header into a new file @code{<fname>}. |
---|
[11dddeb] | 145 | NOTE: preceding \">>\" are deleted and suffix \".tex\" (if not given) |
---|
[5bc214c] | 146 | is added to @code{fname}. |
---|
[ae4196] | 147 | EXAMPLE: example opentex; shows an example |
---|
[651b46] | 148 | " |
---|
[917fb5] | 149 | { |
---|
[ae4196] | 150 | string default = "latex2e"; |
---|
| 151 | string s; |
---|
| 152 | int i =1; |
---|
| 153 | int flag; |
---|
| 154 | |
---|
| 155 | if (size(#)) { default = #[1];} |
---|
| 156 | |
---|
[917fb5] | 157 | if (default == "latex2e") // the default latex2e header |
---|
| 158 | { s = |
---|
[5bc214c] | 159 | "\\documentclass{article}" + newline + |
---|
[ae4196] | 160 | "\\usepackage{amsmath,amssymb}" + newline + |
---|
[1057ab5] | 161 | "%\\setlength{\\textwidth}{390pt}" + newline + |
---|
[917fb5] | 162 | "\\parindent=0pt" + newline + |
---|
[5bc214c] | 163 | "\\newcommand{\\C}{\\mathbb{C}}" + newline + |
---|
| 164 | "\\newcommand{\\F}{\\mathbb{F}}" + newline + |
---|
| 165 | "\\newcommand{\\N}{\\mathbb{N}}" + newline + |
---|
[1057ab5] | 166 | // "\\renewcommand{\\P}{{\\Bbb P}}" + newline + |
---|
[5bc214c] | 167 | "\\newcommand{\\Q}{\\mathbb{Q}}" + newline + |
---|
| 168 | "\\newcommand{\\R}{\\mathbb{R}}" + newline + |
---|
| 169 | "\\newcommand{\\T}{\\mathbb{T}}" + newline + |
---|
| 170 | "\\newcommand{\\Z}{\\mathbb{Z}}" + newline + newline + |
---|
[ae4196] | 171 | "\\begin{document}"; |
---|
| 172 | flag = 1; |
---|
| 173 | } |
---|
| 174 | if (default == "latex") |
---|
[917fb5] | 175 | { s = |
---|
[ae4196] | 176 | "\\documentstyle[12pt,amstex]{article}" + newline + |
---|
| 177 | "\\parindent=0pt" + newline + |
---|
[1057ab5] | 178 | "\\newcommand{\\C}{\\mathbb{C}}" + newline + |
---|
| 179 | "\\newcommand{\\F}{\\mathbb{F}}" + newline + |
---|
| 180 | "\\newcommand{\\N}{\\mathbb{N}}" + newline + |
---|
| 181 | // "\\newcommand{\\P}{\\mathbb{P}}" + newline + |
---|
| 182 | "\\newcommand{\\Q}{\\mathbb{Q}}" + newline + |
---|
| 183 | "\\newcommand{\\R}{\\mathbb{R}}" + newline + |
---|
| 184 | "\\newcommand{\\T}{\\mathbb{T}}" + newline + |
---|
| 185 | "\\newcommand{\\Z}{\\mathbb{Z}}" + newline + newline + |
---|
[ae4196] | 186 | "\\begin{document}"; |
---|
| 187 | flag = 1; |
---|
[917fb5] | 188 | } |
---|
| 189 | if (default == "amstex") |
---|
| 190 | { s = |
---|
[ae4196] | 191 | "\\documentstyle{amsppt} " + newline + newline + |
---|
| 192 | "\\document"; |
---|
[917fb5] | 193 | flag = 1; |
---|
[ae4196] | 194 | } |
---|
| 195 | |
---|
[917fb5] | 196 | if (default == "tex") |
---|
| 197 | { s = |
---|
| 198 | ""; |
---|
[ae4196] | 199 | flag = 1; |
---|
| 200 | } |
---|
| 201 | if (default == "own") // the proper own header |
---|
| 202 | { s = ""; |
---|
| 203 | flag = 1; |
---|
| 204 | } |
---|
| 205 | if (not(flag)) { s = "";} |
---|
| 206 | |
---|
[917fb5] | 207 | if (size(fname)) |
---|
[ae4196] | 208 | { |
---|
| 209 | while (fname[i]==">"){i++;} |
---|
| 210 | fname = fname[i,size(fname)-i+1]; |
---|
| 211 | |
---|
| 212 | if (size(fname)>=4) // check if filename is ending with ".tex" |
---|
| 213 | { if(fname[size(fname)-3,4]!=".tex") {fname = fname +".tex"; } |
---|
| 214 | } |
---|
| 215 | else {fname = fname + ".tex";} |
---|
| 216 | fname = ">" + fname; |
---|
| 217 | write(fname,s); |
---|
| 218 | } |
---|
[917fb5] | 219 | else {return(s);} |
---|
[ae4196] | 220 | } |
---|
| 221 | example |
---|
| 222 | { "EXAMPLE:"; echo=2; |
---|
| 223 | opentex("exmpl"); |
---|
| 224 | texobj("exmpl","hello"); |
---|
| 225 | closetex("exmpl"); |
---|
| 226 | } |
---|
| 227 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 228 | |
---|
[917fb5] | 229 | proc texdemo(list #) |
---|
[651b46] | 230 | "USAGE: texdemo(); |
---|
[5bc214c] | 231 | RETURN: nothing; generates a LaTeX2e file called @code{texlibdemo.tex} |
---|
| 232 | explaining the features of @code{latex.lib} and its global variables. |
---|
[651b46] | 233 | " |
---|
[ae4196] | 234 | { int TeXdemostart = system("pid"); |
---|
| 235 | string fname = "texlibdemo"; |
---|
| 236 | |
---|
[917fb5] | 237 | if (size(#)) |
---|
| 238 | { if (typeof(#[1])=="int") {TeXdemostart = #[1];} |
---|
[ae4196] | 239 | } |
---|
[212d09] | 240 | system("--random",TeXdemostart); |
---|
[917fb5] | 241 | |
---|
[1057ab5] | 242 | //if (size(#) ==2) |
---|
| 243 | //{ if (typeof(#[2]) == "string") { fname = #[2];} |
---|
| 244 | //} |
---|
[ae4196] | 245 | |
---|
| 246 | if (size(fname)) |
---|
| 247 | { |
---|
| 248 | if (size(fname)>=4) // check if filename is ending with ".tex" |
---|
| 249 | { if(fname[size(fname)-3,4]!=".tex") {fname = fname +".tex"; } |
---|
| 250 | } else {fname = fname + ".tex";} |
---|
| 251 | } |
---|
| 252 | |
---|
[5bc214c] | 253 | // -------- save global variables --------- |
---|
[1057ab5] | 254 | if (defined(NoDollars)) {int NoDoll=NoDollars; kill NoDollars;} |
---|
[5bc214c] | 255 | if (defined(TeXaligned)) {int Teali=TeXaligned; kill TeXaligned;} |
---|
| 256 | if (defined(TeXreplace)) {list Terep=TeXreplace; kill TeXreplace;} |
---|
| 257 | if (defined(TeXwidth)) {int Tewid=TeXwidth; kill TeXwidth;} |
---|
| 258 | if (defined(TeXbrack)) {string Tebra=TeXbrack; kill TeXbrack;} |
---|
| 259 | if (defined(TeXnofrac)) {int Tenof=TeXnofrac; kill TeXnofrac;} |
---|
| 260 | if (defined(TeXproj)) {int Tepro=TeXproj; kill TeXproj;} |
---|
| 261 | // ---------------------------------------- |
---|
[1057ab5] | 262 | print(" Generating demofile ."); |
---|
| 263 | part0(fname); print(" ."); |
---|
| 264 | part1(fname); print(" ."); |
---|
| 265 | part2(fname); print(" ."); |
---|
| 266 | part3(fname); print(" ."); |
---|
| 267 | print(" Demofile generated."); |
---|
[ae4196] | 268 | if (size(fname)) |
---|
| 269 | { |
---|
[1057ab5] | 270 | print(" Call latex now by tex(\"texlibdemo\");" ); |
---|
| 271 | print(" To view the file, call xdvi by xdvi(\"texlibdemo\");" ); |
---|
| 272 | // print(" Call latex now by tex(\"" + fname + "\");" ); |
---|
| 273 | //print(" To view the file, call xdvi by xdvi(\"" + fname + "\");" ); |
---|
[ae4196] | 274 | print(" .log and .aux files may be deleted with rmx(\"texlibdemo\");"); |
---|
| 275 | } |
---|
[5bc214c] | 276 | // -------- save global variables --------- |
---|
[1057ab5] | 277 | if (defined(NoDoll)) {int NoDollars=NoDoll; export NoDollars; kill NoDoll;} |
---|
[5bc214c] | 278 | if (defined(Teali)) {int TeXaligned=Teali; export TeXaligned; kill Teali;} |
---|
| 279 | if (defined(Terep)) {list TeXreplace=Terep; export TeXreplace; kill Terep;} |
---|
| 280 | if (defined(Tewid)) {int TeXwidth=Tewid; export TeXwidth; kill Tewid;} |
---|
| 281 | if (defined(Tebra)) {string TeXbrack=Tebra; export TeXbrack; kill Tebra;} |
---|
| 282 | if (defined(Tenof)) {int TeXnofrac=Tenof; export TeXnofrac; kill Tenof;} |
---|
| 283 | if (defined(Tepro)) {int TeXproj=Tepro; export TeXproj; kill Tepro;} |
---|
| 284 | // ---------------------------------------- |
---|
| 285 | |
---|
[ae4196] | 286 | return(); |
---|
| 287 | } |
---|
| 288 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 289 | |
---|
[917fb5] | 290 | proc texfactorize(string fname, poly f, list #) |
---|
[5bc214c] | 291 | "USAGE: texfactorize(fname,f); fname string, f poly |
---|
[3c4dcc] | 292 | RETURN: if @code{fname=\"\"}: string, f as a product of its irreducible |
---|
[5bc214c] | 293 | factors@* |
---|
[3c4dcc] | 294 | otherwise: append this string to the file @code{<fname>}, and |
---|
[5bc214c] | 295 | return nothing. |
---|
[11dddeb] | 296 | NOTE: preceding \">>\" are deleted and suffix \".tex\" (if not given) |
---|
[5bc214c] | 297 | is added to @code{fname}. |
---|
[ae4196] | 298 | EXAMPLE: example texfactorize; shows an example |
---|
[651b46] | 299 | " |
---|
[ae4196] | 300 | { |
---|
| 301 | def @r = basering; |
---|
| 302 | list l; |
---|
| 303 | int i,j,k,Tw,TW,ND;; |
---|
| 304 | intvec v; |
---|
| 305 | string s,t; |
---|
| 306 | string D = "$"; |
---|
| 307 | poly g; |
---|
| 308 | |
---|
| 309 | ND = defined(NoDollars); |
---|
[1057ab5] | 310 | |
---|
[ae4196] | 311 | if (!(ND)) {int NoDollars; export NoDollars;} |
---|
| 312 | else { D = ""; } |
---|
| 313 | TW = defined(TeXwidth); |
---|
[917fb5] | 314 | if (TW) {Tw = TeXwidth; TeXwidth = -1;} |
---|
[ae4196] | 315 | else {int TeXwidth = -1; export TeXwidth;} |
---|
| 316 | |
---|
[1057ab5] | 317 | l = factorize(f); |
---|
[ae4196] | 318 | if (l[1][1]<>1){s = texpoly("",l[1][1]);} |
---|
[1057ab5] | 319 | if (size(l[1])>1) |
---|
| 320 | { |
---|
| 321 | if (l[1][1]!=-1 and l[1][1]!=1) { s = texpoly("",l[1][1]); } |
---|
| 322 | if (l[1][1]==-1) { s = "-";} |
---|
| 323 | } |
---|
| 324 | else |
---|
| 325 | { |
---|
| 326 | s = texpoly("",l[1]); |
---|
| 327 | } |
---|
| 328 | |
---|
[ae4196] | 329 | for(i=2;i<=size(l[1]);i++) |
---|
| 330 | { |
---|
[1057ab5] | 331 | if(size(s) and s!="-"){s = s+"\\cdot ";} |
---|
[ae4196] | 332 | g = l[1][i]; |
---|
| 333 | v = leadexp(g); |
---|
| 334 | k=0; |
---|
| 335 | for(j=1;j<=size(v);j++){k = k + v[j];} |
---|
| 336 | if(size(g)>1 or (size(g)==1 and k>1)) |
---|
| 337 | { t = "(" + texpoly("",l[1][i]) + ")";} |
---|
[917fb5] | 338 | else { t = texpoly("",l[1][i]);} |
---|
[ae4196] | 339 | if (l[2][i]>1) |
---|
| 340 | { t = t+"^{" +string(l[2][i]) + "}";} |
---|
| 341 | s = s + t; |
---|
| 342 | } |
---|
[1057ab5] | 343 | if (!(ND)) { kill NoDollars;} // kill Latex:: |
---|
[ae4196] | 344 | s = D + s + D; |
---|
| 345 | if (TW) {TeXwidth = Tw;} |
---|
[1057ab5] | 346 | if (!TW) {kill TeXwidth;} // kill Latex:: |
---|
| 347 | |
---|
[917fb5] | 348 | if(size(fname)) |
---|
[ae4196] | 349 | { i=1; |
---|
| 350 | while (fname[i]==">"){i++;} |
---|
| 351 | fname = fname[i,size(fname)-i+1]; |
---|
| 352 | |
---|
| 353 | if (size(fname)>=4) // check if filename is ending with ".tex" |
---|
| 354 | { if(fname[size(fname)-3,4]!=".tex") {fname = fname +".tex"; } |
---|
| 355 | } |
---|
| 356 | else {fname = fname + ".tex";} |
---|
| 357 | write(fname,s); |
---|
| 358 | } |
---|
| 359 | else{return(s);} |
---|
| 360 | } |
---|
| 361 | example |
---|
| 362 | { "EXAMPLE:"; echo=2; |
---|
[5bc214c] | 363 | ring r2 = 13,(x,y),dp; |
---|
| 364 | poly f = (x+1+y)^2*x3y*(2x-2y)*y12; |
---|
[ae4196] | 365 | texfactorize("",f); |
---|
| 366 | ring R49 = (7,a),x,dp; |
---|
[5bc214c] | 367 | minpoly = a2+a+3; |
---|
| 368 | poly f = (a24x5+x3)*a2x6*(x+1)^2; |
---|
[917fb5] | 369 | f; |
---|
[ae4196] | 370 | texfactorize("",f); |
---|
| 371 | } |
---|
[5bc214c] | 372 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 373 | |
---|
[ae4196] | 374 | proc texmap(string fname, def m, def @r1, def @r2, list #) |
---|
[5bc214c] | 375 | "USAGE: texmap(fname,m,@r1,@r2); fname string, m string/map, @r1,@r2 rings |
---|
[3c4dcc] | 376 | RETURN: if @code{fname=\"\"}: string, the map m from @r1 to @r2 (preceded |
---|
[5bc214c] | 377 | by its name if m = string) in TeX-typesetting;@* |
---|
[3c4dcc] | 378 | otherwise: append this string to the file @code{<fname>}, and |
---|
[5bc214c] | 379 | return nothing. |
---|
[3c4dcc] | 380 | NOTE: preceding \">>\" are deleted in @code{fname}, and suffix \".tex\" |
---|
[5bc214c] | 381 | (if not given) is added to @code{fname}. |
---|
| 382 | If m is a string then it has to be the name of an existing map |
---|
| 383 | from @r1 to @r2. |
---|
[ae4196] | 384 | EXAMPLE: example texmap; shows an example |
---|
[651b46] | 385 | " |
---|
[917fb5] | 386 | { |
---|
[ae4196] | 387 | int saveDollars= defined(NoDollars); |
---|
| 388 | int TX = defined(TeXwidth); |
---|
| 389 | int Tw; |
---|
| 390 | int i,n; |
---|
| 391 | string r1str,r2str, varr1str, varr2str; |
---|
| 392 | string mapname,t,s; |
---|
| 393 | string D,DD,vrg = "$","$$",","; |
---|
| 394 | def @r = basering; |
---|
| 395 | def themap; |
---|
| 396 | list l1,l2; |
---|
| 397 | string rr1,rr2 = "@r1","@r2"; |
---|
| 398 | |
---|
| 399 | // --- store all actual informations |
---|
| 400 | if(TX) { Tw = TeXwidth; TeXwidth = -1;} |
---|
| 401 | else { int TeXwidth = -1; export TeXwidth;} |
---|
| 402 | if (!(saveDollars)) { int NoDollars; export NoDollars;} |
---|
| 403 | if (defined(TeXproj)) {vrg = ":";} |
---|
| 404 | |
---|
| 405 | if (size(#)) |
---|
| 406 | { if (typeof(#[1])=="list") |
---|
| 407 | { l1 = #[1]; |
---|
| 408 | if(size(#)==2) { l2 = #[2];} |
---|
| 409 | } |
---|
| 410 | else {l1=#; l2 =#;} |
---|
| 411 | } |
---|
| 412 | // --- tex the information in preimring r1 |
---|
| 413 | |
---|
| 414 | setring(@r1); |
---|
| 415 | r1str = texring("",@r1,l1); |
---|
| 416 | // --- avoid an execute; hence construct an ideal |
---|
| 417 | |
---|
| 418 | n = nvars(@r1); |
---|
| 419 | if (n>1) { t = "\\left(";} |
---|
| 420 | ideal @I = var(1); |
---|
| 421 | t = t + texpoly("",var(1)); |
---|
| 422 | for(i=2;i<=n;i++) |
---|
| 423 | { @I = @I + var(i); |
---|
| 424 | t = t + vrg + texpoly("",var(i)); |
---|
| 425 | } |
---|
| 426 | if (n>1) { t = t + "\\right)";} |
---|
| 427 | varr1str = t; |
---|
| 428 | |
---|
| 429 | // --- now the things in ring ring r2 |
---|
| 430 | |
---|
| 431 | setring(@r2); |
---|
| 432 | // listvar(); |
---|
| 433 | |
---|
| 434 | if (typeof(m)=="string") |
---|
| 435 | { themap = `m`; |
---|
| 436 | mapname = m; |
---|
| 437 | if (defined(TeXreplace)) |
---|
[1057ab5] | 438 | { |
---|
| 439 | //mapname = rp(mapname); // rp ausschreiben ! |
---|
| 440 | for(int ii=1;ii<=size(TeXreplace);ii++) |
---|
| 441 | { |
---|
| 442 | if (TeXreplace[ii][1]==mapname) {mapname= TeXreplace[ii][2]; break;} |
---|
| 443 | } |
---|
[ae4196] | 444 | } |
---|
| 445 | mapname = mapname + ":"; |
---|
| 446 | } |
---|
| 447 | if (typeof(m)=="map") { themap = m;} |
---|
| 448 | |
---|
| 449 | r2str = texring("",@r2,l2); |
---|
| 450 | ideal @J = themap(@I); |
---|
| 451 | n = size(matrix(@J)); |
---|
| 452 | if (n>1) { t = " \\left(";} |
---|
| 453 | if (!(defined(TeXaligned)) and (n>1)) |
---|
| 454 | { t = t + newline + "\\begin{array}{c}" + newline;} |
---|
| 455 | t = t + texpoly("",@J[1]); |
---|
| 456 | for (i=2;i<=n; i++) |
---|
[917fb5] | 457 | {if(defined(TeXaligned)) |
---|
[ae4196] | 458 | { t = t + vrg + texpoly("",@J[i]); } |
---|
| 459 | else { t = t + "\\\\" + newline + texpoly("",@J[i]);} |
---|
| 460 | } |
---|
| 461 | if (!(defined(TeXaligned)) and (n>1)) |
---|
| 462 | { t = t + newline + "\\end{array}" + newline;} |
---|
| 463 | if (n>1) {t = t + "\\right)";} |
---|
| 464 | varr2str = t; |
---|
| 465 | |
---|
| 466 | // --- go back to ring r1 to kill @I |
---|
| 467 | |
---|
| 468 | setring(@r1); |
---|
| 469 | kill @I; |
---|
| 470 | |
---|
| 471 | // --- now reset the old settings and stick all the information together |
---|
| 472 | |
---|
| 473 | setring(@r); |
---|
[1057ab5] | 474 | if (!(saveDollars)) { kill NoDollars;} // kill Latex:: |
---|
[ae4196] | 475 | if (TX) {TeXwidth = Tw;} |
---|
[1057ab5] | 476 | else { kill TeXwidth;} // kill Latex:: |
---|
[ae4196] | 477 | if (defined(NoDollars)) |
---|
| 478 | { D,DD = "",""; } |
---|
| 479 | |
---|
| 480 | if (defined(TeXaligned)) |
---|
| 481 | { s = D + mapname; |
---|
| 482 | s = s + r1str + "\\longrightarrow" + r2str + ", \\ " + |
---|
| 483 | varr1str + "\\longmapsto" + varr2str + D; } |
---|
| 484 | else |
---|
| 485 | { s = DD; |
---|
| 486 | s = s + newline + "\\begin{array}{rcc}" + newline; |
---|
| 487 | s = s + mapname + r1str + " & \\longrightarrow & " + r2str + "\\\\[2mm]" |
---|
| 488 | + newline; |
---|
| 489 | s = s + varr1str + " & \\longmapsto & " + newline + varr2str + newline; |
---|
| 490 | s = s + "\\end{array}" + newline; |
---|
| 491 | s = s + DD; |
---|
| 492 | } |
---|
| 493 | |
---|
| 494 | if (size(fname)) |
---|
| 495 | { i=1; |
---|
| 496 | while (fname[i]==">"){i++;} |
---|
| 497 | fname = fname[i,size(fname)-i+1]; |
---|
| 498 | |
---|
| 499 | if (size(fname)>=4) // check if filename is ending with ".tex" |
---|
| 500 | { if(fname[size(fname)-3,4]!=".tex") {fname = fname +".tex"; } |
---|
| 501 | } |
---|
| 502 | else {fname = fname + ".tex";} |
---|
| 503 | write(fname,s); |
---|
| 504 | } |
---|
| 505 | else {return(s);} |
---|
| 506 | } |
---|
[917fb5] | 507 | example |
---|
[5bc214c] | 508 | { |
---|
| 509 | echo=0; |
---|
| 510 | // -------- prepare for example --------- |
---|
| 511 | if (defined(TeXaligned)) {int Teali=TeXaligned; kill TeXaligned;} |
---|
| 512 | if (defined(TeXreplace)) {list Terep=TeXreplace; kill TeXreplace;} |
---|
| 513 | // -------- the example starts here --------- |
---|
| 514 | // |
---|
| 515 | "EXAMPLE:"; echo = 2; |
---|
[ae4196] | 516 | string fname = "tldemo"; |
---|
[5bc214c] | 517 | ring @r1=0,(x,y,z),dp; |
---|
[4698e16] | 518 | export @r1; |
---|
[ae4196] | 519 | ring r2=0,(u,v),dp; |
---|
[5bc214c] | 520 | map @phi =(@r1,u2,uv -v,v2); export @phi; |
---|
[ae4196] | 521 | list TeXreplace; |
---|
[5bc214c] | 522 | TeXreplace[1] = list("@phi","\\phi"); // @phi --> \phi |
---|
[ae4196] | 523 | export TeXreplace; |
---|
[5bc214c] | 524 | texmap("","@phi",@r1,r2); // standard form |
---|
| 525 | // |
---|
| 526 | int TeXaligned; export TeXaligned; // map in one line |
---|
| 527 | texmap("",@phi,@r1,r2); |
---|
| 528 | // |
---|
| 529 | kill @r1,TeXreplace,TeXaligned; |
---|
| 530 | echo = 0; |
---|
| 531 | // |
---|
| 532 | // --- restore global variables if previously defined --- |
---|
| 533 | if (defined(Teali)) {int TeXaligned=Teali; export TeXaligned; kill Teali;} |
---|
| 534 | if (defined(Terep)) {list TeXreplace=Terep; export TeXreplace; kill Terep;} |
---|
[917fb5] | 535 | } |
---|
[5bc214c] | 536 | /////////////////////////////////////////////////////////////////////////////// |
---|
[1057ab5] | 537 | |
---|
[5bc214c] | 538 | static proc manipul(string s) |
---|
[ae4196] | 539 | { |
---|
[5bc214c] | 540 | string st; |
---|
[ae4196] | 541 | int i,anf,end,op,bigch; |
---|
| 542 | int n; |
---|
| 543 | if (s[1]=="{") { return(s[2,size(s)-2]);} |
---|
| 544 | if (s=="") { return(s);} |
---|
| 545 | s = s + newline; // add a terminating sign |
---|
| 546 | anf=1; |
---|
| 547 | while(s[i]!=newline) |
---|
| 548 | { |
---|
[5bc214c] | 549 | i =anf; |
---|
| 550 | while(s[i]<"0" or s[i]>"9" and s[i]!="'" and s[i]!= "_" and s[i]!="~" and |
---|
| 551 | s[i]!="(" and s[i]!=")" and s[i]!= "[" and s[i]!=newline) {i++;} |
---|
| 552 | if (s[i]==newline){st = st + s[anf,i-anf]; n = n+10*(i-anf); return(st);} |
---|
| 553 | st = st + s[anf,i-anf]; // the starting letters |
---|
| 554 | if (s[anf]>="A" and s[anf]<="Z") {bigch=1;} |
---|
| 555 | if (s[i]=="'") { st = st + "'";i++;} |
---|
| 556 | if (s[i]=="~") { st = "\\tilde{" + st + "}"; i++;} |
---|
| 557 | if (s[i]=="_") { i++;} |
---|
| 558 | if (s[i]=="(") { op =1;i++;} |
---|
| 559 | if (s[i]=="[") { anf = i+1; |
---|
| 560 | while(s[i]!="]"){i++;} // matrices and vectors |
---|
[917fb5] | 561 | st = st + "_{" + s[anf,i-anf] + "}"; n = n+ 5*(i-anf); i++; |
---|
[5bc214c] | 562 | // besser: while s[i]<> nwline : scan forward: end, return |
---|
[ae4196] | 563 | } |
---|
| 564 | if (s[i]==newline) {return(st);} |
---|
| 565 | anf =i; |
---|
[5bc214c] | 566 | while (s[i]>="0" and s[i]<="9") {i++;} // parse number after the letters |
---|
[ae4196] | 567 | if (bigch and not(op)) { st = st + "^{" + s[anf,i-anf] + "}"; bigch =0;} |
---|
| 568 | else { st = st + "_{" + s[anf,i-anf] + "}";} |
---|
| 569 | n = n+5*(i-anf); |
---|
| 570 | anf =i; // the next text in ( , ) as exponent |
---|
[3c4dcc] | 571 | if (op) |
---|
| 572 | { |
---|
[5bc214c] | 573 | if (s[i]== ","){anf = anf+1;} |
---|
| 574 | while(s[i] !=")"){ i++;} |
---|
| 575 | if (i<>anf) |
---|
| 576 | { |
---|
| 577 | st = st + "^{" + s[anf,i-anf] + "}"; n = n +5*(i-anf);} |
---|
| 578 | i++; |
---|
| 579 | } |
---|
| 580 | anf =i; |
---|
[ae4196] | 581 | } |
---|
[5bc214c] | 582 | return(st); |
---|
| 583 | } |
---|
| 584 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 585 | |
---|
| 586 | proc texname(string fname, string s) |
---|
| 587 | "USAGE: texname(fname,s); fname,s strings |
---|
[1a3911] | 588 | RETURN: if @code{fname=\"\"}: the transformed string s, for which the |
---|
[3c4dcc] | 589 | following rules apply: |
---|
| 590 | @example |
---|
[5bc214c] | 591 | s' + \"~\" --> \"\\tilde@{\"+ s' +\"@}\" |
---|
[3c4dcc] | 592 | \"_\" + int --> \"_@{\" + int +\"@}\" |
---|
[5bc214c] | 593 | \"[\" + s' + \"]\" --> \"_@{\" + s' + \"@}\" |
---|
[3c4dcc] | 594 | \"A..Z\" + int --> \"A..Z\" + \"^@{\" + int + \"@}\" |
---|
[5bc214c] | 595 | \"a..z\" + int --> \"a..z\" + \"_@{\" + int + \"@}\" |
---|
| 596 | \"(\" + int + \",\" + s' + \")\" --> \"_@{\"+ int +\"@}\" + \"^@{\" + s'+\"@}\" |
---|
| 597 | @end example |
---|
[20e830] | 598 | Furthermore, strings which begin with a left brace are modified |
---|
[1a3911] | 599 | by deleting the first and the last character (which is then assumed to |
---|
[20e830] | 600 | be a right brace). |
---|
[5bc214c] | 601 | |
---|
[3c4dcc] | 602 | if @code{fname!=\"\"}: append the transformed string s to the file |
---|
[5bc214c] | 603 | @code{<fname>}, and return nothing. |
---|
[3c4dcc] | 604 | NOTE: preceding \">>\" are deleted in @code{fname}, and suffix \".tex\" |
---|
[5bc214c] | 605 | (if not given) is added to @code{fname}. |
---|
| 606 | EXAMPLE: example texname; shows an example |
---|
| 607 | " |
---|
| 608 | { |
---|
| 609 | string st, extr; |
---|
| 610 | st=manipul(s); |
---|
[ae4196] | 611 | if (size(fname)) |
---|
[3c4dcc] | 612 | { |
---|
[5bc214c] | 613 | int i=1; |
---|
[ae4196] | 614 | while (fname[i]==">"){i++;} |
---|
| 615 | fname = fname[i,size(fname)-i+1]; |
---|
| 616 | if (size(fname)>=4) // check if filename is ending with ".tex" |
---|
[3c4dcc] | 617 | { |
---|
[5bc214c] | 618 | if(fname[size(fname)-3,4]!=".tex") {fname = fname +".tex"; } |
---|
[ae4196] | 619 | } |
---|
| 620 | else {fname = fname + ".tex";} |
---|
| 621 | write(fname,st); |
---|
| 622 | } |
---|
| 623 | else {return(st);} |
---|
| 624 | } |
---|
| 625 | example |
---|
| 626 | { "EXAMPLE:"; echo =2; |
---|
| 627 | ring r = 0,(x,y),lp; |
---|
| 628 | poly f = 3xy4 + 2xy2 + x5y3 + x + y6; |
---|
| 629 | texname("","{f(10)}"); |
---|
| 630 | texname("","f(10) ="); |
---|
| 631 | texname("","n1"); |
---|
| 632 | texname("","T1_12"); |
---|
| 633 | texname("","g'_11"); |
---|
| 634 | texname("","f23"); |
---|
| 635 | texname("","M[2,3]"); |
---|
| 636 | texname("","A(0,3);"); |
---|
| 637 | texname("","E~(3)"); |
---|
| 638 | } |
---|
| 639 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 640 | |
---|
| 641 | proc texobj(string fname, list #) |
---|
[5bc214c] | 642 | "USAGE: texobj(fname,l); fname string, l list |
---|
[b6b6153] | 643 | RETURN: if @code{fname=\"\"}: string, the entries of l in LaTeX-typesetting;@* |
---|
[3c4dcc] | 644 | otherwise: append this string to the file @code{<fname>}, and |
---|
[5bc214c] | 645 | return nothing. |
---|
[3c4dcc] | 646 | NOTE: preceding \">>\" are deleted in @code{fname}, and suffix \".tex\" |
---|
[5bc214c] | 647 | (if not given) is added to @code{fname}. |
---|
[ae4196] | 648 | EXAMPLE: example texobj; shows an example |
---|
[651b46] | 649 | " |
---|
[ae4196] | 650 | { |
---|
| 651 | int i,j,k,nr,nc,linear,Tw,Dollars; |
---|
| 652 | int ND = defined(NoDollars); |
---|
| 653 | int TW = defined(TeXwidth); |
---|
| 654 | |
---|
| 655 | if(defined(basering)){ poly g,h; matrix M;} |
---|
| 656 | string s,t,l,ineq,sg,Iname; |
---|
| 657 | string sep= ","; |
---|
[1057ab5] | 658 | string D,DA,DE = "$","$$"+newline,"$$"; |
---|
[917fb5] | 659 | string OB,CB = "(",")"; |
---|
[ae4196] | 660 | if (defined(TeXbrack)) |
---|
| 661 | {// if (TeXbrack=="(") {OB = "("; CB = ")";} |
---|
| 662 | if (TeXbrack=="<") {OB = "<"; CB = ">";} |
---|
| 663 | if (TeXbrack=="{") {OB = "{"; CB = "}";} |
---|
| 664 | if (TeXbrack=="|") {OB = "|"; CB = "|";} |
---|
| 665 | if (TeXbrack=="" ) {OB = "."; CB = ".";} |
---|
| 666 | } |
---|
| 667 | |
---|
| 668 | if (!(TW)) { int TeXwidth = -1; export TeXwidth; } |
---|
| 669 | Tw = TeXwidth; |
---|
| 670 | |
---|
| 671 | if (defined(TeXproj)){ sep = ":";} |
---|
| 672 | if(ND) { D,DA,DE="","","";} |
---|
| 673 | else {int NoDollars; export NoDollars;} |
---|
| 674 | |
---|
| 675 | if (size(#)==1) |
---|
[917fb5] | 676 | { if (typeof(#[1])=="int" or typeof(#[1])=="intvec" or typeof(#[1])=="vector" |
---|
[7f3ad4] | 677 | or typeof(#[1])=="number" or typeof(#[1])=="bigint" or defined(TeXaligned)) |
---|
| 678 | { DA = D; DE = D; } |
---|
[2301b7] | 679 | } |
---|
[ae4196] | 680 | |
---|
| 681 | s = DA; |
---|
| 682 | |
---|
| 683 | for (k=1; k<=size(#); k++) |
---|
| 684 | { def obj = #[k]; |
---|
[917fb5] | 685 | if (typeof(obj) == "string") |
---|
[ae4196] | 686 | { if (defined(`obj`)) |
---|
[917fb5] | 687 | { if (typeof(`obj`)=="ideal") |
---|
[3c4dcc] | 688 | { |
---|
[b6b6153] | 689 | Iname = obj; def e = `obj`; //convert to correct type ideal |
---|
[5bc214c] | 690 | kill obj; def obj = e; kill e; |
---|
| 691 | } |
---|
[b6b6153] | 692 | else {s = s + obj + newline;} |
---|
[5bc214c] | 693 | } |
---|
[b6b6153] | 694 | else {s = s + obj + newline;} |
---|
[ae4196] | 695 | } |
---|
[7f3ad4] | 696 | if (typeof(obj) == "int" or typeof(#[1])=="bigint") |
---|
[2301b7] | 697 | { s = s + " " + string(obj) + " ";} |
---|
[917fb5] | 698 | |
---|
| 699 | if (typeof(obj) == "intvec") |
---|
[5bc214c] | 700 | { s = s + " ("; |
---|
[ae4196] | 701 | for(j=1; j<size(obj);j++) { s = s + string(obj[j]) + sep;} |
---|
[5bc214c] | 702 | s = s + string(obj[j]) + ") "; |
---|
[ae4196] | 703 | } |
---|
| 704 | |
---|
[917fb5] | 705 | if (typeof(obj) == "number" ) |
---|
[ae4196] | 706 | { s = s + texpoly("",obj) + newline; |
---|
| 707 | } |
---|
| 708 | |
---|
| 709 | if (typeof(obj) == "poly") |
---|
| 710 | { int TeXdisplay; export TeXdisplay; |
---|
[5bc214c] | 711 | s = s + "\\begin{array}{rl}" + newline; |
---|
[ae4196] | 712 | s = s + texpoly("",obj) + "\\\\" + newline; |
---|
[5bc214c] | 713 | s = s + "\\end{array}" + newline; |
---|
[ae4196] | 714 | kill TeXdisplay; |
---|
| 715 | } |
---|
| 716 | |
---|
[917fb5] | 717 | if (typeof(obj) == "vector") |
---|
[ae4196] | 718 | { if (obj==0) { s = s + "0" ;} |
---|
| 719 | else |
---|
| 720 | { if (Tw==0) { TeXwidth = -1;} |
---|
| 721 | s = s + "\\left" + OB; |
---|
| 722 | for(j=1; j<nrows(obj); j++) {s = s + texpoly("",obj[j]) + sep;} |
---|
| 723 | s = s + texpoly("",obj[j]) + "\\right" + CB + newline; |
---|
| 724 | TeXwidth = Tw; |
---|
| 725 | } |
---|
| 726 | } |
---|
| 727 | |
---|
[917fb5] | 728 | if (typeof(obj) == "ideal") |
---|
[ae4196] | 729 | { if (size(Iname)) // verwende hier align |
---|
| 730 | { if (Tw==0) {TeXwidth = -1;} |
---|
| 731 | |
---|
| 732 | // Lasse hier TeXwidth == 0 zu ! |
---|
| 733 | // if (!(defined(TeXaligned))) |
---|
| 734 | // { untereinander } |
---|
| 735 | // else { hintereinander } |
---|
[917fb5] | 736 | // |
---|
| 737 | // |
---|
| 738 | // s = s + Iname + "=" + texpoly("",obj,","); |
---|
[ae4196] | 739 | // siehe ebenso noch einmal am Ende : ! (TeXwidth <> 0 !? ) |
---|
| 740 | |
---|
| 741 | s = s + "\\begin{array}{rcl}" + newline; |
---|
| 742 | for (i=1;i<=size(matrix(obj));i++) |
---|
[917fb5] | 743 | { s = s + Iname+ "_{" + string(i) + "} & = & " |
---|
[ae4196] | 744 | + texpoly("",obj[i]); |
---|
| 745 | if (i<size(matrix(obj))){ s = s + "\\\\" + newline;} |
---|
| 746 | } |
---|
| 747 | s = s + newline; |
---|
| 748 | s = s + "\\end{array}" + newline; |
---|
| 749 | TeXwidth = Tw; |
---|
| 750 | Iname =""; |
---|
| 751 | } |
---|
[917fb5] | 752 | else |
---|
| 753 | { |
---|
| 754 | if (TeXwidth==0) |
---|
[ae4196] | 755 | { TeXwidth = -1; |
---|
| 756 | obj= simplify(obj,2); |
---|
| 757 | linear = 1; |
---|
| 758 | for (j=1;j<=size(obj);j++) |
---|
| 759 | { if (deg(obj[j])>1){linear =0; break;} |
---|
| 760 | } |
---|
| 761 | if (!(linear)) |
---|
| 762 | { s = s + "\\begin{array}{rcl}" + newline; |
---|
| 763 | for(j=1;j<=size(obj);j++) |
---|
[1057ab5] | 764 | { h = jet(obj[j],0); // absterm |
---|
[8cae10] | 765 | ineq = "=" ; |
---|
[ae4196] | 766 | l = texpoly("",obj[j]-h) + " & " + ineq + " & " + texpoly("",-h); |
---|
| 767 | if(j<size(obj)) { l = l + " \\\\";} |
---|
| 768 | s =s+ l + newline; |
---|
| 769 | } |
---|
| 770 | s = s + "\\end{array}" + newline; |
---|
| 771 | } |
---|
| 772 | else // linear |
---|
[917fb5] | 773 | { s = s + |
---|
[ae4196] | 774 | "\\begin{array}{*{" + string(2*nvars(basering)-1) + "}{c}cr}" + newline; |
---|
[917fb5] | 775 | for(j=1; j<=size(obj);j++) |
---|
[1057ab5] | 776 | { h = jet(obj[j],0); // absterm |
---|
[8cae10] | 777 | ineq = "="; |
---|
[ae4196] | 778 | l = ""; nc = 0; |
---|
| 779 | for (i=1; i<=nvars(basering);i++) |
---|
| 780 | { t = " "; sg =""; |
---|
| 781 | g = obj[j]-subst(obj[j],var(i),0); |
---|
| 782 | if (g!=0) { t = texpoly("",g);} |
---|
| 783 | if (i>1) |
---|
| 784 | { if (t[1]!="-" and t[1]!= " " and nc ){sg = "+";} |
---|
| 785 | if (t[1]=="-") { sg = "-"; nc =1; t=t[2,size(t)-1];} |
---|
[917fb5] | 786 | if (t==" ") {sg ="";} |
---|
[ae4196] | 787 | l = l + " & " + sg + " & " + t; |
---|
| 788 | } |
---|
| 789 | else { l = t;} |
---|
| 790 | if (g!=0) {nc = 1;} |
---|
| 791 | } |
---|
| 792 | |
---|
| 793 | l = l + " & " + ineq + " & " + texpoly("",-h); |
---|
| 794 | if (j < size(obj)) { l = l + " \\\\";} |
---|
| 795 | s = s + l + newline; |
---|
| 796 | } // end for (j) |
---|
| 797 | s = s + "\\end{array}"; |
---|
| 798 | } // end else linear |
---|
| 799 | TeXwidth = 0; |
---|
| 800 | } // end TeXwidth == 0 |
---|
| 801 | else // TeXwidth <> 0 |
---|
| 802 | { s = s + "\\left"+ OB; |
---|
| 803 | if (defined(TeXaligned)) |
---|
| 804 | { s = s + texpoly("",obj,","); |
---|
[917fb5] | 805 | } |
---|
[ae4196] | 806 | else |
---|
| 807 | { s = s + newline + "\\begin{array}{c}" + newline + |
---|
[917fb5] | 808 | texpoly("",obj,", \\\\" + newline) + |
---|
[ae4196] | 809 | newline + "\\end{array}" + newline; |
---|
| 810 | } |
---|
| 811 | s = s + "\\right" + CB; |
---|
[917fb5] | 812 | } // end TeXwidth <> 0 |
---|
[ae4196] | 813 | } // not Iname |
---|
| 814 | // s; |
---|
| 815 | } |
---|
| 816 | |
---|
[917fb5] | 817 | if (typeof(obj) == "module") |
---|
[ae4196] | 818 | { M = matrix(obj); |
---|
| 819 | if (Tw ==0 or Tw > 9) { TeXwidth = -1;} |
---|
| 820 | s = s + "\\left" + OB + newline; |
---|
| 821 | if (!(defined(TeXaligned))) |
---|
| 822 | { // Naechste Zeile nicht notwendig ! |
---|
[917fb5] | 823 | // s = s + "\\begin{array}{*{"+ string(ncols(M)) + "}{c}}" + newline; |
---|
| 824 | for(j=1;j<=ncols(M);j++) |
---|
[ae4196] | 825 | { l = "\\left" + OB + newline + "\\begin{array}{c}" + newline; |
---|
| 826 | l = l + texpoly("",ideal(M[1..nrows(M),j]), " \\\\" + newline) |
---|
| 827 | + newline + "\\end{array}" +newline + "\\right" + CB + newline; |
---|
| 828 | if (j< ncols(M)) { l = l + " , " + newline;} |
---|
| 829 | s = s + l ; |
---|
| 830 | } |
---|
| 831 | } |
---|
| 832 | else // TeXaligned |
---|
[917fb5] | 833 | { |
---|
| 834 | for(j=1;j<=ncols(M);j++) |
---|
[ae4196] | 835 | { s = s + "\\left" + OB + newline + |
---|
| 836 | texpoly("",ideal(M[1..nrows(M),j]),",") + newline + "\\right" + CB; |
---|
| 837 | if (j<ncols(M)) { s = s + "," + newline; } |
---|
| 838 | } |
---|
| 839 | } |
---|
| 840 | s = s + "\\right" + CB + newline; |
---|
| 841 | } // module part |
---|
| 842 | |
---|
| 843 | if (typeof(obj) == "matrix") |
---|
| 844 | { if (Tw==0 or Tw > 9) {TeXwidth = -1;} |
---|
| 845 | l = ""; |
---|
| 846 | // M = transpose(obj); |
---|
[917fb5] | 847 | s = s + "\\left" + OB + newline + |
---|
[ae4196] | 848 | "\\begin{array}{*{"+ string(ncols(obj)) + "}{c}" + "}"+ newline; |
---|
| 849 | for(i=1;i<=nrows(obj);i++) |
---|
| 850 | { l = l + texpoly("",ideal(obj[i,1..ncols(obj)])," & "); |
---|
| 851 | if (i<nrows(obj)) { l = l + " \\\\" + newline;} |
---|
| 852 | } |
---|
| 853 | l = l + newline; |
---|
[917fb5] | 854 | s = s + l + "\\end{array}" + newline + |
---|
[ae4196] | 855 | "\\right" + CB + newline; |
---|
| 856 | TeXwidth = Tw; |
---|
| 857 | } |
---|
[917fb5] | 858 | |
---|
[ae4196] | 859 | if (typeof(obj) == "intmat") |
---|
| 860 | { nr,nc = nrows(obj),ncols(obj); |
---|
| 861 | l = ""; |
---|
[917fb5] | 862 | l = "\\left" + OB + newline + |
---|
[ae4196] | 863 | "\\begin{array}{*{"+ string(nc) + "}{r}}"+ newline; |
---|
| 864 | for(i=1;i<=nr;i++) |
---|
[917fb5] | 865 | { for(j=1;j<=nc;j++) |
---|
[ae4196] | 866 | { l = l + string(obj[i,j]); |
---|
| 867 | if (j <nc ) { l = l + " & ";} |
---|
| 868 | else {if( i < nr) { l = l + "\\\\" + newline;}} |
---|
| 869 | } |
---|
| 870 | } |
---|
[917fb5] | 871 | l = l + newline + "\\end{array}" + newline + |
---|
[ae4196] | 872 | "\\right" + CB + newline; |
---|
[917fb5] | 873 | s = s + l; |
---|
[ae4196] | 874 | } |
---|
| 875 | |
---|
| 876 | if (typeof(obj) == "ring" or |
---|
| 877 | typeof(obj) == "qring") { s = s + D + texring("",obj) + D + newline;} |
---|
| 878 | |
---|
| 879 | kill obj; |
---|
| 880 | } |
---|
| 881 | |
---|
[1057ab5] | 882 | s = s + DE;// + newline; |
---|
[ae4196] | 883 | |
---|
[1057ab5] | 884 | if(!(ND)) { kill NoDollars;} // kill Latex:: |
---|
| 885 | if(!(TW)) { kill TeXwidth;} // kill Latex:: |
---|
[ae4196] | 886 | |
---|
| 887 | if(size(fname)) |
---|
| 888 | { i=1; |
---|
| 889 | while (fname[i]==">"){i++;} |
---|
| 890 | fname = fname[i,size(fname)-i+1]; |
---|
| 891 | if (size(fname)>=4) // check if filename is ending with ".tex" |
---|
| 892 | { if(fname[size(fname)-3,4]!=".tex") {fname = fname +".tex"; } |
---|
| 893 | } |
---|
| 894 | else {fname = fname + ".tex";} |
---|
| 895 | write(fname,s); |
---|
| 896 | } |
---|
| 897 | else {return(s);} |
---|
| 898 | } |
---|
| 899 | example |
---|
[3c4dcc] | 900 | { |
---|
[5bc214c] | 901 | echo=0; |
---|
| 902 | // -------- prepare for example --------- |
---|
| 903 | if (defined(TeXaligned)) {int Teali=TeXaligned; kill TeXaligned;} |
---|
| 904 | if (defined(TeXbrack)){string Tebra=TeXbrack; kill TeXbrack;} |
---|
| 905 | "EXAMPLE:"; echo = 2; |
---|
| 906 | // |
---|
| 907 | // -------------- typesetting for polynomials ---------- |
---|
[ae4196] | 908 | ring r = 0,(x,y),lp; |
---|
[5bc214c] | 909 | poly f = x5y3 + 3xy4 + 2xy2 + y6; |
---|
| 910 | f; |
---|
| 911 | texobj("",f); |
---|
| 912 | pause(); |
---|
| 913 | // -------------- typesetting for ideals ---------- |
---|
[ae4196] | 914 | ideal G = jacob(f); |
---|
[5bc214c] | 915 | G; |
---|
| 916 | texobj("",G); |
---|
| 917 | pause(); |
---|
| 918 | // -------------- variation of typesetting for ideals ---------- |
---|
| 919 | int TeXaligned = 1; export TeXaligned; |
---|
| 920 | string TeXbrack = "<"; export TeXbrack; |
---|
[ae4196] | 921 | texobj("",G); |
---|
[5bc214c] | 922 | pause(); |
---|
| 923 | kill TeXaligned, TeXbrack; |
---|
| 924 | // -------------- typesetting for matrices ---------- |
---|
[ae4196] | 925 | matrix J = jacob(G); |
---|
| 926 | texobj("",J); |
---|
[5bc214c] | 927 | pause(); |
---|
| 928 | // -------------- typesetting for intmats ---------- |
---|
| 929 | intmat m[3][4] = 9,2,4,5,2,5,-2,4,-6,10,-1,2,7; |
---|
[ae4196] | 930 | texobj("",m); |
---|
[5bc214c] | 931 | echo=0; |
---|
| 932 | // |
---|
| 933 | // --- restore global variables if previously defined --- |
---|
| 934 | if (defined(Teali)){int TeXaligned=Teali; export TeXaligned; kill Teali;} |
---|
| 935 | if (defined(Tebra)){string TeXbrack=Tebra; export TeXbrack; kill Tebra;} |
---|
[ae4196] | 936 | } |
---|
| 937 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 938 | |
---|
[917fb5] | 939 | proc texproc(string fname,string pname) |
---|
[5bc214c] | 940 | "USAGE: texproc(fname,pname); fname,pname strings |
---|
| 941 | ASSUME: @code{`pname`} is a procedure. |
---|
[3c4dcc] | 942 | RETURN: if @code{fname=\"\"}: string, the proc @code{`pname`} in a verbatim |
---|
[5bc214c] | 943 | environment in LaTeX-typesetting;@* |
---|
[3c4dcc] | 944 | otherwise: append this string to the file @code{<fname>}, and |
---|
[5bc214c] | 945 | return nothing. |
---|
[3c4dcc] | 946 | NOTE: preceding \">>\" are deleted in @code{fname}, and suffix \".tex\" |
---|
[5bc214c] | 947 | (if not given) is added to @code{fname}.@* |
---|
[ae4196] | 948 | EXAMPLE: example texproc; shows an example |
---|
[651b46] | 949 | " |
---|
[ae4196] | 950 | { |
---|
[1057ab5] | 951 | int i,j,k,nl; |
---|
| 952 | string @p,s,t; |
---|
[ae4196] | 953 | |
---|
[1057ab5] | 954 | j = 1; |
---|
| 955 | |
---|
| 956 | if (defined(`pname`)) |
---|
[ae4196] | 957 | { if (typeof(`pname`)=="proc") |
---|
[1057ab5] | 958 | { @p = string(`pname`); |
---|
| 959 | nl = find(@p,newline); |
---|
[ae4196] | 960 | s = "\\begin{verbatim}" + newline; |
---|
| 961 | s = s + "proc " + pname + "("; |
---|
[1057ab5] | 962 | i = find(@p,"parameter"); // collecting the parameters |
---|
| 963 | k = find(@p,"alias"); // and the alias arguments |
---|
| 964 | while((i and i < nl) or (k and k < nl)) |
---|
| 965 | { |
---|
| 966 | if (i and (k==0 or i<k)) |
---|
| 967 | { |
---|
| 968 | j=find(@p,";",i); |
---|
| 969 | t = @p[i+10,j-i-10]; |
---|
| 970 | if(i>1){s = s + ",";}; |
---|
| 971 | s = s + t; |
---|
| 972 | } |
---|
| 973 | if (k and (i==0 or k<i)) |
---|
| 974 | { |
---|
| 975 | j=find(@p,";",k); |
---|
| 976 | t = @p[k,j-k]; |
---|
| 977 | if(k>1){s = s + ",";}; |
---|
| 978 | s = s + t; |
---|
| 979 | } |
---|
| 980 | i = find(@p,"parameter",j); |
---|
| 981 | k = find(@p,"alias",j); |
---|
[ae4196] | 982 | } |
---|
| 983 | s = s + ")" + newline; |
---|
| 984 | j++; // skip one for the newline |
---|
[1057ab5] | 985 | i = find(@p,";"+"return();"+newline,j); |
---|
[ae4196] | 986 | if (!(i)) |
---|
[1057ab5] | 987 | { i = find(@p,";"+"RETURN();"+newline,j); } // j kann hier weg |
---|
| 988 | s = s + "{" + @p[j,i-j-1] + "}" + newline; |
---|
[ae4196] | 989 | s = s + "\\end{verbatim}" + newline; |
---|
| 990 | } |
---|
| 991 | } |
---|
| 992 | else |
---|
[1057ab5] | 993 | { print(" // -- Error: No such proc defined"); |
---|
[ae4196] | 994 | return(); |
---|
| 995 | } |
---|
| 996 | if(size(fname)) |
---|
| 997 | { i=1; |
---|
| 998 | while (fname[i]==">"){i++;} |
---|
| 999 | fname = fname[i,size(fname)-i+1]; |
---|
| 1000 | if (size(fname)>=4) // check if filename is ending with ".tex" |
---|
| 1001 | { if(fname[size(fname)-3,4]!=".tex") {fname = fname +".tex"; } |
---|
| 1002 | } |
---|
[917fb5] | 1003 | else {fname = fname + ".tex";} |
---|
[ae4196] | 1004 | write(fname,s); |
---|
| 1005 | } |
---|
[917fb5] | 1006 | else{return(s);} |
---|
[ae4196] | 1007 | } |
---|
| 1008 | example |
---|
| 1009 | { "EXAMPLE:"; echo=2; |
---|
[1057ab5] | 1010 | texproc("","texproc"); |
---|
[5bc214c] | 1011 | } |
---|
| 1012 | |
---|
| 1013 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 1014 | |
---|
| 1015 | static proc tvar(intvec v) |
---|
| 1016 | { |
---|
| 1017 | int i,j,ldots; |
---|
| 1018 | string s; |
---|
| 1019 | j = 1; |
---|
| 1020 | s = texpoly("",var(1)); |
---|
| 1021 | |
---|
| 1022 | if (nvars(basering)==1) { return(s);} |
---|
| 1023 | if (nvars(basering)==2) { return(s + "," + texpoly("",var(2)));} |
---|
| 1024 | if (size(v)==1 and v[1] == 1) |
---|
| 1025 | {return(s + ",\\ldots,"+ texpoly("",var(nvars(basering))));} |
---|
| 1026 | if (v[1]==1 and size(v) >1) {j++;} |
---|
| 1027 | for(i=2;i<nvars(basering);i++) |
---|
| 1028 | { if (i<v[j] and !(ldots)) |
---|
| 1029 | { s = s + ",\\ldots"; |
---|
| 1030 | ldots =1; |
---|
| 1031 | } |
---|
| 1032 | if (i== v[j]) |
---|
| 1033 | { s = s + "," + texpoly("",var(i)); |
---|
| 1034 | ldots =0; |
---|
| 1035 | if (j< size(v)) {j++;} |
---|
| 1036 | } |
---|
| 1037 | } |
---|
[1057ab5] | 1038 | if (v[j]<nvars(basering)-1) { s = s + ",\\ldots";} |
---|
| 1039 | return(s + "," + texpoly("",var(nvars(basering)))); |
---|
[ae4196] | 1040 | } |
---|
| 1041 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 1042 | |
---|
[917fb5] | 1043 | proc texring(string fname, def r, list #) |
---|
[5bc214c] | 1044 | "USAGE: texring(fname, r[,L]); fname string, r ring, L list |
---|
| 1045 | RETURN: if @code{fname=\"\"}: string, the ring in TeX-typesetting;@* |
---|
[3c4dcc] | 1046 | otherwise: append this string to the file @code{<fname>} and |
---|
[5bc214c] | 1047 | return nothing. |
---|
[11dddeb] | 1048 | NOTE: preceding \">>\" are deleted and suffix \".tex\" (if not given) |
---|
[5bc214c] | 1049 | is added to @code{fname}.@* |
---|
| 1050 | The optional list L is assumed to be a list of strings which control, |
---|
[1a3911] | 1051 | for instance the symbol for the field of coefficients.@* |
---|
[5bc214c] | 1052 | For more details call @code{texdemo();} (generates a LaTeX2e |
---|
| 1053 | file called @code{texlibdemo.tex} which explains all features of |
---|
| 1054 | @code{texring}). |
---|
[ae4196] | 1055 | EXAMPLE: example texring; shows an example |
---|
[651b46] | 1056 | " |
---|
[917fb5] | 1057 | { |
---|
[1057ab5] | 1058 | int i,galT,intT,flag,mipo,nopar,Dollars,TB,TA; |
---|
[ae4196] | 1059 | string ob,cb,cf,en,s,t,savebrack; //opening bracket, closing br, coef.field |
---|
| 1060 | intvec v; |
---|
| 1061 | |
---|
| 1062 | setring r; |
---|
| 1063 | if (!(defined(NoDollars))){ Dollars = 1; int NoDollars; export NoDollars;} |
---|
| 1064 | ob,cb = "[","]"; |
---|
[5bc214c] | 1065 | if (find(ordstr(r),"s")) { ob,cb="[[","]]";} |
---|
[ae4196] | 1066 | if(char(r)==0){cf="\\Q";} |
---|
[1057ab5] | 1067 | if(find(charstr(r),"integer")) // 4.10.10 |
---|
| 1068 | { |
---|
| 1069 | intT=1; |
---|
| 1070 | cf="\\Z"; |
---|
| 1071 | if (char(r)>0) { cf=cf+"_{"+string(char(r))+"}";} |
---|
| 1072 | } |
---|
| 1073 | if(find(charstr(r),"real")){cf="\\R";} |
---|
| 1074 | if(find(charstr(r),"complex")){cf="\\C"; nopar=1;} // 28.10.06 |
---|
[ae4196] | 1075 | if(char(r)==prime(char(r))){cf="\\Z_{"+string(char(r))+"}";} |
---|
[1057ab5] | 1076 | if(char(r)>0 and !intT) |
---|
[ae4196] | 1077 | { i = find(charstr(r),","); |
---|
| 1078 | if(i) |
---|
| 1079 | { t= charstr(r)[1,i-1]; |
---|
| 1080 | galT = (t <> string(char(r))); |
---|
| 1081 | if (galT) { cf = "\\F_{"+ t + "}";} |
---|
| 1082 | } |
---|
| 1083 | } // all other cases are cover already by char(r)=? prime(char) |
---|
| 1084 | |
---|
| 1085 | if (size(#)) |
---|
| 1086 | { if (typeof(#[1])=="list") { # = #[1];} |
---|
[917fb5] | 1087 | } |
---|
[ae4196] | 1088 | for (i=1;i<=size(#);i++) |
---|
| 1089 | { flag =0; |
---|
| 1090 | if(typeof(#[i])=="string") |
---|
| 1091 | { |
---|
| 1092 | if(#[i][1]=="^" or #[i][1]=="_"){en=en+#[i];flag = 1;} |
---|
| 1093 | if(#[i]=="mipo"){mipo=1; flag = 1;} |
---|
| 1094 | if(#[i]=="{"){ob,cb="\\{","\\}";flag=1;} |
---|
| 1095 | if(#[i]=="{{"){ob,cb="\\{\\{","\\}\\}";flag=1;} |
---|
| 1096 | if(#[i]=="["){ob,cb="[","]";flag=1;} |
---|
| 1097 | if(#[i]=="[["){ob,cb="[[","]]";flag=1;} |
---|
| 1098 | if(#[i]=="<"){ob,cb="<",">";flag=1;} |
---|
| 1099 | if(#[i]=="<<"){ob,cb="{\\ll}","{\\gg}";flag=1;} |
---|
| 1100 | if(#[i]=="C"){cf="\\C";flag=1;} |
---|
| 1101 | if(#[i]=="Q"){cf="\\Q";flag=1;} |
---|
| 1102 | if((#[i]=="k" or #[i]=="K" or #[i]=="R") and !(galT)) |
---|
| 1103 | {cf=#[i]; flag=1; nopar=1;} |
---|
| 1104 | if (flag!=1) {cf = #[i];} // for all the cases not covered here e.g Z_(p) |
---|
| 1105 | } // or Q[i] |
---|
| 1106 | |
---|
| 1107 | if ((typeof(#[i])=="intvec") or |
---|
| 1108 | (typeof(#[i])=="int")){v=#[i];} |
---|
| 1109 | } |
---|
| 1110 | s = cf; |
---|
| 1111 | // now the parameters |
---|
| 1112 | // t; |
---|
| 1113 | if(npars(r) and ((t==string(char(r))) or char(r)==0) and !(nopar)) |
---|
| 1114 | { |
---|
| 1115 | s = s + "("; // !! mit ideal !! |
---|
| 1116 | for(i=1;i<npars(r);i++) {s = s + texpoly("",par(i)) + ",";} |
---|
| 1117 | s = s + texpoly("",par(npars(r))) + ")"; |
---|
| 1118 | } // parameters done |
---|
[917fb5] | 1119 | if (!(galT) and mipo and minpoly!=0) |
---|
[ae4196] | 1120 | { s = s + "/" + list(parsp(string(minpoly),0))[1];} |
---|
| 1121 | s = s + ob; |
---|
| 1122 | if (v!=0 and nvars(r)>3) |
---|
| 1123 | { s = s + tvar(v);} |
---|
| 1124 | else |
---|
| 1125 | { s = s + texpoly("",maxideal(1),","); } |
---|
| 1126 | s = s + cb + en; |
---|
| 1127 | |
---|
| 1128 | if (typeof(r)=="qring") |
---|
| 1129 | { ideal @I = ideal(r); |
---|
[917fb5] | 1130 | if (defined(TeXbrack)) |
---|
[ae4196] | 1131 | { |
---|
[917fb5] | 1132 | TB =1; savebrack = TeXbrack; |
---|
[ae4196] | 1133 | if (TeXbrack!= "<" and TeXbrack!="(") { TeXbrack = "<";} |
---|
| 1134 | } |
---|
| 1135 | TA = defined(TeXaligned); |
---|
| 1136 | if (!(TA)) { int TeXaligned; export TeXaligned; } |
---|
| 1137 | t = texobj("",@I); |
---|
| 1138 | // @I; |
---|
| 1139 | // t; |
---|
| 1140 | if (TB) { TeXbrack = savebrack;} |
---|
[1057ab5] | 1141 | if (!(TA)) { kill TeXaligned;} // kill Latex:: |
---|
[ae4196] | 1142 | s = s + "/" + t; |
---|
| 1143 | } |
---|
| 1144 | |
---|
[917fb5] | 1145 | if (Dollars) |
---|
[1057ab5] | 1146 | { kill NoDollars; // kill Latex:: |
---|
[ae4196] | 1147 | s = "$" + s + "$"; |
---|
| 1148 | } |
---|
| 1149 | if (size(fname)) |
---|
| 1150 | { i=1; |
---|
| 1151 | while (fname[i]==">"){i++;} |
---|
| 1152 | fname = fname[i,size(fname)-i+1]; |
---|
| 1153 | |
---|
| 1154 | if (size(fname)>=4) // check if filename is ending with ".tex" |
---|
| 1155 | { if(fname[size(fname)-3,4]!=".tex") {fname = fname +".tex"; } |
---|
| 1156 | } |
---|
| 1157 | else {fname = fname + ".tex";} |
---|
| 1158 | write(fname,s); |
---|
| 1159 | } |
---|
| 1160 | else{return(s);} |
---|
[917fb5] | 1161 | } |
---|
[ae4196] | 1162 | example |
---|
| 1163 | { "EXAMPLE:"; echo=2; |
---|
[5bc214c] | 1164 | ring r0 = 0,(x,y),dp; // char = 0, polynomial ordering |
---|
[ae4196] | 1165 | texring("",r0); |
---|
[5bc214c] | 1166 | // |
---|
| 1167 | ring r7 =7,(x(0..2)),ds; // char = 7, local ordering |
---|
[ae4196] | 1168 | texring("",r7); |
---|
[5bc214c] | 1169 | // |
---|
[ae4196] | 1170 | ring r1 = 0,(x1,x2,y1,y2),wp(1,2,3,4); |
---|
| 1171 | texring("",r1); |
---|
[5bc214c] | 1172 | // |
---|
| 1173 | ring rr = real,(x),dp; // real numbers |
---|
[ae4196] | 1174 | texring("",rr); |
---|
[5bc214c] | 1175 | // |
---|
[1057ab5] | 1176 | ring rC = complex,x,dp; // complex coefficients |
---|
| 1177 | texring("",rC); |
---|
| 1178 | // |
---|
[5bc214c] | 1179 | pause(); |
---|
| 1180 | |
---|
| 1181 | ring rabc =(0,t1,t2,t3),(x,y),dp; // ring with parameters |
---|
[ae4196] | 1182 | texring("",rabc); |
---|
[5bc214c] | 1183 | // |
---|
| 1184 | ring ralg = (7,a),(x1,x2),ds; // algebraic extension |
---|
[ae4196] | 1185 | minpoly = a2-a+3; |
---|
| 1186 | texring("",ralg); |
---|
| 1187 | texring("",ralg,"mipo"); |
---|
[5bc214c] | 1188 | // |
---|
[3c4dcc] | 1189 | ring r49=(49,a),x,dp; // Galois field |
---|
[917fb5] | 1190 | texring("",r49); |
---|
[5bc214c] | 1191 | // |
---|
| 1192 | setring r0; // quotient ring |
---|
| 1193 | ideal i = x2-y3; |
---|
[ae4196] | 1194 | qring q = std(i); |
---|
| 1195 | texring("",q); |
---|
[5bc214c] | 1196 | // |
---|
| 1197 | pause(); |
---|
[1057ab5] | 1198 | |
---|
[5bc214c] | 1199 | // ------------------ additional features ------------------- |
---|
| 1200 | ring r9 =0,(x(0..9)),ds; |
---|
| 1201 | texring("",r9,1); |
---|
| 1202 | texring("",r9,"C","{","^G"); |
---|
| 1203 | // |
---|
[ae4196] | 1204 | ring rxy = 0,(x(1..5),y(1..6)),ds; |
---|
| 1205 | intvec v = 5,6; |
---|
| 1206 | texring("",rxy,v); |
---|
| 1207 | } |
---|
| 1208 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 1209 | |
---|
| 1210 | proc rmx(string fname) |
---|
[5bc214c] | 1211 | "USAGE: rmx(fname); fname string |
---|
[3c4dcc] | 1212 | RETURN: nothing; removes the @code{.log} and @code{.aux} files associated to |
---|
[5bc214c] | 1213 | the LaTeX file <fname>.@* |
---|
[3c4dcc] | 1214 | NOTE: If @code{fname} ends by @code{\".dvi\"} or @code{\".tex\"}, the |
---|
[5bc214c] | 1215 | @code{.dvi} or @code{.tex} file will be deleted, too. |
---|
[ae4196] | 1216 | EXAMPLE: example rmx; shows an example |
---|
[651b46] | 1217 | " |
---|
[ae4196] | 1218 | { |
---|
| 1219 | int i,suffix= 1,0; |
---|
[917fb5] | 1220 | int retval; |
---|
[ae4196] | 1221 | |
---|
| 1222 | if (size(fname)) |
---|
| 1223 | { |
---|
| 1224 | while (fname[i]==">"){i++;} |
---|
| 1225 | fname = fname[i,size(fname)-i+1]; |
---|
| 1226 | if (size(fname)>4) |
---|
| 1227 | { if (fname[size(fname)-3,4]==".tex") { suffix = 2;} |
---|
| 1228 | if (fname[size(fname)-3,4]==".dvi") { suffix = 1; } |
---|
| 1229 | if (suffix) { fname = fname[1,size(fname)-4]; } |
---|
[917fb5] | 1230 | } |
---|
[ae4196] | 1231 | retval = system("sh","rm " + fname + ".aux"); |
---|
| 1232 | retval = system("sh","rm " + fname + ".log"); |
---|
| 1233 | if (suffix==2) {retval = system("sh","/bin/rm -i " + fname +".tex");} |
---|
| 1234 | if (suffix>=1) {retval = system("sh","/bin/rm -i " + fname +".dvi");} |
---|
| 1235 | } |
---|
| 1236 | else |
---|
| 1237 | {" -- Need a filename "; |
---|
| 1238 | return(); |
---|
[917fb5] | 1239 | } |
---|
[ae4196] | 1240 | } |
---|
| 1241 | example |
---|
| 1242 | { "EXAMPLE:"; echo =2; |
---|
| 1243 | ring r; |
---|
| 1244 | poly f = x+y+z; |
---|
| 1245 | opentex("exp001"); // defaulted latex2e document |
---|
| 1246 | texobj("exp001","A polynom",f); |
---|
| 1247 | closetex("exp001"); |
---|
| 1248 | tex("exp001"); |
---|
| 1249 | rmx("exp001"); // removes aux and log file of exp001 |
---|
| 1250 | echo = 0; |
---|
[917fb5] | 1251 | pause("remaining files will be deleted after pressing <RETURN>"); |
---|
[ae4196] | 1252 | echo = 2; |
---|
[5bc214c] | 1253 | system("sh","rm exp001.*"); |
---|
[ae4196] | 1254 | } |
---|
| 1255 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 1256 | |
---|
| 1257 | proc xdvi(string fname, list #) |
---|
[651b46] | 1258 | "USAGE: xdvi(fname[,style]); fname,style = string |
---|
[ae4196] | 1259 | RETURN: nothing; displays dvi-file fname.dvi with previewer xdvi |
---|
[a15d90] | 1260 | NOTE: suffix .dvi may be omitted in fname |
---|
[1a3911] | 1261 | style captures the program that will be called instead of the default (xdvi) |
---|
[651b46] | 1262 | EXAMPLE: example xdvi; shows an example |
---|
| 1263 | " |
---|
[ae4196] | 1264 | { |
---|
| 1265 | int i=1; |
---|
| 1266 | int retval; |
---|
[917fb5] | 1267 | string default = "xdvi"; |
---|
| 1268 | |
---|
[ae4196] | 1269 | if (size(#)) {default = string(#[1]);} |
---|
[917fb5] | 1270 | |
---|
[ae4196] | 1271 | if (size(fname)) |
---|
| 1272 | { |
---|
| 1273 | while (fname[i]==">") {i++;} |
---|
| 1274 | fname = fname[i,size(fname)-i+1]; |
---|
| 1275 | |
---|
| 1276 | if (size(fname)>=4) |
---|
| 1277 | { if(fname[size(fname)-3,4]==".tex") {fname = fname[1,size(fname)-4];}} |
---|
[917fb5] | 1278 | |
---|
| 1279 | "calling ",default, " for :",fname,newline; |
---|
| 1280 | |
---|
[0e6c7f] | 1281 | if (default=="latex2e") |
---|
| 1282 | { |
---|
| 1283 | retval = system("sh","latex " + fname +" &"); |
---|
| 1284 | } |
---|
| 1285 | else |
---|
| 1286 | { |
---|
| 1287 | retval = system("sh",default + " " + fname +" &"); |
---|
| 1288 | } |
---|
[ae4196] | 1289 | } |
---|
| 1290 | else |
---|
| 1291 | { " -- Need a filename "; |
---|
| 1292 | return(); |
---|
| 1293 | } |
---|
| 1294 | } |
---|
| 1295 | example |
---|
| 1296 | { "EXAMPLE:"; echo = 2; |
---|
[5bc214c] | 1297 | intmat m[3][4] = 9,2,4,5,2,5,-2,4,-6,10,-1,2,7; |
---|
[3c4dcc] | 1298 | opentex("exp001"); |
---|
[5bc214c] | 1299 | texobj("exp001","An intmat: ",m); |
---|
[ae4196] | 1300 | closetex("exp001"); |
---|
| 1301 | tex("exp001"); |
---|
| 1302 | xdvi("exp001"); |
---|
| 1303 | echo = 0; |
---|
[917fb5] | 1304 | pause("the created files will be deleted after pressing <RETURN>"); |
---|
[ae4196] | 1305 | echo = 2; |
---|
[5bc214c] | 1306 | system("sh","rm exp001.*"); |
---|
| 1307 | } |
---|
| 1308 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 1309 | |
---|
| 1310 | static proc parsr(string s) // parse real |
---|
[3c4dcc] | 1311 | { |
---|
[5bc214c] | 1312 | string t; |
---|
| 1313 | if (s==" Inf") { return("\\infty",3);} |
---|
| 1314 | if (s==" -Inf") { return("\\-infty",6);} |
---|
| 1315 | if (s[7]=="-"){t ="-";} |
---|
| 1316 | if (s[8]<>"0"){t = t + s[8];} |
---|
| 1317 | if (s[9]<>"0" or s[8]<>"0"){t = t + s[9];} |
---|
| 1318 | if (size(t)) |
---|
| 1319 | { if (t=="1") {return(s[1,5]+"*10",21);} |
---|
| 1320 | if (size(t)>1) {return(s[1,5]+"*10^{"+t+"}",21+2*size(t));} |
---|
| 1321 | else {return(s[1,5]+"*10^"+t,23);} |
---|
| 1322 | } |
---|
[3c4dcc] | 1323 | else |
---|
[5bc214c] | 1324 | { |
---|
| 1325 | return(s[1,5],12); |
---|
| 1326 | } |
---|
| 1327 | } |
---|
[1057ab5] | 1328 | /////////////////////////////////////////////////////////////////////////////// |
---|
[5bc214c] | 1329 | |
---|
[b6b6153] | 1330 | static proc parsg(string s) // parse Galois field |
---|
[3c4dcc] | 1331 | { |
---|
[5bc214c] | 1332 | string t; |
---|
[1057ab5] | 1333 | |
---|
| 1334 | if (s=="1") {return("1",5);} |
---|
[5bc214c] | 1335 | if (short) |
---|
[3c4dcc] | 1336 | { |
---|
[5bc214c] | 1337 | t =s[1]; |
---|
| 1338 | if(size(s)>1) {return(t+"^{" + s[2,size(s)-1] + "}",3+2*(size(s)-1));} |
---|
| 1339 | else{return(t,5);} |
---|
| 1340 | } |
---|
| 1341 | else |
---|
[3c4dcc] | 1342 | { |
---|
[5bc214c] | 1343 | return(parselong(s+"!")); |
---|
| 1344 | } |
---|
[ae4196] | 1345 | } |
---|
| 1346 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 1347 | |
---|
| 1348 | proc texpoly(string fname,def p,list #) |
---|
[5bc214c] | 1349 | "USAGE: texpoly(fname,p); fname string, p poly |
---|
[3754ca] | 1350 | RETURN: if @code{fname=\"\"}: string, the polynomial p in LaTeX-typesetting;@* |
---|
[3c4dcc] | 1351 | otherwise: append this string to the file @code{<fname>}, and |
---|
[5bc214c] | 1352 | return nothing. |
---|
[3c4dcc] | 1353 | NOTE: preceding \">>\" are deleted in @code{fname}, and suffix \".tex\" |
---|
[5bc214c] | 1354 | (if not given) is added to @code{fname}. |
---|
[afcf7d] | 1355 | EXAMPLE: example texpoly; shows an example |
---|
[651b46] | 1356 | " |
---|
[917fb5] | 1357 | { |
---|
[ae4196] | 1358 | def @r = basering; |
---|
| 1359 | |
---|
| 1360 | poly f,monom; |
---|
| 1361 | ideal I; |
---|
| 1362 | number cfm; |
---|
[1057ab5] | 1363 | string sign,cfmt,pt,s,bg,t,monomt,lnbreak; |
---|
[ae4196] | 1364 | string sep = newline; |
---|
[917fb5] | 1365 | int i,b,b2,n, msz,linesz, count,k; |
---|
[1057ab5] | 1366 | int realT, parT, galT, complT; |
---|
| 1367 | int TW = defined(TeXwidth); |
---|
| 1368 | |
---|
[ae4196] | 1369 | int C = 2 + defined(TeXdisplay); |
---|
| 1370 | |
---|
[1057ab5] | 1371 | string notvalid = "intvec intmat vector matrix module map"; |
---|
[ae4196] | 1372 | |
---|
| 1373 | if (typeof(p) == "int") { return(p);} |
---|
| 1374 | if (typeof(p) == "ring" or typeof(p) == "qring") |
---|
| 1375 | { " -- Call texring instead "; return();} |
---|
[917fb5] | 1376 | if (find(notvalid,typeof(p))) |
---|
[ae4196] | 1377 | { " -- Call texobj instead "; return();} |
---|
| 1378 | if (typeof(p) == "map") |
---|
| 1379 | { " -- Call texmap instead "; return();} |
---|
| 1380 | if (typeof(p) == "proc") |
---|
| 1381 | { " -- Call texmap instead "; return();} |
---|
| 1382 | if (typeof(p) == "link" or typeof(p) == "list" or typeof(p) == "resolution") |
---|
[1057ab5] | 1383 | { ERROR(" // -- Object cannot translated into tex "); return();} |
---|
[ae4196] | 1384 | |
---|
| 1385 | if (!(defined(TeXdisplay))){ lnbreak = "\\\\[2mm]" + newline;} |
---|
| 1386 | else { lnbreak = "\\\\" + newline;} |
---|
| 1387 | |
---|
[917fb5] | 1388 | |
---|
[ae4196] | 1389 | if (defined(TeXdisplay)) { bg = "& ";} |
---|
[1057ab5] | 1390 | if (!TW) { int TeXwidth = -1; export TeXwidth;} |
---|
[ae4196] | 1391 | |
---|
| 1392 | // -- Type check |
---|
[917fb5] | 1393 | |
---|
[ae4196] | 1394 | if (typeof(p)=="string") |
---|
| 1395 | { if(defined(`p`)) |
---|
[917fb5] | 1396 | { pt = p + " = "; |
---|
| 1397 | p = `p`; |
---|
[ae4196] | 1398 | } |
---|
| 1399 | } |
---|
| 1400 | if (typeof(p)=="poly" or typeof(p)=="number") {I = p;} |
---|
[917fb5] | 1401 | |
---|
| 1402 | if (typeof(p)=="ideal") |
---|
[ae4196] | 1403 | { I = p; |
---|
| 1404 | if(size(#)){ sep = #[1];} |
---|
| 1405 | } |
---|
| 1406 | |
---|
[917fb5] | 1407 | if (I==0) |
---|
[ae4196] | 1408 | { if (!(defined(NoDollars))){return("$0$");} |
---|
| 1409 | else {return("0");} |
---|
| 1410 | } |
---|
| 1411 | |
---|
[917fb5] | 1412 | // -- Type check ende |
---|
[ae4196] | 1413 | |
---|
[917fb5] | 1414 | //--------------------- |
---|
[ae4196] | 1415 | |
---|
| 1416 | //------- set flags: -------------------------------------------------------- |
---|
[917fb5] | 1417 | |
---|
[ae4196] | 1418 | if (size(#)) |
---|
| 1419 | { if (typeof(#[1])=="int") { linesz = #[1];} |
---|
| 1420 | // if (typeof(#[1])=="string") { linesz = #[1];} |
---|
| 1421 | } |
---|
| 1422 | |
---|
| 1423 | parT = npars(@r); |
---|
| 1424 | realT = (charstr(@r)=="real"); |
---|
[1057ab5] | 1425 | complT = find(charstr(@r),"complex"); // 28.10.06 |
---|
| 1426 | if (complT) {parT=0;} |
---|
[ae4196] | 1427 | i = find(charstr(@r),","); |
---|
[1057ab5] | 1428 | if (i and !realT and !complT) |
---|
[ae4196] | 1429 | { t = charstr(@r)[1,i-1]; |
---|
| 1430 | galT = (t <> string(char(@r))); // the char is not the same as the ... |
---|
[917fb5] | 1431 | } |
---|
[ae4196] | 1432 | i = 0; |
---|
[917fb5] | 1433 | |
---|
[5bc214c] | 1434 | //------- parse the polynomial |
---|
[ae4196] | 1435 | pt = bg; |
---|
[917fb5] | 1436 | |
---|
[1057ab5] | 1437 | for(k=1;k<=ncols(I);k++) |
---|
[ae4196] | 1438 | { i = 0; linesz = 0; count =0; |
---|
[917fb5] | 1439 | sign =""; |
---|
[ae4196] | 1440 | f = I[k]; |
---|
| 1441 | if (f==0) { pt = pt + "0";} |
---|
| 1442 | while(f<>0) |
---|
| 1443 | { count++; msz = 0; |
---|
| 1444 | |
---|
| 1445 | // ------ tex the coefficient |
---|
[917fb5] | 1446 | monom = lead(f); |
---|
| 1447 | f = f - monom; |
---|
[ae4196] | 1448 | cfm = leadcoef(monom); |
---|
[1057ab5] | 1449 | if (cfm*1 != 0) { monom = leadmonom(monom);} // to conform with integer |
---|
[2301b7] | 1450 | if (defined(TeXreplace)) { short =0;} // this is essential //31.5.07 |
---|
[ae4196] | 1451 | s = string(monom) + "!"; // add a terminating sign |
---|
| 1452 | cfmt = ""; |
---|
[917fb5] | 1453 | |
---|
[ae4196] | 1454 | cfmt = string(cfm); |
---|
| 1455 | if (size(cfmt)>1) // check if sign is < 0 |
---|
| 1456 | { if (cfmt[2]=="-") { cfm = (-1) *cfm; sign = "-";}} |
---|
| 1457 | if (cfmt[1] == "-") { cfm = (-1) * cfm; sign = "-";} |
---|
| 1458 | if (cfm!=1 or monom==1) {cfmt = string(cfm);} |
---|
| 1459 | else {cfmt="";} |
---|
| 1460 | |
---|
| 1461 | if (defined(TeXwidth) and TeXwidth > 0 and TeXwidth <9 and count> TeXwidth) |
---|
[5bc214c] | 1462 | { pt = pt + sign + "\\ldots"; break;} |
---|
[ae4196] | 1463 | // ---------------------------------------- linesz ?? |
---|
| 1464 | |
---|
| 1465 | if (size(cfmt)) // parse the coefficient |
---|
| 1466 | { |
---|
| 1467 | monomt = cfmt; // (already a good choice for integers) |
---|
| 1468 | msz = 3*size(cfmt); |
---|
| 1469 | |
---|
| 1470 | if(realT) { monomt,msz = parsr(cfmt);} |
---|
| 1471 | if (galT) { monomt,msz = parsg(cfmt);} |
---|
[2301b7] | 1472 | b = find(cfmt,"/("); // look if fraction // 31.5.07 |
---|
[ae4196] | 1473 | b2 = find(cfmt,"/"); |
---|
[2301b7] | 1474 | // if (b) {b++;} // 31.5.07 |
---|
[ae4196] | 1475 | n = size(cfmt); |
---|
[917fb5] | 1476 | if (!(parT) and !(realT) and !(galT)) |
---|
| 1477 | { if( !(b2) or defined(TeXnofrac)) |
---|
[ae4196] | 1478 | { monomt = cfmt; msz = 3*size(monomt);} |
---|
| 1479 | else |
---|
| 1480 | { monomt = "\\frac{" + cfmt[1,b2-1] + "}{" + cfmt[b2+1,n-b2] + "}"; |
---|
| 1481 | if (n-2*b2>0) {msz = C*(n-b2);} |
---|
| 1482 | else {msz = C*b2;} |
---|
| 1483 | } |
---|
| 1484 | } |
---|
| 1485 | if (parT and !(galT)) |
---|
| 1486 | { monomt,msz = parsp(cfmt,b);} |
---|
| 1487 | } |
---|
[1057ab5] | 1488 | if (monom!=1 and monomt!="" and parT) // 21.4.10 |
---|
| 1489 | { monomt = monomt+"\\cdot ";} // at least a blank is needed for TeXreplace |
---|
[ae4196] | 1490 | |
---|
| 1491 | // -- now parse the monom |
---|
| 1492 | if (monom <> 1) |
---|
[917fb5] | 1493 | { i = 1; |
---|
[ae4196] | 1494 | if(short) |
---|
| 1495 | { while(s[i]<>"!") |
---|
[917fb5] | 1496 | { monomt = monomt + s[i]; i++; |
---|
[ae4196] | 1497 | b = i; |
---|
| 1498 | msz = msz + 3; // it was a single lettered var |
---|
| 1499 | while(s[i]!="!" and s[i]>="0" and s[i]<="9"){i++;} |
---|
| 1500 | if (i-b) |
---|
| 1501 | { monomt = monomt + "^{" + s[b,i-b] + "}"; |
---|
| 1502 | msz = msz + 2*(i-b); |
---|
| 1503 | } |
---|
| 1504 | } |
---|
| 1505 | } |
---|
| 1506 | else // not short |
---|
| 1507 | { t,i = parselong(s); |
---|
| 1508 | monomt = monomt + t; |
---|
| 1509 | msz = msz + i; |
---|
| 1510 | } |
---|
| 1511 | } |
---|
[917fb5] | 1512 | |
---|
[ae4196] | 1513 | msz = msz + 6*size(sign); // Wieso mal 6 ?? |
---|
| 1514 | // string(msz) + " ," + string(linesz) + " " + string(cfm*monom); |
---|
| 1515 | |
---|
| 1516 | if (TeXwidth > 10 and (linesz + msz > 3*TeXwidth) and linesz) |
---|
[917fb5] | 1517 | { pt = pt + lnbreak + bg; |
---|
| 1518 | linesz = msz; |
---|
[ae4196] | 1519 | } |
---|
[917fb5] | 1520 | else { linesz = linesz + msz; } // 3 for sign |
---|
[ae4196] | 1521 | pt = pt + sign + monomt; |
---|
| 1522 | sign = "+"; |
---|
| 1523 | monomt = ""; |
---|
| 1524 | } |
---|
| 1525 | |
---|
[1057ab5] | 1526 | if (k<ncols(I)){ pt = pt + sep;} |
---|
[ae4196] | 1527 | } |
---|
| 1528 | |
---|
| 1529 | if (TeXwidth==0 and typeof(p)=="poly"){ pt = pt + "= 0";} |
---|
[1057ab5] | 1530 | if (!TW) { kill TeXwidth;} // kill Latex:: |
---|
[ae4196] | 1531 | if (not(defined(NoDollars))) { pt = "$"+pt+"$";} |
---|
| 1532 | |
---|
| 1533 | if (size(fname)) |
---|
| 1534 | { i=1; |
---|
| 1535 | while (fname[i]==">"){i++;} |
---|
| 1536 | fname = fname[i,size(fname)-i+1]; |
---|
| 1537 | |
---|
| 1538 | if (size(fname)>=4) // check if filename is ending with ".tex" |
---|
| 1539 | { if(fname[size(fname)-3,4]!=".tex") {fname = fname +".tex"; } |
---|
| 1540 | } |
---|
| 1541 | else {fname = fname + ".tex";} |
---|
| 1542 | write(fname,pt); |
---|
| 1543 | } |
---|
| 1544 | else {return(pt);} |
---|
[917fb5] | 1545 | } |
---|
[ae4196] | 1546 | example |
---|
| 1547 | { "EXAMPLE:"; echo =2; |
---|
| 1548 | ring r0=0,(x,y,z),dp; |
---|
| 1549 | poly f = -1x^2 + 2; |
---|
| 1550 | texpoly("",f); |
---|
[5bc214c] | 1551 | ring rr= real,(x,y,z),dp; |
---|
[ae4196] | 1552 | texpoly("",2x2y23z); |
---|
| 1553 | ring r7= 7,(x,y,z),dp; |
---|
| 1554 | poly f = 2x2y23z; |
---|
| 1555 | texpoly("",f); |
---|
| 1556 | ring rab =(0,a,b),(x,y,z),dp; |
---|
| 1557 | poly f = (-2a2 +b3 -2)/a * x2y4z5 + (a2+1)*x + a+1; |
---|
| 1558 | f; |
---|
| 1559 | texpoly("",f); |
---|
[2301b7] | 1560 | texpoly("",1/(a2+2)*x+2/b); |
---|
[917fb5] | 1561 | } |
---|
[1057ab5] | 1562 | /////////////////////////////////////////////////////////////////////////////// |
---|
[ae4196] | 1563 | |
---|
[651b46] | 1564 | static proc parsp(string cfmt, int b) |
---|
[ae4196] | 1565 | { string mt, nom,denom; |
---|
| 1566 | int fl1,fl2,sz1,sz2,msz; |
---|
| 1567 | |
---|
| 1568 | if (!(b)) |
---|
| 1569 | { mt,fl1 = parst(cfmt,0); msz = size(cfmt)-2; |
---|
| 1570 | if (fl1) { mt = "(" + mt + ")"; msz = msz +1; } |
---|
| 1571 | } |
---|
| 1572 | else |
---|
| 1573 | { nom,fl1 = parst(cfmt[1,b-1],1); |
---|
| 1574 | denom,fl2 = parst(cfmt[b+1,size(cfmt)-b],1); |
---|
| 1575 | if (defined(TeXnofrac)) |
---|
| 1576 | { if(fl1) { nom = "(" + nom + ")"; sz1++;} |
---|
| 1577 | if(fl2) {denom = "(" + denom + ")"; sz2++;} |
---|
[2301b7] | 1578 | mt = "(" + nom+ "/"+ denom+ ")"; msz = sz1+sz2 +1; //31.5.07 |
---|
[ae4196] | 1579 | } |
---|
| 1580 | else |
---|
| 1581 | { mt = "\\frac{" + nom + "}{" + denom + "}"; |
---|
| 1582 | if (sz1-sz2) { msz = 5*sz1;} |
---|
| 1583 | else {msz = 5*sz2;} |
---|
| 1584 | } |
---|
| 1585 | } |
---|
| 1586 | return(mt,msz); |
---|
| 1587 | } |
---|
| 1588 | example |
---|
| 1589 | {"EXAMPLE:"; echo =2; |
---|
| 1590 | ring r=(0,a,b),x,dp; |
---|
| 1591 | int i; |
---|
| 1592 | poly f = (a2b12 + 23a2 -b13-1)/(a2+2b -1); |
---|
| 1593 | f; |
---|
| 1594 | string s; |
---|
| 1595 | s= string(f); |
---|
| 1596 | i = find(s,")/("); |
---|
| 1597 | parsp(s,i); |
---|
| 1598 | } |
---|
[1057ab5] | 1599 | /////////////////////////////////////////////////////////////////////////////// |
---|
[ae4196] | 1600 | |
---|
[651b46] | 1601 | static proc parst(string s,int sec) // parse parameter |
---|
[ae4196] | 1602 | // sec parameter to see if in parsp a fraction follows |
---|
[1057ab5] | 1603 | { |
---|
| 1604 | int i,j =1,-1; |
---|
| 1605 | int b,k,jj,mz,in; // begin and end, in for index |
---|
[ae4196] | 1606 | int saveshort=short; |
---|
[1057ab5] | 1607 | string t,c,vn,nom,denom,sg; |
---|
| 1608 | |
---|
[6a7528] | 1609 | if (s[1]=="(") { s = s[2,size(s)-2]; } |
---|
| 1610 | s = s + "!"; |
---|
[ae4196] | 1611 | |
---|
| 1612 | if (short) |
---|
[7f3ad4] | 1613 | { j = 0; // 31.5.07 |
---|
[2301b7] | 1614 | while(s[i]<>"!") |
---|
| 1615 | { b=i; if (s[i]=="+" or s[i]=="-") {j++;} // 31.5.07 |
---|
[ae4196] | 1616 | while(s[i]>="0" and s[i]<="9" or (s[i]=="+" or s[i]=="-") and s[i]!="!") |
---|
[6a7528] | 1617 | {i++;} // scan the number |
---|
[ae4196] | 1618 | t =s[b,i-b]; |
---|
| 1619 | // if (t=="-1" and s[i]!="!" and s[i]!="-" and s[i]!="+"){t = "-";} |
---|
| 1620 | if (t=="-1" and (s[i]<="0" or s[i]>="9") and s[i]!= "/" and s[i]!="!") |
---|
[1057ab5] | 1621 | {t = "-";} |
---|
[6a7528] | 1622 | if (s[i]=="/") |
---|
[ae4196] | 1623 | { i++; |
---|
| 1624 | sg = ""; |
---|
| 1625 | if (t[1]=="+" or t[1]=="-") |
---|
| 1626 | { nom = t[2,size(t)-1]; |
---|
| 1627 | sg = t[1]; |
---|
| 1628 | } |
---|
| 1629 | else { nom = t;} |
---|
[6a7528] | 1630 | b =i; |
---|
[ae4196] | 1631 | while(s[i]>="0" and s[i]<="9") {i++;} |
---|
| 1632 | denom = s[b,i-b]; |
---|
| 1633 | if (!(sec) and (!(defined(TeXaligned)))) |
---|
| 1634 | { t = sg + "\\frac{" + nom + "}{" + denom + "}";} |
---|
| 1635 | else |
---|
| 1636 | { t = sg + "(" + nom + "/" + denom + ")"; |
---|
| 1637 | } |
---|
[6a7528] | 1638 | } |
---|
[ae4196] | 1639 | c = c + t; |
---|
| 1640 | if(s[i]!="!"){c = c + s[i]; i++;} // the parameter |
---|
| 1641 | b=i; |
---|
| 1642 | while(s[i]>="0" and s[i]<="9") |
---|
| 1643 | {i++;} //the exponent |
---|
[1057ab5] | 1644 | if(i-b){ c = c + "^{" + s[b,i-b]+"}";} |
---|
[ae4196] | 1645 | } |
---|
| 1646 | } |
---|
| 1647 | else // if not short .... |
---|
[6a7528] | 1648 | { while (s[i] <> "!") |
---|
[1057ab5] | 1649 | { b=i; j++; in=0; // 4.10.10 |
---|
[ae4196] | 1650 | while(s[i]=="-" or s[i]=="+" or (s[i]>="0" and s[i]<="9")){i++;} |
---|
| 1651 | t = s[b,i-b]; |
---|
| 1652 | if (t=="-1" and s[i]=="*" ) {t="-";} |
---|
[1057ab5] | 1653 | if (s[i]=="/") |
---|
| 1654 | { i++; |
---|
| 1655 | sg = ""; |
---|
| 1656 | if (t[1]=="+" or t[1]=="-") |
---|
| 1657 | { nom = t[2,size(t)-1]; |
---|
| 1658 | sg = t[1]; |
---|
| 1659 | } |
---|
| 1660 | else { nom = t;} |
---|
| 1661 | b =i; |
---|
| 1662 | while(s[i]>="0" and s[i]<="9") {i++;} |
---|
| 1663 | denom = s[b,i-b]; |
---|
| 1664 | if (!(sec) and (!(defined(TeXaligned)))) |
---|
| 1665 | { t = sg + "\\frac{" + nom + "}{" + denom + "}";} |
---|
| 1666 | else |
---|
| 1667 | { t = sg + "(" + nom + "/" + denom + ")"; |
---|
| 1668 | } |
---|
| 1669 | } |
---|
[6a7528] | 1670 | c = c+t; t=""; |
---|
| 1671 | if (s[i]=="*"){i++;} |
---|
[ae4196] | 1672 | b=i; |
---|
[1057ab5] | 1673 | // string(s[1,b]); |
---|
| 1674 | |
---|
[ae4196] | 1675 | while(s[i]!="+" and s[i]!="-" and s[i]!="!") //pass a monom |
---|
[6a7528] | 1676 | { // start with letters |
---|
[ae4196] | 1677 | // alternativ: |
---|
[1057ab5] | 1678 | //in=0; // 4.10.10 |
---|
[ae4196] | 1679 | while((s[i]>="a" and s[i]<="z") or (s[i]>="A" and s[i]<="Z")){i++;} |
---|
[1057ab5] | 1680 | k = i-b; |
---|
[ae4196] | 1681 | vn = s[b,k]; |
---|
| 1682 | if (defined(TeXreplace)) |
---|
[6a7528] | 1683 | { for (jj=1; jj<= size(TeXreplace);jj++) |
---|
| 1684 | { if (vn == TeXreplace[jj][1]) |
---|
[ae4196] | 1685 | {vn = TeXreplace[jj][2]; k=1; |
---|
[6a7528] | 1686 | if (s[i]=="*") {vn = vn + " ";} |
---|
[ae4196] | 1687 | break;} //suppose replacing by a single sign |
---|
| 1688 | } |
---|
| 1689 | } |
---|
| 1690 | t = t + vn; |
---|
| 1691 | mz = mz + 10*k; |
---|
[1057ab5] | 1692 | if (s[i]=="_" or s[i]=="(") {in++; i++;} // the index is coming |
---|
[ae4196] | 1693 | b = i; |
---|
| 1694 | while(s[i]>="0" and s[i]<="9"){ i++;} |
---|
| 1695 | k = i-b; |
---|
[1057ab5] | 1696 | if (k and in<=1) {t = t + "_{";in++;} //and k i.e. there was an index |
---|
| 1697 | if (k){ t = t +s[b,k];} |
---|
[ae4196] | 1698 | if(s[i]==")") {i++;} |
---|
[1057ab5] | 1699 | if(k and s[i]!="(" and s[i]!="_"){ t = t + "}";} // index closed |
---|
| 1700 | if(s[i]=="(" or s[i]=="_") {i++; t = t + ",";in++;} |
---|
| 1701 | if (s[i]=="^") |
---|
[ae4196] | 1702 | { i++; b = i; |
---|
| 1703 | while(s[i]>="0" and s[i]<="9"){ i++;} // for neg. expon. |
---|
| 1704 | if (b-i) { t = t + "^{" + s[b,i-b] + "}";} |
---|
| 1705 | } |
---|
[1057ab5] | 1706 | if (i-b > k) { mz = mz + 5*(i-b);} |
---|
[ae4196] | 1707 | else {mz = mz + 5*k;} |
---|
[1057ab5] | 1708 | if (s[i]=="*"){i++;in=0;} |
---|
| 1709 | b=i; |
---|
| 1710 | } |
---|
| 1711 | c =c+t; |
---|
[ae4196] | 1712 | } |
---|
| 1713 | } |
---|
[1057ab5] | 1714 | short = saveshort; |
---|
| 1715 | return(c,j); |
---|
[ae4196] | 1716 | } |
---|
| 1717 | example |
---|
| 1718 | { "EXAMPLE:"; echo =2; |
---|
| 1719 | ring r=(0,a,b),x,dp; |
---|
| 1720 | poly f = (a2b12 + 23a2 -b13-1); |
---|
| 1721 | f; |
---|
[1057ab5] | 1722 | parst(string(f),0); |
---|
[6a7528] | 1723 | |
---|
[ae4196] | 1724 | f =(-a +4b2 -2); |
---|
| 1725 | f; |
---|
[1057ab5] | 1726 | parst(string(f),0); |
---|
[6a7528] | 1727 | |
---|
[ae4196] | 1728 | f = a23; |
---|
| 1729 | f; |
---|
[1057ab5] | 1730 | parst(string(f),0); |
---|
[ae4196] | 1731 | f = 2a12b3 -4ab15 +2a4b12 -2; |
---|
| 1732 | short =0; |
---|
| 1733 | f; |
---|
[1057ab5] | 1734 | parst(string(f),0); |
---|
[ae4196] | 1735 | ring r2=(0,a1,b1),x,dp; |
---|
| 1736 | poly f = 2*a1^12*b1^3 -4*a1*b1^15 +2*a1^4*b1^12 -2; |
---|
| 1737 | f; |
---|
[1057ab5] | 1738 | parst(string(f),0); |
---|
[ae4196] | 1739 | } |
---|
[1057ab5] | 1740 | /////////////////////////////////////////////////////////////////////////////// |
---|
[ae4196] | 1741 | |
---|
[651b46] | 1742 | static proc parselong(string s) |
---|
[6a7528] | 1743 | { |
---|
[1057ab5] | 1744 | int i,j,k,b,mz,in; // in is a counter for indices |
---|
[ae4196] | 1745 | string t,vn; // varname |
---|
[6a7528] | 1746 | |
---|
| 1747 | i = 1; |
---|
| 1748 | while (s[i] <> "!") |
---|
| 1749 | { b=i; |
---|
| 1750 | |
---|
[1057ab5] | 1751 | // -- scan now the letter ... |
---|
[ae4196] | 1752 | // while(s[i]!="!" and ) |
---|
| 1753 | |
---|
| 1754 | // alternativ: |
---|
| 1755 | while((s[i]>="a" and s[i]<="z") or (s[i]>="A" and s[i]<="Z")) |
---|
| 1756 | { i++;} |
---|
| 1757 | // s[i]; i; |
---|
[6a7528] | 1758 | k = i-b; |
---|
[ae4196] | 1759 | vn = s[b,k]; |
---|
| 1760 | |
---|
| 1761 | if (defined(TeXreplace)) |
---|
[6a7528] | 1762 | { for (j=1; j<= size(TeXreplace);j++) |
---|
| 1763 | { if (vn == TeXreplace[j][1]) |
---|
[ae4196] | 1764 | {vn = TeXreplace[j][2]; k=1; |
---|
[6a7528] | 1765 | if (s[i]=="*") {vn = vn + " ";} |
---|
[ae4196] | 1766 | break;} //suppose replacing by a single sign |
---|
| 1767 | } |
---|
| 1768 | } |
---|
| 1769 | t = t + vn; |
---|
| 1770 | mz = mz + 10*k; |
---|
[1057ab5] | 1771 | if (s[i]=="_" or s[i]=="(") { in++;i++;} // the index is coming |
---|
[ae4196] | 1772 | b = i; |
---|
[1057ab5] | 1773 | while(s[i]>="0" and s[i]<="9" or s[i]=="-"){ i++;} // "-" for neg indices |
---|
[ae4196] | 1774 | j = i-b; |
---|
[1057ab5] | 1775 | // if (j){ t = t + "_{" +s[b,j] + "}";} // formely |
---|
| 1776 | if (j and in<=1) {t = t + "_{";in++;} // and j i.e. there was an index |
---|
| 1777 | if (j){ t = t +s[b,j];} |
---|
[ae4196] | 1778 | if(s[i]==")") {i++;} |
---|
[1057ab5] | 1779 | if(j and s[i]!="(" and s[i]!="_"){ t = t + "}";} // index closed |
---|
| 1780 | if(s[i]=="(" or s[i]=="_") {i++; t = t + ",";in++;} |
---|
[ae4196] | 1781 | if (s[i]=="^") |
---|
| 1782 | { i++; b = i; |
---|
| 1783 | while(s[i]>="0" and s[i]<="9" or s[i]=="-") |
---|
| 1784 | { i++;} // for neg. expon. |
---|
| 1785 | if (b-i) { t = t + "^{" + s[b,i-b] + "}";} |
---|
| 1786 | } |
---|
| 1787 | if (i-b > j) { mz = mz + 5*(i-b);} |
---|
| 1788 | else {mz = mz + 5*j;} |
---|
[1057ab5] | 1789 | if (s[i]=="*"){i++;in=0;} |
---|
[ae4196] | 1790 | } |
---|
| 1791 | return(t,mz); |
---|
| 1792 | } |
---|
| 1793 | example |
---|
[6a7528] | 1794 | { "EXAMPLE:"; echo =2; |
---|
[ae4196] | 1795 | ring r =(49,a),x,dp; |
---|
| 1796 | number f = a13; |
---|
| 1797 | parsg(string(f)); |
---|
| 1798 | list TeXreplace; export TeXreplace; |
---|
| 1799 | TeXreplace[1] = list("b","\\beta"); |
---|
| 1800 | TeXreplace[2] = list("a","\\alpha"); |
---|
[6a7528] | 1801 | TeXreplace[3] = list("c","\\gamma"); |
---|
[ae4196] | 1802 | parselong(string(f)+"!"); |
---|
| 1803 | } |
---|
| 1804 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 1805 | |
---|
[1057ab5] | 1806 | /* obsolete |
---|
[5bc214c] | 1807 | static proc tktex (def d) |
---|
[afcf7d] | 1808 | { |
---|
| 1809 | // calls appropriate proc from latex lib |
---|
| 1810 | |
---|
| 1811 | string typeofd =typeof(d); |
---|
| 1812 | if (typeofd=="int" or typeofd=="string" or typeofd=="resolution" or typeofd=="map" or typeofd =="list"){ return(d);} |
---|
| 1813 | |
---|
| 1814 | if (typeofd=="intvec" or typeofd == "intmat" or typeofd =="vector" or |
---|
| 1815 | typeofd=="matrix" or typeofd == "module") { return(texobj("",d));} |
---|
| 1816 | if (typeofd=="ring" or typeofd=="qring") { return(texring("",d));} |
---|
| 1817 | if (typeofd =="ideal") { return(texobj("",d));} |
---|
| 1818 | if (typeofd=="number" or typeofd=="poly" or typeofd=="ideal") |
---|
| 1819 | { return(texpoly("",d));} |
---|
| 1820 | if (typeofd=="link") {return(d);} |
---|
| 1821 | |
---|
| 1822 | } |
---|
[1057ab5] | 1823 | */ |
---|
[5bc214c] | 1824 | ///////////////////////////// PART0 ////////////////////////////////////////// |
---|
[1057ab5] | 1825 | |
---|
[5bc214c] | 1826 | static proc part0(string fname) |
---|
| 1827 | { |
---|
| 1828 | int texdemopart =0; |
---|
| 1829 | export texdemopart; |
---|
| 1830 | |
---|
| 1831 | |
---|
| 1832 | // Singular script for generating tldemo.tex |
---|
[917fb5] | 1833 | |
---|
[ae4196] | 1834 | string nl = newline; |
---|
| 1835 | string nl2 = newline + newline; |
---|
| 1836 | string lb = "\\\\"; |
---|
| 1837 | string bv = "\\begin{verbatim}" + newline ; |
---|
[1057ab5] | 1838 | string ev = newline + "\\end{verbatim}" +newline ; |
---|
[ae4196] | 1839 | |
---|
[5bc214c] | 1840 | // "generating part0 of " + fname + nl; |
---|
[ae4196] | 1841 | |
---|
| 1842 | opentex(fname); |
---|
| 1843 | |
---|
[1057ab5] | 1844 | write(fname,"\\newcommand{\\Line}{{}\\par\\noindent\\rule{\\textwidth}{0.25mm}\\\\[1mm]}"); |
---|
[ae4196] | 1845 | |
---|
[1057ab5] | 1846 | write(fname,"\\centerline{\\textbf{\\large Demo file for latex.lib }}"); |
---|
| 1847 | // write(fname,"\\centerline{\\textbf{\\large Christian Gorzel }}"); |
---|
| 1848 | write(fname,"\\centerline{07/10/2010}"); |
---|
[ae4196] | 1849 | write(fname,"\\vspace{1cm}"); |
---|
| 1850 | |
---|
| 1851 | //-- |
---|
| 1852 | |
---|
[1057ab5] | 1853 | write(fname,"","\\section{Introduction}"); |
---|
[651b46] | 1854 | write(fname,"The procedures in \\verb|latex.lib| translate the output of |
---|
[b6b6153] | 1855 | {\\sc Singular} into \\LaTeX \\ text. |
---|
| 1856 | This document illustrates the functionality of the library."+"\\\\" + nl); |
---|
[5bc214c] | 1857 | write(fname,"\\begin{tabular}{ll}" + nl + |
---|
[3c4dcc] | 1858 | "LIBRARY: {\\tt latex.lib} & PROCEDURES FOR TYPESETTING SINGULAR" + |
---|
[5bc214c] | 1859 | "\\\\" + nl + |
---|
| 1860 | " & OBJECTS IN LATEX2E"+ |
---|
| 1861 | "\\\\" + nl + |
---|
| 1862 | "{\\tt closetex(fnm);} & writes closing line for \\LaTeX-document"+ |
---|
| 1863 | "\\\\" + nl + |
---|
| 1864 | "{\\tt opentex(fnm);} & writes header for \\LaTeX-file fnm"+ |
---|
| 1865 | "\\\\" + nl + |
---|
| 1866 | "{\\tt tex(fnm);} & calls \\LaTeX2e for file fnm"+ |
---|
| 1867 | "\\\\" + nl + |
---|
| 1868 | "{\\tt texdemo([n]);} & produces a file explaining the features of this lib"+ |
---|
| 1869 | "\\\\" + nl + |
---|
[3c4dcc] | 1870 | "{\\tt texfactorize(fnm,f);} & creates string in \\LaTeX-format for |
---|
[3754ca] | 1871 | factors of polynomial f"+ "\\\\" + nl + |
---|
[5bc214c] | 1872 | "{\\tt texmap(fnm,m,r1,r2);} & creates string in \\LaTeX-format for |
---|
| 1873 | map m:r1$\\rightarrow$r2"+ "\\\\" + nl + |
---|
[3c4dcc] | 1874 | "{\\tt texname(fnm,s);} & creates string in \\LaTeX-format for |
---|
[5bc214c] | 1875 | identifier"+ "\\\\" + nl + |
---|
| 1876 | "{\\tt texobj(l);} & creates string in \\LaTeX-format for |
---|
| 1877 | any (basic) type"+ "\\\\" + nl + |
---|
| 1878 | "{\\tt texpoly(f,n[,l]);} & creates string in \\LaTeX-format for poly"+ |
---|
| 1879 | "\\\\" + nl + |
---|
| 1880 | "{\\tt texproc(fnm,p);} & creates string in \\LaTeX-format of |
---|
| 1881 | text from proc p"+ "\\\\" + nl + |
---|
[1057ab5] | 1882 | "{\\tt texring(fnm,r[,l]);} & creates string in \\LaTeX-format for |
---|
[5bc214c] | 1883 | ring/qring"+ "\\\\" + nl + |
---|
| 1884 | "{\\tt rmx(s);} & removes .aux and .log files of \\LaTeX-files"+ |
---|
| 1885 | "\\\\" + nl + |
---|
| 1886 | "{\\tt xdvi(s);} & calls xdvi for dvi-files"+ |
---|
| 1887 | "\\\\" + nl + |
---|
| 1888 | " \\end{tabular} " + nl2 + "\\vspace{0.2cm}" + nl2 + |
---|
| 1889 | "(parameters in square brackets {\\tt [ ]} are optional)"+ |
---|
| 1890 | "\\\\" + nl2 + "\\vspace{0.2cm}" + nl2 + |
---|
| 1891 | "The global variables {\\tt TeXwidth}, {\\tt TeXnofrac}, {\\tt |
---|
[3c4dcc] | 1892 | TeXbrack}, {\\tt TeXproj}, {\\tt TeXaligned}, {\\tt TeXreplace}, {\\tt |
---|
[5bc214c] | 1893 | NoDollars} are used to control the typesetting: " |
---|
| 1894 | ); |
---|
[ae4196] | 1895 | |
---|
| 1896 | write(fname, |
---|
| 1897 | bv + |
---|
| 1898 | " |
---|
[5bc214c] | 1899 | TeXwidth (int) -1, 0, 1..9, >9: controls breaking of long polynomials |
---|
| 1900 | TeXnofrac (int) flag: write 1/2 instead of \\frac{1}{2} |
---|
| 1901 | TeXbrack (string) \"{\", \"(\", \"<\", \"|\", empty string: |
---|
| 1902 | controls brackets around ideals and matrices |
---|
| 1903 | TeXproj (int) flag: write \":\" instead of \",\" in vectors |
---|
| 1904 | TeXaligned (int) flag: write mappings (and ideals) aligned |
---|
| 1905 | TeXreplace (list) list entries = 2 strings: replacing symbols |
---|
| 1906 | NoDollars (int) flag: suppresses surrounding $ signs |
---|
[917fb5] | 1907 | |
---|
[ae4196] | 1908 | " + |
---|
| 1909 | ev); |
---|
[b6b6153] | 1910 | write(fname,"Notice that none of these global variables are defined when |
---|
| 1911 | loading \\verb|latex.lib|. A flag variable is set as soon as it is defined."); |
---|
[3c4dcc] | 1912 | |
---|
[ae4196] | 1913 | |
---|
| 1914 | //% The procs and |
---|
| 1915 | //% the global variables |
---|
| 1916 | |
---|
| 1917 | //----------------------- opentex ----------------------------- |
---|
[1057ab5] | 1918 | write(fname,"","\\section{Opening a \\LaTeX\\ file}"); |
---|
| 1919 | write(fname,"","In order to create a \\LaTeX\\ document and write a standard |
---|
| 1920 | header into it, use the following command."+ nl + |
---|
[b6b6153] | 1921 | bv+ |
---|
| 1922 | "> string fname = \"" + fname + "\";" + nl + |
---|
[3c4dcc] | 1923 | "> texopen(fname);" + |
---|
[1057ab5] | 1924 | ev); |
---|
[b6b6153] | 1925 | |
---|
| 1926 | write(fname,"The variable \\verb|fname| is always the first argument when |
---|
| 1927 | calling one of the procedures of \\verb|latex.lib|. If this string is the |
---|
| 1928 | empty string, then the output in not written into a file but displayed on |
---|
| 1929 | the screen."); |
---|
[6a7528] | 1930 | |
---|
[ae4196] | 1931 | //% opentex, defaulted to latex, possibly extension are ... and |
---|
[6a7528] | 1932 | //% ``own'' |
---|
[ae4196] | 1933 | |
---|
| 1934 | |
---|
| 1935 | pagewidth = 65; |
---|
[651b46] | 1936 | int TeXwidth = 100; export TeXwidth; |
---|
[5bc214c] | 1937 | // "part 0 generated " + nl; |
---|
[ae4196] | 1938 | } //part0 |
---|
| 1939 | |
---|
| 1940 | |
---|
| 1941 | ///////////////////////////// PART1 ////////////////////////////////////////// |
---|
| 1942 | |
---|
[651b46] | 1943 | static proc part1(string fname) |
---|
[3c4dcc] | 1944 | { |
---|
[5bc214c] | 1945 | |
---|
| 1946 | int st = defined(texdemopart); |
---|
| 1947 | string nl = newline; |
---|
| 1948 | string nl2 = newline + newline; |
---|
| 1949 | string lb = "\\\\"; |
---|
| 1950 | string bv = "\\begin{verbatim}" + newline ; |
---|
[1057ab5] | 1951 | string ev = newline + "\\end{verbatim}" + newline ; |
---|
[ae4196] | 1952 | |
---|
| 1953 | if (not(st) or texdemopart>=1) |
---|
| 1954 | { print(" Call part0 first"); |
---|
| 1955 | return(); |
---|
| 1956 | } |
---|
| 1957 | else { texdemopart=1; } |
---|
[6a7528] | 1958 | |
---|
[5bc214c] | 1959 | //"Continuing part1 of " + fname + nl; |
---|
[ae4196] | 1960 | |
---|
[1057ab5] | 1961 | write(fname,"","\\section{Rings, polynomials and ideals}",""); |
---|
[ae4196] | 1962 | |
---|
| 1963 | // -1a------ a ring in char 0, short varnames and poly. ordering ---------- |
---|
| 1964 | write(fname, |
---|
[3c4dcc] | 1965 | " A ring in characteristic 0 with short names of variables and polynomial |
---|
[b6b6153] | 1966 | ordering." +nl); |
---|
[d6cc54] | 1967 | ring r0=0,(x,y,z),dp; |
---|
[5bc214c] | 1968 | poly g=-x2y+2y13z+1; |
---|
[ae4196] | 1969 | write(fname, |
---|
| 1970 | bv + |
---|
[5bc214c] | 1971 | "> ring r0=0,(x,y,z),dp;" +nl+ |
---|
| 1972 | "> texring(fname,r0);" + |
---|
| 1973 | ev); |
---|
[3c4dcc] | 1974 | texring(fname,r0); |
---|
[5bc214c] | 1975 | write(fname,nl2); |
---|
| 1976 | write(fname, |
---|
| 1977 | bv + |
---|
[b6b6153] | 1978 | "> poly g=-x2y+2y13z+1; g;" + nl + |
---|
[1057ab5] | 1979 | "> texpoly(fname,g);" + |
---|
[5bc214c] | 1980 | ev); |
---|
[3c4dcc] | 1981 | texpoly(fname,g); |
---|
[1057ab5] | 1982 | write(fname,"\\\\"+nl); |
---|
[5bc214c] | 1983 | |
---|
[ae4196] | 1984 | // write(fname,"\\Line"); |
---|
| 1985 | |
---|
[3754ca] | 1986 | // -1b------ still in the same ring, a polynomial with rational coefs -------- |
---|
[ae4196] | 1987 | write(fname, |
---|
[1057ab5] | 1988 | ""," A polynomial with rational coefficients." +nl); |
---|
[ae4196] | 1989 | write(fname, |
---|
| 1990 | bv + |
---|
[1057ab5] | 1991 | "> texpoly(fname,g/280);" + |
---|
[ae4196] | 1992 | ev |
---|
[6a7528] | 1993 | ); |
---|
[3c4dcc] | 1994 | texpoly(fname,g/280); |
---|
[5bc214c] | 1995 | kill r0; |
---|
[3c4dcc] | 1996 | |
---|
[1057ab5] | 1997 | write(fname,"\\Line","%-----------------------------------------------------"); |
---|
[ae4196] | 1998 | // -2-------- a ring in char 7, indexed varnames and series ordering ---------- |
---|
| 1999 | write(fname, |
---|
[3c4dcc] | 2000 | " A ring in characteristic 7 with indexed names of variables and local |
---|
[1057ab5] | 2001 | ordering.",""); |
---|
[d6cc54] | 2002 | ring r1=7,(x1,x2,x3,x4),Ds; |
---|
[3c4dcc] | 2003 | poly g=-2*x1+x4-1; |
---|
[ae4196] | 2004 | write(fname, |
---|
| 2005 | bv + |
---|
[3c4dcc] | 2006 | "> ring r1=7,(x1,x2,x3,x4),Ds;" +nl + |
---|
[1057ab5] | 2007 | "> texring(fname,r1);" + |
---|
[5bc214c] | 2008 | ev); |
---|
[3c4dcc] | 2009 | texring(fname,r1); |
---|
[1057ab5] | 2010 | |
---|
[5bc214c] | 2011 | |
---|
| 2012 | write(fname, bv + |
---|
[3c4dcc] | 2013 | "> poly g=-2*x1+x4-1; g;" +nl + |
---|
[1057ab5] | 2014 | "> texpoly(fname,g);" + |
---|
[5bc214c] | 2015 | ev); |
---|
| 2016 | |
---|
| 2017 | texpoly(fname,g); |
---|
[3c4dcc] | 2018 | |
---|
[1057ab5] | 2019 | write(fname,"\\Line","%-----------------------------------------------------"); |
---|
[ae4196] | 2020 | |
---|
[5bc214c] | 2021 | // -3-------- a ring in char 0, indexed varnames and local ordering ---------- |
---|
[ae4196] | 2022 | write(fname, |
---|
[3c4dcc] | 2023 | " A ring in characteristic 0 with indexed names of variables and local |
---|
[5bc214c] | 2024 | ordering. |
---|
[ae4196] | 2025 | " +nl); |
---|
[5bc214c] | 2026 | ring r2=0,(x(1..5),y(1..2)),(ds(5),ls(2)); |
---|
[b6b6153] | 2027 | poly g=-y(1)^3*x(5) +y(1)*x(2); |
---|
| 2028 | write(fname, |
---|
| 2029 | bv + |
---|
| 2030 | "> ring r2=0,(x(1..5),y(1..2)),(ds(5),ls(2));" + nl + |
---|
[1057ab5] | 2031 | "> texring(fname,r2);" + |
---|
[b6b6153] | 2032 | ev); |
---|
[3c4dcc] | 2033 | texring(fname,r2); |
---|
[b6b6153] | 2034 | |
---|
[ae4196] | 2035 | write(fname, |
---|
| 2036 | bv + |
---|
[b6b6153] | 2037 | "> poly g=-y(1)^3*x(5)+y(1)*x(2); g;" +nl+ |
---|
[3c4dcc] | 2038 | string(g) + nl + |
---|
[1057ab5] | 2039 | "> texpoly(fname,g);" + |
---|
[917fb5] | 2040 | ev |
---|
| 2041 | ); |
---|
[3c4dcc] | 2042 | texpoly(fname,g); |
---|
| 2043 | |
---|
[1057ab5] | 2044 | write(fname,"\\Line","%-----------------------------------------------------"); |
---|
[ae4196] | 2045 | |
---|
| 2046 | // -4-------- a ring in char 0, indexed varnames and weighted ordering ------ |
---|
| 2047 | write(fname, |
---|
[b6b6153] | 2048 | " A ring in characteristic 0 with indexed names of variables and weighted |
---|
| 2049 | ordering." +nl); |
---|
[d6cc54] | 2050 | ring r3=0,(x_1,x_2,x_3),wp(3,2,1); |
---|
[b6b6153] | 2051 | poly g=-x_1*x_2+2*x_2*x_3+x_1*x_3; |
---|
[ae4196] | 2052 | write(fname, |
---|
| 2053 | bv + |
---|
[b6b6153] | 2054 | "> ring r3=0,(x_1,x_2,x_3),wp(3,2,1);" +nl+ |
---|
[1057ab5] | 2055 | "> texring(fname,r3);" + |
---|
[b6b6153] | 2056 | ev); |
---|
| 2057 | texring(fname,r3); |
---|
| 2058 | write(fname, |
---|
| 2059 | bv + |
---|
| 2060 | "> poly g=-x_1*x_2+2*x_2*x_3+x_1*x_3; g;" +nl+ |
---|
[917fb5] | 2061 | string(g) + nl + |
---|
[1057ab5] | 2062 | "> texpoly(fname,g);" + |
---|
[ae4196] | 2063 | ev |
---|
[917fb5] | 2064 | ); |
---|
[1057ab5] | 2065 | texpoly(fname,g); |
---|
[3c4dcc] | 2066 | |
---|
[1057ab5] | 2067 | write(fname,"\\Line","%-----------------------------------------------------"); |
---|
[ae4196] | 2068 | |
---|
| 2069 | // -5-------- a ring with real coeff and matrix ordering ------------------- |
---|
| 2070 | write(fname, |
---|
| 2071 | " A ring with real coefficients and matrix ordering. |
---|
| 2072 | " +nl); |
---|
[b6b6153] | 2073 | ring rr=real,(x,y),M(1,2,3,4); |
---|
| 2074 | poly g =-1.2e-10*x2+y+1; |
---|
[ae4196] | 2075 | write(fname, |
---|
| 2076 | bv + |
---|
[b6b6153] | 2077 | "> ring rr=real,(x,y),M(1,2,3,4);"+nl+ |
---|
[1057ab5] | 2078 | "> texring(fname,rr);"+ |
---|
[b6b6153] | 2079 | ev); |
---|
| 2080 | texring(fname,rr); |
---|
| 2081 | |
---|
| 2082 | write(fname, |
---|
| 2083 | bv + |
---|
| 2084 | "> poly g=-1.2e-10*x2+y+1; g;"+nl+ |
---|
| 2085 | string(g) + nl + |
---|
[1057ab5] | 2086 | "> texpoly(fname,g);" + |
---|
[b6b6153] | 2087 | ev); |
---|
[1057ab5] | 2088 | texpoly(fname,g); |
---|
[b6b6153] | 2089 | |
---|
[1057ab5] | 2090 | write(fname,"\\Line","%-----------------------------------------------------"); |
---|
[ae4196] | 2091 | |
---|
| 2092 | // -6a-------- a ring in char 0, and indexed parameters --------- ---------- |
---|
| 2093 | write(fname, |
---|
[1057ab5] | 2094 | " A ring in characteristic 0 with parameters. |
---|
[ae4196] | 2095 | " +nl); |
---|
[917fb5] | 2096 | ring r0t=(0,s,t),(x,y),dp; |
---|
[b6b6153] | 2097 | poly g=8*(-s+2t)/(st+t3)*x+t2*x-1; |
---|
[ae4196] | 2098 | write(fname, |
---|
| 2099 | bv + |
---|
[b6b6153] | 2100 | "> ring r0t=(0,s,t),(x,y),dp;" +nl + |
---|
[1057ab5] | 2101 | "> texring(fname,r0t);" + |
---|
[b6b6153] | 2102 | ev); |
---|
| 2103 | texring(fname,r0t); |
---|
[3c4dcc] | 2104 | write(fname, |
---|
[b6b6153] | 2105 | bv + |
---|
| 2106 | "> poly g=8*(-s+2t)/(st+t3)*x+t2*x-1; g;"+nl+ |
---|
| 2107 | string(g) +nl + |
---|
[1057ab5] | 2108 | "> texpoly(fname,g);" + |
---|
[b6b6153] | 2109 | ev); |
---|
[1057ab5] | 2110 | texpoly(fname,g); |
---|
| 2111 | write(fname,"\\Line","%-----------------------------------------------------"); |
---|
| 2112 | write(fname,"\\newpage"); |
---|
[ae4196] | 2113 | |
---|
[651b46] | 2114 | // -6b------- a ring in char 11003, and indexed parameters --------- ---------- |
---|
[ae4196] | 2115 | write(fname, |
---|
| 2116 | " A ring in characteristic 11 and indexed parameters. |
---|
| 2117 | " +nl); |
---|
[917fb5] | 2118 | ring rt=(11003,t1,t2,t3),(X,Y),dp; |
---|
[b6b6153] | 2119 | poly g=8*(-t1+t2)/(t1+t3)*X+t2*Y-1; |
---|
[ae4196] | 2120 | write(fname, |
---|
| 2121 | bv + |
---|
[b6b6153] | 2122 | "> ring rt=(11003,t1,t2,t3),(X,Y),dp;" +nl + |
---|
[1057ab5] | 2123 | "> texring(fname,rt);" + |
---|
[b6b6153] | 2124 | ev); |
---|
| 2125 | texring(fname,rt); |
---|
| 2126 | |
---|
| 2127 | write(fname, |
---|
| 2128 | bv + |
---|
| 2129 | "> poly g=8*(-t1+t2)/(t1+t3)*X+t2*Y-1; g;" + nl+ |
---|
| 2130 | string(g) +nl + |
---|
[1057ab5] | 2131 | "> texpoly(fname,g);" + |
---|
[b6b6153] | 2132 | ev); |
---|
[1057ab5] | 2133 | texpoly(fname,g); |
---|
[b6b6153] | 2134 | |
---|
[1057ab5] | 2135 | write(fname,"\\Line","%-----------------------------------------------------"); |
---|
[ae4196] | 2136 | |
---|
| 2137 | // -7-------- a ring over an algebraic extension in char 7 --------------- |
---|
[1057ab5] | 2138 | write(fname," A ring over an algebraic extension in char 7."); |
---|
[5bc214c] | 2139 | |
---|
| 2140 | ring ralg = (7,a),x,dp; |
---|
| 2141 | minpoly = a2-a+3; |
---|
| 2142 | poly g = -(2a13+a)*x2+a2*x-a+1; |
---|
| 2143 | |
---|
[ae4196] | 2144 | write(fname, |
---|
| 2145 | bv + |
---|
[b6b6153] | 2146 | "> ring ralg=(7,a),x,dp;" +nl + |
---|
| 2147 | "> minpoly=a2-a+3;" +nl + |
---|
[1057ab5] | 2148 | "> texring(fname,ralg);" + |
---|
[b6b6153] | 2149 | ev); |
---|
| 2150 | texring(fname,ralg); |
---|
| 2151 | |
---|
| 2152 | write(fname, |
---|
| 2153 | bv + |
---|
| 2154 | "> poly g=-(2a13+a)*x2+a2*x-a+1; g;"+nl+ |
---|
| 2155 | string(g) +nl + |
---|
[1057ab5] | 2156 | "> texpoly(fname,g);" + |
---|
[ae4196] | 2157 | ev |
---|
[917fb5] | 2158 | ); |
---|
[1057ab5] | 2159 | texpoly(fname,g); |
---|
[b6b6153] | 2160 | |
---|
[1057ab5] | 2161 | write(fname,"\\Line","%-----------------------------------------------------"); |
---|
[ae4196] | 2162 | |
---|
| 2163 | // -8-------- the same ring a in 7 ralg, defined with gftables -- F_49 ------- |
---|
| 2164 | write(fname, |
---|
[917fb5] | 2165 | " A ring defined with \\verb|gftables|, the same as \\verb|ralg| before, but |
---|
[b6b6153] | 2166 | with primitive element in the Galois field $\\F_{49}$." +nl); |
---|
[d6cc54] | 2167 | ring r49 =(49,a),x,dp; |
---|
[b6b6153] | 2168 | poly g=-(2a13+a)*x2+a2*x-a+1; |
---|
[ae4196] | 2169 | write(fname, |
---|
| 2170 | bv + |
---|
[b6b6153] | 2171 | "> ring r49 =(49,a),x,dp;" +nl+ |
---|
[1057ab5] | 2172 | "> texring(fname,r49);" + |
---|
[b6b6153] | 2173 | ev); |
---|
| 2174 | texring(fname,r49); |
---|
| 2175 | |
---|
| 2176 | write(fname, |
---|
[3c4dcc] | 2177 | bv + |
---|
[b6b6153] | 2178 | "> poly g=-(2a13+a)*x2+a2*x-a+1; g;" +nl+ |
---|
| 2179 | string(g) +nl + |
---|
[1057ab5] | 2180 | "> texpoly(fname,g);" + |
---|
[b6b6153] | 2181 | ev); |
---|
[1057ab5] | 2182 | texpoly(fname,g); |
---|
[b6b6153] | 2183 | |
---|
[1057ab5] | 2184 | write(fname,"\\Line","%-----------------------------------------------------"); |
---|
[ae4196] | 2185 | |
---|
| 2186 | // -9-------- a ring over the Gaussian numbers ---------- |
---|
| 2187 | write(fname, |
---|
| 2188 | " A ring over the Gaussian numbers. |
---|
| 2189 | " +nl); |
---|
| 2190 | ring ri=(0,i),(x,y,z),ls; |
---|
[b6b6153] | 2191 | minpoly=i2+1; |
---|
| 2192 | poly g=-(i+1)*x+2i2y2+i+x; |
---|
[ae4196] | 2193 | write(fname, |
---|
| 2194 | bv + |
---|
[b6b6153] | 2195 | "> ring ri=(0,i),(x,y,z),ls;" +nl + |
---|
| 2196 | "> minpoly=i2+1;" +nl + |
---|
[1057ab5] | 2197 | "> texring(fname,ri);" + |
---|
[b6b6153] | 2198 | ev); |
---|
| 2199 | texring(fname,ri); |
---|
| 2200 | |
---|
| 2201 | write(fname, |
---|
[3c4dcc] | 2202 | bv + |
---|
[b6b6153] | 2203 | "> poly g=-(i+1)*x+2i2y2+i+x; g;" +nl+ |
---|
| 2204 | string(g) +nl + |
---|
[1057ab5] | 2205 | "> texpoly(fname,g);" + |
---|
[ae4196] | 2206 | ev |
---|
[917fb5] | 2207 | ); |
---|
[1057ab5] | 2208 | texpoly(fname,g); |
---|
[b6b6153] | 2209 | |
---|
[1057ab5] | 2210 | write(fname,"\\Line","%-----------------------------------------------------"); |
---|
[ae4196] | 2211 | |
---|
| 2212 | // -10--------- a quotient ring performed from ---------- |
---|
[1057ab5] | 2213 | write(fname," A quotient ring performed of \\verb|r0| by an ideal."); |
---|
[5bc214c] | 2214 | ring r0=0,(x,y,z),dp; |
---|
[1057ab5] | 2215 | ideal I = x2-y, y+z2, xy; |
---|
[ae4196] | 2216 | I = std(I); |
---|
| 2217 | string sI = string(I); |
---|
| 2218 | qring qr = I; |
---|
| 2219 | write(fname, |
---|
| 2220 | bv + |
---|
[1057ab5] | 2221 | "> setring r0; |
---|
| 2222 | > ideal I=x2-y,y+z2, xy; |
---|
| 2223 | > I=std(I); |
---|
| 2224 | > string(I);" + nl + |
---|
| 2225 | string(sI) + nl + |
---|
| 2226 | "> qring qr=I; |
---|
| 2227 | > texring(fname,qr);" + |
---|
[ae4196] | 2228 | ev |
---|
[917fb5] | 2229 | ); |
---|
[1057ab5] | 2230 | texring(fname,qr); |
---|
[ae4196] | 2231 | |
---|
[1057ab5] | 2232 | //write(fname,"\\Line","%-----------------------------------------------------"); |
---|
[ae4196] | 2233 | |
---|
| 2234 | // ------------------------- Features for rings |
---|
| 2235 | |
---|
[1057ab5] | 2236 | write(fname,"","\\subsection{Features for rings}"); |
---|
[ae4196] | 2237 | |
---|
[b6b6153] | 2238 | write(fname, |
---|
| 2239 | "In many cases it might be convenient to change the standard typesetting |
---|
| 2240 | of rings. This can be done by passing additional arguments to \\verb|texring|." |
---|
| 2241 | +nl); |
---|
[ae4196] | 2242 | |
---|
| 2243 | // changing the brackets |
---|
| 2244 | |
---|
[b6b6153] | 2245 | write(fname,nl,"In order to change the displayed brackets one has to give |
---|
| 2246 | the desired ones as additional argument (accepted brackets are: \\verb|\"\{\"|, |
---|
| 2247 | \\verb|\"\{\{\"|,\\verb|\"[\"|,\\verb|\"[[\"|,\\verb|\"<\"|,\\verb|\"<<\"|)."); |
---|
[ae4196] | 2248 | |
---|
| 2249 | write(fname, |
---|
| 2250 | bv + |
---|
[1057ab5] | 2251 | "> texring(fname,rr,\"{{\");" + |
---|
[ae4196] | 2252 | ev |
---|
[917fb5] | 2253 | ); |
---|
[ae4196] | 2254 | |
---|
| 2255 | texring(fname,rr,"{{"); |
---|
| 2256 | |
---|
| 2257 | write(fname, |
---|
| 2258 | bv + |
---|
[1057ab5] | 2259 | "> texring(fname,r2,\"[\");" + |
---|
[ae4196] | 2260 | ev |
---|
[917fb5] | 2261 | ); |
---|
[ae4196] | 2262 | |
---|
| 2263 | texring(fname,r2,"["); |
---|
| 2264 | |
---|
[b6b6153] | 2265 | write(fname,nl+"\\vspace{0.2cm}" + nl2); |
---|
[ae4196] | 2266 | |
---|
[b6b6153] | 2267 | write(fname,"The brackets around the ideal in a quotient ring can be |
---|
| 2268 | changed by setting the global variable \\verb|TeXbrack| (see section |
---|
| 2269 | {\\tt Ideals}).",nl); |
---|
[ae4196] | 2270 | |
---|
| 2271 | write(fname, |
---|
| 2272 | bv + |
---|
[b6b6153] | 2273 | "> string TeXbrack = \"<\";" +nl + |
---|
[1057ab5] | 2274 | "> texring(fname,qr);" + |
---|
[ae4196] | 2275 | ev |
---|
[917fb5] | 2276 | ); |
---|
[ae4196] | 2277 | |
---|
[b6b6153] | 2278 | string TeXbrack = "<"; export TeXbrack; |
---|
| 2279 | texring(fname,qr); |
---|
| 2280 | kill TeXbrack; |
---|
| 2281 | |
---|
| 2282 | write(fname, |
---|
| 2283 | bv + |
---|
[1057ab5] | 2284 | "> kill TeXbrack;" + |
---|
[b6b6153] | 2285 | ev); |
---|
| 2286 | |
---|
[1057ab5] | 2287 | //write(fname,"\\Line","%-----------------------------------------------------"); |
---|
[ae4196] | 2288 | |
---|
[b6b6153] | 2289 | // changing the ground field |
---|
[ae4196] | 2290 | // ------------------------------------------------- |
---|
| 2291 | |
---|
[b6b6153] | 2292 | write(fname, |
---|
| 2293 | "It is possible to display a ground field different from the |
---|
| 2294 | actual one by passing any letter in \\LaTeX \\ notation as additional |
---|
[3c4dcc] | 2295 | argument. Predefined values are \\verb|\"\\\\C\"|, \\verb|\"\\\\R\"|, |
---|
[b6b6153] | 2296 | \\verb|\"k\"|, \\verb|\"K\"| and \\verb|\"R\"|."+nl+ |
---|
| 2297 | "If for example a ground field of characteristic 0 should be written as |
---|
[1057ab5] | 2298 | $\\C$ instead of $\\Q$ use this as additional argument.",nl); |
---|
[ae4196] | 2299 | |
---|
| 2300 | write(fname, |
---|
| 2301 | bv + |
---|
[1057ab5] | 2302 | "> texring(fname,r3,\"\\\\C\");" + |
---|
[b6b6153] | 2303 | ev); |
---|
[ae4196] | 2304 | |
---|
| 2305 | texring(fname,r3,"\\C"); |
---|
[b6b6153] | 2306 | write(fname,nl+ "\\vspace{0.2cm}" + nl2); |
---|
[ae4196] | 2307 | |
---|
[b6b6153] | 2308 | write(fname,"The values \\verb|\"k\"|, \\verb|\"K\"|, \\verb|\"R\"| play a |
---|
| 2309 | special role when the ground field is an algebraic extension. In this case |
---|
| 2310 | the parameters will be omitted."); |
---|
[3c4dcc] | 2311 | |
---|
[ae4196] | 2312 | write(fname, |
---|
| 2313 | bv + |
---|
[1057ab5] | 2314 | "> texring(fname,ralg,\"k\");" + |
---|
[ae4196] | 2315 | ev |
---|
[917fb5] | 2316 | ); |
---|
[ae4196] | 2317 | |
---|
| 2318 | texring(fname, ralg,"k"); |
---|
[b6b6153] | 2319 | write(fname,nl+"\\vspace{0.2cm}" + nl2); |
---|
[917fb5] | 2320 | |
---|
[b6b6153] | 2321 | write(fname,"If an algebraic extension should be displayed together with |
---|
| 2322 | its minimal polynomial the optional parameter \\verb|mipo| has to be used."); |
---|
[651b46] | 2323 | |
---|
| 2324 | write(fname, |
---|
| 2325 | bv + |
---|
[1057ab5] | 2326 | "> texring(fname,ralg,\"mipo\");" + |
---|
[651b46] | 2327 | ev |
---|
[917fb5] | 2328 | ); |
---|
[651b46] | 2329 | |
---|
| 2330 | texring(fname, ralg,"mipo"); |
---|
[1057ab5] | 2331 | write(fname,"\\Line","%-----------------------------------------------------"); |
---|
[b6b6153] | 2332 | |
---|
[ae4196] | 2333 | // displaying only certain vars |
---|
| 2334 | |
---|
[b6b6153] | 2335 | write(fname,"By default all variables of a ring will be displayed. It is |
---|
| 2336 | possible to print only certain variables with $\\ldots$ between |
---|
| 2337 | them. The positions of the variables which should be displayed have to be |
---|
| 2338 | passed to \\verb|texring| as an \\verb|intvec|."); |
---|
[ae4196] | 2339 | |
---|
| 2340 | write(fname, |
---|
| 2341 | bv + |
---|
[b6b6153] | 2342 | "> intvec v=5,6; |
---|
[1057ab5] | 2343 | > texring(fname,r2,v);" + |
---|
[ae4196] | 2344 | ev |
---|
[917fb5] | 2345 | ); |
---|
[ae4196] | 2346 | |
---|
[b6b6153] | 2347 | intvec v = 5,6; |
---|
| 2348 | texring(fname,r2,v); |
---|
| 2349 | kill v; |
---|
| 2350 | |
---|
| 2351 | write(fname, |
---|
| 2352 | bv + |
---|
[1057ab5] | 2353 | "> kill v;" + |
---|
[b6b6153] | 2354 | ev |
---|
| 2355 | ); |
---|
[ae4196] | 2356 | |
---|
[b6b6153] | 2357 | write(fname,nl+ "\\vspace{0.2cm}" + nl2); |
---|
[3c4dcc] | 2358 | |
---|
[b6b6153] | 2359 | write(fname,"The first and the last variable will always be printed. |
---|
| 2360 | In order to print only these it is sufficient to give a 1 as third argument."); |
---|
[ae4196] | 2361 | |
---|
| 2362 | write(fname, |
---|
| 2363 | bv + |
---|
[1057ab5] | 2364 | "> texring(fname,r1,1);" + |
---|
[ae4196] | 2365 | ev |
---|
[917fb5] | 2366 | ); |
---|
[ae4196] | 2367 | texring(fname,r1,1); |
---|
| 2368 | |
---|
[1057ab5] | 2369 | write(fname,"\\Line","%-----------------------------------------------------"); |
---|
[ae4196] | 2370 | |
---|
[b6b6153] | 2371 | // invariant ring under a group action |
---|
[ae4196] | 2372 | |
---|
[b6b6153] | 2373 | write(fname,"If you want for example to display a ring as the invariant ring |
---|
| 2374 | under a group, additional information starting with \\verb|^| may be added."); |
---|
[ae4196] | 2375 | |
---|
| 2376 | write(fname, |
---|
| 2377 | bv + |
---|
[1057ab5] | 2378 | "> texring(fname,r0,\"^G\");" + |
---|
[ae4196] | 2379 | ev |
---|
[917fb5] | 2380 | ); |
---|
[ae4196] | 2381 | |
---|
| 2382 | texring(fname, r0,"^G"); |
---|
[1057ab5] | 2383 | write(fname,"\\Line","%-----------------------------------------------------"); |
---|
[917fb5] | 2384 | |
---|
[b6b6153] | 2385 | // passing several optional arguments at once |
---|
| 2386 | |
---|
| 2387 | write(fname,"It is also possible to pass several of the arguments described |
---|
| 2388 | above at once (in any order)."); |
---|
[3c4dcc] | 2389 | |
---|
[ae4196] | 2390 | |
---|
| 2391 | write(fname, |
---|
| 2392 | bv + |
---|
[1057ab5] | 2393 | "> texring(fname,r3,\"\\\\R\",\"{{\",\"^G\");" + |
---|
[ae4196] | 2394 | ev |
---|
[917fb5] | 2395 | ); |
---|
[ae4196] | 2396 | |
---|
[b6b6153] | 2397 | texring(fname, r3,"\\R","{{","^G"); |
---|
[5bc214c] | 2398 | //"end part 1" + nl; |
---|
[ae4196] | 2399 | } |
---|
| 2400 | |
---|
| 2401 | |
---|
| 2402 | ///////////////////////////// PART2 ////////////////////////////////////////// |
---|
| 2403 | |
---|
| 2404 | |
---|
[651b46] | 2405 | static proc part2(string fname) |
---|
[3c4dcc] | 2406 | { |
---|
[5bc214c] | 2407 | |
---|
| 2408 | int st = defined(texdemopart); |
---|
| 2409 | string nl = newline; |
---|
| 2410 | string nl2 = newline + newline; |
---|
| 2411 | string lb = "\\\\"; |
---|
| 2412 | string bv = "\\begin{verbatim}" + newline ; |
---|
[1057ab5] | 2413 | string ev = newline + "\\end{verbatim}" + newline ; |
---|
| 2414 | // string ev = "\\end{verbatim}" ; |
---|
[ae4196] | 2415 | |
---|
| 2416 | if (not(st) or texdemopart>=2) |
---|
| 2417 | { print(" Call part1 first"); |
---|
| 2418 | return(); |
---|
| 2419 | } |
---|
| 2420 | else { texdemopart=2; } |
---|
[917fb5] | 2421 | |
---|
[5bc214c] | 2422 | // "Continuing Part2 of " + fname + nl; |
---|
[ae4196] | 2423 | |
---|
| 2424 | //-------------------- texfactorize ------------------------------ |
---|
[1057ab5] | 2425 | write(fname,"","\\subsection{Factorized polynomials}"); |
---|
[ae4196] | 2426 | |
---|
[3c4dcc] | 2427 | write(fname,"The command \\verb|texfactorize| calls internally the |
---|
| 2428 | {\\sc Singular} command \\verb|factorize| and returns the product of the |
---|
| 2429 | irreducible factors. Note that, at the moment, it is not possible to pass |
---|
[b6b6153] | 2430 | any optional arguments for \\verb|factorize| through \\verb|texfactorize|."); |
---|
[ae4196] | 2431 | |
---|
[5bc214c] | 2432 | ring r0=0,(x,y,z),dp; |
---|
[b6b6153] | 2433 | poly h=(x+1+y)^2*x3y*(2x-2y)*y12; |
---|
[5bc214c] | 2434 | |
---|
[ae4196] | 2435 | write(fname, |
---|
| 2436 | bv + |
---|
[1057ab5] | 2437 | "> setring r0; |
---|
| 2438 | > poly h=(x+1+y)^2*x3y*(2x-2y)*y12; h;" +nl+ |
---|
| 2439 | string(h) + nl + |
---|
[b6b6153] | 2440 | "> texfactorize(fname,h);" + |
---|
[ae4196] | 2441 | ev); |
---|
[b6b6153] | 2442 | texfactorize(fname,h); |
---|
[5bc214c] | 2443 | |
---|
| 2444 | // setring ralg; |
---|
| 2445 | ring ralg = (7,a),x,dp; |
---|
| 2446 | minpoly = a2-a+3; |
---|
| 2447 | poly h = (a24x5+x3)*a2x6*(x+1)^2; |
---|
[ae4196] | 2448 | |
---|
| 2449 | write(fname, |
---|
| 2450 | bv + |
---|
[1057ab5] | 2451 | "> setring ralg; |
---|
| 2452 | > poly h=(a24x5+x3)*a2x6*(x+1)^2; h;"+ nl + |
---|
| 2453 | string(h) + nl + |
---|
| 2454 | "> texfactorize(fname,h);"+ |
---|
[ae4196] | 2455 | ev); |
---|
[b6b6153] | 2456 | texfactorize(fname,h); |
---|
[ae4196] | 2457 | |
---|
| 2458 | //--------------------- features for polynomials ----------------- |
---|
[1057ab5] | 2459 | write(fname,"","\\subsection{Features for polynomials}"); |
---|
[ae4196] | 2460 | |
---|
| 2461 | // TeXreplace |
---|
| 2462 | // --------------------------------------------- |
---|
[b6b6153] | 2463 | write(fname,"By setting the global variable \\verb|TeXreplace| it is possible |
---|
[3c4dcc] | 2464 | to define rules for replacing strings or variable names. |
---|
[b6b6153] | 2465 | \\verb|TeXreplace| has to be a list of twoelemented lists where the first |
---|
| 2466 | entry is the text which should be replaced by the second entry. |
---|
[3c4dcc] | 2467 | This may be applied to replace names of variables, but is also used |
---|
[b6b6153] | 2468 | when calling \\verb|texname| or \\verb|texmap|. Note that it |
---|
| 2469 | is necessary to write a double backslash \\verb|\\\\\| at the beginning of |
---|
[1057ab5] | 2470 | a \\TeX \\ symbol.",""); |
---|
[b6b6153] | 2471 | |
---|
| 2472 | write(fname,"Let us denote the primitive element of an algebraic extension |
---|
| 2473 | by $\\xi$."); |
---|
| 2474 | |
---|
[ae4196] | 2475 | list TeXreplace; export TeXreplace; |
---|
| 2476 | TeXreplace[1] = list("a","\\xi"); |
---|
[5bc214c] | 2477 | // setring r49; |
---|
| 2478 | ring r49 =(49,a),x,dp; |
---|
| 2479 | poly g=-(2a13 +a)*x2+a2*x-a+1; |
---|
[ae4196] | 2480 | write(fname, |
---|
| 2481 | bv + |
---|
[b6b6153] | 2482 | "> list TeXreplace;" +nl + |
---|
| 2483 | "> TeXreplace[1]=list(\"a\",\"\\\\xi\");" +nl+ |
---|
| 2484 | "> setring r49;" +nl+ |
---|
[1057ab5] | 2485 | "> texpoly(fname,g);"+ |
---|
[ae4196] | 2486 | ev); |
---|
| 2487 | |
---|
| 2488 | texpoly(fname,g); |
---|
| 2489 | |
---|
[b6b6153] | 2490 | write(fname,nl+ "\\vspace{0.2cm}" + nl2); |
---|
| 2491 | write(fname,"Now let us write $\\lambda$ and $\\mu$ for deformation |
---|
| 2492 | parameters."); |
---|
[ae4196] | 2493 | TeXreplace[2]= list("s","\\lambda"); |
---|
| 2494 | TeXreplace[3]= list("t","\\mu"); |
---|
[5bc214c] | 2495 | // setring(r0t); |
---|
| 2496 | ring r0t=(0,s,t),(x,y),dp; |
---|
| 2497 | poly g=8*(-s+2t)/(st+t3)*x+t2*x-1; |
---|
[ae4196] | 2498 | write(fname, |
---|
| 2499 | bv + |
---|
[b6b6153] | 2500 | "> TeXreplace[2]=list(\"s\",\"\\\\lambda\");"+nl+ |
---|
| 2501 | "> TeXreplace[3]=list(\"t\",\"\\\\mu\");"+nl+ |
---|
| 2502 | "> setring(r0t);"+nl+ |
---|
[1057ab5] | 2503 | "> texpoly(fname,g);"+ |
---|
[ae4196] | 2504 | ev); |
---|
[5bc214c] | 2505 | texpoly(fname,g); |
---|
[ae4196] | 2506 | |
---|
| 2507 | kill TeXreplace; |
---|
[1057ab5] | 2508 | write(fname,nl+ "\\vspace{0.4cm}"); |
---|
| 2509 | write(fname,nl+"Note that, if \\verb|TeXreplace| is defined, the translation |
---|
| 2510 | into \\LaTeX code runs a little bit slower, because every polynomial is |
---|
[b6b6153] | 2511 | compiled in the \\verb|non short| mode."+ lb ); |
---|
[ae4196] | 2512 | |
---|
[1057ab5] | 2513 | write(fname,nl,"\\Line","%-----------------------------------------------------"); |
---|
[b6b6153] | 2514 | |
---|
[ae4196] | 2515 | //linebreaking TeXwdith |
---|
| 2516 | //----------------------------------------------------------------------- |
---|
[917fb5] | 2517 | write(fname,"The global variable \\verb|TeXwidth| controls the wrapping of |
---|
[ae4196] | 2518 | polynomials; possible values are:" + lb); |
---|
| 2519 | |
---|
| 2520 | write(fname, |
---|
| 2521 | "\\[ " + nl + |
---|
[1057ab5] | 2522 | "\\text{\\tt TeXwidth} = ", |
---|
[ae4196] | 2523 | "\\begin{cases} ", |
---|
[1057ab5] | 2524 | " -1 & \\text{no line-breaking} \\\\ ", |
---|
[b6b6153] | 2525 | " 0 & \\text{print the polynomial as equation } f=0 \\\\ ", |
---|
| 2526 | " 1,\\dots,9 & \\text{the first n terms followed by the sign of the next |
---|
[ae4196] | 2527 | term} \\\\ ", |
---|
[b6b6153] | 2528 | " > 9 & \\text{line break after terms of length n (see below)} ", |
---|
[ae4196] | 2529 | "\\end{cases}", |
---|
| 2530 | "\\]",nl); |
---|
| 2531 | |
---|
[3c4dcc] | 2532 | write(fname,"Note that the size of terms is calculated with certain |
---|
[b6b6153] | 2533 | multiplicities.",nl); |
---|
[ae4196] | 2534 | |
---|
| 2535 | //---------------------------------------------------------- |
---|
| 2536 | |
---|
[1057ab5] | 2537 | write(fname,"\\begin{itemize}"); |
---|
| 2538 | write(fname,"\\item"); |
---|
[ae4196] | 2539 | |
---|
| 2540 | write(fname, |
---|
| 2541 | bv + |
---|
[b6b6153] | 2542 | "> TeXwidth=-1;"+nl+ |
---|
| 2543 | "> setring r0;"+nl+ |
---|
| 2544 | "> poly f=g^2;"+nl+ |
---|
[1057ab5] | 2545 | "> texpoly(fname,f);" + |
---|
[ae4196] | 2546 | ev); |
---|
| 2547 | |
---|
[3c4dcc] | 2548 | setring r0; |
---|
[5bc214c] | 2549 | poly g=-x2y+2y13z+1; |
---|
[b6b6153] | 2550 | poly f=g^2; |
---|
[5bc214c] | 2551 | texpoly(fname,f); |
---|
[ae4196] | 2552 | |
---|
[1057ab5] | 2553 | write(fname,"\\item"); |
---|
[ae4196] | 2554 | |
---|
| 2555 | write(fname, |
---|
| 2556 | bv + |
---|
[1057ab5] | 2557 | "> TeXwidth=0; |
---|
| 2558 | > texpoly(fname,f);"+ |
---|
[ae4196] | 2559 | ev); |
---|
| 2560 | TeXwidth = 0; |
---|
[b6b6153] | 2561 | texpoly(fname,f); |
---|
[ae4196] | 2562 | |
---|
[1057ab5] | 2563 | write(fname,"\\item"); |
---|
[ae4196] | 2564 | write(fname, |
---|
| 2565 | bv + |
---|
[1057ab5] | 2566 | "> TeXwidth=2; |
---|
| 2567 | > texpoly(fname,f);"+ |
---|
[ae4196] | 2568 | ev); |
---|
[b6b6153] | 2569 | TeXwidth=2; |
---|
[5bc214c] | 2570 | texpoly(fname,f); |
---|
[b6b6153] | 2571 | |
---|
[1057ab5] | 2572 | write(fname,"\\item"); |
---|
[ae4196] | 2573 | write(fname, |
---|
| 2574 | bv + |
---|
[b6b6153] | 2575 | "> TeXwidth=20;"+nl+ |
---|
[1057ab5] | 2576 | "> texpoly(fname,f);"+ |
---|
[ae4196] | 2577 | ev); |
---|
[b6b6153] | 2578 | TeXwidth=20; |
---|
| 2579 | texpoly(fname,f); |
---|
| 2580 | TeXwidth=-1; |
---|
[ae4196] | 2581 | |
---|
[1057ab5] | 2582 | write(fname,"\\end{itemize}"); |
---|
[ae4196] | 2583 | |
---|
[1057ab5] | 2584 | write(fname,"\\Line","%-----------------------------------------------------"); |
---|
[ae4196] | 2585 | |
---|
[3c4dcc] | 2586 | write(fname,"There are two possibilities to convert a polynomial into |
---|
[1057ab5] | 2587 | \\LaTeX{} code: either by using \\verb|texpoly| or by calling \\verb|texobj|. |
---|
| 2588 | The difference is that \\verb|texpoly| puts the polynomial in text-mode |
---|
[b6b6153] | 2589 | while \\verb|texobj| uses the display mode."+nl+ |
---|
| 2590 | "The following examples show the different outputs:"); |
---|
[ae4196] | 2591 | |
---|
| 2592 | write(fname, |
---|
| 2593 | bv + |
---|
| 2594 | "> setring r3; |
---|
[1057ab5] | 2595 | > texpoly(fname,g/180);" + |
---|
[ae4196] | 2596 | ev); |
---|
| 2597 | |
---|
[5bc214c] | 2598 | // setring r3; |
---|
[3c4dcc] | 2599 | |
---|
[5bc214c] | 2600 | ring r3=0,(x_1,x_2,x_3),wp(3,2,1); |
---|
[b6b6153] | 2601 | poly g=-x_1*x_2+2*x_2*x_3+x_1*x_3; |
---|
[5bc214c] | 2602 | texpoly(fname,g/180); |
---|
[ae4196] | 2603 | |
---|
| 2604 | write(fname, |
---|
| 2605 | bv + |
---|
[5bc214c] | 2606 | "> texobj(fname,g/180); |
---|
[1057ab5] | 2607 | " + |
---|
[ae4196] | 2608 | ev); |
---|
| 2609 | |
---|
[5bc214c] | 2610 | texobj(fname,g/180); |
---|
[ae4196] | 2611 | |
---|
[b6b6153] | 2612 | //write(fname,"Some explanation how it works: if \\verb|texobj| is called for |
---|
| 2613 | //a polynomial, then it defines a global variable \\verb|TeXdisp| which forces |
---|
| 2614 | //\\verb|texpoly| to count fraction with space corresponding |
---|
| 2615 | //the displaymode."+lb,nl2); |
---|
[ae4196] | 2616 | //---------------------texobj for ideal --------------- |
---|
[b6b6153] | 2617 | |
---|
[1057ab5] | 2618 | write(fname,"","\\subsection{Ideals}"); |
---|
[b6b6153] | 2619 | write(fname,"By default, ideals are displayed as column vectors."); |
---|
[ae4196] | 2620 | |
---|
[5bc214c] | 2621 | ring r; |
---|
[b6b6153] | 2622 | ideal I=3xz5+x2y3-3z,7xz5+y3z+x-z,-xyz2+4yz+2x; |
---|
[ae4196] | 2623 | |
---|
| 2624 | write(fname, |
---|
| 2625 | bv + |
---|
[b6b6153] | 2626 | "> ring r; // the default ring"+nl+ |
---|
| 2627 | "> ideal I=3xz5+x2y3-3z,7xz5+y3z+x-z,-xyz2+4yz+2x;"+nl+ |
---|
[1057ab5] | 2628 | "> texobj(fname,I);" + |
---|
[b6b6153] | 2629 | ev); |
---|
[ae4196] | 2630 | |
---|
| 2631 | texobj(fname,I); |
---|
| 2632 | |
---|
[1057ab5] | 2633 | write(fname,"\\Line","%-----------------------------------------------------"); |
---|
[ae4196] | 2634 | //---------------------------------------------------------------------- |
---|
[b6b6153] | 2635 | write(fname,"If the global variable \\verb|Texaligned| is set then the ideal |
---|
| 2636 | is displayed as a row vector."); |
---|
[3c4dcc] | 2637 | |
---|
[ae4196] | 2638 | write(fname, |
---|
| 2639 | bv + |
---|
| 2640 | "> int TeXaligned; |
---|
[1057ab5] | 2641 | > texobj(fname,I);" + |
---|
[ae4196] | 2642 | ev); |
---|
| 2643 | |
---|
| 2644 | int TeXaligned; export TeXaligned; |
---|
| 2645 | texobj(fname,I); |
---|
| 2646 | |
---|
[1057ab5] | 2647 | write(fname,nl+"\\Line","%-----------------------------------------------------"); |
---|
[ae4196] | 2648 | //---------------------------------------------------------------------- |
---|
[b6b6153] | 2649 | write(fname,"By setting the global variable \\verb|TeXbrack| it is possible |
---|
| 2650 | to change the brackets."); |
---|
[ae4196] | 2651 | |
---|
| 2652 | write(fname, |
---|
| 2653 | bv + |
---|
[b6b6153] | 2654 | "> string TeXbrack=\"<\";"+nl+ |
---|
[1057ab5] | 2655 | "> texobj(fname,I);"+ |
---|
[ae4196] | 2656 | ev); |
---|
| 2657 | |
---|
[b6b6153] | 2658 | string TeXbrack="<"; export TeXbrack; |
---|
[ae4196] | 2659 | texobj(fname,I); |
---|
[b6b6153] | 2660 | |
---|
| 2661 | write(fname, |
---|
| 2662 | bv + |
---|
[1057ab5] | 2663 | "> kill TeXbrack, TeXaligned;" + |
---|
[b6b6153] | 2664 | ev); |
---|
| 2665 | |
---|
[ae4196] | 2666 | kill TeXbrack,TeXaligned; |
---|
[1057ab5] | 2667 | write(fname,"\\Line","%-----------------------------------------------------"); |
---|
[ae4196] | 2668 | //---------------------------------------------------------------------- |
---|
| 2669 | write(fname, |
---|
[b6b6153] | 2670 | " If \\verb|TeXwidth| is 0, an ideal is displayed as a system of |
---|
| 2671 | equations."); |
---|
[ae4196] | 2672 | |
---|
| 2673 | // ------------- a linear equation system |
---|
| 2674 | |
---|
[b6b6153] | 2675 | ring r5=0,x(1..5),dp; |
---|
[5bc214c] | 2676 | ideal I=-x(1)+2*x(3)+x(5), x(2)-x(4)+2*x(5)-1, 8*x(1)+x(4)+2; |
---|
[b6b6153] | 2677 | TeXwidth=0; |
---|
[ae4196] | 2678 | |
---|
| 2679 | write(fname, |
---|
| 2680 | bv + |
---|
[b6b6153] | 2681 | "> ring r5=0,x(1..5),dp;"+nl+ |
---|
| 2682 | "> ideal I=-x(1)+2*x(3)+x(5), x(2)-x(4)+2*x(5)-1, 8*x(1)+x(4)+2;"+nl+ |
---|
| 2683 | "> TeXwidth=0;"+nl+ |
---|
[1057ab5] | 2684 | "> texobj(fname,I);" + |
---|
[b6b6153] | 2685 | ev); |
---|
[ae4196] | 2686 | |
---|
[5bc214c] | 2687 | texobj(fname,I); |
---|
[ae4196] | 2688 | |
---|
[5bc214c] | 2689 | setring r; |
---|
[b6b6153] | 2690 | ideal J=4x4y21+z25y7-y2,x3+y2,y2-z4; |
---|
[ae4196] | 2691 | |
---|
| 2692 | write(fname, |
---|
| 2693 | bv + |
---|
[b6b6153] | 2694 | "> setring r;"+nl+ |
---|
| 2695 | "> ideal J=4x4y21+z25y7-y2,x3+y2,y2-z4;"+nl+ |
---|
[1057ab5] | 2696 | "> texobj(fname,J);" + |
---|
[ae4196] | 2697 | ev |
---|
[917fb5] | 2698 | ); |
---|
[5bc214c] | 2699 | texobj(fname,J); |
---|
[ae4196] | 2700 | |
---|
[1057ab5] | 2701 | write(fname,"\\Line","%-----------------------------------------------------"); |
---|
[ae4196] | 2702 | //----------------------------------------------------------------------- |
---|
[b6b6153] | 2703 | write(fname,"Call the ideal by its name and it is printed as follows"); |
---|
| 2704 | |
---|
[ae4196] | 2705 | write(fname, |
---|
| 2706 | bv + |
---|
| 2707 | "> setring r; |
---|
[b6b6153] | 2708 | > ideal I=3xz5+x2y3-3z,7xz5+y3z+x-z,-xyz2+4yz+2x; |
---|
[1057ab5] | 2709 | > texobj(fname,\"I\");" + |
---|
[ae4196] | 2710 | ev); |
---|
| 2711 | |
---|
[b6b6153] | 2712 | setring r; export(I); |
---|
| 2713 | texobj(fname,"I"); |
---|
| 2714 | kill I,r; |
---|
[5bc214c] | 2715 | //" end part 2 " + nl; |
---|
[ae4196] | 2716 | } |
---|
| 2717 | |
---|
| 2718 | ///////////////////////////// PART3 ////////////////////////////////////////// |
---|
| 2719 | |
---|
[651b46] | 2720 | static proc part3(string fname) |
---|
[3c4dcc] | 2721 | { |
---|
[b6b6153] | 2722 | int st=defined(texdemopart); |
---|
| 2723 | string nl=newline; |
---|
| 2724 | string nl2=newline + newline; |
---|
| 2725 | string lb="\\\\"; |
---|
[1057ab5] | 2726 | string bv=newline+"\\begin{verbatim}"; |
---|
| 2727 | // string ev = newline + "\\end{verbatim}" + newline ; |
---|
[b6b6153] | 2728 | string ev="\\end{verbatim}" ; |
---|
[ae4196] | 2729 | |
---|
| 2730 | if (not(st) or st>=3) |
---|
[1057ab5] | 2731 | |
---|
[3c4dcc] | 2732 | { |
---|
[5bc214c] | 2733 | print(" Call part2 first"); |
---|
[ae4196] | 2734 | return(); |
---|
| 2735 | } |
---|
| 2736 | else { texdemopart=3; } |
---|
| 2737 | |
---|
[5bc214c] | 2738 | // " Continuing part 3 of " + fname + |
---|
| 2739 | // " : map,matrices,vectors,intvec,intmats,proc"; |
---|
[ae4196] | 2740 | |
---|
| 2741 | //---------------------- texmap ------------------------------ |
---|
[1057ab5] | 2742 | write(fname,"","\\section{Typesetting maps between rings}"); |
---|
[b6b6153] | 2743 | write(fname,"By default, maps are displayed in the following way:"); |
---|
[3c4dcc] | 2744 | |
---|
[b6b6153] | 2745 | write(fname, |
---|
[1057ab5] | 2746 | bv, |
---|
| 2747 | "> ring r4=0,(x,y,z),dp; |
---|
| 2748 | > ring r5=0,(u,v),dp; |
---|
| 2749 | > map phi=r1,u2,uv -v,v2; |
---|
| 2750 | > texmap(fname,phi,r4,r5);", |
---|
[b6b6153] | 2751 | ev); |
---|
[3c4dcc] | 2752 | |
---|
[5bc214c] | 2753 | ring @r4_h=0,(x,y,z),dp; |
---|
[731e67e] | 2754 | export @r4_h; |
---|
[5bc214c] | 2755 | ring r5=0,(u,v),dp; |
---|
[b6b6153] | 2756 | map @phi_h=@r4_h,u2,uv -v,v2; export @phi_h; |
---|
| 2757 | texmap(fname,@phi_h,@r4_h,r5); |
---|
[ae4196] | 2758 | |
---|
[1057ab5] | 2759 | write(fname,"\\Line","%-----------------------------------------------------"); |
---|
[ae4196] | 2760 | //-------------------------------------------------------------------- |
---|
| 2761 | |
---|
[b6b6153] | 2762 | write(fname,"If the global variable \\verb|TeXaligned| is set, then the |
---|
| 2763 | map is displayed in one line."); |
---|
[3c4dcc] | 2764 | |
---|
[b6b6153] | 2765 | write(fname, |
---|
[1057ab5] | 2766 | bv, |
---|
| 2767 | "> int TeXaligned; |
---|
| 2768 | > texmap(fname,phi,r4,r5,\"\\\\C\");", |
---|
[ae4196] | 2769 | ev ); |
---|
| 2770 | |
---|
| 2771 | int TeXaligned; export TeXaligned; |
---|
[5bc214c] | 2772 | texmap(fname,@phi_h,@r4_h,r5,"\\C"); |
---|
[ae4196] | 2773 | |
---|
[1057ab5] | 2774 | write(fname,nl+"\\Line","%-----------------------------------------------------"); |
---|
[b6b6153] | 2775 | //-------------------------------------------------------------------- |
---|
[ae4196] | 2776 | |
---|
[b6b6153] | 2777 | write(fname,"It is possible to pass the same additional arguments to |
---|
| 2778 | \\verb|texmap| as to \\verb|texring| (see section {\\tt Rings}). This can |
---|
| 2779 | be done by calling \\verb|texmap| with two lists as additional parameters, |
---|
| 2780 | where the first list contains the optional parameters for the source and |
---|
| 2781 | the second one contains the parameters for the domain. Note that if only one |
---|
| 2782 | list is present then it is applied to both of the rings."); |
---|
[3c4dcc] | 2783 | |
---|
[b6b6153] | 2784 | write(fname, |
---|
[1057ab5] | 2785 | bv, |
---|
| 2786 | "> texmap(fname,phi,r4,r5,\"\\\\C\",\"{\");", |
---|
[b6b6153] | 2787 | ev ); |
---|
| 2788 | texmap(fname,@phi_h,@r4_h,r5,"\\C","{"); |
---|
[ae4196] | 2789 | |
---|
[b6b6153] | 2790 | write(fname,nl+ "\\vspace{0.2cm}" + nl); |
---|
| 2791 | write(fname,"The next example shows how to format the two rings in different |
---|
| 2792 | ways."); |
---|
[ae4196] | 2793 | |
---|
[b6b6153] | 2794 | write(fname, |
---|
[1057ab5] | 2795 | bv, |
---|
| 2796 | "> texmap(fname,phi,r4,r5,list(),list(\"{\"));", |
---|
[ae4196] | 2797 | ev ); |
---|
| 2798 | |
---|
[3c4dcc] | 2799 | texmap(fname,@phi_h,@r4_h,r5,list(),list("{")); |
---|
[ae4196] | 2800 | |
---|
[1057ab5] | 2801 | write(fname,"\\Line","%-----------------------------------------------------"); |
---|
[b6b6153] | 2802 | //-------------------------------------------------------------------- |
---|
[ae4196] | 2803 | |
---|
[b6b6153] | 2804 | write(fname,"If the map is called by its name then \\verb|texmap| displays, |
---|
| 2805 | in addition, also the name of the map."); |
---|
[ae4196] | 2806 | |
---|
[b6b6153] | 2807 | write(fname, |
---|
[1057ab5] | 2808 | bv, |
---|
| 2809 | "> list TeXreplace; |
---|
| 2810 | > TeXreplace[1]=list(\"phi\",\"\\\\phi\"); |
---|
| 2811 | > texmap(fname,\"phi\",r4,r5);", |
---|
[b6b6153] | 2812 | ev); |
---|
[1c1d96b] | 2813 | |
---|
[b6b6153] | 2814 | list TeXreplace; |
---|
| 2815 | TeXreplace[1]=list("@phi_h","\\phi"); |
---|
| 2816 | export TeXreplace; |
---|
| 2817 | texmap(fname,"@phi_h",@r4_h,r5); |
---|
| 2818 | kill @phi_h,@r4_h,r5,TeXreplace,TeXaligned; |
---|
| 2819 | |
---|
| 2820 | write(fname, |
---|
[1057ab5] | 2821 | bv, |
---|
| 2822 | "> kill phi,r4,r5,TeXreplace,TeXaligned;", |
---|
[b6b6153] | 2823 | ev); |
---|
[ae4196] | 2824 | |
---|
| 2825 | |
---|
| 2826 | //% the texobj part |
---|
[1057ab5] | 2827 | write(fname,"","\\section{Typesetting composed data structures}"); |
---|
[ae4196] | 2828 | //======================================================================= |
---|
| 2829 | |
---|
[b6b6153] | 2830 | write(fname, "Complex data structures such as matrices, vectors or modules |
---|
| 2831 | can be displayed by using the procedure \\verb|texobj|."); |
---|
[3c4dcc] | 2832 | |
---|
[1057ab5] | 2833 | write(fname,"","\\subsection{Matrices and vectors}"); |
---|
[ae4196] | 2834 | //======================================================================= |
---|
| 2835 | |
---|
[1057ab5] | 2836 | write(fname,"The following example shows how to typeset the Hessian of a |
---|
| 2837 | polynomial."); |
---|
| 2838 | |
---|
| 2839 | write(fname, |
---|
| 2840 | bv, |
---|
| 2841 | "> ring r; |
---|
| 2842 | > poly h=2xy3-x2z+x4z7+y4z2; |
---|
| 2843 | > matrix H=jacob(jacob(h)); |
---|
| 2844 | > texobj(fname,H);", |
---|
[ae4196] | 2845 | ev ); |
---|
| 2846 | |
---|
| 2847 | ring r; |
---|
[b6b6153] | 2848 | poly h=2xy3-x2z+x4z7+y4z2; |
---|
| 2849 | matrix H=jacob(jacob(h)); |
---|
[ae4196] | 2850 | texobj(fname,H); |
---|
| 2851 | |
---|
[b6b6153] | 2852 | write(fname,"By default, \\verb|vectors| are written as row vectors:"); |
---|
[ae4196] | 2853 | |
---|
[b6b6153] | 2854 | vector V = H[2]; |
---|
[ae4196] | 2855 | |
---|
[b6b6153] | 2856 | write(fname, |
---|
[1057ab5] | 2857 | bv, |
---|
| 2858 | "> vector V=H[2]; |
---|
| 2859 | > texobj(fname,V);", |
---|
[ae4196] | 2860 | ev ); |
---|
| 2861 | |
---|
| 2862 | texobj(fname,V); |
---|
| 2863 | |
---|
[1057ab5] | 2864 | write(fname,nl+"\\vspace{0.2cm}"+nl); |
---|
[b6b6153] | 2865 | write(fname,"In order to transpose it, it has to be converted into a |
---|
| 2866 | matrix."); |
---|
| 2867 | write(fname, |
---|
[1057ab5] | 2868 | bv, |
---|
[ae4196] | 2869 | "> texobj(fname,matrix(V));", |
---|
| 2870 | ev ); |
---|
| 2871 | |
---|
| 2872 | texobj(fname,matrix(V)); |
---|
| 2873 | |
---|
[1057ab5] | 2874 | write(fname,nl+"\\Line","%-----------------------------------------------------"); |
---|
[ae4196] | 2875 | //------------------------------------------------------------------------ |
---|
| 2876 | |
---|
[b6b6153] | 2877 | write(fname,"All the features for typesetting polynomials work also for |
---|
| 2878 | matrices or vectors with polynomial entries."); |
---|
| 2879 | write(fname,nl+ "\\vspace{0.2cm}" + nl); |
---|
| 2880 | write(fname,"By setting the global variable \\verb|TeXwidth| it is possible |
---|
| 2881 | to display only the first terms of the polynomials."); |
---|
[ae4196] | 2882 | |
---|
[1057ab5] | 2883 | write(fname,bv, |
---|
| 2884 | "> TeXwidth=1; |
---|
| 2885 | > texobj(fname,H); |
---|
| 2886 | > TeXwidth=-1;", |
---|
[ae4196] | 2887 | ev ); |
---|
| 2888 | |
---|
| 2889 | TeXwidth = 1; |
---|
[917fb5] | 2890 | texobj(fname,H); |
---|
[ae4196] | 2891 | TeXwidth = -1; |
---|
| 2892 | |
---|
[1057ab5] | 2893 | write(fname,nl,"\\Line","%-----------------------------------------------------"); |
---|
[ae4196] | 2894 | //------------------------------------------------------------------------ |
---|
[b6b6153] | 2895 | write(fname,"The flag variable \\verb|TeXnofrac| controls the typesetting |
---|
| 2896 | of fractions."); |
---|
[ae4196] | 2897 | |
---|
[b6b6153] | 2898 | write(fname, |
---|
[1057ab5] | 2899 | bv, |
---|
| 2900 | "> ring R0=0,x,dp; |
---|
| 2901 | > matrix M[2][3]=1/2, 0, 1/2, 0, 1/3, 2/3; |
---|
| 2902 | > texobj(fname,M);", |
---|
[ae4196] | 2903 | ev); |
---|
| 2904 | |
---|
| 2905 | |
---|
[5bc214c] | 2906 | ring R0 = 0,x,dp; |
---|
[ae4196] | 2907 | matrix M[2][3] = 1/2, 0, 1/2, 0, 1/3, 2/3; |
---|
| 2908 | texobj(fname,M); |
---|
| 2909 | |
---|
[1057ab5] | 2910 | write(fname,bv, |
---|
| 2911 | "> int TeXnofrac; |
---|
| 2912 | > texobj(fname,M);", |
---|
[ae4196] | 2913 | ev ); |
---|
| 2914 | |
---|
[b6b6153] | 2915 | int TeXnofrac; export TeXnofrac; |
---|
| 2916 | texobj(fname,M); |
---|
| 2917 | kill TeXnofrac; |
---|
| 2918 | |
---|
[1057ab5] | 2919 | write(fname,bv, |
---|
[b6b6153] | 2920 | "> kill TeXnofrac;", |
---|
| 2921 | ev ); |
---|
[ae4196] | 2922 | |
---|
[1057ab5] | 2923 | write(fname,nl,"\\Line","%-----------------------------------------------------"); |
---|
[ae4196] | 2924 | //------------------------------------------------------------------------ |
---|
| 2925 | |
---|
[b6b6153] | 2926 | write(fname,"Printing a vector with homogeneous coordinates can be done by |
---|
| 2927 | setting \\verb|TeXproj|."); |
---|
[ae4196] | 2928 | write(fname,bv + |
---|
[1057ab5] | 2929 | "> setring r; |
---|
| 2930 | > int TeXproj; |
---|
| 2931 | > texobj(fname,V);", |
---|
[ae4196] | 2932 | ev ); |
---|
| 2933 | |
---|
[3c4dcc] | 2934 | setring r; |
---|
[b6b6153] | 2935 | ideal I=3xz5+x2y3-3z,7xz5+y3z+x-z,-xyz2+4yz+2x; |
---|
[5bc214c] | 2936 | int TeXproj; export TeXproj; |
---|
[3c4dcc] | 2937 | |
---|
[5bc214c] | 2938 | texobj(fname,V); |
---|
| 2939 | kill TeXproj; |
---|
[ae4196] | 2940 | |
---|
[b6b6153] | 2941 | write(fname, |
---|
[1057ab5] | 2942 | bv, |
---|
| 2943 | "> kill TeXproj;", |
---|
[b6b6153] | 2944 | ev); |
---|
[3c4dcc] | 2945 | |
---|
[1057ab5] | 2946 | write(fname,"","\\subsection{Modules}"); |
---|
[ae4196] | 2947 | |
---|
[1057ab5] | 2948 | write(fname,"By default, modules are displayed in the following way:"); |
---|
| 2949 | write(fname, |
---|
| 2950 | bv, |
---|
| 2951 | "> setring r; |
---|
| 2952 | > module md=module(H); |
---|
| 2953 | > texobj(fname,md);", |
---|
[ae4196] | 2954 | ev ); |
---|
| 2955 | |
---|
| 2956 | setring r; |
---|
| 2957 | module md = module(H); |
---|
| 2958 | texobj(fname,md); |
---|
| 2959 | |
---|
[1057ab5] | 2960 | write(fname,"\\Line","%-----------------------------------------------------"); |
---|
[b6b6153] | 2961 | //------------------------------------------------------------------------ |
---|
[ae4196] | 2962 | |
---|
[b6b6153] | 2963 | write(fname,"In order to write the generators of a module aligned, the flag |
---|
[1057ab5] | 2964 | variable \\verb|TeXaligned| has to be defined."); |
---|
[ae4196] | 2965 | |
---|
[1057ab5] | 2966 | write(fname,bv, |
---|
| 2967 | "> int TeXaligned; |
---|
| 2968 | > texobj(fname,md);", |
---|
[ae4196] | 2969 | ev ); |
---|
| 2970 | |
---|
| 2971 | int TeXaligned; export TeXaligned; |
---|
| 2972 | texobj(fname,md); |
---|
| 2973 | kill TeXaligned; |
---|
[1057ab5] | 2974 | write(fname,bv, |
---|
[b6b6153] | 2975 | "> kill TeXaligned;", |
---|
[ae4196] | 2976 | ev ); |
---|
| 2977 | |
---|
[b6b6153] | 2978 | //---------------------------------------------------------------- |
---|
[1057ab5] | 2979 | write(fname,"","\\subsection{Integer matrices and vectors}"); |
---|
[ae4196] | 2980 | |
---|
[b6b6153] | 2981 | write(fname,"Integer matrices are displayed in the following way."); |
---|
[3c4dcc] | 2982 | |
---|
[b6b6153] | 2983 | intmat m[3][4]=-1,3,5,2,-2,8,6,0,2,5,8,7; |
---|
[ae4196] | 2984 | |
---|
| 2985 | write(fname, |
---|
[1057ab5] | 2986 | bv, |
---|
| 2987 | "> intmat m[3][4]=-1,3,5,2,-2,8,6,0,2,5,8,7; |
---|
| 2988 | > m;" + nl + |
---|
[917fb5] | 2989 | string(m) + nl + |
---|
[1057ab5] | 2990 | "> texobj(fname,m);", |
---|
[ae4196] | 2991 | ev ); |
---|
| 2992 | |
---|
| 2993 | texobj(fname,m); |
---|
[b6b6153] | 2994 | write(fname,nl+ "\\vspace{0.2cm}" + nl); |
---|
| 2995 | write(fname,"Integer vectors are displayed as row vectors."); |
---|
| 2996 | intvec v = 1..4; |
---|
[ae4196] | 2997 | write(fname, |
---|
[1057ab5] | 2998 | bv, |
---|
| 2999 | "> intvec v=1..4; |
---|
| 3000 | > v;" + nl + |
---|
[b6b6153] | 3001 | string(v) + nl + |
---|
[1057ab5] | 3002 | "> texobj(fname,v);", |
---|
[ae4196] | 3003 | ev ); |
---|
| 3004 | |
---|
| 3005 | texobj(fname,v); |
---|
| 3006 | |
---|
[b6b6153] | 3007 | write(fname,nl+ "\\vspace{0.2cm}" + nl); |
---|
| 3008 | write(fname,"To typeset the transposed vector, it has to be converted into |
---|
| 3009 | an integer matrix."+ |
---|
[1057ab5] | 3010 | bv, |
---|
| 3011 | "> texobj(fname,intmat(v));", |
---|
[ae4196] | 3012 | ev ); |
---|
| 3013 | |
---|
| 3014 | texobj(fname,intmat(v)); |
---|
| 3015 | |
---|
[b6b6153] | 3016 | write(fname,nl+ "\\vspace{0.2cm}" + nl); |
---|
| 3017 | |
---|
| 3018 | write(fname,"The following example shows how to typeset the multiplication of |
---|
[1057ab5] | 3019 | a matrix with a vector."); |
---|
| 3020 | write(fname, |
---|
| 3021 | bv, |
---|
| 3022 | "> texobj(fname,intmat(m*v),\"=\",m,\"*\",intmat(v));", |
---|
[ae4196] | 3023 | ev ); |
---|
| 3024 | |
---|
| 3025 | texobj(fname,intmat(m*v),"=",m,"*",intmat(v)); |
---|
| 3026 | |
---|
| 3027 | //----------------------------------------------------------------- |
---|
[1057ab5] | 3028 | write(fname,"\\Line","%-----------------------------------------------------"); |
---|
[ae4196] | 3029 | |
---|
[b6b6153] | 3030 | write(fname,"Of course, the brackets of a \\verb|intmat| can be changed |
---|
| 3031 | by setting \\verb|TeXbrack|."); |
---|
[ae4196] | 3032 | |
---|
| 3033 | write(fname, |
---|
[1057ab5] | 3034 | bv, |
---|
| 3035 | "> intmat mat[3][3]=1,2,3,4,5,6,7,8,9; |
---|
| 3036 | > string TeXbrack=\"|\"; |
---|
| 3037 | > texobj(fname,mat,\" = \",det(mat)); ", |
---|
[ae4196] | 3038 | ev ); |
---|
| 3039 | |
---|
| 3040 | intmat mat[3][3] = 1,2,3,4,5,6,7,8,9; |
---|
| 3041 | string TeXbrack = "|"; export TeXbrack; |
---|
[b6b6153] | 3042 | texobj(fname,mat," = ",det(mat)); |
---|
[ae4196] | 3043 | kill TeXbrack; |
---|
| 3044 | |
---|
| 3045 | //----------------------------------texname------------------- |
---|
| 3046 | |
---|
[651b46] | 3047 | //write(fname,"\\section{Names of identifiers}"); |
---|
[ae4196] | 3048 | |
---|
| 3049 | |
---|
[917fb5] | 3050 | //write(fname,"The proc \\verb|texname| is used to write indexed names in a |
---|
[651b46] | 3051 | //correct way"+lb,nl); |
---|
[ae4196] | 3052 | |
---|
| 3053 | |
---|
| 3054 | |
---|
| 3055 | // ------------------------------- texproc ------------------------------- |
---|
[5bc214c] | 3056 | proc milnor_number (poly p) |
---|
| 3057 | { |
---|
[1057ab5] | 3058 | ideal i = std(jacob(p)); |
---|
| 3059 | int m_nr = vdim(i); |
---|
[5bc214c] | 3060 | if (m_nr<0) |
---|
| 3061 | { |
---|
[1057ab5] | 3062 | "//-- not an isolated singularity"; |
---|
[5bc214c] | 3063 | } |
---|
[3c4dcc] | 3064 | return(m_nr); |
---|
[5bc214c] | 3065 | } |
---|
| 3066 | export(milnor_number); |
---|
[1c1d96b] | 3067 | |
---|
[1057ab5] | 3068 | write(fname,"","\\section{Typesetting procedures}"); |
---|
[b6b6153] | 3069 | write(fname,"The following procedure allows to include the source code |
---|
| 3070 | of procedures into a \\LaTeX document."); |
---|
[3c4dcc] | 3071 | write(fname, |
---|
[1057ab5] | 3072 | bv, |
---|
| 3073 | "> texproc(fname,\"milnor\_number\");", |
---|
[b6b6153] | 3074 | ev); |
---|
[3c4dcc] | 3075 | |
---|
[b6b6153] | 3076 | texproc(fname,"milnor_number"); |
---|
[ae4196] | 3077 | |
---|
[3b77465] | 3078 | kill milnor_number; |
---|
[3c4dcc] | 3079 | |
---|
[ae4196] | 3080 | // ------------------------------ closing the tex file ------------------- |
---|
[1057ab5] | 3081 | write(fname,"","\\section{Closing the \\LaTeX\\ file}"); |
---|
[b6b6153] | 3082 | write(fname,"To close the file use \\verb|closetex(fname);|. It should now |
---|
| 3083 | contain pure \\LaTeX \\ code and may be compiled with " + |
---|
| 3084 | "\\verb|tex(fname)| and displayed with \\verb|xdvi(fname)|."); |
---|
[ae4196] | 3085 | |
---|
[651b46] | 3086 | // write(fname,"\\section{Remarks}"); |
---|
[ae4196] | 3087 | closetex(fname); |
---|
[5bc214c] | 3088 | //"end of part3" + nl; |
---|
[651b46] | 3089 | |
---|
| 3090 | pagewidth =80; |
---|
[5bc214c] | 3091 | kill texdemopart,TeXwidth; |
---|
[ae4196] | 3092 | } |
---|
[8942a5] | 3093 | /////////////////////////////////////////////////////////////////////////////// |
---|
[1057ab5] | 3094 | |
---|
| 3095 | /* |
---|
| 3096 | |
---|
| 3097 | texring extended for Z,Z_m,real,complex |
---|
| 3098 | |
---|
| 3099 | // Test for new functionality: |
---|
| 3100 | // texring: |
---|
| 3101 | ring rZ = integer,x,dp; |
---|
| 3102 | texring("",rZ); |
---|
| 3103 | ring rZ8 = (integer,8),x,dp; |
---|
| 3104 | texring("",rZ8); |
---|
| 3105 | |
---|
| 3106 | ring rR = real,x,dp; |
---|
| 3107 | texring("",rR); |
---|
| 3108 | |
---|
| 3109 | ring rR2010 = (real,20,10),x,dp; |
---|
| 3110 | texring("",rR2010); |
---|
| 3111 | |
---|
| 3112 | ring rC = complex,x,dp; |
---|
| 3113 | texring("",rC); |
---|
| 3114 | |
---|
| 3115 | ring rC2010 = (complex,20,10),x,dp; |
---|
| 3116 | texring("",rC2010); |
---|
| 3117 | |
---|
| 3118 | // multi-indexed parameters and variables |
---|
| 3119 | |
---|
| 3120 | ring rmultind34 = 0,(a(1..3)(1..4)),dp; |
---|
| 3121 | texring("",r34); |
---|
| 3122 | matrix A[3][4] = maxideal(1); |
---|
| 3123 | texobj("",A); |
---|
| 3124 | |
---|
| 3125 | ring rmultind2 = 0,(x1_2,y_1_1,z),ds; |
---|
| 3126 | texring("",rmultind2); |
---|
| 3127 | |
---|
| 3128 | ring rmultind3 = 0,(x(-1..1)(0)(3..4)),ds; |
---|
| 3129 | texobj("",maxideal(1)); |
---|
| 3130 | |
---|
| 3131 | ring rmultind4 = (0,b1(0..2),b2_1(3)),x,ds; |
---|
| 3132 | texpoly("",par(1)*par(2)*par(3)+par(4)*x); |
---|
| 3133 | |
---|
| 3134 | */ |
---|
| 3135 | // last changed 10/10/10 |
---|
| 3136 | ///////////////////////// end of latex.lib //////////////////////////////////// |
---|
| 3137 | |
---|