diff options
Diffstat (limited to 'Build/source/utils/asymptote')
87 files changed, 3263 insertions, 3910 deletions
diff --git a/Build/source/utils/asymptote/ChangeLog b/Build/source/utils/asymptote/ChangeLog index d7f1d1796ff..5d7a5c6f5b8 100644 --- a/Build/source/utils/asymptote/ChangeLog +++ b/Build/source/utils/asymptote/ChangeLog @@ -1,4 +1,219 @@ ------------------------------------------------------------------------ +r5053 | jcbowman | 2010-06-25 13:27:05 -0600 (Fri, 25 Jun 2010) | 2 lines +Changed paths: + M /trunk/asymptote/builtin.cc + +Fix warning message. + +------------------------------------------------------------------------ +r5052 | jcbowman | 2010-06-25 12:57:35 -0600 (Fri, 25 Jun 2010) | 1 line +Changed paths: + M /trunk/asymptote/util.h + +Port to CYGWIN. +------------------------------------------------------------------------ +r5051 | jcbowman | 2010-06-25 12:09:33 -0600 (Fri, 25 Jun 2010) | 2 lines +Changed paths: + A /trunk/asymptote/examples/bars3.asy + M /trunk/asymptote/examples/pipes.asy + +Add 3D bar graph example. + +------------------------------------------------------------------------ +r5050 | jcbowman | 2010-06-25 11:49:46 -0600 (Fri, 25 Jun 2010) | 2 lines +Changed paths: + M /trunk/asymptote/examples/cones.asy + M /trunk/asymptote/examples/cylinder.asy + M /trunk/asymptote/examples/hyperboloid.asy + A /trunk/asymptote/examples/pipes.asy + M /trunk/asymptote/examples/projectrevolution.asy + M /trunk/asymptote/examples/sacone3D.asy + M /trunk/asymptote/examples/sacylinder3D.asy + M /trunk/asymptote/examples/shellmethod.asy + M /trunk/asymptote/examples/teapot.asy + M /trunk/asymptote/examples/torus.asy + M /trunk/asymptote/examples/workcone.asy + +Update examples. + +------------------------------------------------------------------------ +r5049 | jcbowman | 2010-06-25 11:44:08 -0600 (Fri, 25 Jun 2010) | 2 lines +Changed paths: + M /trunk/asymptote/base/three.asy + +Fix viewportmargin. + +------------------------------------------------------------------------ +r5048 | jcbowman | 2010-06-25 11:14:09 -0600 (Fri, 25 Jun 2010) | 2 lines +Changed paths: + M /trunk/asymptote/base/three.asy + +Fix orthographic sizing. + +------------------------------------------------------------------------ +r5047 | jcbowman | 2010-06-25 02:32:04 -0600 (Fri, 25 Jun 2010) | 2 lines +Changed paths: + D /trunk/asymptote/tests/gsl/gsl.asy + A /trunk/asymptote/tests/gsl/random.asy (from /trunk/asymptote/tests/gsl/gsl.asy:5046) + +Rename GSL test. + +------------------------------------------------------------------------ +r5046 | jcbowman | 2010-06-25 02:25:11 -0600 (Fri, 25 Jun 2010) | 2 lines +Changed paths: + M /trunk/asymptote/drawsurface.cc + M /trunk/asymptote/prc/writePRC.cc + +Fix displayed PRC units. + +------------------------------------------------------------------------ +r5045 | jcbowman | 2010-06-25 01:08:24 -0600 (Fri, 25 Jun 2010) | 1 line +Changed paths: + M /trunk/asymptote/drawsurface.h + +Remove unused array. +------------------------------------------------------------------------ +r5044 | jcbowman | 2010-06-24 17:01:12 -0600 (Thu, 24 Jun 2010) | 2 lines +Changed paths: + M /trunk/asymptote/base/three.asy + +Fix drawing of 3D thick lines of length 0. + +------------------------------------------------------------------------ +r5043 | jcbowman | 2010-06-24 00:57:58 -0600 (Thu, 24 Jun 2010) | 6 lines +Changed paths: + M /trunk/asymptote/arrayop.h + M /trunk/asymptote/base/graph3.asy + M /trunk/asymptote/base/math.asy + M /trunk/asymptote/base/plain_Label.asy + M /trunk/asymptote/base/plain_picture.asy + M /trunk/asymptote/base/three.asy + M /trunk/asymptote/base/three_surface.asy + M /trunk/asymptote/builtin.cc + M /trunk/asymptote/doc/asymptote.texi + M /trunk/asymptote/examples/splitpatch.asy + M /trunk/asymptote/runarray.in + M /trunk/asymptote/runlabel.in + M /trunk/asymptote/settings.cc + A /trunk/asymptote/tests/array/sort.asy + +Make lexorder in math.asy a strict partial order. + +Implement int search(T[] a, T key, bool less(T i, T j)). + +Batch 3D TeX labels. + +------------------------------------------------------------------------ +r5042 | jcbowman | 2010-06-23 00:09:35 -0600 (Wed, 23 Jun 2010) | 1 line +Changed paths: + M /trunk/asymptote/base/three_surface.asy + +Remove unused code. +------------------------------------------------------------------------ +r5041 | jcbowman | 2010-06-21 08:54:34 -0600 (Mon, 21 Jun 2010) | 2 lines +Changed paths: + M /trunk/asymptote/texfile.cc + +Suppress plain TeX page numbers. + +------------------------------------------------------------------------ +r5040 | jcbowman | 2010-06-20 12:32:46 -0600 (Sun, 20 Jun 2010) | 1 line +Changed paths: + M /trunk/asymptote/tests/gsl/gsl.asy + +Disable nonportable GSL tests. +------------------------------------------------------------------------ +r5039 | jcbowman | 2010-06-20 12:20:46 -0600 (Sun, 20 Jun 2010) | 1 line +Changed paths: + M /trunk/asymptote/Makefile.in + M /trunk/asymptote/tests/Makefile + +Make gsl optional by moving it to make check-all. +------------------------------------------------------------------------ +r5038 | jcbowman | 2010-06-20 11:54:27 -0600 (Sun, 20 Jun 2010) | 2 lines +Changed paths: + M /trunk/asymptote/Makefile.in + M /trunk/asymptote/main.cc + M /trunk/asymptote/tests/Makefile + M /trunk/asymptote/tests/gsl/gsl.asy + +More GSL portability fixes. + +------------------------------------------------------------------------ +r5037 | jcbowman | 2010-06-20 09:15:43 -0600 (Sun, 20 Jun 2010) | 4 lines +Changed paths: + M /trunk/asymptote/Makefile.in + M /trunk/asymptote/asymptote.spec + M /trunk/asymptote/gsl.cc + M /trunk/asymptote/tests/Makefile + A /trunk/asymptote/tests/gsl + A /trunk/asymptote/tests/gsl/gsl.asy + +Fix GSL typos; add tests. + +Restrict make check to a single processor. + +------------------------------------------------------------------------ +r5036 | jcbowman | 2010-06-19 22:25:10 -0600 (Sat, 19 Jun 2010) | 2 lines +Changed paths: + M /trunk/asymptote/common.h + +Fix preprocessor conditional. + +------------------------------------------------------------------------ +r5035 | jcbowman | 2010-06-19 22:16:51 -0600 (Sat, 19 Jun 2010) | 1 line +Changed paths: + M /trunk/asymptote/Makefile.in + +Fix typo. +------------------------------------------------------------------------ +r5034 | jcbowman | 2010-06-19 22:16:08 -0600 (Sat, 19 Jun 2010) | 4 lines +Changed paths: + M /trunk/asymptote/Makefile.in + M /trunk/asymptote/arrayop.h + M /trunk/asymptote/builtin.cc + M /trunk/asymptote/builtin.h + A /trunk/asymptote/gsl.cc + M /trunk/asymptote/runhistory.in + M /trunk/asymptote/runtime.pl + M /trunk/asymptote/runtimebase.in + M /trunk/asymptote/types.cc + +Move GSL functions to gsl.cc; implement Elmar's contributed GSL functions. + +Invoke the C preprocessor in pretranslating symbols. + +------------------------------------------------------------------------ +r5033 | jcbowman | 2010-06-19 21:51:07 -0600 (Sat, 19 Jun 2010) | 2 lines +Changed paths: + M /trunk/asymptote/item.h + +Add unsigned int constructors. + +------------------------------------------------------------------------ +r5032 | jcbowman | 2010-06-19 09:08:34 -0600 (Sat, 19 Jun 2010) | 2 lines +Changed paths: + M /trunk/asymptote/doc/asymptote.texi + M /trunk/asymptote/examples/condor.asy + M /trunk/asymptote/glrender.cc + +Update example. + +------------------------------------------------------------------------ +r5031 | jcbowman | 2010-06-18 02:44:57 -0600 (Fri, 18 Jun 2010) | 1 line +Changed paths: + M /trunk/asymptote/asymptote.spec + M /trunk/asymptote/configure.ac + +Increment version to 2.00svn. +------------------------------------------------------------------------ +r5030 | jcbowman | 2010-06-18 02:07:40 -0600 (Fri, 18 Jun 2010) | 2 lines +Changed paths: + M /trunk/asymptote/glrender.cc + +Fix warning message. + +------------------------------------------------------------------------ r5029 | jcbowman | 2010-06-18 01:01:53 -0600 (Fri, 18 Jun 2010) | 1 line Changed paths: M /trunk/asymptote/tests/gc/pen.asy diff --git a/Build/source/utils/asymptote/Makefile.in b/Build/source/utils/asymptote/Makefile.in index eab0bd238f3..13040078e88 100644 --- a/Build/source/utils/asymptote/Makefile.in +++ b/Build/source/utils/asymptote/Makefile.in @@ -21,14 +21,14 @@ RUNTIME_FILES = runtime runbacktrace runpicture runlabel runhistory runarray \ runmath # Files to be scanned for pre-translated symbols defined by SYM(name). -SYMBOL_FILES = types builtin $(RUNTIME_FILES) +SYMBOL_FILES = types builtin gsl $(RUNTIME_FILES) PRC = PRCbitStream oPRCFile PRCdouble writePRC -FILES = $(CAMP) $(RUNTIME_FILES) env genv main stm dec errormsg \ - callable name symbol types entry exp newexp stack camp.tab lex.yy \ - access virtualfieldaccess absyn record interact fileio builtin fftw++ \ - simpson coder coenv \ +FILES = $(CAMP) $(SYMBOL_FILES) env genv main stm dec errormsg \ + callable name symbol entry exp newexp stack camp.tab lex.yy \ + access virtualfieldaccess absyn record interact fileio \ + fftw++ simpson coder coenv \ @getopt@ locate parser program application varinit fundec refaccess \ envcompleter process constructor array Delaunay predicates \ $(PRC) glrender tr arcball algebra3 quaternion svnrevision @@ -37,8 +37,11 @@ DIST = camp.tab.h camp.tab.cc lex.yy.cc runtime.h runtime.cc keywords.cc \ asy-keywords.el NAME = asy XNAME = x$(NAME) -CLEAN = camp.output asy.list svnrevision.cc doc/version.texi GUI/xasyVersion.py $(XNAME) -EXTRA = asy-mode.el asy-init.el asy.vim asy-kate.sh asymptote.py reload.js nopapersize.ps +CLEAN = camp.output asy.list svnrevision.cc doc/version.texi \ + $(SYMBOL_FILES:=.symbols.h) allsymbols.h opsymbols.h \ + GUI/xasyVersion.py $(XNAME) +EXTRA = asy-mode.el asy-init.el asy.vim asy-kate.sh asymptote.py reload.js \ + nopapersize.ps EXEXTRA = piicon.eps *.views *.dat DOCEXTRA = *.asy *.csv *.dat latexusage.tex externalprc.tex pixel.pdf KEYWORDS = base $(ASYMPTOTE_SITEDIR) @@ -118,7 +121,8 @@ $(GCLIB): $(GC).tar.gz cd $(GC)/include && patch < ../../patches/gc6.8_AIX.patch; \ fi if test "$(GC)" = "gc-7.0"; then \ - cd $(GC)/include/private && patch < ../../../patches/gc-7.0nomem.patch;\ + cd $(GC)/include/private && \ + patch < ../../../patches/gc-7.0nomem.patch;\ fi cd $(GC); \ ./configure $(GCOPTIONS); \ @@ -142,12 +146,14 @@ $(RUNTIME_FILES:=.cc): %.cc: runtime.pl opsymbols.h runtimebase.in %.in ./runtime.pl $(@:.cc=) $(SYMBOL_FILES:=.symbols.h): %.symbols.h: findsym.pl %.cc - ./findsym.pl $@ $(@:.symbols.h=.cc) + $(CXX) -E -DNOSYM $(OPTS) $(INCL) $(@:.symbols.h=.cc) | \ + ./findsym.pl $@ - $(SYMBOL_FILES:=.o): %.o: %.symbols.h allsymbols.h: findsym.pl $(SYMBOL_FILES:=.cc) - ./findsym.pl $@ $(SYMBOL_FILES:=.cc) + $(CXX) -E -DNOSYM $(OPTS) $(INCL) $(SYMBOL_FILES:=.cc) | \ + ./findsym.pl $@ - symbol.o: opsymbols.h allsymbols.h @@ -191,7 +197,8 @@ install-asy: asy -${INSTALL} -d $(latexdir) -${INSTALL} -d $(contextdir) ${INSTALL} -p -m 755 $(NAME) $(bindir) - ${INSTALL} -p -m 644 asy-keywords.el base/*.asy $(addprefix base/,$(EXTRA)) $(asydir) + ${INSTALL} -p -m 644 asy-keywords.el base/*.asy \ + $(addprefix base/,$(EXTRA)) $(asydir) ${INSTALL} -p -m 755 GUI/*.py $(GUIdir) ln -sf @datadir@/asymptote/GUI/xasy.py $(bindir)/$(XNAME) ${INSTALL} -p -m 644 examples/*.asy $(addprefix examples/,$(EXEXTRA)) \ @@ -262,6 +269,10 @@ check: asy FORCE ./wce $(MAKE) -C tests +check-all: asy FORCE + ./wce + $(MAKE) -C tests all + .SUFFIXES: .c .cc .o .d .cc.o: $(CXX) $(OPTS) $(INCL) -o $@ -c $< diff --git a/Build/source/utils/asymptote/ReleaseNotes b/Build/source/utils/asymptote/ReleaseNotes index eeb16955d6e..9614132eb82 100644 --- a/Build/source/utils/asymptote/ReleaseNotes +++ b/Build/source/utils/asymptote/ReleaseNotes @@ -1,9 +1,18 @@ +Release Notes for Version 2.00 + +The construction of 3D TeX labels was sped up greatly. Plain TeX page +numbers were suppressed. Dotted 3D lines and 3D sizing problems were fixed. +A general search function for sorted structures was implemented; the +lexorder functions in math.asy now return strict partial orders. Additional +GSL functions were added. The correct PRC units (PostScript pt units, +properly called bp) are now displayed in Adobe Reader. + Release Notes for Version 1.99 A segmentation fault was fixed. Perspective animations were fixed. A bug in -the bezulate topological sorting algorithm was fixed. A settings.framedelay -parameter was added for working around OpenGL animation rendering buffer -overruns. Further optimizations were made. A portability issue was addressed. +the bezulate topological sorting algorithm was fixed. A framedelay setting +was added for working around OpenGL animation rendering buffer overruns. +Further optimizations were made. A portability issue was addressed. Release Notes for Version 1.98 diff --git a/Build/source/utils/asymptote/allsymbols.h b/Build/source/utils/asymptote/allsymbols.h deleted file mode 100644 index e00feb33c03..00000000000 --- a/Build/source/utils/asymptote/allsymbols.h +++ /dev/null @@ -1,685 +0,0 @@ -/***** - * This file is automatically generated by findsym.pl - * Changes will be overwritten. - *****/ - -// If the ADDSYMBOL macro is not already defined, define it with the default -// purpose of referring to an external pre-translated symbol, such that -// SYM(name) also refers to that symbol. -#ifndef ADDSYMBOL - #define ADDSYMBOL(name) extern sym::symbol PRETRANSLATED_SYMBOL_##name - #ifdef PRESYM - #define SYM(name) PRETRANSLATED_SYMBOL_##name - #else - #define SYM(name) sym::symbol::trans(#name) - #endif -#endif - -ADDSYMBOL(AND); -ADDSYMBOL(Ai); -ADDSYMBOL(Ai_deriv); -ADDSYMBOL(Ai_deriv_scaled); -ADDSYMBOL(Ai_scaled); -ADDSYMBOL(Bi); -ADDSYMBOL(Bi_deriv); -ADDSYMBOL(Bi_deriv_scaled); -ADDSYMBOL(Bi_scaled); -ADDSYMBOL(CLZ); -ADDSYMBOL(CTZ); -ADDSYMBOL(Ceil); -ADDSYMBOL(Chi); -ADDSYMBOL(Ci); -ADDSYMBOL(Cos); -ADDSYMBOL(D); -ADDSYMBOL(Degrees); -ADDSYMBOL(E); -ADDSYMBOL(E1); -ADDSYMBOL(E2); -ADDSYMBOL(Ei); -ADDSYMBOL(Ei3); -ADDSYMBOL(En); -ADDSYMBOL(F); -ADDSYMBOL(FermiDirac); -ADDSYMBOL(FermiDirac0); -ADDSYMBOL(FermiDirac1); -ADDSYMBOL(FermiDirac2); -ADDSYMBOL(FermiDirac3Half); -ADDSYMBOL(FermiDiracHalf); -ADDSYMBOL(FermiDiracInc0); -ADDSYMBOL(FermiDiracM1); -ADDSYMBOL(FermiDiracMHalf); -ADDSYMBOL(Floor); -ADDSYMBOL(H3d); -ADDSYMBOL(H3d0); -ADDSYMBOL(H3d1); -ADDSYMBOL(I); -ADDSYMBOL(I0); -ADDSYMBOL(I0_scaled); -ADDSYMBOL(I1); -ADDSYMBOL(I1_scaled); -ADDSYMBOL(I_scaled); -ADDSYMBOL(J); -ADDSYMBOL(J0); -ADDSYMBOL(J1); -ADDSYMBOL(Jn); -ADDSYMBOL(K); -ADDSYMBOL(K0); -ADDSYMBOL(K0_scaled); -ADDSYMBOL(K1); -ADDSYMBOL(K1_scaled); -ADDSYMBOL(K_scaled); -ADDSYMBOL(L); -ADDSYMBOL(L1); -ADDSYMBOL(L2); -ADDSYMBOL(L3); -ADDSYMBOL(NOT); -ADDSYMBOL(OR); -ADDSYMBOL(P); -ADDSYMBOL(P1); -ADDSYMBOL(P2); -ADDSYMBOL(P3); -ADDSYMBOL(Pl); -ADDSYMBOL(Plm); -ADDSYMBOL(Q0); -ADDSYMBOL(Q1); -ADDSYMBOL(Ql); -ADDSYMBOL(RC); -ADDSYMBOL(RD); -ADDSYMBOL(RF); -ADDSYMBOL(RJ); -ADDSYMBOL(Round); -ADDSYMBOL(Shi); -ADDSYMBOL(Si); -ADDSYMBOL(Sin); -ADDSYMBOL(Tan); -ADDSYMBOL(U); -ADDSYMBOL(VERSION); -ADDSYMBOL(W0); -ADDSYMBOL(Wm1); -ADDSYMBOL(XOR); -ADDSYMBOL(Y); -ADDSYMBOL(Y0); -ADDSYMBOL(Y1); -ADDSYMBOL(Yn); -ADDSYMBOL(Z); -ADDSYMBOL(_begingroup3); -ADDSYMBOL(_cputime); -ADDSYMBOL(_draw); -ADDSYMBOL(_eval); -ADDSYMBOL(_image); -ADDSYMBOL(_labelpath); -ADDSYMBOL(_projection); -ADDSYMBOL(_strokepath); -ADDSYMBOL(_texpath); -ADDSYMBOL(a); -ADDSYMBOL(aCos); -ADDSYMBOL(aI); -ADDSYMBOL(aR); -ADDSYMBOL(aSin); -ADDSYMBOL(aTan); -ADDSYMBOL(abort); -ADDSYMBOL(abs); -ADDSYMBOL(acc); -ADDSYMBOL(accel); -ADDSYMBOL(acos); -ADDSYMBOL(acosh); -ADDSYMBOL(add); -ADDSYMBOL(adjust); -ADDSYMBOL(alias); -ADDSYMBOL(align); -ADDSYMBOL(all); -ADDSYMBOL(ambient); -ADDSYMBOL(angle); -ADDSYMBOL(animate); -ADDSYMBOL(antialias); -ADDSYMBOL(append); -ADDSYMBOL(arclength); -ADDSYMBOL(arctime); -ADDSYMBOL(args); -ADDSYMBOL(array); -ADDSYMBOL(asin); -ADDSYMBOL(asinh); -ADDSYMBOL(assert); -ADDSYMBOL(asydir); -ADDSYMBOL(atLeast); -ADDSYMBOL(atan); -ADDSYMBOL(atan2); -ADDSYMBOL(atanh); -ADDSYMBOL(atanint); -ADDSYMBOL(atbreakpoint); -ADDSYMBOL(atexit); -ADDSYMBOL(atleast); -ADDSYMBOL(atupdate); -ADDSYMBOL(axialshade); -ADDSYMBOL(azimuth); -ADDSYMBOL(b); -ADDSYMBOL(background); -ADDSYMBOL(basealign); -ADDSYMBOL(beginclip); -ADDSYMBOL(begingroup); -ADDSYMBOL(beta); -ADDSYMBOL(bezier); -ADDSYMBOL(bezierP); -ADDSYMBOL(bezierPP); -ADDSYMBOL(bezierPPP); -ADDSYMBOL(binput); -ADDSYMBOL(blend); -ADDSYMBOL(boutput); -ADDSYMBOL(breakpoint); -ADDSYMBOL(breakpoints); -ADDSYMBOL(byte); -ADDSYMBOL(c); -ADDSYMBOL(c0); -ADDSYMBOL(c1); -ADDSYMBOL(cbrt); -ADDSYMBOL(cd); -ADDSYMBOL(ceil); -ADDSYMBOL(center); -ADDSYMBOL(change2); -ADDSYMBOL(check); -ADDSYMBOL(choose); -ADDSYMBOL(clausen); -ADDSYMBOL(clear); -ADDSYMBOL(clip); -ADDSYMBOL(close); -ADDSYMBOL(closed); -ADDSYMBOL(cmyk); -ADDSYMBOL(colatitude); -ADDSYMBOL(colorless); -ADDSYMBOL(colors); -ADDSYMBOL(colorspace); -ADDSYMBOL(comment); -ADDSYMBOL(complement); -ADDSYMBOL(compression); -ADDSYMBOL(concat); -ADDSYMBOL(conicalP_0); -ADDSYMBOL(conicalP_1); -ADDSYMBOL(conicalP_cyl_reg); -ADDSYMBOL(conicalP_half); -ADDSYMBOL(conicalP_mhalf); -ADDSYMBOL(conicalP_sph_reg); -ADDSYMBOL(conj); -ADDSYMBOL(controlSpecifier); -ADDSYMBOL(convert); -ADDSYMBOL(copy); -ADDSYMBOL(cos); -ADDSYMBOL(cosh); -ADDSYMBOL(coupling_3j); -ADDSYMBOL(coupling_6j); -ADDSYMBOL(coupling_9j); -ADDSYMBOL(cross); -ADDSYMBOL(csv); -ADDSYMBOL(cubicroots); -ADDSYMBOL(curlSpecifier); -ADDSYMBOL(currentpen); -ADDSYMBOL(cyclic); -ADDSYMBOL(d); -ADDSYMBOL(data); -ADDSYMBOL(dawson); -ADDSYMBOL(debye_1); -ADDSYMBOL(debye_2); -ADDSYMBOL(debye_3); -ADDSYMBOL(debye_4); -ADDSYMBOL(debye_5); -ADDSYMBOL(debye_6); -ADDSYMBOL(deconstruct); -ADDSYMBOL(defaultpen); -ADDSYMBOL(deg); -ADDSYMBOL(degrees); -ADDSYMBOL(delete); -ADDSYMBOL(deletepreamble); -ADDSYMBOL(depth); -ADDSYMBOL(dest); -ADDSYMBOL(determinant); -ADDSYMBOL(diagonal); -ADDSYMBOL(diffuse); -ADDSYMBOL(digits); -ADDSYMBOL(dilog); -ADDSYMBOL(dimension); -ADDSYMBOL(dir); -ADDSYMBOL(dirSpecifier); -ADDSYMBOL(dirtime); -ADDSYMBOL(divisor); -ADDSYMBOL(dobreak); -ADDSYMBOL(dot); -ADDSYMBOL(doublefact); -ADDSYMBOL(downcase); -ADDSYMBOL(draw); -ADDSYMBOL(drawPRCcylinder); -ADDSYMBOL(drawPRCdisk); -ADDSYMBOL(drawPRCsphere); -ADDSYMBOL(drawPRCtube); -ADDSYMBOL(dval); -ADDSYMBOL(dxmax); -ADDSYMBOL(e); -ADDSYMBOL(edges); -ADDSYMBOL(embedded); -ADDSYMBOL(empty); -ADDSYMBOL(endclip); -ADDSYMBOL(endgroup); -ADDSYMBOL(endgroup3); -ADDSYMBOL(eof); -ADDSYMBOL(eol); -ADDSYMBOL(epsilon); -ADDSYMBOL(erase); -ADDSYMBOL(erf); -ADDSYMBOL(erf_Q); -ADDSYMBOL(erf_Z); -ADDSYMBOL(erfc); -ADDSYMBOL(error); -ADDSYMBOL(eta); -ADDSYMBOL(exit); -ADDSYMBOL(exp); -ADDSYMBOL(exp_mult); -ADDSYMBOL(expi); -ADDSYMBOL(expm1); -ADDSYMBOL(exprel); -ADDSYMBOL(exprel_2); -ADDSYMBOL(extension); -ADDSYMBOL(f); -ADDSYMBOL(fabs); -ADDSYMBOL(fact); -ADDSYMBOL(factorial); -ADDSYMBOL(fcmp); -ADDSYMBOL(fft); -ADDSYMBOL(file); -ADDSYMBOL(fill); -ADDSYMBOL(fillrule); -ADDSYMBOL(final); -ADDSYMBOL(find); -ADDSYMBOL(floor); -ADDSYMBOL(flush); -ADDSYMBOL(fmod); -ADDSYMBOL(font); -ADDSYMBOL(fontcommand); -ADDSYMBOL(fontsize); -ADDSYMBOL(format); -ADDSYMBOL(fprime); -ADDSYMBOL(from); -ADDSYMBOL(functionshade); -ADDSYMBOL(fuzz); -ADDSYMBOL(g); -ADDSYMBOL(gamma); -ADDSYMBOL(gamma_P); -ADDSYMBOL(gamma_Q); -ADDSYMBOL(gammainv); -ADDSYMBOL(gammastar); -ADDSYMBOL(gegenpoly); -ADDSYMBOL(gegenpoly_1); -ADDSYMBOL(gegenpoly_2); -ADDSYMBOL(gegenpoly_3); -ADDSYMBOL(generate_random_backtrace); -ADDSYMBOL(getc); -ADDSYMBOL(gouraudshade); -ADDSYMBOL(granularity); -ADDSYMBOL(gray); -ADDSYMBOL(grestore); -ADDSYMBOL(gsave); -ADDSYMBOL(gsl); -ADDSYMBOL(half); -ADDSYMBOL(hazard); -ADDSYMBOL(height); -ADDSYMBOL(hex); -ADDSYMBOL(history); -ADDSYMBOL(hy0F1); -ADDSYMBOL(hy1F1); -ADDSYMBOL(hy2F0); -ADDSYMBOL(hy2F1); -ADDSYMBOL(hy2F1_conj); -ADDSYMBOL(hy2F1_conj_renorm); -ADDSYMBOL(hy2F1_renorm); -ADDSYMBOL(hydrogenicR); -ADDSYMBOL(hydrogenicR_1); -ADDSYMBOL(hypot); -ADDSYMBOL(hzeta); -ADDSYMBOL(i); -ADDSYMBOL(i0_scaled); -ADDSYMBOL(i1_scaled); -ADDSYMBOL(i2_scaled); -ADDSYMBOL(i_scaled); -ADDSYMBOL(identity); -ADDSYMBOL(imports); -ADDSYMBOL(in); -ADDSYMBOL(incircle); -ADDSYMBOL(index); -ADDSYMBOL(inf); -ADDSYMBOL(infinity); -ADDSYMBOL(initial); -ADDSYMBOL(initialized); -ADDSYMBOL(input); -ADDSYMBOL(insert); -ADDSYMBOL(inside); -ADDSYMBOL(intMax); -ADDSYMBOL(intMin); -ADDSYMBOL(interaction); -ADDSYMBOL(interactive); -ADDSYMBOL(interactivewrite); -ADDSYMBOL(interp); -ADDSYMBOL(intersect); -ADDSYMBOL(intersections); -ADDSYMBOL(inverse); -ADDSYMBOL(invisible); -ADDSYMBOL(is3D); -ADDSYMBOL(iterations); -ADDSYMBOL(j); -ADDSYMBOL(j0); -ADDSYMBOL(j1); -ADDSYMBOL(j2); -ADDSYMBOL(justify); -ADDSYMBOL(k); -ADDSYMBOL(k0_scaled); -ADDSYMBOL(k1_scaled); -ADDSYMBOL(k2_scaled); -ADDSYMBOL(k_scaled); -ADDSYMBOL(key); -ADDSYMBOL(keys); -ADDSYMBOL(knot); -ADDSYMBOL(l); -ADDSYMBOL(label); -ADDSYMBOL(labels); -ADDSYMBOL(lambda); -ADDSYMBOL(latex); -ADDSYMBOL(latitude); -ADDSYMBOL(latticeshade); -ADDSYMBOL(layer); -ADDSYMBOL(ldexp); -ADDSYMBOL(length); -ADDSYMBOL(lighton); -ADDSYMBOL(lights); -ADDSYMBOL(line); -ADDSYMBOL(linecap); -ADDSYMBOL(linejoin); -ADDSYMBOL(lineskip); -ADDSYMBOL(linetype); -ADDSYMBOL(linewidth); -ADDSYMBOL(list); -ADDSYMBOL(lnK); -ADDSYMBOL(lnbeta); -ADDSYMBOL(lnchoose); -ADDSYMBOL(lncosh); -ADDSYMBOL(lndoublefact); -ADDSYMBOL(lnfact); -ADDSYMBOL(lngamma); -ADDSYMBOL(lnpoch); -ADDSYMBOL(lnsinh); -ADDSYMBOL(locale); -ADDSYMBOL(locatefile); -ADDSYMBOL(location); -ADDSYMBOL(log); -ADDSYMBOL(log10); -ADDSYMBOL(log1p); -ADDSYMBOL(log1pm); -ADDSYMBOL(log_erfc); -ADDSYMBOL(logabs); -ADDSYMBOL(longitude); -ADDSYMBOL(m); -ADDSYMBOL(magnification); -ADDSYMBOL(makepen); -ADDSYMBOL(map); -ADDSYMBOL(max); -ADDSYMBOL(max3); -ADDSYMBOL(maxbezier); -ADDSYMBOL(maxbound); -ADDSYMBOL(maxratio); -ADDSYMBOL(maxtimes); -ADDSYMBOL(microseconds); -ADDSYMBOL(min); -ADDSYMBOL(min3); -ADDSYMBOL(minbezier); -ADDSYMBOL(minbound); -ADDSYMBOL(minratio); -ADDSYMBOL(mintimes); -ADDSYMBOL(miterlimit); -ADDSYMBOL(mode); -ADDSYMBOL(n); -ADDSYMBOL(name); -ADDSYMBOL(nativeformat); -ADDSYMBOL(newpage); -ADDSYMBOL(newton); -ADDSYMBOL(nib); -ADDSYMBOL(nobreak); -ADDSYMBOL(norm); -ADDSYMBOL(normal); -ADDSYMBOL(normalize); -ADDSYMBOL(nowarn); -ADDSYMBOL(nu); -ADDSYMBOL(nurb); -ADDSYMBOL(nx); -ADDSYMBOL(ny); -ADDSYMBOL(nz); -ADDSYMBOL(offset); -ADDSYMBOL(opacity); -ADDSYMBOL(openFunc); -ADDSYMBOL(out); -ADDSYMBOL(outname); -ADDSYMBOL(output); -ADDSYMBOL(overwrite); -ADDSYMBOL(p); -ADDSYMBOL(palette); -ADDSYMBOL(path3); -ADDSYMBOL(pattern); -ADDSYMBOL(pdf); -ADDSYMBOL(pena); -ADDSYMBOL(penb); -ADDSYMBOL(perm); -ADDSYMBOL(perp); -ADDSYMBOL(phi); -ADDSYMBOL(pi); -ADDSYMBOL(piecewisestraight); -ADDSYMBOL(poch); -ADDSYMBOL(pochrel); -ADDSYMBOL(point); -ADDSYMBOL(polar); -ADDSYMBOL(pop); -ADDSYMBOL(pos); -ADDSYMBOL(position); -ADDSYMBOL(post); -ADDSYMBOL(postcontrol); -ADDSYMBOL(postscript); -ADDSYMBOL(pow); -ADDSYMBOL(pow10); -ADDSYMBOL(prc); -ADDSYMBOL(prcshininess); -ADDSYMBOL(pre); -ADDSYMBOL(preamble); -ADDSYMBOL(precision); -ADDSYMBOL(precontrol); -ADDSYMBOL(prefix); -ADDSYMBOL(prepend); -ADDSYMBOL(print_random_addresses); -ADDSYMBOL(project); -ADDSYMBOL(prompt); -ADDSYMBOL(psi); -ADDSYMBOL(psi1); -ADDSYMBOL(psi_1piy); -ADDSYMBOL(purge); -ADDSYMBOL(push); -ADDSYMBOL(q); -ADDSYMBOL(quadraticroots); -ADDSYMBOL(quotient); -ADDSYMBOL(r); -ADDSYMBOL(ra); -ADDSYMBOL(radialshade); -ADDSYMBOL(radians); -ADDSYMBOL(radius); -ADDSYMBOL(rand); -ADDSYMBOL(randMax); -ADDSYMBOL(rb); -ADDSYMBOL(read); -ADDSYMBOL(readline); -ADDSYMBOL(realDigits); -ADDSYMBOL(realEpsilon); -ADDSYMBOL(realMax); -ADDSYMBOL(realMin); -ADDSYMBOL(realmult); -ADDSYMBOL(reflect); -ADDSYMBOL(relativedistance); -ADDSYMBOL(remainder); -ADDSYMBOL(rename); -ADDSYMBOL(replace); -ADDSYMBOL(resetdefaultpen); -ADDSYMBOL(reverse); -ADDSYMBOL(rfind); -ADDSYMBOL(rgb); -ADDSYMBOL(rotate); -ADDSYMBOL(round); -ADDSYMBOL(s); -ADDSYMBOL(saveline); -ADDSYMBOL(scale); -ADDSYMBOL(search); -ADDSYMBOL(seconds); -ADDSYMBOL(seed); -ADDSYMBOL(seek); -ADDSYMBOL(seekeof); -ADDSYMBOL(sequence); -ADDSYMBOL(sgn); -ADDSYMBOL(shader); -ADDSYMBOL(shift); -ADDSYMBOL(shiftless); -ADDSYMBOL(shininess); -ADDSYMBOL(shipout); -ADDSYMBOL(shipout3); -ADDSYMBOL(side); -ADDSYMBOL(sign); -ADDSYMBOL(signedint); -ADDSYMBOL(simpson); -ADDSYMBOL(sin); -ADDSYMBOL(sinc); -ADDSYMBOL(singleint); -ADDSYMBOL(singlereal); -ADDSYMBOL(sinh); -ADDSYMBOL(size); -ADDSYMBOL(size3); -ADDSYMBOL(slant); -ADDSYMBOL(sleep); -ADDSYMBOL(solve); -ADDSYMBOL(sort); -ADDSYMBOL(spec); -ADDSYMBOL(specular); -ADDSYMBOL(sphPlm); -ADDSYMBOL(sqrt); -ADDSYMBOL(srand); -ADDSYMBOL(src); -ADDSYMBOL(stop); -ADDSYMBOL(store); -ADDSYMBOL(straight); -ADDSYMBOL(straightness); -ADDSYMBOL(string); -ADDSYMBOL(stripdirectory); -ADDSYMBOL(stripextension); -ADDSYMBOL(stripfile); -ADDSYMBOL(stroke); -ADDSYMBOL(subpath); -ADDSYMBOL(substr); -ADDSYMBOL(suffix); -ADDSYMBOL(sum); -ADDSYMBOL(synchrotron_1); -ADDSYMBOL(synchrotron_2); -ADDSYMBOL(system); -ADDSYMBOL(t); -ADDSYMBOL(tabcompletion); -ADDSYMBOL(tan); -ADDSYMBOL(tanh); -ADDSYMBOL(taylorcoeff); -ADDSYMBOL(tell); -ADDSYMBOL(tensionSpecifier); -ADDSYMBOL(tensorshade); -ADDSYMBOL(tessellate); -ADDSYMBOL(test); -ADDSYMBOL(tex); -ADDSYMBOL(texpreamble); -ADDSYMBOL(texreset); -ADDSYMBOL(texsize); -ADDSYMBOL(textpath); -ADDSYMBOL(theta); -ADDSYMBOL(time); -ADDSYMBOL(tin); -ADDSYMBOL(to); -ADDSYMBOL(tok); -ADDSYMBOL(tout); -ADDSYMBOL(transform); -ADDSYMBOL(translate); -ADDSYMBOL(transport_2); -ADDSYMBOL(transport_3); -ADDSYMBOL(transport_4); -ADDSYMBOL(transport_5); -ADDSYMBOL(transpose); -ADDSYMBOL(triangulate); -ADDSYMBOL(tridiagonal); -ADDSYMBOL(two_ja); -ADDSYMBOL(two_jb); -ADDSYMBOL(two_jc); -ADDSYMBOL(two_jd); -ADDSYMBOL(two_je); -ADDSYMBOL(two_jf); -ADDSYMBOL(two_jg); -ADDSYMBOL(two_jh); -ADDSYMBOL(two_ji); -ADDSYMBOL(two_ma); -ADDSYMBOL(two_mb); -ADDSYMBOL(two_mc); -ADDSYMBOL(type); -ADDSYMBOL(u); -ADDSYMBOL(uknot); -ADDSYMBOL(unit); -ADDSYMBOL(unitrand); -ADDSYMBOL(unstraighten); -ADDSYMBOL(upcase); -ADDSYMBOL(update); -ADDSYMBOL(uptodate); -ADDSYMBOL(usleep); -ADDSYMBOL(v); -ADDSYMBOL(value); -ADDSYMBOL(verbose); -ADDSYMBOL(view); -ADDSYMBOL(viewportlighting); -ADDSYMBOL(vknot); -ADDSYMBOL(w); -ADDSYMBOL(w0); -ADDSYMBOL(w1); -ADDSYMBOL(w2); -ADDSYMBOL(w3); -ADDSYMBOL(wait); -ADDSYMBOL(warn); -ADDSYMBOL(warning); -ADDSYMBOL(weights); -ADDSYMBOL(width); -ADDSYMBOL(windingnumber); -ADDSYMBOL(word); -ADDSYMBOL(write); -ADDSYMBOL(x); -ADDSYMBOL(x1); -ADDSYMBOL(x2); -ADDSYMBOL(xform); -ADDSYMBOL(xinput); -ADDSYMBOL(xoutput); -ADDSYMBOL(xpart); -ADDSYMBOL(xscale); -ADDSYMBOL(xx); -ADDSYMBOL(xy); -ADDSYMBOL(y); -ADDSYMBOL(y0); -ADDSYMBOL(y1); -ADDSYMBOL(y2); -ADDSYMBOL(ypart); -ADDSYMBOL(yscale); -ADDSYMBOL(yx); -ADDSYMBOL(yy); -ADDSYMBOL(z); -ADDSYMBOL(z0); -ADDSYMBOL(z1); -ADDSYMBOL(z2); -ADDSYMBOL(z3); -ADDSYMBOL(zero_Ai); -ADDSYMBOL(zero_Ai_deriv); -ADDSYMBOL(zero_Bi); -ADDSYMBOL(zero_Bi_deriv); -ADDSYMBOL(zero_J); -ADDSYMBOL(zero_J0); -ADDSYMBOL(zero_J1); -ADDSYMBOL(zeta); -ADDSYMBOL(zetam1); -ADDSYMBOL(zin); -ADDSYMBOL(zoom); -ADDSYMBOL(zout); -ADDSYMBOL(zpart); diff --git a/Build/source/utils/asymptote/arrayop.h b/Build/source/utils/asymptote/arrayop.h index dd21a80a1d6..378b313627e 100644 --- a/Build/source/utils/asymptote/arrayop.h +++ b/Build/source/utils/asymptote/arrayop.h @@ -297,16 +297,16 @@ void searchArray(vm::stack *s) { T key=pop<T>(s); array *a=pop<array*>(s); - Int size=(Int) a->size(); + size_t size= a->size(); if(size == 0 || key < read<T>(a,0)) {s->push(-1); return;} - Int u=size-1; - if(key >= read<T>(a,u)) {s->push(u); return;} - Int l=0; + size_t u=size-1; + if(key >= read<T>(a,u)) {s->push((Int) u); return;} + size_t l=0; while (l < u) { - Int i=(l+u)/2; - if(read<T>(a,i) <= key && key < read<T>(a,i+1)) {s->push(i); return;} + size_t i=(l+u)/2; if(key < read<T>(a,i)) u=i; + else if(key < read<T>(a,i+1)) {s->push((Int) i); return;} else l=i+1; } s->push(0); @@ -507,6 +507,71 @@ camp::triple multshiftless(const vm::array& t, const camp::triple& v); double norm(double *a, size_t n); double norm(camp::triple *a, size_t n); +inline size_t checkdimension(const vm::array *a, size_t dim) +{ + size_t size=checkArray(a); + if(dim && size != dim) { + ostringstream buf; + buf << "array of length " << dim << " expected"; + vm::error(buf); + } + return size; +} + +template<class T> +inline void copyArrayC(T* &dest, const vm::array *a, size_t dim=0, + GCPlacement placement=NoGC) +{ + size_t size=checkdimension(a,dim); + dest=(placement == NoGC) ? new T[size] : new(placement) T[size]; + for(size_t i=0; i < size; i++) + dest[i]=vm::read<T>(a,i); +} + +template<class T, class A> +inline void copyArrayC(T* &dest, const vm::array *a, T (*cast)(A), + size_t dim=0, GCPlacement placement=NoGC) +{ + size_t size=checkdimension(a,dim); + dest=(placement == NoGC) ? new T[size] : new(placement) T[size]; + for(size_t i=0; i < size; i++) + dest[i]=cast(vm::read<A>(a,i)); +} + +template<typename T> +inline vm::array* copyCArray(const size_t n, const T* p, + GCPlacement placement=NoGC) +{ + vm::array* a = new vm::array(n); + for(size_t i=0; i < n; ++i) (*a)[i] = p[i]; + return a; +} + +template<class T> +inline void copyArray2C(T* &dest, const vm::array *a, bool square=true, + size_t dim2=0, GCPlacement placement=NoGC) +{ + size_t n=checkArray(a); + size_t m=(square || n == 0) ? n : checkArray(vm::read<vm::array*>(a,0)); + if(n > 0 && dim2 && m != dim2) { + ostringstream buf; + buf << "second matrix dimension must be " << dim2; + vm::error(buf); + } + + dest=(placement == NoGC) ? new T[n*m] : new(placement) T[n*m]; + for(size_t i=0; i < n; i++) { + vm::array *ai=vm::read<vm::array*>(a,i); + size_t aisize=checkArray(ai); + if(aisize == m) { + T *desti=dest+i*m; + for(size_t j=0; j < m; j++) + desti[j]=vm::read<T>(ai,j); + } else + vm::error(square ? "matrix must be square" : "matrix must be rectangular"); + } +} + } // namespace run #endif // ARRAYOP_H diff --git a/Build/source/utils/asymptote/asy-keywords.el b/Build/source/utils/asymptote/asy-keywords.el index d5d4a97fb87..d49d2af2bfe 100644 --- a/Build/source/utils/asymptote/asy-keywords.el +++ b/Build/source/utils/asymptote/asy-keywords.el @@ -2,7 +2,7 @@ ;; This file is automatically generated by asy-list.pl. ;; Changes will be overwritten. ;; -(defvar asy-keywords-version "1.99") +(defvar asy-keywords-version "2.00") (defvar asy-keyword-name '( and controls tension atleast curl if else while for do return break continue struct typedef new access import unravel from include quote static public private restricted this explicit true false null cycle newframe operator )) diff --git a/Build/source/utils/asymptote/asymptote.spec b/Build/source/utils/asymptote/asymptote.spec index 78f7288d067..076b13c553f 100644 --- a/Build/source/utils/asymptote/asymptote.spec +++ b/Build/source/utils/asymptote/asymptote.spec @@ -1,7 +1,7 @@ %{!?_texmf: %define _texmf %(eval "echo `kpsewhich -expand-var '$TEXMFLOCAL'`")} Name: asymptote -Version: 1.99 +Version: 2.00 Release: 1%{?dist} Summary: Descriptive vector graphics language diff --git a/Build/source/utils/asymptote/base/graph3.asy b/Build/source/utils/asymptote/base/graph3.asy index 9eee4209134..e588c8aa4d6 100644 --- a/Build/source/utils/asymptote/base/graph3.asy +++ b/Build/source/utils/asymptote/base/graph3.asy @@ -148,7 +148,7 @@ void labelaxis(picture pic, transform3 T, Label L, path3 g, add(f,F.fit3(identity4,pic2,P)); },exact=false); - path3[] G=path3(texpath(L)); + path3[] G=path3(texpath(L,bbox=true)); if(G.length > 0) { G=L.align.is3D ? align(G,O,align,L.p) : L.T3*G; triple v=point(g,relative(L,g)); diff --git a/Build/source/utils/asymptote/base/math.asy b/Build/source/utils/asymptote/base/math.asy index a684307e5a5..0dfddff7f2f 100644 --- a/Build/source/utils/asymptote/base/math.asy +++ b/Build/source/utils/asymptote/base/math.asy @@ -167,11 +167,11 @@ int unique(string[] a, string x) { } bool lexorder(pair a, pair b) { - return a.x < b.x || (a.x == b.x && a.y <= b.y); + return a.x < b.x || (a.x == b.x && a.y < b.y); } bool lexorder(triple a, triple b) { - return a.x < b.x || (a.x == b.x && (a.y < b.y || (a.y == b.y && a.z <= b.z))); + return a.x < b.x || (a.x == b.x && (a.y < b.y || (a.y == b.y && a.z < b.z))); } real[] zero(int n) diff --git a/Build/source/utils/asymptote/base/plain_Label.asy b/Build/source/utils/asymptote/base/plain_Label.asy index 4f9d9a20f11..86d11f8acc0 100644 --- a/Build/source/utils/asymptote/base/plain_Label.asy +++ b/Build/source/utils/asymptote/base/plain_Label.asy @@ -578,53 +578,100 @@ frame pack(pair align=2S ... object inset[]) return F; } -path[] texpath(Label L, bool tex=settings.tex != "none") -{ - static string[] stringcache; - static pen[] pencache; - static path[][] pathcache; - path[] g; +path[] texpath(Label L, bool tex=settings.tex != "none", bool bbox=false) +{ + struct stringfont + { + string s; + real fontsize; + string font; + + void operator init(Label L) + { + s=L.s; + fontsize=fontsize(L.p); + font=font(L.p); + } + + pen pen() {return fontsize(fontsize)+fontcommand(font);} + } + + bool lexorder(stringfont a, stringfont b) { + return a.s < b.s || (a.s == b.s && (a.fontsize < b.fontsize || + (a.fontsize == b.fontsize && + a.font < b.font))); + } - string s=L.s; - pen p=fontcommand(font(L.p))+fontsize(fontsize(L.p)); + static stringfont[] stringcache; + static path[][] pathcache; - // PDF tex engines lose track of the baseline. - bool adjust=tex && basealign(L.p) == 1 && pdf(); - if(adjust) p=p+basealign; + static stringfont[] stringlist; + static bool adjust[]; - int k=0; - int i; - while((i=find(stringcache == s,++k)) >= 0) { - if(pencache[i] == p) { - g=pathcache[i]; - break; + path[] G; + + stringfont s=stringfont(L); + pen p=s.pen(); + + int i=search(stringcache,s,lexorder); + if(i == -1 || lexorder(stringcache[i],s)) { + int k=search(stringlist,s,lexorder); + if(k == -1 || lexorder(stringlist[k],s)) { + ++k; + stringlist.insert(k,s); + // PDF tex engines lose track of the baseline. + adjust.insert(k,tex && basealign(L.p) == 1 && pdf()); } } - if(i == -1) { - if(tex) { - if(adjust) { - g=_texpath("."+s,p); - if(g.length == 0) return g; - real y=min(g[0]).y; - g.delete(0); - g=shift(0,-y)*g; - } else g=_texpath(s,p); - } else g=textpath(s,p); + path[] transform(path[] g, Label L) { + pair m=min(g); + pair M=max(g); + pair dir=rectify(inverse(L.T)*-L.align.dir); + if(tex && basealign(L.p) == 1) + dir -= (0,(1-dir.y)*m.y/(M.y-m.y)); + pair a=m+realmult(dir,M-m); - stringcache.push(s); - pencache.push(p); - pathcache.push(g); + return shift(L.position+L.align.dir*labelmargin(L.p))*L.T*shift(-a)*g; } + + if(tex && bbox) { + frame f; + label(f,L); + return transform(box(min(f),max(f)),L); + } + + if(stringlist.length > 0) { + path[][] g; + int n=stringlist.length; + string[] s=new string[n]; + pen[] p=new pen[n]; + for(int i=0; i < n; ++i) { + stringfont S=stringlist[i]; + s[i]=adjust[i] ? "."+S.s : S.s; + p[i]=adjust[i] ? S.pen()+basealign : S.pen(); + } + + g=tex ? _texpath(s,p) : textpath(s,p); + + if(tex) + for(int i=0; i < n; ++i) + if(adjust[i]) { + real y=min(g[i][0]).y; + g[i].delete(0); + g[i]=shift(0,-y)*g[i]; + } + - pair a; - if(g.length == 0) return g; - pair m=min(g); - pair M=max(g); - pair dir=rectify(inverse(L.T)*-L.align.dir); - if(tex && basealign(L.p) == 1) - dir -= (0,(1-dir.y)*m.y/(M.y-m.y)); - a=m+realmult(dir,M-m); - - return shift(L.position+L.align.dir*labelmargin(p))*L.T*shift(-a)*g; + for(int i=0; i < stringlist.length; ++i) { + stringfont s=stringlist[i]; + int j=search(stringcache,s,lexorder)+1; + stringcache.insert(j,s); + pathcache.insert(j,g[i]); + } + stringlist.delete(); + adjust.delete(); + } + + return transform(pathcache[search(stringcache,stringfont(L),lexorder)],L); } diff --git a/Build/source/utils/asymptote/base/plain_picture.asy b/Build/source/utils/asymptote/base/plain_picture.asy index 044ba90e7a7..2ec467727d2 100644 --- a/Build/source/utils/asymptote/base/plain_picture.asy +++ b/Build/source/utils/asymptote/base/plain_picture.asy @@ -420,6 +420,8 @@ struct projection { bool autoadjust=true; // Adjust camera to lie outside bounding volume? bool center=false; // Center target within bounding volume? int ninterpolate; // Used for projecting nurbs to 2D Bezier curves. + bool bboxonly=true; // Typeset label bounding box only. + transformation T; void calculate() { @@ -469,6 +471,7 @@ struct projection { P.center=center; P.projector=projector; P.ninterpolate=ninterpolate; + P.bboxonly=bboxonly; P.T=T.copy(); return P; } @@ -588,7 +591,7 @@ struct picture { // The functions to do the deferred drawing. drawerBound[] nodes; drawerBound3[] nodes3; - + bool uptodate=true; // The coordinates in flex space to be used in sizing the picture. diff --git a/Build/source/utils/asymptote/base/three.asy b/Build/source/utils/asymptote/base/three.asy index f528e2a9e52..528a1da13c1 100644 --- a/Build/source/utils/asymptote/base/three.asy +++ b/Build/source/utils/asymptote/base/three.asy @@ -2162,9 +2162,9 @@ draw=new void(frame f, path3 g, material p=currentpen, pen q=(pen) p; if(is3D()) { p=material(p); + real width=linewidth(q); void drawthick(path3 g) { if(settings.thick) { - real width=linewidth(q); if(width > 0) { bool prc=prc(); void cylinder(transform3) {}; @@ -2179,16 +2179,13 @@ draw=new void(frame f, path3 g, material p=currentpen, pipe=new void(path3 center, path3 g) {drawPRCtube(f,center,g,p,light);}; } - real linecap; - real r; + real linecap=linecap(q); + real r=0.5*width; bool open=!cyclic(g); int L=length(g); - triple g0,gL; + triple g0=point(g,0); + triple gL=point(g,L); if(open && L > 0) { - g0=point(g,0); - gL=point(g,L); - linecap=linecap(q); - r=0.5*width; if(linecap == 2) { g0 -= r*dir(g,0); gL += r*dir(g,L); @@ -2239,11 +2236,11 @@ draw=new void(frame f, path3 g, material p=currentpen, } else _draw(f,g,q); } else _draw(f,g,q); } - real[] dash=linetype(adjust(q,arclength(g),cyclic(g))); if(q != nullpen) begingroup3(f,name == "" ? "curve" : name,render); - if(dash.length == 0) drawthick(g); + if(linetype(q).length == 0) drawthick(g); else { + real[] dash=linetype(adjust(q,arclength(g),cyclic(g))); if(sum(dash) > 0) { dash.cyclic=true; real offset=offset(q); @@ -2787,17 +2784,25 @@ struct scene adjusted=adjusted | this.P.adjust(m,M); } + bool scale=xsize != 0 || ysize != 0; + bool scaleAdjust=scale && this.P.autoadjust; + bool noAdjust=(this.P.absolute || !scaleAdjust); + + if(pic.bounds3.exact && noAdjust) + this.P.bboxonly=false; + f=pic.fit3(t,pic.bounds3.exact ? pic2 : null,this.P); if(!pic.bounds3.exact) { + if(noAdjust) + this.P.bboxonly=false; + transform3 s=pic.scale3(f,xsize3,ysize3,zsize3,keepAspect); t=s*t; this.P=s*this.P; f=pic.fit3(t,pic2,this.P); } - bool scale=xsize != 0 || ysize != 0; - if(is3D || scale) { pic2.bounds.exact=true; transform s=pic2.scaling(xsize,ysize,keepAspect); @@ -2810,7 +2815,7 @@ struct scene height=ceil(lambda.y+2*viewportmargin.y); if(!this.P.absolute) { - if(scale && this.P.autoadjust) { + if(scaleAdjust) { pair v=(s.xx,s.yy); transform3 T=this.P.t; pair x=project(X,T); @@ -2826,6 +2831,7 @@ struct scene s=shift(this.P.target)*s*shift(-this.P.target); t=s*t; this.P=s*this.P; + this.P.bboxonly=false; f=pic.fit3(t,is3D ? null : pic2,this.P); } @@ -2897,11 +2903,10 @@ object embed(string label="", string text=label, string prefix=defaultfilename, if(P.infinity) { triple m=min3(S.f); triple M=max3(S.f); - triple lambda=M-m; S.viewportmargin=viewportmargin((lambda.x,lambda.y)); - S.width=ceil(max(S.width,lambda.x)+2*S.viewportmargin.x); - S.height=ceil(max(S.height,lambda.y)+2*S.viewportmargin.y); + S.width=ceil(lambda.x+2*S.viewportmargin.x); + S.height=ceil(lambda.y+2*S.viewportmargin.y); S.f=shift((-0.5(m.x+M.x),-0.5*(m.y+M.y),0))*S.f; // Eye will be at (0,0,0) } else { if(P.angle == 0) { diff --git a/Build/source/utils/asymptote/base/three_surface.asy b/Build/source/utils/asymptote/base/three_surface.asy index 6d0c54d2479..8e48b0606a3 100644 --- a/Build/source/utils/asymptote/base/three_surface.asy +++ b/Build/source/utils/asymptote/base/three_surface.asy @@ -1403,16 +1403,16 @@ surface align(surface s, transform3 t=identity4, triple position, return shift(position+align*labelmargin(p))*t*shift(-a)*s; } -surface surface(Label L, triple position=O) +surface surface(Label L, triple position=O, bool bbox=false) { - surface s=surface(texpath(L)); + surface s=surface(texpath(L,bbox=bbox)); return L.align.is3D ? align(s,L.T3,position,L.align.dir3,L.p) : shift(position)*L.T3*s; } private path[] path(Label L, pair z=0, projection P) { - path[] g=texpath(L); + path[] g=texpath(L,bbox=P.bboxonly); return L.align.is3D ? align(g,z,project(L.align.dir3,P)-project(O,P),L.p) : shift(z)*g; } @@ -1433,7 +1433,7 @@ void label(frame f, Label L, triple position, align align=NoAlign, begingroup3(f,name == "" ? L.s : name,render); if(is3D()) { bool lighton=light.on(); - for(patch S : surface(L,position).s) { + for(patch S : surface(L,position,bbox=P.bboxonly).s) { draw3D(f,S,position,L.p,light,interaction); if(render.labelfill && !lighton) // Fill subdivision cracks _draw(f,S.external(),position,L.p,interaction.type); @@ -1465,7 +1465,8 @@ void label(picture pic=currentpicture, Label L, triple position, L.align(align); L.p(p); L.position(0); - pic.add(new void(frame f, transform3 t, picture pic, projection P) { + + pic.add(new void(frame f, transform3 t, picture pic2, projection P) { // Handle relative projected 3D alignments. Label L=L.copy(); triple v=t*position; @@ -1478,29 +1479,29 @@ void label(picture pic=currentpicture, Label L, triple position, if(L.defaulttransform3) L.T3=transform3(P); - surface S=surface(L,v); begingroup3(f,name == "" ? L.s : name,render,v,interaction.type); bool lighton=light.on(); + if(is3D()) { - for(patch S : surface(L,v).s) { + for(patch S : surface(L,v,bbox=P.bboxonly).s) { draw3D(f,S,v,L.p,light,interaction); if(render.labelfill && !lighton) // Fill subdivision cracks _draw(f,S.external(),v,L.p,interaction.type); } } - if(pic != null) { + if(pic2 != null) { pen p=color(L.T3*Z,L.p,light,shiftless(P.T.modelview)); if(L.defaulttransform3) { if(L.filltype == NoFill) - fill(project(v,P.t),pic,path(L,P),p); + fill(project(v,P.t),pic2,path(L,P),p); else { picture d; fill(project(v,P.t),d,path(L,P),p); - add(pic,d,L.filltype); + add(pic2,d,L.filltype); } } else - pic.add(new void(frame f, transform T) { + pic2.add(new void(frame f, transform T) { for(patch S : surface(L,v).s) fill(f,T*project(S.external(),P,1),p); }); @@ -1510,10 +1511,11 @@ void label(picture pic=currentpicture, Label L, triple position, },!L.defaulttransform3); Label L=L.copy(); + if(interaction.targetsize && settings.render != 0) L.T=L.T*scale(abs(currentprojection.camera-position)/ abs(currentprojection.vector())); - path[] g=texpath(L); + path[] g=texpath(L,bbox=true); if(g.length == 0 || (g.length == 1 && size(g[0]) == 0)) return; if(L.defaulttransform3) L.T3=transform3(currentprojection); @@ -1580,8 +1582,10 @@ surface surface(Label L, surface s, real uoffset, real voffset, real u=uoffset+(z.x-m.x)/lambda.x; real v=voffset+(z.y-m.y)/lambda.y; if(((u < 0 || u >= nu) && !s.ucyclic()) || - ((v < 0 || v >= nv) && !s.vcyclic())) + ((v < 0 || v >= nv) && !s.vcyclic())) { warning("cannotfit","cannot fit string to surface"); + u=v=0; + } return s.point(u,v)+height*unit(s.normal(u,v)); }); } diff --git a/Build/source/utils/asymptote/builtin.cc b/Build/source/utils/asymptote/builtin.cc index 2e95dc2f394..7435d08cb7a 100644 --- a/Build/source/utils/asymptote/builtin.cc +++ b/Build/source/utils/asymptote/builtin.cc @@ -37,14 +37,11 @@ #include "settings.h" #include "opsymbols.h" -#include "builtin.symbols.h" -#ifdef HAVE_LIBGSL -#include <gsl/gsl_math.h> -#include <gsl/gsl_sf.h> -#include <gsl/gsl_errno.h> +#ifndef NOSYM +#include "builtin.symbols.h" #endif - + using namespace types; using namespace camp; using namespace vm; @@ -75,7 +72,7 @@ void gen_runtriple_venv(venv &ve); void gen_runpath_venv(venv &ve); void gen_runpath3d_venv(venv &ve); void gen_runmath_venv(venv &ve); - +void gen_rungsl_venv(venv &ve); void addType(tenv &te, symbol name, ty *t) { @@ -215,411 +212,6 @@ void addRealIntFunc(venv& ve, symbol name, symbol arg1, addFunc(ve, realRealInt<fcn>, primReal(), name, formal(primReal(), arg1), formal(primInt(), arg2)); } - -#ifdef HAVE_LIBGSL -bool GSLerror=false; - -types::dummyRecord *GSLModule; - -types::record *getGSLModule() -{ - return GSLModule; -} - -inline void checkGSLerror() -{ - if(GSLerror) { - GSLerror=false; - throw handled_error(); - } -} - -template <double (*func)(double)> -void realRealGSL(vm::stack *s) -{ - double x=pop<double>(s); - s->push(func(x)); - checkGSLerror(); -} - -template <double (*func)(double, gsl_mode_t)> -void realRealDOUBLE(vm::stack *s) -{ - double x=pop<double>(s); - s->push(func(x,GSL_PREC_DOUBLE)); - checkGSLerror(); -} - -template <double (*func)(double, double, gsl_mode_t)> -void realRealRealDOUBLE(vm::stack *s) -{ - double y=pop<double>(s); - double x=pop<double>(s); - s->push(func(x,y,GSL_PREC_DOUBLE)); - checkGSLerror(); -} - -template <double (*func)(unsigned)> -void realIntGSL(vm::stack *s) -{ - s->push(func(unsignedcast(pop<Int>(s)))); - checkGSLerror(); -} - -template <double (*func)(int, double)> -void realIntRealGSL(vm::stack *s) -{ - double x=pop<double>(s); - - s->push(func(intcast(pop<Int>(s)),x)); - checkGSLerror(); -} - -template <double (*func)(double, double)> -void realRealRealGSL(vm::stack *s) -{ - double x=pop<double>(s); - double n=pop<double>(s); - s->push(func(n,x)); - checkGSLerror(); -} - -template <int (*func)(double, double, double)> -void intRealRealRealGSL(vm::stack *s) -{ - double x=pop<double>(s); - double n=pop<double>(s); - double a=pop<double>(s); - s->push(func(a,n,x)); - checkGSLerror(); -} - -template <double (*func)(double, double, double)> -void realRealRealRealGSL(vm::stack *s) -{ - double x=pop<double>(s); - double n=pop<double>(s); - double a=pop<double>(s); - s->push(func(a,n,x)); - checkGSLerror(); -} - -template <double (*func)(double, unsigned)> -void realRealIntGSL(vm::stack *s) -{ - Int n=pop<Int>(s); - double x=pop<double>(s); - s->push(func(x,unsignedcast(n))); - checkGSLerror(); -} - -// Add a GSL special function from the GNU GSL library -template<double (*fcn)(double)> -void addGSLRealFunc(symbol name, symbol arg1=SYM(x)) -{ - addFunc(GSLModule->e.ve, realRealGSL<fcn>, primReal(), name, - formal(primReal(),arg1)); -} - -// Add a GSL_PREC_DOUBLE GSL special function. -template<double (*fcn)(double, gsl_mode_t)> -void addGSLDOUBLEFunc(symbol name, symbol arg1=SYM(x)) -{ - addFunc(GSLModule->e.ve, realRealDOUBLE<fcn>, primReal(), name, - formal(primReal(),arg1)); -} - -template<double (*fcn)(double, double, gsl_mode_t)> -void addGSLDOUBLE2Func(symbol name, symbol arg1=SYM(phi), - symbol arg2=SYM(k)) -{ - addFunc(GSLModule->e.ve, realRealRealDOUBLE<fcn>, primReal(), name, - formal(primReal(),arg1), formal(primReal(),arg2)); -} - -template <double (*func)(double, double, double, gsl_mode_t)> -void realRealRealRealDOUBLE(vm::stack *s) -{ - double z=pop<double>(s); - double y=pop<double>(s); - double x=pop<double>(s); - s->push(func(x,y,z,GSL_PREC_DOUBLE)); - checkGSLerror(); -} - -template<double (*fcn)(double, double, double, gsl_mode_t)> -void addGSLDOUBLE3Func(symbol name, symbol arg1, symbol arg2, - symbol arg3) -{ - addFunc(GSLModule->e.ve, realRealRealRealDOUBLE<fcn>, primReal(), name, - formal(primReal(),arg1), formal(primReal(),arg2), - formal(primReal(), arg3)); -} - -template <double (*func)(double, double, double, double, gsl_mode_t)> -void realRealRealRealRealDOUBLE(vm::stack *s) -{ - double z=pop<double>(s); - double y=pop<double>(s); - double x=pop<double>(s); - double w=pop<double>(s); - s->push(func(w,x,y,z,GSL_PREC_DOUBLE)); - checkGSLerror(); -} - -template<double (*fcn)(double, double, double, double, gsl_mode_t)> -void addGSLDOUBLE4Func(symbol name, symbol arg1, symbol arg2, - symbol arg3, symbol arg4) -{ - addFunc(GSLModule->e.ve, realRealRealRealRealDOUBLE<fcn>, primReal(), name, - formal(primReal(),arg1), formal(primReal(),arg2), - formal(primReal(), arg3), formal(primReal(), arg4)); -} - -template<double (*fcn)(unsigned)> -void addGSLIntFunc(symbol name) -{ - addFunc(GSLModule->e.ve, realIntGSL<fcn>, primReal(), name, - formal(primInt(),SYM(s))); -} - -template <double (*func)(int)> -void realSignedGSL(vm::stack *s) -{ - Int a = pop<Int>(s); - s->push(func(intcast(a))); - checkGSLerror(); -} - -template<double (*fcn)(int)> -void addGSLSignedFunc(symbol name, symbol arg1) -{ - addFunc(GSLModule->e.ve, realSignedGSL<fcn>, primReal(), name, - formal(primInt(),arg1)); -} - -template<double (*fcn)(int, double)> -void addGSLIntRealFunc(symbol name, symbol arg1=SYM(n), - symbol arg2=SYM(x)) -{ - addFunc(GSLModule->e.ve, realIntRealGSL<fcn>, primReal(), name, - formal(primInt(),arg1), formal(primReal(),arg2)); -} - -template<double (*fcn)(double, double)> -void addGSLRealRealFunc(symbol name, symbol arg1=SYM(nu), - symbol arg2=SYM(x)) -{ - addFunc(GSLModule->e.ve, realRealRealGSL<fcn>, primReal(), name, - formal(primReal(),arg1), formal(primReal(),arg2)); -} - -template<double (*fcn)(double, double, double)> -void addGSLRealRealRealFunc(symbol name, symbol arg1, - symbol arg2, symbol arg3) -{ - addFunc(GSLModule->e.ve, realRealRealRealGSL<fcn>, primReal(), name, - formal(primReal(),arg1), formal(primReal(),arg2), - formal(primReal(), arg3)); -} - -template<int (*fcn)(double, double, double)> -void addGSLRealRealRealFuncInt(symbol name, symbol arg1, - symbol arg2, symbol arg3) -{ - addFunc(GSLModule->e.ve, intRealRealRealGSL<fcn>, primInt(), name, - formal(primReal(),arg1), formal(primReal(),arg2), - formal(primReal(), arg3)); -} - -template<double (*fcn)(double, unsigned)> -void addGSLRealIntFunc(symbol name, symbol arg1=SYM(nu), - symbol arg2=SYM(s)) -{ - addFunc(GSLModule->e.ve, realRealIntGSL<fcn>, primReal(), name, - formal(primReal(),arg1), formal(primInt(),arg2)); -} - -template<double (*func)(double, int)> -void realRealSignedGSL(vm::stack *s) -{ - Int b = pop<Int>(s); - double a = pop<double>(s); - s->push(func(a, intcast(b))); - checkGSLerror(); -} - -template<double (*fcn)(double, int)> -void addGSLRealSignedFunc(symbol name, symbol arg1, symbol arg2) -{ - addFunc(GSLModule->e.ve, realRealSignedGSL<fcn>, primReal(), name, - formal(primReal(),arg1), formal(primInt(),arg2)); -} - -template<double (*func)(unsigned int, unsigned int)> -void realUnsignedUnsignedGSL(vm::stack *s) -{ - Int b = pop<Int>(s); - Int a = pop<Int>(s); - s->push(func(unsignedcast(a), unsignedcast(b))); - checkGSLerror(); -} - -template<double (*fcn)(unsigned int, unsigned int)> -void addGSLUnsignedUnsignedFunc(symbol name, symbol arg1, - symbol arg2) -{ - addFunc(GSLModule->e.ve, realUnsignedUnsignedGSL<fcn>, primReal(), name, - formal(primInt(), arg1), formal(primInt(), arg2)); -} - -template<double (*func)(int, double, double)> -void realIntRealRealGSL(vm::stack *s) -{ - double c = pop<double>(s); - double b = pop<double>(s); - Int a = pop<Int>(s); - s->push(func(intcast(a), b, c)); - checkGSLerror(); -} - -template<double (*fcn)(int, double, double)> -void addGSLIntRealRealFunc(symbol name, symbol arg1, - symbol arg2, symbol arg3) -{ - addFunc(GSLModule->e.ve, realIntRealRealGSL<fcn>, primReal(), name, - formal(primInt(), arg1), formal(primReal(), arg2), - formal(primReal(), arg3)); -} - -template<double (*func)(int, int, double)> -void realIntIntRealGSL(vm::stack *s) -{ - double c = pop<double>(s); - Int b = pop<Int>(s); - Int a = pop<Int>(s); - s->push(func(intcast(a), intcast(b), c)); - checkGSLerror(); -} - -template<double (*fcn)(int, int, double)> -void addGSLIntIntRealFunc(symbol name, symbol arg1, symbol arg2, - symbol arg3) -{ - addFunc(GSLModule->e.ve, realIntIntRealGSL<fcn>, primReal(), name, - formal(primInt(), arg1), formal(primInt(), arg2), - formal(primReal(), arg3)); -} - -template<double (*func)(int, int, double, double)> -void realIntIntRealRealGSL(vm::stack *s) -{ - double d = pop<double>(s); - double c = pop<double>(s); - Int b = pop<Int>(s); - Int a = pop<Int>(s); - s->push(func(intcast(a), intcast(b), c, d)); - checkGSLerror(); -} - -template<double (*fcn)(int, int, double, double)> -void addGSLIntIntRealRealFunc(symbol name, symbol arg1, - symbol arg2, symbol arg3, - symbol arg4) -{ - addFunc(GSLModule->e.ve, realIntIntRealRealGSL<fcn>, primReal(), name, - formal(primInt(), arg1), formal(primInt(), arg2), - formal(primReal(), arg3), formal(primReal(), arg4)); -} - -template<double (*func)(double, double, double, double)> -void realRealRealRealRealGSL(vm::stack *s) -{ - double d = pop<double>(s); - double c = pop<double>(s); - double b = pop<double>(s); - double a = pop<double>(s); - s->push(func(a, b, c, d)); - checkGSLerror(); -} - -template<double (*fcn)(double, double, double, double)> -void addGSLRealRealRealRealFunc(symbol name, symbol arg1, - symbol arg2, symbol arg3, - symbol arg4) -{ - addFunc(GSLModule->e.ve, realRealRealRealRealGSL<fcn>, primReal(), name, - formal(primReal(), arg1), formal(primReal(), arg2), - formal(primReal(), arg3), formal(primReal(), arg4)); -} - -template<double (*func)(int, int, int, int, int, int)> -void realIntIntIntIntIntIntGSL(vm::stack *s) -{ - Int f = pop<Int>(s); - Int e = pop<Int>(s); - Int d = pop<Int>(s); - Int c = pop<Int>(s); - Int b = pop<Int>(s); - Int a = pop<Int>(s); - s->push(func(intcast(a), intcast(b), intcast(c), intcast(d), intcast(e), - intcast(f))); - checkGSLerror(); -} - -template<double (*fcn)(int, int, int, int, int, int)> -void addGSLIntIntIntIntIntIntFunc(symbol name, symbol arg1, - symbol arg2, symbol arg3, - symbol arg4, symbol arg5, - symbol arg6) -{ - addFunc(GSLModule->e.ve, realIntIntIntIntIntIntGSL<fcn>, primReal(), name, - formal(primInt(), arg1), formal(primInt(), arg2), - formal(primInt(), arg3), formal(primInt(), arg4), - formal(primInt(), arg5), formal(primInt(), arg6)); -} - -template<double (*func)(int, int, int, int, int, int, int, int, int)> -void realIntIntIntIntIntIntIntIntIntGSL(vm::stack *s) -{ - Int i = pop<Int>(s); - Int h = pop<Int>(s); - Int g = pop<Int>(s); - Int f = pop<Int>(s); - Int e = pop<Int>(s); - Int d = pop<Int>(s); - Int c = pop<Int>(s); - Int b = pop<Int>(s); - Int a = pop<Int>(s); - s->push(func(intcast(a), intcast(b), intcast(c), intcast(d), intcast(e), - intcast(f), intcast(g), intcast(h), intcast(i))); - checkGSLerror(); -} - -template<double (*fcn)(int, int, int, int, int, int, int, int, int)> -void addGSLIntIntIntIntIntIntIntIntIntFunc(symbol name, symbol arg1, - symbol arg2, symbol arg3, - symbol arg4, symbol arg5, - symbol arg6, symbol arg7, - symbol arg8, symbol arg9) -{ - addFunc(GSLModule->e.ve, realIntIntIntIntIntIntIntIntIntGSL<fcn>, primReal(), - name, formal(primInt(), arg1), formal(primInt(), arg2), - formal(primInt(), arg3), formal(primInt(), arg4), - formal(primInt(), arg5), formal(primInt(), arg6), - formal(primInt(), arg7), formal(primInt(), arg8), - formal(primInt(), arg9)); -} - -// Handle GSL errors gracefully. -void GSLerrorhandler(const char *reason, const char *, int, int) -{ - if(!GSLerror) { - vm::errornothrow(reason); - GSLerror=true; - } -} -#endif void addInitializer(venv &ve, ty *t, access *a) { @@ -826,7 +418,8 @@ void addBooleanOps(venv &ve, ty *t1, symbol name, ty *t2) void addWrite(venv &ve, bltin f, ty *t1, ty *t2) { addRestFunc(ve,f,primVoid(),SYM(write),t2, - formal(primFile(),SYM(file),true),formal(primString(),SYM(s),true), + formal(primFile(),SYM(file),true), + formal(primString(),SYM(s),true), formal(t1,SYM(x)),formal(voidFileFunction(),SYM(suffix),true)); } @@ -838,7 +431,8 @@ void addUnorderedOps(venv &ve, ty *t1, ty *t2, ty *t3, ty *t4) addFunc(ve, run::array2Equals<T>, primBoolean(), SYM_EQ, formal(t3, SYM(a)), formal(t3, SYM(b))); - addFunc(ve, run::array2NotEquals<T>, primBoolean(), SYM_NEQ, formal(t3, SYM(a)), + addFunc(ve, run::array2NotEquals<T>, primBoolean(), + SYM_NEQ, formal(t3, SYM(a)), formal(t3, SYM(b))); addCast(ve,t1,primFile(),read<T>); @@ -848,7 +442,8 @@ void addUnorderedOps(venv &ve, ty *t1, ty *t2, ty *t3, ty *t4) addWrite(ve,write<T>,t1,t2); addRestFunc(ve,writeArray<T>,primVoid(),SYM(write),t3, - formal(primFile(),SYM(file),true),formal(primString(),SYM(s),true), + formal(primFile(),SYM(file),true), + formal(primString(),SYM(s),true), formal(t2,SYM(a),false,true)); addFunc(ve,writeArray2<T>,primVoid(),SYM(write), formal(primFile(),SYM(file),true),t3); @@ -916,7 +511,8 @@ void addBasicOps(venv &ve, ty *t1, ty *t2, ty *t3, ty *t4, bool integer=false, addFunc(ve,Negate<T>,t1,SYM_MINUS,formal(t1,SYM(a))); addFunc(ve,arrayFunc<T,T,negate>,t2,SYM_MINUS,formal(t2,SYM(a))); addFunc(ve,arrayFunc2<T,T,negate>,t3,SYM_MINUS,formal(t3,SYM(a))); - if(!integer) addFunc(ve,interp<T>,t1,SYM(interp),formal(t1,SYM(a),false,Explicit), + if(!integer) addFunc(ve,interp<T>,t1,SYM(interp), + formal(t1,SYM(a),false,Explicit), formal(t1,SYM(b),false,Explicit), formal(primReal(),SYM(t))); @@ -966,7 +562,7 @@ void addArrayOps(venv &ve, types::array *t) typedef void (*stackFcn)(stack *Stack); static stackFcn routine[]={run::copyArray0,run::copyArray1,run::copyArray2}; - Int ndepth=sizeof(routine)/sizeof(stackFcn); + size_t ndepth=sizeof(routine)/sizeof(stackFcn); if(depth <= ndepth) { addFunc(ve, routine[depth-1], @@ -983,10 +579,14 @@ void addArrayOps(venv &ve, types::array *t) t, SYM(sequence), formal(new function(ct, primInt()), SYM(f)), formal(primInt(), SYM(n))); addFunc(ve, run::arrayFunction, - t, SYM(map), formal(new function(ct, ct), SYM(f)), formal(t, SYM(a))); + t, SYM(map), formal(new function(ct, ct), SYM(f)), + formal(t, SYM(a))); addFunc(ve, run::arraySort, t, SYM(sort), formal(t, SYM(a)), - formal(new function(primBoolean(), ct, ct), SYM(f))); + formal(new function(primBoolean(), ct, ct), SYM(less))); + addFunc(ve, run::arraySearch, + primInt(), SYM(search), formal(t, SYM(a)), formal(ct, SYM(key)), + formal(new function(primBoolean(), ct, ct), SYM(less))); break; case 2: addFunc(ve, run::array2Copy, t, SYM(copy), formal(t, SYM(a))); @@ -1162,288 +762,6 @@ void base_venv(venv &ve) addRealFunc(pow10,SYM(pow10)); addRealFunc(identity,SYM(identity)); -#ifdef HAVE_LIBGSL - GSLModule=new dummyRecord(SYM(gsl)); - gsl_set_error_handler(GSLerrorhandler); - - // Common functions - addGSLRealRealFunc<gsl_hypot>(SYM(hypot),SYM(x),SYM(y)); -// addGSLRealRealRealFunc<gsl_hypot3>(SYM(hypot),SYM(x),SYM(y),SYM(z)); - addGSLRealRealRealFuncInt<gsl_fcmp>(SYM(fcmp),SYM(x),SYM(y),SYM(epsilon)); - - // Airy functions - addGSLDOUBLEFunc<gsl_sf_airy_Ai>(SYM(Ai)); - addGSLDOUBLEFunc<gsl_sf_airy_Bi>(SYM(Bi)); - addGSLDOUBLEFunc<gsl_sf_airy_Ai_scaled>(SYM(Ai_scaled)); - addGSLDOUBLEFunc<gsl_sf_airy_Bi_scaled>(SYM(Bi_scaled)); - addGSLDOUBLEFunc<gsl_sf_airy_Ai_deriv>(SYM(Ai_deriv)); - addGSLDOUBLEFunc<gsl_sf_airy_Bi_deriv>(SYM(Bi_deriv)); - addGSLDOUBLEFunc<gsl_sf_airy_Ai_deriv_scaled>(SYM(Ai_deriv_scaled)); - addGSLDOUBLEFunc<gsl_sf_airy_Bi_deriv_scaled>(SYM(Bi_deriv_scaled)); - addGSLIntFunc<gsl_sf_airy_zero_Ai>(SYM(zero_Ai)); - addGSLIntFunc<gsl_sf_airy_zero_Bi>(SYM(zero_Bi)); - addGSLIntFunc<gsl_sf_airy_zero_Ai_deriv>(SYM(zero_Ai_deriv)); - addGSLIntFunc<gsl_sf_airy_zero_Bi_deriv>(SYM(zero_Bi_deriv)); - - // Bessel functions - addGSLRealFunc<gsl_sf_bessel_J0>(SYM(J0)); - addGSLRealFunc<gsl_sf_bessel_J1>(SYM(J1)); - addGSLIntRealFunc<gsl_sf_bessel_Jn>(SYM(Jn)); - addGSLRealFunc<gsl_sf_bessel_Y0>(SYM(Y0)); - addGSLRealFunc<gsl_sf_bessel_Y1>(SYM(Y1)); - addGSLIntRealFunc<gsl_sf_bessel_Yn>(SYM(Yn)); - addGSLRealFunc<gsl_sf_bessel_I0>(SYM(I0)); - addGSLRealFunc<gsl_sf_bessel_I1>(SYM(I1)); - addGSLIntRealFunc<gsl_sf_bessel_In>(SYM(I)); - addGSLRealFunc<gsl_sf_bessel_I0_scaled>(SYM(I0_scaled)); - addGSLRealFunc<gsl_sf_bessel_I1_scaled>(SYM(I1_scaled)); - addGSLIntRealFunc<gsl_sf_bessel_In_scaled>(SYM(I_scaled)); - addGSLRealFunc<gsl_sf_bessel_K0>(SYM(K0)); - addGSLRealFunc<gsl_sf_bessel_K1>(SYM(K1)); - addGSLIntRealFunc<gsl_sf_bessel_Kn>(SYM(K)); - addGSLRealFunc<gsl_sf_bessel_K0_scaled>(SYM(K0_scaled)); - addGSLRealFunc<gsl_sf_bessel_K1_scaled>(SYM(K1_scaled)); - addGSLIntRealFunc<gsl_sf_bessel_Kn_scaled>(SYM(K_scaled)); - addGSLRealFunc<gsl_sf_bessel_j0>(SYM(j0)); - addGSLRealFunc<gsl_sf_bessel_j1>(SYM(j1)); - addGSLRealFunc<gsl_sf_bessel_j2>(SYM(j2)); - addGSLIntRealFunc<gsl_sf_bessel_jl>(SYM(j),SYM(l)); - addGSLRealFunc<gsl_sf_bessel_y0>(SYM(y0)); - addGSLRealFunc<gsl_sf_bessel_y1>(SYM(y1)); - addGSLRealFunc<gsl_sf_bessel_y2>(SYM(y2)); - addGSLIntRealFunc<gsl_sf_bessel_yl>(SYM(y),SYM(l)); - addGSLRealFunc<gsl_sf_bessel_i0_scaled>(SYM(i0_scaled)); - addGSLRealFunc<gsl_sf_bessel_i1_scaled>(SYM(i1_scaled)); - addGSLRealFunc<gsl_sf_bessel_i2_scaled>(SYM(i2_scaled)); - addGSLIntRealFunc<gsl_sf_bessel_il_scaled>(SYM(i_scaled),SYM(l)); - addGSLRealFunc<gsl_sf_bessel_k0_scaled>(SYM(k0_scaled)); - addGSLRealFunc<gsl_sf_bessel_k1_scaled>(SYM(k1_scaled)); - addGSLRealFunc<gsl_sf_bessel_k2_scaled>(SYM(k2_scaled)); - addGSLIntRealFunc<gsl_sf_bessel_kl_scaled>(SYM(k_scaled),SYM(l)); - addGSLRealRealFunc<gsl_sf_bessel_Jnu>(SYM(J)); - addGSLRealRealFunc<gsl_sf_bessel_Ynu>(SYM(Y)); - addGSLRealRealFunc<gsl_sf_bessel_Inu>(SYM(I)); - addGSLRealRealFunc<gsl_sf_bessel_Inu_scaled>(SYM(I_scaled)); - addGSLRealRealFunc<gsl_sf_bessel_Knu>(SYM(K)); - addGSLRealRealFunc<gsl_sf_bessel_lnKnu>(SYM(lnK)); - addGSLRealRealFunc<gsl_sf_bessel_Knu_scaled>(SYM(K_scaled)); - addGSLIntFunc<gsl_sf_bessel_zero_J0>(SYM(zero_J0)); - addGSLIntFunc<gsl_sf_bessel_zero_J1>(SYM(zero_J1)); - addGSLRealIntFunc<gsl_sf_bessel_zero_Jnu>(SYM(zero_J)); - - // Clausen functions - addGSLRealFunc<gsl_sf_clausen>(SYM(clausen)); - - // Coulomb functions - addGSLRealRealFunc<gsl_sf_hydrogenicR_1>(SYM(hydrogenicR_1),SYM(Z),SYM(r)); - addGSLIntIntRealRealFunc<gsl_sf_hydrogenicR>(SYM(hydrogenicR),SYM(n),SYM(l),SYM(Z), - SYM(r)); - // Missing: F_L(eta,x), G_L(eta,x), C_L(eta) - - // Coupling coefficients - addGSLIntIntIntIntIntIntFunc<gsl_sf_coupling_3j>(SYM(coupling_3j),SYM(two_ja), - SYM(two_jb),SYM(two_jc),SYM(two_ma), - SYM(two_mb),SYM(two_mc)); - addGSLIntIntIntIntIntIntFunc<gsl_sf_coupling_6j>(SYM(coupling_6j),SYM(two_ja), - SYM(two_jb),SYM(two_jc),SYM(two_jd), - SYM(two_je),SYM(two_jf)); - addGSLIntIntIntIntIntIntIntIntIntFunc<gsl_sf_coupling_9j>(SYM(coupling_9j), - SYM(two_ja),SYM(two_jb), - SYM(two_jc),SYM(two_jd), - SYM(two_je),SYM(two_jf), - SYM(two_jg),SYM(two_jh), - SYM(two_ji)); - // Dawson function - addGSLRealFunc<gsl_sf_dawson>(SYM(dawson)); - - // Debye functions - addGSLRealFunc<gsl_sf_debye_1>(SYM(debye_1)); - addGSLRealFunc<gsl_sf_debye_2>(SYM(debye_2)); - addGSLRealFunc<gsl_sf_debye_3>(SYM(debye_3)); - addGSLRealFunc<gsl_sf_debye_4>(SYM(debye_4)); - addGSLRealFunc<gsl_sf_debye_5>(SYM(debye_5)); - addGSLRealFunc<gsl_sf_debye_6>(SYM(debye_6)); - - // Dilogarithm - addGSLRealFunc<gsl_sf_dilog>(SYM(dilog)); - // Missing: complex dilogarithm - - // Elementary operations - // we don't support errors at the moment - - // Elliptic integrals - addGSLDOUBLEFunc<gsl_sf_ellint_Kcomp>(SYM(K),SYM(k)); - addGSLDOUBLEFunc<gsl_sf_ellint_Ecomp>(SYM(E),SYM(k)); - addGSLDOUBLE2Func<gsl_sf_ellint_Pcomp>(SYM(P),SYM(k),SYM(n)); - addGSLDOUBLE2Func<gsl_sf_ellint_F>(SYM(F)); - addGSLDOUBLE2Func<gsl_sf_ellint_E>(SYM(E)); - addGSLDOUBLE3Func<gsl_sf_ellint_P>(SYM(P),SYM(phi),SYM(k),SYM(n)); - addGSLDOUBLE3Func<gsl_sf_ellint_D>(SYM(D),SYM(phi),SYM(k),SYM(n)); - addGSLDOUBLE2Func<gsl_sf_ellint_RC>(SYM(RC),SYM(x),SYM(y)); - addGSLDOUBLE3Func<gsl_sf_ellint_RD>(SYM(RD),SYM(x),SYM(y),SYM(z)); - addGSLDOUBLE3Func<gsl_sf_ellint_RF>(SYM(RF),SYM(x),SYM(y),SYM(z)); - addGSLDOUBLE4Func<gsl_sf_ellint_RJ>(SYM(RJ),SYM(x),SYM(y),SYM(z),SYM(p)); - - // Elliptic functions (Jacobi) - // to be implemented - - // Error functions - addGSLRealFunc<gsl_sf_erf>(SYM(erf)); - addGSLRealFunc<gsl_sf_erfc>(SYM(erfc)); - addGSLRealFunc<gsl_sf_log_erfc>(SYM(log_erfc)); - addGSLRealFunc<gsl_sf_erf_Z>(SYM(erf_Z)); - addGSLRealFunc<gsl_sf_erf_Q>(SYM(erf_Q)); - addGSLRealFunc<gsl_sf_hazard>(SYM(hazard)); - - // Exponential functions - addGSLRealRealFunc<gsl_sf_exp_mult>(SYM(exp_mult),SYM(x),SYM(y)); -// addGSLRealFunc<gsl_sf_expm1>(SYM(expm1)); - addGSLRealFunc<gsl_sf_exprel>(SYM(exprel)); - addGSLRealFunc<gsl_sf_exprel_2>(SYM(exprel_2)); - addGSLIntRealFunc<gsl_sf_exprel_n>(SYM(exprel),SYM(n),SYM(x)); - - // Exponential integrals - addGSLRealFunc<gsl_sf_expint_E1>(SYM(E1)); - addGSLRealFunc<gsl_sf_expint_E2>(SYM(E2)); -// addGSLIntRealFunc<gsl_sf_expint_En>(SYM(En),SYM(n),SYM(x)); - addGSLRealFunc<gsl_sf_expint_Ei>(SYM(Ei)); - addGSLRealFunc<gsl_sf_Shi>(SYM(Shi)); - addGSLRealFunc<gsl_sf_Chi>(SYM(Chi)); - addGSLRealFunc<gsl_sf_expint_3>(SYM(Ei3)); - addGSLRealFunc<gsl_sf_Si>(SYM(Si)); - addGSLRealFunc<gsl_sf_Ci>(SYM(Ci)); - addGSLRealFunc<gsl_sf_atanint>(SYM(atanint)); - - // Fermi--Dirac function - addGSLRealFunc<gsl_sf_fermi_dirac_m1>(SYM(FermiDiracM1)); - addGSLRealFunc<gsl_sf_fermi_dirac_0>(SYM(FermiDirac0)); - addGSLRealFunc<gsl_sf_fermi_dirac_1>(SYM(FermiDirac1)); - addGSLRealFunc<gsl_sf_fermi_dirac_2>(SYM(FermiDirac2)); - addGSLIntRealFunc<gsl_sf_fermi_dirac_int>(SYM(FermiDirac),SYM(j),SYM(x)); - addGSLRealFunc<gsl_sf_fermi_dirac_mhalf>(SYM(FermiDiracMHalf)); - addGSLRealFunc<gsl_sf_fermi_dirac_half>(SYM(FermiDiracHalf)); - addGSLRealFunc<gsl_sf_fermi_dirac_3half>(SYM(FermiDirac3Half)); - addGSLRealRealFunc<gsl_sf_fermi_dirac_inc_0>(SYM(FermiDiracInc0),SYM(x),SYM(b)); - - // Gamma and beta functions - addGSLRealFunc<gsl_sf_gamma>(SYM(gamma)); - addGSLRealFunc<gsl_sf_lngamma>(SYM(lngamma)); - addGSLRealFunc<gsl_sf_gammastar>(SYM(gammastar)); - addGSLRealFunc<gsl_sf_gammainv>(SYM(gammainv)); - addGSLIntFunc<gsl_sf_fact>(SYM(fact)); - addGSLIntFunc<gsl_sf_doublefact>(SYM(doublefact)); - addGSLIntFunc<gsl_sf_lnfact>(SYM(lnfact)); - addGSLIntFunc<gsl_sf_lndoublefact>(SYM(lndoublefact)); - addGSLUnsignedUnsignedFunc<gsl_sf_choose>(SYM(choose),SYM(n),SYM(m)); - addGSLUnsignedUnsignedFunc<gsl_sf_lnchoose>(SYM(lnchoose),SYM(n),SYM(m)); - addGSLIntRealFunc<gsl_sf_taylorcoeff>(SYM(taylorcoeff),SYM(n),SYM(x)); - addGSLRealRealFunc<gsl_sf_poch>(SYM(poch),SYM(a),SYM(x)); - addGSLRealRealFunc<gsl_sf_lnpoch>(SYM(lnpoch),SYM(a),SYM(x)); - addGSLRealRealFunc<gsl_sf_pochrel>(SYM(pochrel),SYM(a),SYM(x)); - addGSLRealRealFunc<gsl_sf_gamma_inc>(SYM(gamma),SYM(a),SYM(x)); - addGSLRealRealFunc<gsl_sf_gamma_inc_Q>(SYM(gamma_Q),SYM(a),SYM(x)); - addGSLRealRealFunc<gsl_sf_gamma_inc_P>(SYM(gamma_P),SYM(a),SYM(x)); - addGSLRealRealFunc<gsl_sf_beta>(SYM(beta),SYM(a),SYM(b)); - addGSLRealRealFunc<gsl_sf_lnbeta>(SYM(lnbeta),SYM(a),SYM(b)); - addGSLRealRealRealFunc<gsl_sf_beta_inc>(SYM(beta),SYM(a),SYM(b),SYM(x)); - - // Gegenbauer functions - addGSLRealRealFunc<gsl_sf_gegenpoly_1>(SYM(gegenpoly_1),SYM(lambda),SYM(x)); - addGSLRealRealFunc<gsl_sf_gegenpoly_2>(SYM(gegenpoly_2),SYM(lambda),SYM(x)); - addGSLRealRealFunc<gsl_sf_gegenpoly_3>(SYM(gegenpoly_3),SYM(lambda),SYM(x)); - addGSLIntRealRealFunc<gsl_sf_gegenpoly_n>(SYM(gegenpoly),SYM(n),SYM(lambda),SYM(x)); - - // Hypergeometric functions - addGSLRealRealFunc<gsl_sf_hyperg_0F1>(SYM(hy0F1),SYM(c),SYM(x)); - addGSLIntIntRealFunc<gsl_sf_hyperg_1F1_int>(SYM(hy1F1),SYM(m),SYM(n),SYM(x)); - addGSLRealRealRealFunc<gsl_sf_hyperg_1F1>(SYM(hy1F1),SYM(a),SYM(b),SYM(x)); - addGSLIntIntRealFunc<gsl_sf_hyperg_U_int>(SYM(U),SYM(m),SYM(n),SYM(x)); - addGSLRealRealRealFunc<gsl_sf_hyperg_U>(SYM(U),SYM(a),SYM(b),SYM(x)); - addGSLRealRealRealRealFunc<gsl_sf_hyperg_2F1>(SYM(hy2F1),SYM(a),SYM(b),SYM(c),SYM(x)); - addGSLRealRealRealRealFunc<gsl_sf_hyperg_2F1_conj>(SYM(hy2F1_conj),SYM(aR),SYM(aI),SYM(c), - SYM(x)); - addGSLRealRealRealRealFunc<gsl_sf_hyperg_2F1_renorm>(SYM(hy2F1_renorm),SYM(a),SYM(b), - SYM(c),SYM(x)); - addGSLRealRealRealRealFunc<gsl_sf_hyperg_2F1_conj_renorm>(SYM(hy2F1_conj_renorm), - SYM(aR),SYM(aI),SYM(c),SYM(x)); - addGSLRealRealRealFunc<gsl_sf_hyperg_2F0>(SYM(hy2F0),SYM(a),SYM(b),SYM(x)); - - // Laguerre functions - addGSLRealRealFunc<gsl_sf_laguerre_1>(SYM(L1),SYM(a),SYM(x)); - addGSLRealRealFunc<gsl_sf_laguerre_2>(SYM(L2),SYM(a),SYM(x)); - addGSLRealRealFunc<gsl_sf_laguerre_3>(SYM(L3),SYM(a),SYM(x)); - addGSLIntRealRealFunc<gsl_sf_laguerre_n>(SYM(L),SYM(n),SYM(a),SYM(x)); - - // Lambert W functions - addGSLRealFunc<gsl_sf_lambert_W0>(SYM(W0)); - addGSLRealFunc<gsl_sf_lambert_Wm1>(SYM(Wm1)); - - // Legendre functions and spherical harmonics - addGSLRealFunc<gsl_sf_legendre_P1>(SYM(P1)); - addGSLRealFunc<gsl_sf_legendre_P2>(SYM(P2)); - addGSLRealFunc<gsl_sf_legendre_P3>(SYM(P3)); - addGSLIntRealFunc<gsl_sf_legendre_Pl>(SYM(Pl),SYM(l)); - addGSLRealFunc<gsl_sf_legendre_Q0>(SYM(Q0)); - addGSLRealFunc<gsl_sf_legendre_Q1>(SYM(Q1)); - addGSLIntRealFunc<gsl_sf_legendre_Ql>(SYM(Ql),SYM(l)); - addGSLIntIntRealFunc<gsl_sf_legendre_Plm>(SYM(Plm),SYM(l),SYM(m),SYM(x)); - addGSLIntIntRealFunc<gsl_sf_legendre_sphPlm>(SYM(sphPlm),SYM(l),SYM(m),SYM(x)); - addGSLRealRealFunc<gsl_sf_conicalP_half>(SYM(conicalP_half),SYM(lambda),SYM(x)); - addGSLRealRealFunc<gsl_sf_conicalP_mhalf>(SYM(conicalP_mhalf),SYM(lambda),SYM(x)); - addGSLRealRealFunc<gsl_sf_conicalP_0>(SYM(conicalP_0),SYM(lambda),SYM(x)); - addGSLRealRealFunc<gsl_sf_conicalP_1>(SYM(conicalP_1),SYM(lambda),SYM(x)); - addGSLIntRealRealFunc<gsl_sf_conicalP_sph_reg>(SYM(conicalP_sph_reg),SYM(l), - SYM(lambda),SYM(x)); - addGSLIntRealRealFunc<gsl_sf_conicalP_cyl_reg>(SYM(conicalP_cyl_reg),SYM(m), - SYM(lambda),SYM(x)); - addGSLRealRealFunc<gsl_sf_legendre_H3d_0>(SYM(H3d0),SYM(lambda),SYM(eta)); - addGSLRealRealFunc<gsl_sf_legendre_H3d_1>(SYM(H3d1),SYM(lambda),SYM(eta)); - addGSLIntRealRealFunc<gsl_sf_legendre_H3d>(SYM(H3d),SYM(l),SYM(lambda),SYM(eta)); - - // Logarithm and related functions - addGSLRealFunc<gsl_sf_log_abs>(SYM(logabs)); -// addGSLRealFunc<gsl_sf_log_1plusx>(SYM(log1p)); - addGSLRealFunc<gsl_sf_log_1plusx_mx>(SYM(log1pm)); - - // Matthieu functions - // to be implemented - - // Power function - addGSLRealSignedFunc<gsl_sf_pow_int>(SYM(pow),SYM(x),SYM(n)); - - // Psi (digamma) function - addGSLSignedFunc<gsl_sf_psi_int>(SYM(psi),SYM(n)); - addGSLRealFunc<gsl_sf_psi>(SYM(psi)); - addGSLRealFunc<gsl_sf_psi_1piy>(SYM(psi_1piy),SYM(y)); - addGSLSignedFunc<gsl_sf_psi_1_int>(SYM(psi1),SYM(n)); - addGSLRealFunc<gsl_sf_psi_1>(SYM(psi1),SYM(x)); - addGSLIntRealFunc<gsl_sf_psi_n>(SYM(psi),SYM(n),SYM(x)); - - // Synchrotron functions - addGSLRealFunc<gsl_sf_synchrotron_1>(SYM(synchrotron_1)); - addGSLRealFunc<gsl_sf_synchrotron_2>(SYM(synchrotron_2)); - - // Transport functions - addGSLRealFunc<gsl_sf_transport_2>(SYM(transport_2)); - addGSLRealFunc<gsl_sf_transport_3>(SYM(transport_3)); - addGSLRealFunc<gsl_sf_transport_4>(SYM(transport_4)); - addGSLRealFunc<gsl_sf_transport_5>(SYM(transport_5)); - - // Trigonometric functions - addGSLRealFunc<gsl_sf_sinc>(SYM(sinc)); - addGSLRealFunc<gsl_sf_lnsinh>(SYM(lnsinh)); - addGSLRealFunc<gsl_sf_lncosh>(SYM(lncosh)); - - // Zeta functions - addGSLSignedFunc<gsl_sf_zeta_int>(SYM(zeta),SYM(n)); - addGSLRealFunc<gsl_sf_zeta>(SYM(zeta),SYM(s)); - addGSLSignedFunc<gsl_sf_zetam1_int>(SYM(zetam1),SYM(n)); - addGSLRealFunc<gsl_sf_zetam1>(SYM(zetam1),SYM(s)); - addGSLRealRealFunc<gsl_sf_hzeta>(SYM(hzeta),SYM(s),SYM(q)); - addGSLSignedFunc<gsl_sf_eta_int>(SYM(eta),SYM(n)); - addGSLRealFunc<gsl_sf_eta>(SYM(eta),SYM(s)); -#endif - #ifdef STRUCTEXAMPLE dummyRecord *fun=createDummyRecord(ve, SYM(test)); addFunc(fun->e.ve,realReal<sin>,primReal(),SYM(f),formal(primReal(),SYM(x))); @@ -1503,6 +821,10 @@ void base_venv(venv &ve) gen_runpath_venv(ve); gen_runpath3d_venv(ve); gen_runmath_venv(ve); + +#ifdef HAVE_LIBGSL + gen_rungsl_venv(ve); +#endif } } //namespace trans diff --git a/Build/source/utils/asymptote/builtin.h b/Build/source/utils/asymptote/builtin.h index 617400803c0..955063ca9a4 100644 --- a/Build/source/utils/asymptote/builtin.h +++ b/Build/source/utils/asymptote/builtin.h @@ -9,6 +9,7 @@ #include "vm.h" #include "types.h" +#include "arrayop.h" namespace trans { @@ -38,7 +39,10 @@ void addArrayOps(venv &ve, types::array *t); void addRecordOps(venv &ve, types::record *r); void addFunctionOps(venv &ve, types::function *f); +#ifdef HAVE_LIBGSL types::record *getGSLModule(); +void GSLrngFree(); +#endif } //namespace trans diff --git a/Build/source/utils/asymptote/builtin.symbols.h b/Build/source/utils/asymptote/builtin.symbols.h deleted file mode 100644 index 21db5448461..00000000000 --- a/Build/source/utils/asymptote/builtin.symbols.h +++ /dev/null @@ -1,292 +0,0 @@ -/***** - * This file is automatically generated by findsym.pl - * Changes will be overwritten. - *****/ - -// If the ADDSYMBOL macro is not already defined, define it with the default -// purpose of referring to an external pre-translated symbol, such that -// SYM(name) also refers to that symbol. -#ifndef ADDSYMBOL - #define ADDSYMBOL(name) extern sym::symbol PRETRANSLATED_SYMBOL_##name - #ifdef PRESYM - #define SYM(name) PRETRANSLATED_SYMBOL_##name - #else - #define SYM(name) sym::symbol::trans(#name) - #endif -#endif - -ADDSYMBOL(Ai); -ADDSYMBOL(Ai_deriv); -ADDSYMBOL(Ai_deriv_scaled); -ADDSYMBOL(Ai_scaled); -ADDSYMBOL(Bi); -ADDSYMBOL(Bi_deriv); -ADDSYMBOL(Bi_deriv_scaled); -ADDSYMBOL(Bi_scaled); -ADDSYMBOL(Chi); -ADDSYMBOL(Ci); -ADDSYMBOL(D); -ADDSYMBOL(E); -ADDSYMBOL(E1); -ADDSYMBOL(E2); -ADDSYMBOL(Ei); -ADDSYMBOL(Ei3); -ADDSYMBOL(En); -ADDSYMBOL(F); -ADDSYMBOL(FermiDirac); -ADDSYMBOL(FermiDirac0); -ADDSYMBOL(FermiDirac1); -ADDSYMBOL(FermiDirac2); -ADDSYMBOL(FermiDirac3Half); -ADDSYMBOL(FermiDiracHalf); -ADDSYMBOL(FermiDiracInc0); -ADDSYMBOL(FermiDiracM1); -ADDSYMBOL(FermiDiracMHalf); -ADDSYMBOL(H3d); -ADDSYMBOL(H3d0); -ADDSYMBOL(H3d1); -ADDSYMBOL(I); -ADDSYMBOL(I0); -ADDSYMBOL(I0_scaled); -ADDSYMBOL(I1); -ADDSYMBOL(I1_scaled); -ADDSYMBOL(I_scaled); -ADDSYMBOL(J); -ADDSYMBOL(J0); -ADDSYMBOL(J1); -ADDSYMBOL(Jn); -ADDSYMBOL(K); -ADDSYMBOL(K0); -ADDSYMBOL(K0_scaled); -ADDSYMBOL(K1); -ADDSYMBOL(K1_scaled); -ADDSYMBOL(K_scaled); -ADDSYMBOL(L); -ADDSYMBOL(L1); -ADDSYMBOL(L2); -ADDSYMBOL(L3); -ADDSYMBOL(P); -ADDSYMBOL(P1); -ADDSYMBOL(P2); -ADDSYMBOL(P3); -ADDSYMBOL(Pl); -ADDSYMBOL(Plm); -ADDSYMBOL(Q0); -ADDSYMBOL(Q1); -ADDSYMBOL(Ql); -ADDSYMBOL(RC); -ADDSYMBOL(RD); -ADDSYMBOL(RF); -ADDSYMBOL(RJ); -ADDSYMBOL(Shi); -ADDSYMBOL(Si); -ADDSYMBOL(U); -ADDSYMBOL(VERSION); -ADDSYMBOL(W0); -ADDSYMBOL(Wm1); -ADDSYMBOL(Y); -ADDSYMBOL(Y0); -ADDSYMBOL(Y1); -ADDSYMBOL(Yn); -ADDSYMBOL(Z); -ADDSYMBOL(a); -ADDSYMBOL(aI); -ADDSYMBOL(aR); -ADDSYMBOL(abs); -ADDSYMBOL(acos); -ADDSYMBOL(acosh); -ADDSYMBOL(alias); -ADDSYMBOL(array); -ADDSYMBOL(asin); -ADDSYMBOL(asinh); -ADDSYMBOL(atan); -ADDSYMBOL(atanh); -ADDSYMBOL(atanint); -ADDSYMBOL(b); -ADDSYMBOL(beta); -ADDSYMBOL(c); -ADDSYMBOL(cbrt); -ADDSYMBOL(choose); -ADDSYMBOL(clausen); -ADDSYMBOL(concat); -ADDSYMBOL(conicalP_0); -ADDSYMBOL(conicalP_1); -ADDSYMBOL(conicalP_cyl_reg); -ADDSYMBOL(conicalP_half); -ADDSYMBOL(conicalP_mhalf); -ADDSYMBOL(conicalP_sph_reg); -ADDSYMBOL(conj); -ADDSYMBOL(copy); -ADDSYMBOL(cos); -ADDSYMBOL(cosh); -ADDSYMBOL(coupling_3j); -ADDSYMBOL(coupling_6j); -ADDSYMBOL(coupling_9j); -ADDSYMBOL(currentpen); -ADDSYMBOL(dawson); -ADDSYMBOL(debye_1); -ADDSYMBOL(debye_2); -ADDSYMBOL(debye_3); -ADDSYMBOL(debye_4); -ADDSYMBOL(debye_5); -ADDSYMBOL(debye_6); -ADDSYMBOL(depth); -ADDSYMBOL(diagonal); -ADDSYMBOL(dilog); -ADDSYMBOL(doublefact); -ADDSYMBOL(e); -ADDSYMBOL(epsilon); -ADDSYMBOL(erf); -ADDSYMBOL(erf_Q); -ADDSYMBOL(erf_Z); -ADDSYMBOL(erfc); -ADDSYMBOL(eta); -ADDSYMBOL(exp); -ADDSYMBOL(exp_mult); -ADDSYMBOL(expm1); -ADDSYMBOL(exprel); -ADDSYMBOL(exprel_2); -ADDSYMBOL(f); -ADDSYMBOL(fabs); -ADDSYMBOL(fact); -ADDSYMBOL(fcmp); -ADDSYMBOL(file); -ADDSYMBOL(gamma); -ADDSYMBOL(gamma_P); -ADDSYMBOL(gamma_Q); -ADDSYMBOL(gammainv); -ADDSYMBOL(gammastar); -ADDSYMBOL(gegenpoly); -ADDSYMBOL(gegenpoly_1); -ADDSYMBOL(gegenpoly_2); -ADDSYMBOL(gegenpoly_3); -ADDSYMBOL(gsl); -ADDSYMBOL(hazard); -ADDSYMBOL(hy0F1); -ADDSYMBOL(hy1F1); -ADDSYMBOL(hy2F0); -ADDSYMBOL(hy2F1); -ADDSYMBOL(hy2F1_conj); -ADDSYMBOL(hy2F1_conj_renorm); -ADDSYMBOL(hy2F1_renorm); -ADDSYMBOL(hydrogenicR); -ADDSYMBOL(hydrogenicR_1); -ADDSYMBOL(hypot); -ADDSYMBOL(hzeta); -ADDSYMBOL(i0_scaled); -ADDSYMBOL(i1_scaled); -ADDSYMBOL(i2_scaled); -ADDSYMBOL(i_scaled); -ADDSYMBOL(identity); -ADDSYMBOL(inf); -ADDSYMBOL(infinity); -ADDSYMBOL(intMax); -ADDSYMBOL(intMin); -ADDSYMBOL(interp); -ADDSYMBOL(j); -ADDSYMBOL(j0); -ADDSYMBOL(j1); -ADDSYMBOL(j2); -ADDSYMBOL(k); -ADDSYMBOL(k0_scaled); -ADDSYMBOL(k1_scaled); -ADDSYMBOL(k2_scaled); -ADDSYMBOL(k_scaled); -ADDSYMBOL(key); -ADDSYMBOL(l); -ADDSYMBOL(lambda); -ADDSYMBOL(ldexp); -ADDSYMBOL(lnK); -ADDSYMBOL(lnbeta); -ADDSYMBOL(lnchoose); -ADDSYMBOL(lncosh); -ADDSYMBOL(lndoublefact); -ADDSYMBOL(lnfact); -ADDSYMBOL(lngamma); -ADDSYMBOL(lnpoch); -ADDSYMBOL(lnsinh); -ADDSYMBOL(log); -ADDSYMBOL(log10); -ADDSYMBOL(log1p); -ADDSYMBOL(log1pm); -ADDSYMBOL(log_erfc); -ADDSYMBOL(logabs); -ADDSYMBOL(m); -ADDSYMBOL(map); -ADDSYMBOL(max); -ADDSYMBOL(maxbound); -ADDSYMBOL(min); -ADDSYMBOL(minbound); -ADDSYMBOL(n); -ADDSYMBOL(nu); -ADDSYMBOL(openFunc); -ADDSYMBOL(p); -ADDSYMBOL(perm); -ADDSYMBOL(phi); -ADDSYMBOL(pi); -ADDSYMBOL(poch); -ADDSYMBOL(pochrel); -ADDSYMBOL(pow); -ADDSYMBOL(pow10); -ADDSYMBOL(psi); -ADDSYMBOL(psi1); -ADDSYMBOL(psi_1piy); -ADDSYMBOL(q); -ADDSYMBOL(r); -ADDSYMBOL(randMax); -ADDSYMBOL(realDigits); -ADDSYMBOL(realEpsilon); -ADDSYMBOL(realMax); -ADDSYMBOL(realMin); -ADDSYMBOL(s); -ADDSYMBOL(search); -ADDSYMBOL(sequence); -ADDSYMBOL(sin); -ADDSYMBOL(sinc); -ADDSYMBOL(sinh); -ADDSYMBOL(sort); -ADDSYMBOL(sphPlm); -ADDSYMBOL(sqrt); -ADDSYMBOL(suffix); -ADDSYMBOL(sum); -ADDSYMBOL(synchrotron_1); -ADDSYMBOL(synchrotron_2); -ADDSYMBOL(t); -ADDSYMBOL(tan); -ADDSYMBOL(tanh); -ADDSYMBOL(taylorcoeff); -ADDSYMBOL(test); -ADDSYMBOL(transport_2); -ADDSYMBOL(transport_3); -ADDSYMBOL(transport_4); -ADDSYMBOL(transport_5); -ADDSYMBOL(transpose); -ADDSYMBOL(two_ja); -ADDSYMBOL(two_jb); -ADDSYMBOL(two_jc); -ADDSYMBOL(two_jd); -ADDSYMBOL(two_je); -ADDSYMBOL(two_jf); -ADDSYMBOL(two_jg); -ADDSYMBOL(two_jh); -ADDSYMBOL(two_ji); -ADDSYMBOL(two_ma); -ADDSYMBOL(two_mb); -ADDSYMBOL(two_mc); -ADDSYMBOL(value); -ADDSYMBOL(write); -ADDSYMBOL(x); -ADDSYMBOL(y); -ADDSYMBOL(y0); -ADDSYMBOL(y1); -ADDSYMBOL(y2); -ADDSYMBOL(z); -ADDSYMBOL(zero_Ai); -ADDSYMBOL(zero_Ai_deriv); -ADDSYMBOL(zero_Bi); -ADDSYMBOL(zero_Bi_deriv); -ADDSYMBOL(zero_J); -ADDSYMBOL(zero_J0); -ADDSYMBOL(zero_J1); -ADDSYMBOL(zeta); -ADDSYMBOL(zetam1); diff --git a/Build/source/utils/asymptote/common.h b/Build/source/utils/asymptote/common.h index 0ae0f2cccd1..78ab9e5e6a5 100644 --- a/Build/source/utils/asymptote/common.h +++ b/Build/source/utils/asymptote/common.h @@ -59,7 +59,7 @@ typedef unsigned int unsignedInt; #endif #endif -#ifdef COMPACT +#if COMPACT // Reserve highest two values for DefaultValue and Undefined states. #define Int_MAX (Int_MAX2-2) #else diff --git a/Build/source/utils/asymptote/configure b/Build/source/utils/asymptote/configure index 8c7a8072cb7..a49f969fb76 100755 --- a/Build/source/utils/asymptote/configure +++ b/Build/source/utils/asymptote/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.63 for Asymptote 1.99. +# Generated by GNU Autoconf 2.63 for Asymptote 2.00. # # Report bugs to <http://sourceforge.net/projects/asymptote>. # @@ -596,8 +596,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='Asymptote' PACKAGE_TARNAME='asymptote' -PACKAGE_VERSION='1.99' -PACKAGE_STRING='Asymptote 1.99' +PACKAGE_VERSION='2.00' +PACKAGE_STRING='Asymptote 2.00' PACKAGE_BUGREPORT='http://sourceforge.net/projects/asymptote' # Factoring default headers for most tests. @@ -1294,7 +1294,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures Asymptote 1.99 to adapt to many kinds of systems. +\`configure' configures Asymptote 2.00 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1355,7 +1355,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of Asymptote 1.99:";; + short | recursive ) echo "Configuration of Asymptote 2.00:";; esac cat <<\_ACEOF @@ -1465,7 +1465,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -Asymptote configure 1.99 +Asymptote configure 2.00 generated by GNU Autoconf 2.63 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -1479,7 +1479,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by Asymptote $as_me 1.99, which was +It was created by Asymptote $as_me 2.00, which was generated by GNU Autoconf 2.63. Invocation command line was $ $0 $@ @@ -12022,7 +12022,7 @@ exec 6>&1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by Asymptote $as_me 1.99, which was +This file was extended by Asymptote $as_me 2.00, which was generated by GNU Autoconf 2.63. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -12081,7 +12081,7 @@ Report bugs to <bug-autoconf@gnu.org>." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_version="\\ -Asymptote config.status 1.99 +Asymptote config.status 2.00 configured by $0, generated by GNU Autoconf 2.63, with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" diff --git a/Build/source/utils/asymptote/configure.ac b/Build/source/utils/asymptote/configure.ac index 45a3b47644b..1031be3f02d 100644 --- a/Build/source/utils/asymptote/configure.ac +++ b/Build/source/utils/asymptote/configure.ac @@ -3,7 +3,7 @@ # this file. AC_PREREQ(2) -AC_INIT([Asymptote],[1.99],[http://sourceforge.net/projects/asymptote]) +AC_INIT([Asymptote],[2.00],[http://sourceforge.net/projects/asymptote]) VERSION=$PACKAGE_VERSION AC_SUBST(VERSION) diff --git a/Build/source/utils/asymptote/doc/CAD.pdf b/Build/source/utils/asymptote/doc/CAD.pdf Binary files differindex 1d787c85f52..7076ef94893 100644 --- a/Build/source/utils/asymptote/doc/CAD.pdf +++ b/Build/source/utils/asymptote/doc/CAD.pdf diff --git a/Build/source/utils/asymptote/doc/FAQ/asy-faq.info b/Build/source/utils/asymptote/doc/FAQ/asy-faq.info index 61c827ac745..4741db226ae 100644 --- a/Build/source/utils/asymptote/doc/FAQ/asy-faq.info +++ b/Build/source/utils/asymptote/doc/FAQ/asy-faq.info @@ -9,7 +9,7 @@ END-INFO-DIR-ENTRY File: $prefix.info, Node: Top, Next: Question 1.1, Up: (dir) ASYMPTOTE FREQUENTLY ASKED QUESTIONS - 18 Jun 2010 + 25 Jun 2010 This is the list of Frequently Asked Questions about Asymptote (asy). diff --git a/Build/source/utils/asymptote/doc/asymptote.pdf b/Build/source/utils/asymptote/doc/asymptote.pdf Binary files differindex 3056f8acbf0..f21cc658464 100644 --- a/Build/source/utils/asymptote/doc/asymptote.pdf +++ b/Build/source/utils/asymptote/doc/asymptote.pdf diff --git a/Build/source/utils/asymptote/doc/asymptote.texi b/Build/source/utils/asymptote/doc/asymptote.texi index 38b624a5ed3..7c4f3d4e9d3 100644 --- a/Build/source/utils/asymptote/doc/asymptote.texi +++ b/Build/source/utils/asymptote/doc/asymptote.texi @@ -5121,12 +5121,17 @@ If @code{n} is negative, search backwards from the end of the array for the @cindex @code{search} @item int search(T[] a, T key) -For built-in ordered types @code{T}, searches a sorted ordered array +For built-in ordered types @code{T}, searches a sorted array @code{a} of @code{n} elements for k, returning the index @code{i} if @code{a[i] <= key < a[i+1]}, @code{-1} if @code{key} is less than all elements of @code{a}, or @code{n-1} if @code{key} is greater than or equal to the last element of @code{a}. +@cindex @code{search} +@item int search(T[] a, T key, bool less(T i, T j)) +searches an array @code{a} sorted in ascending order such that element +@code{i} precedes element @code{j} if @code{less(i,j)} is true; + @cindex @code{copy} @item T[] copy(T[] a) returns a copy of the array @code{a}; @@ -5152,6 +5157,7 @@ returns @code{true} if the arrays @code{a} and @code{b} are identical; For built-in ordered types @code{T}, returns a copy of @code{a} sorted in ascending order; +@cindex @code{sort} @anchor{sort} @item T[][] sort(T[][] a) For built-in ordered types @code{T}, returns a copy of @code{a} with the rows @@ -5173,9 +5179,9 @@ pete 7 @end verbatim @cindex @code{sort} -@item T[] sort(T[] a, bool compare(T i, T j)) +@item T[] sort(T[] a, bool less(T i, T j)) returns a copy of @code{a} stably sorted in ascending order such that -element @code{i} precedes element @code{j} if @code{compare(i,j)} is true. +element @code{i} precedes element @code{j} if @code{less(i,j)} is true. @cindex @code{transpose} @item T[][] transpose(T[][] a) @@ -6148,11 +6154,11 @@ sequentially, returning the index of @code{x} in the resulting array. @cindex @code{lexorder} @item bool lexorder(pair a, pair b) -returns the lexicographical partial order of @code{a} and @code{b}. +returns the strict lexicographical partial order of @code{a} and @code{b}. @cindex @code{lexorder} @item bool lexorder(triple a, triple b) -returns the lexicographical partial order of @code{a} and @code{b}. +returns the strict lexicographical partial order of @code{a} and @code{b}. @end table @node interpolate @@ -6574,6 +6580,11 @@ The points are connected using the interpolation specified by @code{join}: the abbreviation @code{Spline} is also accepted); @cindex @code{Hermite} +@cindex @code{notaknot} +@cindex @code{natural} +@cindex @code{periodic} +@cindex @code{clamped} +@cindex @code{monotonic} @cindex @code{Hermite(splinetype splinetype} @item @code{Hermite} (standard cubic spline interpolation using boundary condition @code{notaknot}, @code{natural}, @code{periodic}, diff --git a/Build/source/utils/asymptote/doc/png/asymptote.info b/Build/source/utils/asymptote/doc/png/asymptote.info index d672a648432..45ab814b89a 100644 --- a/Build/source/utils/asymptote/doc/png/asymptote.info +++ b/Build/source/utils/asymptote/doc/png/asymptote.info @@ -1,7 +1,7 @@ This is asymptote.info, produced by makeinfo version 4.13 from ../asymptote.texi. -This file documents `Asymptote', version 1.99. +This file documents `Asymptote', version 2.00. `http://asymptote.sourceforge.net' @@ -23,7 +23,7 @@ File: asymptote.info, Node: Top, Next: Description, Up: (dir) Asymptote ********* -This file documents `Asymptote', version 1.99. +This file documents `Asymptote', version 2.00. `http://asymptote.sourceforge.net' @@ -3996,10 +3996,14 @@ of type `T[]'. the `-n'th value; `int search(T[] a, T key)' - For built-in ordered types `T', searches a sorted ordered array - `a' of `n' elements for k, returning the index `i' if `a[i] <= key - < a[i+1]', `-1' if `key' is less than all elements of `a', or - `n-1' if `key' is greater than or equal to the last element of `a'. + For built-in ordered types `T', searches a sorted array `a' of `n' + elements for k, returning the index `i' if `a[i] <= key < a[i+1]', + `-1' if `key' is less than all elements of `a', or `n-1' if `key' + is greater than or equal to the last element of `a'. + +`int search(T[] a, T key, bool less(T i, T j))' + searches an array `a' sorted in ascending order such that element + `i' precedes element `j' if `less(i,j)' is true; `T[] copy(T[] a)' returns a copy of the array `a'; @@ -4034,9 +4038,9 @@ of type `T[]'. bob 9 pete 7 -`T[] sort(T[] a, bool compare(T i, T j))' +`T[] sort(T[] a, bool less(T i, T j))' returns a copy of `a' stably sorted in ascending order such that - element `i' precedes element `j' if `compare(i,j)' is true. + element `i' precedes element `j' if `less(i,j)' is true. `T[][] transpose(T[][] a)' returns the transpose of `a'. @@ -4946,10 +4950,10 @@ useful functions such as sequentially, returning the index of `x' in the resulting array. `bool lexorder(pair a, pair b)' - returns the lexicographical partial order of `a' and `b'. + returns the strict lexicographical partial order of `a' and `b'. `bool lexorder(triple a, triple b)' - returns the lexicographical partial order of `a' and `b'. + returns the strict lexicographical partial order of `a' and `b'. File: asymptote.info, Node: interpolate, Next: geometry, Prev: math, Up: Base modules @@ -8443,11 +8447,11 @@ Index (line 48) * Airy: Mathematical functions. (line 48) -* alias <1>: Arrays. (line 182) +* alias <1>: Arrays. (line 186) * alias: Structures. (line 52) * align: Options. (line 167) * Align: label. (line 12) -* all: Arrays. (line 330) +* all: Arrays. (line 334) * Allow: Pens. (line 327) * AND: Arithmetic & logical. (line 80) @@ -8625,6 +8629,7 @@ Index * circle: Paths and guides. (line 10) * circlebarframe: markers. (line 18) * CJK: unicode. (line 12) +* clamped: graph. (line 37) * clear <1>: Debugger. (line 23) * clear: Files. (line 88) * clip: fill. (line 111) @@ -8641,7 +8646,7 @@ Index * colorless: Pens. (line 54) * colors: Pens. (line 51) * comma: Files. (line 58) -* comma-separated-value mode: Arrays. (line 363) +* comma-separated-value mode: Arrays. (line 367) * command-line options <1>: Options. (line 6) * command-line options: Configuring. (line 83) * comment character: Files. (line 15) @@ -8649,7 +8654,7 @@ Index * Compiling from UNIX source: Compiling from UNIX source. (line 6) * complement: Arrays. (line 149) -* concat: Arrays. (line 178) +* concat: Arrays. (line 182) * conditional <1>: Arithmetic & logical. (line 73) * conditional: Programming. (line 8) @@ -8673,7 +8678,7 @@ Index * convert: Configuring. (line 67) * convertOptions: Options. (line 129) * Coons shading: fill. (line 74) -* copy: Arrays. (line 169) +* copy: Arrays. (line 173) * Cos: Mathematical functions. (line 20) * cos: Mathematical functions. @@ -8687,10 +8692,10 @@ Index * cross: Data types. (line 167) * crossframe: markers. (line 23) * crosshatch: Pens. (line 267) -* csv: Arrays. (line 363) +* csv: Arrays. (line 367) * CTZ: Arithmetic & logical. (line 80) -* cubicroots: Arrays. (line 319) +* cubicroots: Arrays. (line 323) * curl <1>: three. (line 6) * curl: Bezier curves. (line 63) * curlSpecifier: Paths and guides. (line 391) @@ -8731,9 +8736,9 @@ Index * delete <1>: Arrays. (line 39) * delete: Files. (line 145) * description: Description. (line 6) -* diagonal: Arrays. (line 304) +* diagonal: Arrays. (line 308) * diamond: flowchart. (line 57) -* dimension: Arrays. (line 368) +* dimension: Arrays. (line 372) * dir <1>: three. (line 502) * dir <2>: Paths and guides. (line 98) * dir <3>: Data types. (line 85) @@ -8744,7 +8749,7 @@ Index * dirtime: Paths and guides. (line 152) * display: Configuring. (line 67) * do: Programming. (line 29) -* dot <1>: Arrays. (line 260) +* dot <1>: Arrays. (line 264) * dot <2>: Data types. (line 98) * dot: draw. (line 83) * DotMargin: draw. (line 42) @@ -8796,9 +8801,9 @@ Index * EndPoint: label. (line 57) * envelope: Frames and pictures. (line 22) * environment variables: Configuring. (line 87) -* eof <1>: Arrays. (line 345) +* eof <1>: Arrays. (line 349) * eof: Files. (line 88) -* eol <1>: Arrays. (line 345) +* eol <1>: Arrays. (line 349) * eol: Files. (line 88) * EPS <1>: Options. (line 142) * EPS: label. (line 80) @@ -8843,7 +8848,7 @@ Index (line 15) * feynman: feynman. (line 6) * fft <1>: math. (line 26) -* fft: Arrays. (line 247) +* fft: Arrays. (line 251) * FFTW: Compiling from UNIX source. (line 58) * file <1>: Debugger. (line 45) @@ -8956,7 +8961,7 @@ Index * i_scaled: Mathematical functions. (line 48) * iconic: three. (line 210) -* identity <1>: Arrays. (line 301) +* identity <1>: Arrays. (line 305) * identity <2>: Mathematical functions. (line 6) * identity: Transforms. (line 24) @@ -9009,7 +9014,7 @@ Index * InTicks: graph3. (line 34) * intMax: Data types. (line 28) * intMin: Data types. (line 28) -* inverse <1>: Arrays. (line 307) +* inverse <1>: Arrays. (line 311) * inverse: Transforms. (line 16) * invert: three. (line 422) * invisible: Pens. (line 39) @@ -9068,8 +9073,8 @@ Index * libsigsegv <1>: Help. (line 33) * libsigsegv: Functions. (line 88) * limits: graph. (line 636) -* line: Arrays. (line 345) -* line mode: Arrays. (line 345) +* line: Arrays. (line 349) +* line mode: Arrays. (line 349) * Linear: graph. (line 682) * linecap: Pens. (line 129) * linejoin: Pens. (line 138) @@ -9112,7 +9117,7 @@ Index * mathematical functions: Mathematical functions. (line 6) * max <1>: three. (line 502) -* max <2>: Arrays. (line 226) +* max <2>: Arrays. (line 230) * max <3>: Frames and pictures. (line 7) * max: Paths and guides. (line 264) * maxbound: Data types. (line 104) @@ -9133,7 +9138,7 @@ Index * midpoint: Paths and guides. (line 166) * MidPoint: label. (line 57) * min <1>: three. (line 502) -* min <2>: Arrays. (line 219) +* min <2>: Arrays. (line 223) * min <3>: Frames and pictures. (line 7) * min: Paths and guides. (line 260) * minbound: Data types. (line 101) @@ -9143,6 +9148,7 @@ Index * miterlimit: Pens. (line 147) * mm: Tutorial. (line 61) * mode: Files. (line 84) +* monotonic: graph. (line 37) * mouse: GUI. (line 6) * mouse bindings: three. (line 137) * Move: Pens. (line 339) @@ -9153,6 +9159,7 @@ Index * N: Tutorial. (line 104) * name: Files. (line 84) * named arguments: Named arguments. (line 6) +* natural: graph. (line 37) * new <1>: Arrays. (line 109) * new: Structures. (line 6) * newframe: Frames and pictures. (line 7) @@ -9172,6 +9179,7 @@ Index * nosafe: Options. (line 162) * NOT: Arithmetic & logical. (line 80) +* notaknot: graph. (line 37) * NoTicks: graph. (line 161) * NoTicks3: graph3. (line 34) * null: Structures. (line 6) @@ -9222,7 +9230,7 @@ Index * packing: Rest arguments. (line 30) * pair <1>: Data types. (line 41) * pair: Tutorial. (line 49) -* pairs: Arrays. (line 243) +* pairs: Arrays. (line 247) * paperheight: Configuring. (line 61) * papertype: Configuring. (line 61) * paperwidth: Configuring. (line 61) @@ -9250,6 +9258,7 @@ Index * PenMargins: draw. (line 42) * PenMargins2: three. (line 559) * PenMargins3: three. (line 559) +* periodic: graph. (line 37) * perpendicular: geometry. (line 6) * perspective: three. (line 358) * picture: Frames and pictures. (line 35) @@ -9294,7 +9303,7 @@ Index * public: Structures. (line 6) * push: Arrays. (line 39) * Python usage: Interactive mode. (line 80) -* quadraticroots: Arrays. (line 310) +* quadraticroots: Arrays. (line 314) * quarticroots: math. (line 22) * quit <1>: Debugger. (line 54) * quit <2>: Interactive mode. (line 59) @@ -9314,9 +9323,9 @@ Index (line 39) * randMax: Mathematical functions. (line 39) -* read: Arrays. (line 386) +* read: Arrays. (line 390) * reading: Files. (line 11) -* reading string arrays: Arrays. (line 355) +* reading string arrays: Arrays. (line 359) * readline: Files. (line 130) * real: Data types. (line 33) * realDigits: Data types. (line 33) @@ -9440,8 +9449,8 @@ Index * slopefield: slopefield. (line 6) * solid: Pens. (line 95) * solids: solids. (line 9) -* solve: Arrays. (line 279) -* sort: Arrays. (line 185) +* solve: Arrays. (line 283) +* sort: Arrays. (line 189) * Spline <1>: graph3. (line 100) * Spline: graph. (line 34) * split: Data types. (line 261) @@ -9474,7 +9483,7 @@ Index * subpictures: Frames and pictures. (line 103) * substr: Data types. (line 244) * Subversion: Subversion. (line 6) -* sum: Arrays. (line 214) +* sum: Arrays. (line 218) * superpath: Tutorial. (line 132) * Suppress: Pens. (line 331) * SuppressQuiet: Pens. (line 335) @@ -9538,12 +9547,12 @@ Index * transform: Transforms. (line 6) * transform3: three. (line 432) * transparency: Pens. (line 222) -* transpose: Arrays. (line 206) +* transpose: Arrays. (line 210) * tree: tree. (line 9) * trembling: trembling. (line 6) * triangle: geometry. (line 6) * triangulate: contour. (line 157) -* tridiagonal: Arrays. (line 267) +* tridiagonal: Arrays. (line 271) * trigonometric integrals: Mathematical functions. (line 48) * triple: Data types. (line 108) @@ -9590,7 +9599,7 @@ Index (line 6) * vectorfield: graph. (line 975) * vectorfield3: graph3. (line 159) -* vectorization: Arrays. (line 324) +* vectorization: Arrays. (line 328) * verbatim: Frames and pictures. (line 271) * vertex-dependent colors: three. (line 81) * Vertical: flowchart. (line 81) @@ -9607,11 +9616,11 @@ Index * Wheel: palette. (line 22) * wheel mouse: GUI. (line 6) * while: Programming. (line 29) -* white-space string delimiter mode: Arrays. (line 355) +* white-space string delimiter mode: Arrays. (line 359) * width: LaTeX usage. (line 31) * windingnumber: Paths and guides. (line 268) -* word: Arrays. (line 355) -* write <1>: Arrays. (line 395) +* word: Arrays. (line 359) +* write <1>: Arrays. (line 399) * write: Files. (line 50) * X: three. (line 274) * xasy: GUI. (line 6) @@ -9744,80 +9753,80 @@ Node: Named arguments147188 Node: Rest arguments149350 Node: Mathematical functions152160 Node: Arrays156767 -Ref: sort163651 -Ref: tridiagonal166061 -Ref: solve167289 -Node: Slices171482 -Node: Casts175372 -Node: Import177337 -Node: Static182564 -Node: LaTeX usage185458 -Node: Base modules190932 -Node: plain193432 -Node: simplex194084 -Node: math194357 -Node: interpolate197048 -Node: geometry197327 -Node: trembling197921 -Node: stats198272 -Node: patterns198532 -Node: markers198768 -Node: tree200551 -Node: binarytree200739 -Node: drawtree201328 -Node: syzygy201532 -Node: feynman201806 -Node: roundedpath202081 -Node: animation202364 -Ref: animate202781 -Node: embed203920 -Node: slide205709 -Node: MetaPost206049 -Node: unicode206765 -Node: latin1207653 -Node: babel208021 -Node: labelpath208250 -Node: labelpath3209070 -Node: annotate209381 -Node: CAD209852 -Node: graph210162 -Ref: ticks217291 -Ref: pathmarkers230570 -Ref: marker231035 -Ref: markuniform231386 -Ref: errorbars233177 -Ref: automatic scaling237233 -Node: palette247879 -Ref: images247997 -Ref: image252168 -Ref: logimage252646 -Ref: penimage253452 -Node: three253896 -Ref: PostScript3D278438 -Node: obj280130 -Node: graph3280382 -Ref: GaussianSurface285507 -Node: grid3286611 -Node: solids287351 -Node: tube288299 -Node: flowchart290534 -Node: contour295103 -Node: contour3300228 -Node: slopefield300535 -Node: ode301972 -Node: Options302232 -Ref: configuration file308077 -Ref: settings308077 -Ref: convert309278 -Node: Interactive mode312245 -Ref: history314398 -Node: GUI315703 -Node: GUI installation316206 -Node: GUI usage317336 -Node: PostScript to Asymptote318239 -Node: Help318995 -Node: Debugger320731 -Node: Credits322516 -Node: Index323448 +Ref: sort163817 +Ref: tridiagonal166221 +Ref: solve167449 +Node: Slices171642 +Node: Casts175532 +Node: Import177497 +Node: Static182724 +Node: LaTeX usage185618 +Node: Base modules191092 +Node: plain193592 +Node: simplex194244 +Node: math194517 +Node: interpolate197222 +Node: geometry197501 +Node: trembling198095 +Node: stats198446 +Node: patterns198706 +Node: markers198942 +Node: tree200725 +Node: binarytree200913 +Node: drawtree201502 +Node: syzygy201706 +Node: feynman201980 +Node: roundedpath202255 +Node: animation202538 +Ref: animate202955 +Node: embed204094 +Node: slide205883 +Node: MetaPost206223 +Node: unicode206939 +Node: latin1207827 +Node: babel208195 +Node: labelpath208424 +Node: labelpath3209244 +Node: annotate209555 +Node: CAD210026 +Node: graph210336 +Ref: ticks217465 +Ref: pathmarkers230744 +Ref: marker231209 +Ref: markuniform231560 +Ref: errorbars233351 +Ref: automatic scaling237407 +Node: palette248053 +Ref: images248171 +Ref: image252342 +Ref: logimage252820 +Ref: penimage253626 +Node: three254070 +Ref: PostScript3D278612 +Node: obj280304 +Node: graph3280556 +Ref: GaussianSurface285681 +Node: grid3286785 +Node: solids287525 +Node: tube288473 +Node: flowchart290708 +Node: contour295277 +Node: contour3300402 +Node: slopefield300709 +Node: ode302146 +Node: Options302406 +Ref: configuration file308251 +Ref: settings308251 +Ref: convert309452 +Node: Interactive mode312419 +Ref: history314572 +Node: GUI315877 +Node: GUI installation316380 +Node: GUI usage317510 +Node: PostScript to Asymptote318413 +Node: Help319169 +Node: Debugger320905 +Node: Credits322690 +Node: Index323622 End Tag Table diff --git a/Build/source/utils/asymptote/drawsurface.cc b/Build/source/utils/asymptote/drawsurface.cc index 9a52e0c1919..9cf80479c3c 100644 --- a/Build/source/utils/asymptote/drawsurface.cc +++ b/Build/source/utils/asymptote/drawsurface.cc @@ -589,9 +589,9 @@ void drawSphere::P(Triple& t, double x, double y, double z) t[2]=(T[8]*x+T[9]*y+T[10]*z+T[11])*f; } -static const Triple origin={0,0,0}; -static const Triple xaxis={1,0,0}; -static const Triple yaxis={0,1,0}; +static const Triple origin={0.0,0.0,0.0}; +static const Triple xaxis={1.0,0.0,0.0}; +static const Triple yaxis={0.0,1.0,0.0}; static const double Identity4[4][4]={{1.0,0.0,0.0,0.0}, {0.0,1.0,0.0,0.0}, {0.0,0.0,1.0,0.0}, diff --git a/Build/source/utils/asymptote/drawsurface.h b/Build/source/utils/asymptote/drawsurface.h index ed19bd80a60..2a42e110567 100644 --- a/Build/source/utils/asymptote/drawsurface.h +++ b/Build/source/utils/asymptote/drawsurface.h @@ -493,7 +493,6 @@ class drawTube : public drawElement { protected: path3 center; path3 g; - double T[16]; RGBAColour diffuse; RGBAColour ambient; RGBAColour emissive; diff --git a/Build/source/utils/asymptote/examples/bars3.asy b/Build/source/utils/asymptote/examples/bars3.asy new file mode 100644 index 00000000000..4205d46f37c --- /dev/null +++ b/Build/source/utils/asymptote/examples/bars3.asy @@ -0,0 +1,22 @@ +import three; +import palette; +import graph3; + +size(300); + +currentprojection=perspective(-30,-30,30,up=Z); + +surface s; + +for(int i = 0; i < 10; ++i) { + for(int j = 0; j < 10; ++j) { + s.append(shift(i,j,0)*scale(1,1,i+j)*unitcube); + } +} + +s.colors(palette(s.map(zpart),Rainbow())); +draw(s,meshpen=black+thick(),nolight,render(merge=true)); + +xaxis3("$x$",Bounds,InTicks(endlabel=false,Label,2,2)); +yaxis3(YZ()*"$y$",Bounds,InTicks(beginlabel=false,Label,2,2)); +zaxis3(XZ()*"$z$",Bounds,InTicks); diff --git a/Build/source/utils/asymptote/examples/condor.asy b/Build/source/utils/asymptote/examples/condor.asy index d3b48728ea0..5ce5caa2412 100644 --- a/Build/source/utils/asymptote/examples/condor.asy +++ b/Build/source/utils/asymptote/examples/condor.asy @@ -29,4 +29,4 @@ triple condor(pair t) surface s=surface(condor,(-1,0),(1,K),16,Spline); s.colors(palette(s.map(zpart),Rainbow())); -draw(s); +draw(s,render(compression=Low,merge=true)); diff --git a/Build/source/utils/asymptote/examples/cones.asy b/Build/source/utils/asymptote/examples/cones.asy index 4f28796cb92..e63a4281251 100644 --- a/Build/source/utils/asymptote/examples/cones.asy +++ b/Build/source/utils/asymptote/examples/cones.asy @@ -3,14 +3,16 @@ import solids; size(200); currentprojection=orthographic(5,4,2); +render render=render(compression=Low,merge=true); + revolution upcone=cone(-Z,1,1); revolution downcone=cone(Z,1,-1); -draw(surface(upcone),green); -draw(surface(downcone),green); +draw(surface(upcone),green,render); +draw(surface(downcone),green,render); draw(upcone,5,blue,longitudinalpen=nullpen); draw(downcone,5,blue,longitudinalpen=nullpen); revolution cone=shift(2Y-2X)*cone(1,1); -draw(surface(cone),green); +draw(surface(cone),green,render); draw(cone,5,blue); diff --git a/Build/source/utils/asymptote/examples/cylinder.asy b/Build/source/utils/asymptote/examples/cylinder.asy index d326ea579a2..88ff1394bac 100644 --- a/Build/source/utils/asymptote/examples/cylinder.asy +++ b/Build/source/utils/asymptote/examples/cylinder.asy @@ -4,5 +4,5 @@ size(0,100); currentlight=Viewport; revolution r=cylinder(O,1,1.5,Y+Z); -draw(surface(r),green); +draw(surface(r),green,render(merge=true)); draw(r,blue); diff --git a/Build/source/utils/asymptote/examples/hyperboloid.asy b/Build/source/utils/asymptote/examples/hyperboloid.asy index 10d3609f5d0..0cf6da08c40 100644 --- a/Build/source/utils/asymptote/examples/hyperboloid.asy +++ b/Build/source/utils/asymptote/examples/hyperboloid.asy @@ -4,5 +4,5 @@ import solids; currentprojection=perspective(4,4,3); revolution hyperboloid=revolution(new real(real x) {return sqrt(1+x*x);}, -2,2,20,operator..,X); -draw(surface(hyperboloid),green); +draw(surface(hyperboloid),green,render(compression=Low,merge=true)); draw(hyperboloid,6,blue,longitudinalpen=nullpen); diff --git a/Build/source/utils/asymptote/examples/pipes.asy b/Build/source/utils/asymptote/examples/pipes.asy new file mode 100644 index 00000000000..6b2025f6b35 --- /dev/null +++ b/Build/source/utils/asymptote/examples/pipes.asy @@ -0,0 +1,140 @@ +import solids; +import tube; +import graph3; +import palette; +size(8cm); + +currentprojection=perspective( +camera=(13.3596389245356,8.01038090435314,14.4864483364785), +up=(-0.0207054323419367,-0.00472438375047319,0.0236460907598947), +target=(-1.06042550499095,2.68154529985845,0.795007562120261)); + +defaultpen(fontsize(6pt)); + +// draw coordinates and frames +// axis1 is defined by z axis of TBase +// axis2 is defined by z axis of TEnd +void DrawFrame(transform3 TBase, transform3 TEnd, string s) +{ + triple p1,v1,p2,v2; + p1=TBase*O; + v1=TBase*Z-p1; + p2=TEnd*O; + v2=TEnd*Z-p2; + triple n=cross(v1,v2); + + real[][] A= + { + {v1.x,-v2.x,-n.x}, + {v1.y,-v2.y,-n.y}, + {v1.z,-v2.z,-n.z} + }; + + triple vb=p2-p1; + + real[] b={vb.x,vb.y,vb.z}; + + // Get the extention along vector v1 and v2, + // so, we can get the common normal between two axis + real[] x=solve(A,b); + + real s1=x[0]; + real s2=x[1]; + + // get foot of a perpendicular on both axies + triple foot1=p1+s1*v1; + triple foot2=p2+s2*v2; + + // draw two axis + triple axis_a,axis_b; + axis_a=p1+s1*v1*1.5; + axis_b=p1-s1*v1*1.5; + draw(axis_a--axis_b); + + axis_a=p2+s2*v2*1.5; + axis_b=p2-s2*v2*1.5; + draw(axis_a--axis_b); + + // draw "a"(common normal) + draw(Label("$a_{"+s+"}$"),foot1--foot2,linewidth(1pt)); + + // draw the coordinates frame + triple dx,dy,dz,org; + real length=0.8; + + org=foot1; + dx =length*unit(foot2-foot1); // define the x axis of the frame on "a" + dz =length*unit(v1); // define the z axis which is along axis1 + dy =length*unit(cross(dz,dx)); + + draw(Label("$X_{"+s+"}$",1,align=-dy-dz),org--(org+dx),red+linewidth(1.5pt), + Arrow3(8)); + draw(Label("$Y_{"+s+"}$",1,align=2dy-dz-dx),org--(org+dy), + green+linewidth(1.5pt), Arrow3(8)); + draw(Label("$Z_{"+s+"}$",1,align=-2dx-dy),org--(org+dz), + blue+linewidth(1.5pt), Arrow3(8)); + + dot(Label("$O_{"+s+"}$",align =-dx-dz,black),org,black); // origin + +} + +void DrawLink(transform3 TBase, transform3 TEnd, pen objStyle,string s) +{ + real h=1; + real r=0.5; + path3 generator=(0.5*r,0,h)--(r,0,h)--(r,0,0)--(0.5*r,0,0); + revolution vase=revolution(O,generator,0,360); + surface objSurface=surface(vase); + + render render=render(merge=true); + + // draw two cylinders + draw(TBase*objSurface,objStyle,render); + draw(TEnd*shift((0,0,-h))*objSurface,objStyle,render); + + // draw the link between two cylinders + triple pStart=TBase*(0.5*h*Z); + triple pEnd =TEnd*(-0.5*h*Z); + triple pControl1=0.25*(pEnd-pStart)+TBase*(0,0,h); + triple pControl2=-0.25*(pEnd-pStart)+TEnd*(0,0,-h); + path3 p=pStart..controls pControl1 and pControl2..pEnd; + draw(tube(p,scale(0.2)*unitsquare),objStyle,render); +} + +// t1 and t2 define the starting frame and ending frame of the first link(i-1) +transform3 t1=shift((0,0,1)); +transform3 t2=shift((0,0,-1))*rotate(-20,Y)*shift((0,3,2)); +// as, the two links were connected, so t2 is also the starting frame of link(i) +// t3 defines the ending frame of link(i) +transform3 t3=t2*rotate(40,Z)*shift((0,3,1.5))*rotate(-15,Y)*shift(-1.5*Z); + +// draw link(i-1) +DrawLink(t1,t2,palegreen,"i-1"); +DrawFrame(t1,t2,"i-1"); +// draw link(i) +DrawLink(t2,t3,lightmagenta,"i"); +DrawFrame(t2,t3,"i"); + + +// draw angle alpha, which is the angle between axis(i-1) and axis(i) +triple p0=(0,0,-1); +triple p1=(0,0,2.3); +triple p2=shift((0,0,-1))*rotate(-20,Y)*(0,0,4); +draw(p0--p2,cyan); +draw("$\alpha_{i-1}$",arc(p0,p1,p2,Y,CW),ArcArrow3(3)); + + +// draw angle theta, which is the angle between a_i and a_{i-1} +transform3 tx=shift((0,0,-1))*rotate(-20,Y)*shift((0,3,0)); +p0=tx*O; +p1=tx*(0,3,0); +p2=tx*rotate(40,Z)*(0,3,0); +draw(p0--p1,cyan); +draw(p0--p2,cyan); + +triple p1a=tx*(0,1.5,0); +draw("$\theta_{i}$",arc(p0,p1a,p2),ArcArrow3(3)); + +// draw d_{i-1} +triple org_i =t2*shift((0,0,1.5))*O; +draw(Label("$d_{i}$",0.13),p0--org_i,linewidth(1pt)); diff --git a/Build/source/utils/asymptote/examples/projectrevolution.asy b/Build/source/utils/asymptote/examples/projectrevolution.asy index fe639b3b901..25cbe6d4902 100644 --- a/Build/source/utils/asymptote/examples/projectrevolution.asy +++ b/Build/source/utils/asymptote/examples/projectrevolution.asy @@ -11,5 +11,7 @@ surface s=surface(r); surface S=planeproject(shift(-Z)*unitsquare3)*s; S.colors(palette(s.map(zpart),Rainbow())); -draw(S); -draw(s,lightgray); + +render render=render(compression=Low,merge=true); +draw(S,render); +draw(s,lightgray,render); diff --git a/Build/source/utils/asymptote/examples/sacone3D.asy b/Build/source/utils/asymptote/examples/sacone3D.asy index 1ed60da0351..d8f3aa373d3 100644 --- a/Build/source/utils/asymptote/examples/sacone3D.asy +++ b/Build/source/utils/asymptote/examples/sacone3D.asy @@ -5,7 +5,8 @@ real r=1; real h=1; revolution R=cone(r,h); -draw(surface(R),lightgreen+opacity(0.5)); + +draw(surface(R),lightgreen+opacity(0.5),render(compression=Low)); pen edge=blue+0.25mm; draw("$\ell$",(0,r,0)--(0,0,h),W,edge); draw("$r$",(0,0,0)--(r,0,0),red+dashed); diff --git a/Build/source/utils/asymptote/examples/sacylinder3D.asy b/Build/source/utils/asymptote/examples/sacylinder3D.asy index e44f78e8e72..fcc1a487bbe 100644 --- a/Build/source/utils/asymptote/examples/sacylinder3D.asy +++ b/Build/source/utils/asymptote/examples/sacylinder3D.asy @@ -5,7 +5,7 @@ real r=1; real h=3; revolution R=cylinder(-h/2*Z,r,h); -draw(surface(R),lightgreen+opacity(0.5)); +draw(surface(R),lightgreen+opacity(0.5),render(compression=Low)); draw((0,0,-h/2)--(0,0,h/2),dashed); dot((0,0,-h/2)); dot((0,0,h/2)); diff --git a/Build/source/utils/asymptote/examples/shellmethod.asy b/Build/source/utils/asymptote/examples/shellmethod.asy index c1c0155ae3a..c8e541f2a62 100644 --- a/Build/source/utils/asymptote/examples/shellmethod.asy +++ b/Build/source/utils/asymptote/examples/shellmethod.asy @@ -26,11 +26,13 @@ path p=graph(F,0,2,n,operator ..)--cycle; surface s=surface(p); path3 p3=path3(p); +render render=render(compression=0,merge=true); + revolution a=revolution(p3,Y,0,alpha); -draw(surface(a),color); -draw(rotate(alpha,Y)*s,color); +draw(surface(a),color,render); +draw(rotate(alpha,Y)*s,color,render); for(int i=0; i < n; ++i) - draw(surface(blocks[i]),color+opacity(0.5),black); + draw(surface(blocks[i]),color+opacity(0.5),black,render); draw(p3); xaxis3(Label("$x$",1,align=2X),Arrow3); diff --git a/Build/source/utils/asymptote/examples/splitpatch.asy b/Build/source/utils/asymptote/examples/splitpatch.asy index 200fb2c4c44..f1f5b6b98ba 100644 --- a/Build/source/utils/asymptote/examples/splitpatch.asy +++ b/Build/source/utils/asymptote/examples/splitpatch.asy @@ -1,5 +1,7 @@ import three; +size(300); + currentprojection=orthographic(0,0,1); triple[][] A={ diff --git a/Build/source/utils/asymptote/examples/teapot.asy b/Build/source/utils/asymptote/examples/teapot.asy index 9ec5b0cb370..401ecec5ab9 100644 --- a/Build/source/utils/asymptote/examples/teapot.asy +++ b/Build/source/utils/asymptote/examples/teapot.asy @@ -169,4 +169,4 @@ triple[][][] Q={ } }; -draw(surface(Q),blue); +draw(surface(Q),blue,render(compression=Low)); diff --git a/Build/source/utils/asymptote/examples/torus.asy b/Build/source/utils/asymptote/examples/torus.asy index f89c82cde8b..d0b8673d737 100644 --- a/Build/source/utils/asymptote/examples/torus.asy +++ b/Build/source/utils/asymptote/examples/torus.asy @@ -17,4 +17,4 @@ triple f(pair t) { } surface s=surface(f,(radians(90),0),(radians(345),2pi),8,8,Spline); -draw(s,green,render(merge=true)); +draw(s,green,render(compression=Low,merge=true)); diff --git a/Build/source/utils/asymptote/examples/workcone.asy b/Build/source/utils/asymptote/examples/workcone.asy index 5b4f8c94ad5..37efb5cc86b 100644 --- a/Build/source/utils/asymptote/examples/workcone.asy +++ b/Build/source/utils/asymptote/examples/workcone.asy @@ -16,6 +16,8 @@ real x1=r*s1/h; real s2=sr+0.2; real x2=r*s2/h; +//render render=render(compression=Low,merge=true); + path3 p=(0,0,0)--(x,0,s); revolution a=revolution(p,Z); draw(surface(a,4),lightblue+opacity(0.5)); diff --git a/Build/source/utils/asymptote/glrender.cc b/Build/source/utils/asymptote/glrender.cc index 5effe0f5f57..9a0a78486b8 100644 --- a/Build/source/utils/asymptote/glrender.cc +++ b/Build/source/utils/asymptote/glrender.cc @@ -612,7 +612,7 @@ void nextframe(int) endwait(readySignal,readyLock); double framedelay=getSetting<double>("framedelay"); if(framedelay > 0) - usleep(1000.0*framedelay); + usleep((unsigned int) (1000.0*framedelay+0.5)); if(Step) Animate=false; } diff --git a/Build/source/utils/asymptote/gsl.cc b/Build/source/utils/asymptote/gsl.cc new file mode 100644 index 00000000000..0eb8c2590ba --- /dev/null +++ b/Build/source/utils/asymptote/gsl.cc @@ -0,0 +1,1469 @@ +/***** + * gsl.cc + * 2010/05/19 + * + * Initialize gsl builtins. + *****/ + +#include "config.h" + +#ifdef HAVE_LIBGSL + +#include "vm.h" +#include "types.h" +#include "entry.h" +#include "builtin.h" + +#include "record.h" +#include "stack.h" +#include "errormsg.h" +#include "array.h" +#include "triple.h" +#include "callable.h" + +#include <gsl/gsl_math.h> +#include <gsl/gsl_sf.h> +#include <gsl/gsl_errno.h> +#include <gsl/gsl_rng.h> +#include <gsl/gsl_randist.h> +#include <gsl/gsl_cdf.h> + +#include "opsymbols.h" + +#ifndef NOSYM +#include "gsl.symbols.h" +#endif + +namespace trans { + +using types::formal; +using types::primVoid; +using types::primInt; +using types::primReal; +using types::primPair; +using types::primTriple; +using types::primString; +using types::IntArray; +using types::realArray; +using types::stringArray; + +using vm::stack; +using vm::pop; +using vm::error; +using run::copyArrayC; +using run::copyCArray; + +using camp::pair; +using camp::triple; + +const char* GSLrngnull = "GSL random number generator not initialized"; +const char* GSLinvalid = "invalid argument"; + +bool GSLerror=false; +types::dummyRecord *GSLModule; + +types::record *getGSLModule() +{ + return GSLModule; +} + +inline void checkGSLerror() +{ + if(GSLerror) { + GSLerror=false; + throw handled_error(); + } +} + +template <double (*func)(double)> +void realRealGSL(stack *s) +{ + double x=pop<double>(s); + s->push(func(x)); + checkGSLerror(); +} + +template <double (*func)(double, gsl_mode_t)> +void realRealDOUBLE(stack *s) +{ + double x=pop<double>(s); + s->push(func(x,GSL_PREC_DOUBLE)); + checkGSLerror(); +} + +template <double (*func)(double, double, gsl_mode_t)> +void realRealRealDOUBLE(stack *s) +{ + double y=pop<double>(s); + double x=pop<double>(s); + s->push(func(x,y,GSL_PREC_DOUBLE)); + checkGSLerror(); +} + +template <double (*func)(unsigned)> +void realIntGSL(stack *s) +{ + s->push(func(unsignedcast(pop<Int>(s)))); + checkGSLerror(); +} + +template <double (*func)(int, double)> +void realIntRealGSL(stack *s) +{ + double x=pop<double>(s); + s->push(func(intcast(pop<Int>(s)),x)); + checkGSLerror(); +} + +template <double (*func)(double, double)> +void realRealRealGSL(stack *s) +{ + double x=pop<double>(s); + double n=pop<double>(s); + s->push(func(n,x)); + checkGSLerror(); +} + +template <int (*func)(double, double, double)> +void intRealRealRealGSL(stack *s) +{ + double x=pop<double>(s); + double n=pop<double>(s); + double a=pop<double>(s); + s->push(func(a,n,x)); + checkGSLerror(); +} + +template <double (*func)(double, double, double)> +void realRealRealRealGSL(stack *s) +{ + double x=pop<double>(s); + double n=pop<double>(s); + double a=pop<double>(s); + s->push(func(a,n,x)); + checkGSLerror(); +} + +template <double (*func)(double, unsigned)> +void realRealIntGSL(stack *s) +{ + Int n=pop<Int>(s); + double x=pop<double>(s); + s->push(func(x,unsignedcast(n))); + checkGSLerror(); +} + +// Add a GSL special function from the GNU GSL library +template<double (*fcn)(double)> +void addGSLRealFunc(symbol name, symbol arg1=SYM(x)) +{ + addFunc(GSLModule->e.ve, realRealGSL<fcn>, primReal(), name, + formal(primReal(),arg1)); +} + +// Add a GSL_PREC_DOUBLE GSL special function. +template<double (*fcn)(double, gsl_mode_t)> +void addGSLDOUBLEFunc(symbol name, symbol arg1=SYM(x)) +{ + addFunc(GSLModule->e.ve, realRealDOUBLE<fcn>, primReal(), name, + formal(primReal(),arg1)); +} + +template<double (*fcn)(double, double, gsl_mode_t)> +void addGSLDOUBLE2Func(symbol name, symbol arg1=SYM(phi), + symbol arg2=SYM(k)) +{ + addFunc(GSLModule->e.ve, realRealRealDOUBLE<fcn>, primReal(), name, + formal(primReal(),arg1), formal(primReal(),arg2)); +} + +template <double (*func)(double, double, double, gsl_mode_t)> +void realRealRealRealDOUBLE(stack *s) +{ + double z=pop<double>(s); + double y=pop<double>(s); + double x=pop<double>(s); + s->push(func(x,y,z,GSL_PREC_DOUBLE)); + checkGSLerror(); +} + +template<double (*fcn)(double, double, double, gsl_mode_t)> +void addGSLDOUBLE3Func(symbol name, symbol arg1, symbol arg2, + symbol arg3) +{ + addFunc(GSLModule->e.ve, realRealRealRealDOUBLE<fcn>, primReal(), name, + formal(primReal(),arg1), formal(primReal(),arg2), + formal(primReal(), arg3)); +} + +template <double (*func)(double, double, double, double, gsl_mode_t)> +void realRealRealRealRealDOUBLE(stack *s) +{ + double z=pop<double>(s); + double y=pop<double>(s); + double x=pop<double>(s); + double w=pop<double>(s); + s->push(func(w,x,y,z,GSL_PREC_DOUBLE)); + checkGSLerror(); +} + +template<double (*fcn)(double, double, double, double, gsl_mode_t)> +void addGSLDOUBLE4Func(symbol name, symbol arg1, symbol arg2, + symbol arg3, symbol arg4) +{ + addFunc(GSLModule->e.ve, realRealRealRealRealDOUBLE<fcn>, primReal(), name, + formal(primReal(),arg1), formal(primReal(),arg2), + formal(primReal(), arg3), formal(primReal(), arg4)); +} + +template<double (*fcn)(unsigned)> +void addGSLIntFunc(symbol name) +{ + addFunc(GSLModule->e.ve, realIntGSL<fcn>, primReal(), name, + formal(primInt(),SYM(s))); +} + +template <double (*func)(int)> +void realSignedGSL(stack *s) +{ + Int a = pop<Int>(s); + s->push(func(intcast(a))); + checkGSLerror(); +} + +template<double (*fcn)(int)> +void addGSLSignedFunc(symbol name, symbol arg1) +{ + addFunc(GSLModule->e.ve, realSignedGSL<fcn>, primReal(), name, + formal(primInt(),arg1)); +} + +template<double (*fcn)(int, double)> +void addGSLIntRealFunc(symbol name, symbol arg1=SYM(n), + symbol arg2=SYM(x)) +{ + addFunc(GSLModule->e.ve, realIntRealGSL<fcn>, primReal(), name, + formal(primInt(),arg1), formal(primReal(),arg2)); +} + +template<double (*fcn)(double, double)> +void addGSLRealRealFunc(symbol name, symbol arg1=SYM(nu), + symbol arg2=SYM(x)) +{ + addFunc(GSLModule->e.ve, realRealRealGSL<fcn>, primReal(), name, + formal(primReal(),arg1), formal(primReal(),arg2)); +} + +template<double (*fcn)(double, double, double)> +void addGSLRealRealRealFunc(symbol name, symbol arg1, + symbol arg2, symbol arg3) +{ + addFunc(GSLModule->e.ve, realRealRealRealGSL<fcn>, primReal(), name, + formal(primReal(),arg1), formal(primReal(),arg2), + formal(primReal(), arg3)); +} + +template<int (*fcn)(double, double, double)> +void addGSLRealRealRealFuncInt(symbol name, symbol arg1, + symbol arg2, symbol arg3) +{ + addFunc(GSLModule->e.ve, intRealRealRealGSL<fcn>, primInt(), name, + formal(primReal(),arg1), formal(primReal(),arg2), + formal(primReal(), arg3)); +} + +template<double (*fcn)(double, unsigned)> +void addGSLRealIntFunc(symbol name, symbol arg1=SYM(nu), + symbol arg2=SYM(s)) +{ + addFunc(GSLModule->e.ve, realRealIntGSL<fcn>, primReal(), name, + formal(primReal(),arg1), formal(primInt(),arg2)); +} + +template<double (*func)(double, int)> +void realRealSignedGSL(stack *s) +{ + Int b = pop<Int>(s); + double a = pop<double>(s); + s->push(func(a, intcast(b))); + checkGSLerror(); +} + +template<double (*fcn)(double, int)> +void addGSLRealSignedFunc(symbol name, symbol arg1, symbol arg2) +{ + addFunc(GSLModule->e.ve, realRealSignedGSL<fcn>, primReal(), name, + formal(primReal(),arg1), formal(primInt(),arg2)); +} + +template<double (*func)(unsigned int, unsigned int)> +void realUnsignedUnsignedGSL(stack *s) +{ + Int b = pop<Int>(s); + Int a = pop<Int>(s); + s->push(func(unsignedcast(a), unsignedcast(b))); + checkGSLerror(); +} + +template<double (*fcn)(unsigned int, unsigned int)> +void addGSLUnsignedUnsignedFunc(symbol name, symbol arg1, + symbol arg2) +{ + addFunc(GSLModule->e.ve, realUnsignedUnsignedGSL<fcn>, primReal(), name, + formal(primInt(), arg1), formal(primInt(), arg2)); +} + +template<double (*func)(int, double, double)> +void realIntRealRealGSL(stack *s) +{ + double c = pop<double>(s); + double b = pop<double>(s); + Int a = pop<Int>(s); + s->push(func(intcast(a), b, c)); + checkGSLerror(); +} + +template<double (*fcn)(int, double, double)> +void addGSLIntRealRealFunc(symbol name, symbol arg1, + symbol arg2, symbol arg3) +{ + addFunc(GSLModule->e.ve, realIntRealRealGSL<fcn>, primReal(), name, + formal(primInt(), arg1), formal(primReal(), arg2), + formal(primReal(), arg3)); +} + +template<double (*func)(int, int, double)> +void realIntIntRealGSL(stack *s) +{ + double c = pop<double>(s); + Int b = pop<Int>(s); + Int a = pop<Int>(s); + s->push(func(intcast(a), intcast(b), c)); + checkGSLerror(); +} + +template<double (*fcn)(int, int, double)> +void addGSLIntIntRealFunc(symbol name, symbol arg1, symbol arg2, + symbol arg3) +{ + addFunc(GSLModule->e.ve, realIntIntRealGSL<fcn>, primReal(), name, + formal(primInt(), arg1), formal(primInt(), arg2), + formal(primReal(), arg3)); +} + +template<double (*func)(int, int, double, double)> +void realIntIntRealRealGSL(stack *s) +{ + double d = pop<double>(s); + double c = pop<double>(s); + Int b = pop<Int>(s); + Int a = pop<Int>(s); + s->push(func(intcast(a), intcast(b), c, d)); + checkGSLerror(); +} + +template<double (*fcn)(int, int, double, double)> +void addGSLIntIntRealRealFunc(symbol name, symbol arg1, + symbol arg2, symbol arg3, + symbol arg4) +{ + addFunc(GSLModule->e.ve, realIntIntRealRealGSL<fcn>, primReal(), name, + formal(primInt(), arg1), formal(primInt(), arg2), + formal(primReal(), arg3), formal(primReal(), arg4)); +} + +template<double (*func)(double, double, double, double)> +void realRealRealRealRealGSL(stack *s) +{ + double d = pop<double>(s); + double c = pop<double>(s); + double b = pop<double>(s); + double a = pop<double>(s); + s->push(func(a, b, c, d)); + checkGSLerror(); +} + +template<double (*fcn)(double, double, double, double)> +void addGSLRealRealRealRealFunc(symbol name, symbol arg1, + symbol arg2, symbol arg3, + symbol arg4) +{ + addFunc(GSLModule->e.ve, realRealRealRealRealGSL<fcn>, primReal(), name, + formal(primReal(), arg1), formal(primReal(), arg2), + formal(primReal(), arg3), formal(primReal(), arg4)); +} + +template<double (*func)(int, int, int, int, int, int)> +void realIntIntIntIntIntIntGSL(stack *s) +{ + Int f = pop<Int>(s); + Int e = pop<Int>(s); + Int d = pop<Int>(s); + Int c = pop<Int>(s); + Int b = pop<Int>(s); + Int a = pop<Int>(s); + s->push(func(intcast(a), intcast(b), intcast(c), intcast(d), intcast(e), + intcast(f))); + checkGSLerror(); +} + +template<double (*fcn)(int, int, int, int, int, int)> +void addGSLIntIntIntIntIntIntFunc(symbol name, symbol arg1, + symbol arg2, symbol arg3, + symbol arg4, symbol arg5, + symbol arg6) +{ + addFunc(GSLModule->e.ve, realIntIntIntIntIntIntGSL<fcn>, primReal(), name, + formal(primInt(), arg1), formal(primInt(), arg2), + formal(primInt(), arg3), formal(primInt(), arg4), + formal(primInt(), arg5), formal(primInt(), arg6)); +} + +template<double (*func)(int, int, int, int, int, int, int, int, int)> +void realIntIntIntIntIntIntIntIntIntGSL(stack *s) +{ + Int i = pop<Int>(s); + Int h = pop<Int>(s); + Int g = pop<Int>(s); + Int f = pop<Int>(s); + Int e = pop<Int>(s); + Int d = pop<Int>(s); + Int c = pop<Int>(s); + Int b = pop<Int>(s); + Int a = pop<Int>(s); + s->push(func(intcast(a), intcast(b), intcast(c), intcast(d), intcast(e), + intcast(f), intcast(g), intcast(h), intcast(i))); + checkGSLerror(); +} + +template<double (*fcn)(int, int, int, int, int, int, int, int, int)> +void addGSLIntIntIntIntIntIntIntIntIntFunc(symbol name, symbol arg1, + symbol arg2, symbol arg3, + symbol arg4, symbol arg5, + symbol arg6, symbol arg7, + symbol arg8, symbol arg9) +{ + addFunc(GSLModule->e.ve, realIntIntIntIntIntIntIntIntIntGSL<fcn>, primReal(), + name, formal(primInt(), arg1), formal(primInt(), arg2), + formal(primInt(), arg3), formal(primInt(), arg4), + formal(primInt(), arg5), formal(primInt(), arg6), + formal(primInt(), arg7), formal(primInt(), arg8), + formal(primInt(), arg9)); +} + +template<double (*func)(unsigned int, double)> +void realUIntRealGSL(stack *s) +{ + double a = pop<double>(s); + unsigned int k = unsignedcast(pop<Int>(s)); + s->push(func(k,a)); + checkGSLerror(); +} + +template<double (*fcn)(unsigned int, double)> +void addGSLUIntRealFunc(symbol name, symbol arg1, symbol arg2) +{ + addFunc(GSLModule->e.ve, realUIntRealGSL<fcn>, primReal(), name, + formal(primInt(), arg1), formal(primReal(), arg2)); +} + +template<double (*func)(unsigned int, double, unsigned int)> +void realUIntRealUIntGSL(stack *s) +{ + unsigned int n = unsignedcast(pop<Int>(s)); + double a = pop<double>(s); + unsigned int k = unsignedcast(pop<Int>(s)); + s->push(func(k,a,n)); + checkGSLerror(); +} + +template<double (*fcn)(unsigned int, double, unsigned int)> +void addGSLUIntRealUIntFunc(symbol name, symbol arg1, symbol arg2, symbol arg3) +{ + addFunc(GSLModule->e.ve, realUIntRealUIntGSL<fcn>, primReal(), name, + formal(primInt(), arg1), formal(primReal(), arg2), + formal(primInt(), arg3)); +} + +template<double (*func)(unsigned int, double, double)> +void realUIntRealRealGSL(stack *s) +{ + double b = pop<double>(s); + double a = pop<double>(s); + unsigned int k = unsignedcast(pop<Int>(s)); + s->push(func(k,a,b)); + checkGSLerror(); +} + +template<double (*fcn)(unsigned int, double, double)> +void addGSLUIntRealRealFunc(symbol name, symbol arg1, symbol arg2, symbol arg3) +{ + addFunc(GSLModule->e.ve, realUIntRealRealGSL<fcn>, primReal(), name, + formal(primInt(), arg1), formal(primReal(), arg2), + formal(primReal(), arg3)); +} + +template<double (*func)(unsigned int, unsigned int, unsigned int, unsigned int)> +void realUIntUIntUIntUIntGSL(stack *s) +{ + unsigned int t = unsignedcast(pop<Int>(s)); + unsigned int n2 = unsignedcast(pop<Int>(s)); + unsigned int n1 = unsignedcast(pop<Int>(s)); + unsigned int k = unsignedcast(pop<Int>(s)); + s->push(func(k,n1,n2,t)); + checkGSLerror(); +} + +template<double (*fcn)(unsigned int, unsigned int, unsigned int, unsigned int)> +void addGSLUIntUIntUIntUIntFunc(symbol name, symbol arg1, symbol arg2, + symbol arg3, symbol arg4) +{ + addFunc(GSLModule->e.ve, realUIntUIntUIntUIntGSL<fcn>, primReal(), name, + formal(primInt(), arg1), formal(primInt(), arg2), + formal(primInt(), arg3), formal(primInt(), arg4)); +} + +// GSL random number generators +gsl_rng *GSLrng=0; +const gsl_rng_type **GSLrngFirstType=gsl_rng_types_setup(); + +inline void checkGSLrng() +{ + if(GSLrng == 0) error(GSLrngnull); +} + +void GSLrngFree() +{ + if(GSLrng != 0) gsl_rng_free(GSLrng); + GSLrng=0; +} + +void GSLrngInit(stack *s) +{ + string n = pop<string>(s,string()); + const gsl_rng_type **t; + if(n.empty()) t = &gsl_rng_default; + else { + for(t=GSLrngFirstType; *t!=0; ++t) + if(n == string((*t)->name)) break; + if(*t == 0) error(GSLinvalid); + } + GSLrngFree(); + GSLrng = gsl_rng_alloc(*t); + if(GSLrng == 0) { + GSLerror=false; + error("insufficient memory for allocation of GSL random number generator"); + } +} + +void GSLrngList(stack *s) +{ + vm::array* a = new vm::array(0); + const gsl_rng_type **t; + for(t=GSLrngFirstType; *t!=0; ++t) { + a->push(string((*t)->name)); + } + s->push<vm::array*>(a); + checkGSLerror(); +} + +void GSLrngSet(stack *s) +{ + unsigned long int i = unsignedcast(pop<Int>(s,-1)); + checkGSLrng(); + if(i<0) gsl_rng_set(GSLrng,gsl_rng_default_seed); + else gsl_rng_set(GSLrng,i); + checkGSLerror(); +} + +template<unsigned long int (*func)(const gsl_rng*)> +void intVoidGSLrng(stack *s) +{ + s->push<Int>(func(GSLrng)); + checkGSLrng(); + checkGSLerror(); +} + +template<unsigned long int (*fcn)(const gsl_rng*)> +void addGSLrngVoidFuncInt(symbol name) +{ + addFunc(GSLModule->e.ve, intVoidGSLrng<fcn>, primInt(), name); +} + +template<unsigned long int (*func)(const gsl_rng*, unsigned long int)> +void intULongGSLrng(stack *s) +{ + unsigned long int i = unsignedcast(pop<Int>(s)); + checkGSLrng(); + s->push<Int>(func(GSLrng,i)); + checkGSLerror(); +} + +template<unsigned long int (*fcn)(const gsl_rng*, unsigned long int)> +void addGSLrngULongFuncInt(symbol name, symbol arg1) +{ + addFunc(GSLModule->e.ve, intULongGSLrng<fcn>, primInt(), name, + formal(primInt(), arg1)); +} + +template<unsigned int (*func)(const gsl_rng*, double)> +void intRealGSLrng(stack *s) +{ + double x = pop<double>(s); + checkGSLrng(); + s->push<Int>(func(GSLrng,x)); + checkGSLerror(); +} + +template<unsigned int (*fcn)(const gsl_rng*, double)> +void addGSLrngRealFuncInt(symbol name, symbol arg1) +{ + addFunc(GSLModule->e.ve, intRealGSLrng<fcn>, primInt(), name, + formal(primReal(), arg1)); +} + +template<unsigned int (*func)(const gsl_rng*, double, double)> +void intRealRealGSLrng(stack *s) +{ + double y = pop<double>(s); + double x = pop<double>(s); + checkGSLrng(); + s->push<Int>(func(GSLrng,x,y)); + checkGSLerror(); +} + +template<unsigned int (*fcn)(const gsl_rng*, double, double)> +void addGSLrngRealRealFuncInt(symbol name, symbol arg1, symbol arg2) +{ + addFunc(GSLModule->e.ve, intRealRealGSLrng<fcn>, primInt(), name, + formal(primReal(), arg1), formal(primReal(), arg2)); +} + +template<double (*func)(const gsl_rng*)> +void realVoidGSLrng(stack *s) +{ + checkGSLrng(); + s->push(func(GSLrng)); + checkGSLerror(); +} + +template<double (*fcn)(const gsl_rng*)> +void addGSLrngVoidFunc(symbol name) +{ + addFunc(GSLModule->e.ve, realVoidGSLrng<fcn>, primReal(), name); +} + +template<double (*func)(const gsl_rng*, double)> +void realRealGSLrng(stack *s) +{ + double x = pop<double>(s); + checkGSLrng(); + s->push(func(GSLrng,x)); + checkGSLerror(); +} + +template<double (*fcn)(const gsl_rng*, double)> +void addGSLrngRealFunc(symbol name, symbol arg1) +{ + addFunc(GSLModule->e.ve, realRealGSLrng<fcn>, primReal(), name, + formal(primReal(), arg1)); +} + +template<double (*func)(const gsl_rng*, double, double)> +void realRealRealGSLrng(stack *s) +{ + double b = pop<double>(s); + double a = pop<double>(s); + checkGSLrng(); + s->push(func(GSLrng,a,b)); + checkGSLerror(); +} + +template<double (*fcn)(const gsl_rng*, double, double)> +void addGSLrngRealRealFunc(symbol name, symbol arg1, symbol arg2) +{ + addFunc(GSLModule->e.ve, realRealRealGSLrng<fcn>, primReal(), name, + formal(primReal(), arg1), formal(primReal(), arg2)); +} + +template<unsigned int (*func)(const gsl_rng*, double, unsigned int)> +void intRealUIntGSLrng(stack *s) +{ + unsigned int n = unsignedcast(pop<Int>(s)); + double a = pop<double>(s); + checkGSLrng(); + s->push<Int>(func(GSLrng,a,n)); + checkGSLerror(); +} + +template<unsigned int (*fcn)(const gsl_rng*, double, unsigned int)> +void addGSLrngRealUIntFuncInt(symbol name, symbol arg1, symbol arg2) +{ + addFunc(GSLModule->e.ve, intRealUIntGSLrng<fcn>, primInt(), name, + formal(primReal(), arg1), formal(primInt(), arg2)); +} + +template<unsigned int (*func)(const gsl_rng*, unsigned int, unsigned int, + unsigned int)> +void intUIntUIntUIntGSLrng(stack *s) + { + unsigned int t = unsignedcast(pop<Int>(s)); + unsigned int n2 = unsignedcast(pop<Int>(s)); + unsigned int n1 = unsignedcast(pop<Int>(s)); + checkGSLrng(); + s->push<Int>(func(GSLrng,n1,n2,t)); + checkGSLerror(); + } + +template<unsigned int (*fcn)(const gsl_rng*, unsigned int, unsigned int, + unsigned int)> +void addGSLrngUIntUIntUIntFuncInt(symbol name, symbol arg1, symbol arg2, + symbol arg3) +{ + addFunc(GSLModule->e.ve, intUIntUIntUIntGSLrng<fcn>, primInt(), name, + formal(primInt(), arg1), formal(primInt(), arg2), + formal(primInt(), arg3)); +} + +template<const char* (*func)(const gsl_rng*)> +void stringVoidGSLrng(stack *s) +{ + checkGSLrng(); + s->push<string>(func(GSLrng)); + checkGSLerror(); +} + +template<const char* (*fcn)(const gsl_rng*)> +void addGSLrngVoidFuncString(symbol name) +{ + addFunc(GSLModule->e.ve, stringVoidGSLrng<fcn>, primString(), name); +} + +void GSLrng_gaussian(stack *s) +{ + string method = pop<string>(s,string("polar")); + double sigma = pop<double>(s,1.0); + double mu = pop<double>(s,0.0); + checkGSLrng(); + double x=mu; + if(method == "polar") x += gsl_ran_gaussian(GSLrng,sigma); + else if(method == "ziggurat") x += gsl_ran_gaussian_ziggurat(GSLrng,sigma); + else if(method == "ratio") x += gsl_ran_gaussian_ratio_method(GSLrng,sigma); + else error(GSLinvalid); + s->push(x); + checkGSLerror(); +} + +template<double (*func)(double, double)> +void realRealRealRealGSLgaussian(stack *s) +{ + double sigma = pop<double>(s,1.0); + double mu = pop<double>(s,0.0); + double x = pop<double>(s); + s->push(func(x-mu,sigma)); + checkGSLerror(); +} + +template<double (*fcn)(double, double)> +void addGSLgaussianrealRealRealRealFunc(symbol name, symbol arg1) +{ + addFunc(GSLModule->e.ve, realRealRealRealGSLgaussian<fcn>, primReal(), name, + formal(primReal(), arg1), + formal(primReal(), SYM(mu), true, false), + formal(primReal(), SYM(sigma), true, false)); +} + +template<double (*func)(double, double)> +void realRealRealRealGSLinvgaussian(stack *s) +{ + double sigma = pop<double>(s,1.0); + double mu = pop<double>(s,0.0); + double x = pop<double>(s); + s->push(func(x,sigma)+mu); + checkGSLerror(); +} + +template<double (*fcn)(double, double)> +void addGSLinvgaussianrealRealRealRealFunc(symbol name, symbol arg1) +{ + addFunc(GSLModule->e.ve, realRealRealRealGSLinvgaussian<fcn>, primReal(), + name, + formal(primReal(), arg1), + formal(primReal(), SYM(mu), true, false), + formal(primReal(), SYM(sigma), true, false)); +} + +void GSLrng_bivariate_gaussian(stack *s) +{ + double rho = pop<double>(s,0.0); + pair sigma = pop<pair>(s,pair(1.0,1.0)); + pair mu = pop<pair>(s,pair(0.0,0.0)); + checkGSLrng(); + double x,y; + gsl_ran_bivariate_gaussian(GSLrng,sigma.getx(),sigma.gety(),rho,&x,&y); + s->push(pair(x,y)+mu); + checkGSLerror(); +} + +void GSLpdf_bivariate_gaussian(stack *s) +{ + double rho = pop<double>(s,0.0); + pair sigma = pop<pair>(s,pair(1.0,1.0)); + pair mu = pop<pair>(s,pair(0.0,0.0)); + pair z = pop<pair>(s); + s->push(gsl_ran_bivariate_gaussian_pdf(z.getx()+mu.getx(),z.gety()+mu.gety(), + sigma.getx(),sigma.gety(),rho)); + checkGSLerror(); +} + +void GSLrng_levy(stack *s) +{ + double beta = pop<double>(s,0.0); + double alpha = pop<double>(s); + double c = pop<double>(s); + if((alpha<=0) || (alpha>2)) error(GSLinvalid); + if((beta<-1) || (beta>1)) error(GSLinvalid); + checkGSLrng(); + double x; + if(beta==0) x=gsl_ran_levy(GSLrng,c,alpha); + else x=gsl_ran_levy_skew(GSLrng,c,alpha,beta); + s->push(x); + checkGSLerror(); +} + +void GSLrng_gamma(stack *s) +{ + string method = pop<string>(s,string("mt")); + double b = pop<double>(s); + double a = pop<double>(s); + checkGSLrng(); + double x=0.0; + if(method == "mt") x = gsl_ran_gamma(GSLrng,a,b); + else if(method == "knuth") x = gsl_ran_gamma_knuth(GSLrng,a,b); + else error(GSLinvalid); + s->push(x); + checkGSLerror(); +} + +void GSLrng_dir2d(stack *s) +{ + string method = pop<string>(s,string("neumann")); + checkGSLrng(); + double x,y; + if(method == "neumann") gsl_ran_dir_2d(GSLrng,&x,&y); + else if(method == "trig") gsl_ran_dir_2d_trig_method(GSLrng,&x,&y); + else error(GSLinvalid); + s->push(pair(x,y)); + checkGSLerror(); +} + +void GSLrng_dir3d(stack *s) +{ + checkGSLrng(); + double x,y,z; + gsl_ran_dir_3d(GSLrng,&x,&y,&z); + s->push(triple(x,y,z)); + checkGSLerror(); +} + +void GSLrng_dir(stack *s) +{ + size_t n = (size_t) unsignedcast(pop<Int>(s)); + if(n==0) error(GSLinvalid); + checkGSLrng(); + double* p = new double[n]; + gsl_ran_dir_nd(GSLrng,n,p); + s->push<vm::array*>(copyCArray(n,p)); + delete[] p; + checkGSLerror(); +} + +void GSLrng_dirichlet(stack *s) +{ + vm::array* alpha = pop<vm::array*>(s); + size_t K = checkArray(alpha); + checkGSLrng(); + double* calpha; + copyArrayC(calpha,alpha); + double* ctheta = new double[K]; + gsl_ran_dirichlet(GSLrng,K,calpha,ctheta); + s->push<vm::array*>(copyCArray(K,ctheta)); + delete[] ctheta; + delete[] calpha; + checkGSLerror(); +} + +void GSLpdf_dirichlet(stack *s) +{ + vm::array* theta = pop<vm::array*>(s); + vm::array* alpha = pop<vm::array*>(s); + size_t K = checkArray(alpha); + if(checkArray(theta) != K) + error(GSLinvalid); + double* calpha; + copyArrayC(calpha,alpha); + double* ctheta; + copyArrayC(ctheta,theta); + s->push(gsl_ran_dirichlet_pdf(K,calpha,ctheta)); + delete[] ctheta; + delete[] calpha; + checkGSLerror(); +} + +void GSLrng_multinomial(stack *s) +{ + vm::array* p = pop<vm::array*>(s); + unsigned int N = unsignedcast(pop<Int>(s)); + size_t K = checkArray(p); + checkGSLrng(); + double* cp; + copyArrayC(cp,p); + unsigned int* cn = new unsigned int[K]; + gsl_ran_multinomial(GSLrng,K,N,cp,cn); + s->push<vm::array*>(copyCArray(K,cn)); + delete[] cn; + delete[] cp; + checkGSLerror(); +} + +void GSLpdf_multinomial(stack *s) +{ + vm::array* n = pop<vm::array*>(s); + vm::array* p = pop<vm::array*>(s); + size_t K = checkArray(p); + if(K != checkArray(n)) error(GSLinvalid); + double* cp; + copyArrayC(cp,p); + unsigned int* cn; + copyArrayC<unsigned int,Int>(cn,n,unsignedcast); + s->push(gsl_ran_multinomial_pdf(K,cp,cn)); + delete[] cn; + delete[] cp; + checkGSLerror(); +} + +// Handle GSL errors gracefully. +void GSLerrorhandler(const char *reason, const char *, int, int) +{ + if(!GSLerror) { + vm::errornothrow(reason); + GSLerror=true; + } +} + +void gen_rungsl_venv(venv &ve) +{ + GSLModule=new types::dummyRecord(SYM(gsl)); + gsl_set_error_handler(GSLerrorhandler); + + // Common functions + addGSLRealRealFunc<gsl_hypot>(SYM(hypot),SYM(x),SYM(y)); +// addGSLRealRealRealFunc<gsl_hypot3>(SYM(hypot),SYM(x),SYM(y),SYM(z)); + addGSLRealRealRealFuncInt<gsl_fcmp>(SYM(fcmp),SYM(x),SYM(y),SYM(epsilon)); + + // Airy functions + addGSLDOUBLEFunc<gsl_sf_airy_Ai>(SYM(Ai)); + addGSLDOUBLEFunc<gsl_sf_airy_Bi>(SYM(Bi)); + addGSLDOUBLEFunc<gsl_sf_airy_Ai_scaled>(SYM(Ai_scaled)); + addGSLDOUBLEFunc<gsl_sf_airy_Bi_scaled>(SYM(Bi_scaled)); + addGSLDOUBLEFunc<gsl_sf_airy_Ai_deriv>(SYM(Ai_deriv)); + addGSLDOUBLEFunc<gsl_sf_airy_Bi_deriv>(SYM(Bi_deriv)); + addGSLDOUBLEFunc<gsl_sf_airy_Ai_deriv_scaled>(SYM(Ai_deriv_scaled)); + addGSLDOUBLEFunc<gsl_sf_airy_Bi_deriv_scaled>(SYM(Bi_deriv_scaled)); + addGSLIntFunc<gsl_sf_airy_zero_Ai>(SYM(zero_Ai)); + addGSLIntFunc<gsl_sf_airy_zero_Bi>(SYM(zero_Bi)); + addGSLIntFunc<gsl_sf_airy_zero_Ai_deriv>(SYM(zero_Ai_deriv)); + addGSLIntFunc<gsl_sf_airy_zero_Bi_deriv>(SYM(zero_Bi_deriv)); + + // Bessel functions + addGSLRealFunc<gsl_sf_bessel_J0>(SYM(J0)); + addGSLRealFunc<gsl_sf_bessel_J1>(SYM(J1)); + addGSLIntRealFunc<gsl_sf_bessel_Jn>(SYM(Jn)); + addGSLRealFunc<gsl_sf_bessel_Y0>(SYM(Y0)); + addGSLRealFunc<gsl_sf_bessel_Y1>(SYM(Y1)); + addGSLIntRealFunc<gsl_sf_bessel_Yn>(SYM(Yn)); + addGSLRealFunc<gsl_sf_bessel_I0>(SYM(I0)); + addGSLRealFunc<gsl_sf_bessel_I1>(SYM(I1)); + addGSLIntRealFunc<gsl_sf_bessel_In>(SYM(I)); + addGSLRealFunc<gsl_sf_bessel_I0_scaled>(SYM(I0_scaled)); + addGSLRealFunc<gsl_sf_bessel_I1_scaled>(SYM(I1_scaled)); + addGSLIntRealFunc<gsl_sf_bessel_In_scaled>(SYM(I_scaled)); + addGSLRealFunc<gsl_sf_bessel_K0>(SYM(K0)); + addGSLRealFunc<gsl_sf_bessel_K1>(SYM(K1)); + addGSLIntRealFunc<gsl_sf_bessel_Kn>(SYM(K)); + addGSLRealFunc<gsl_sf_bessel_K0_scaled>(SYM(K0_scaled)); + addGSLRealFunc<gsl_sf_bessel_K1_scaled>(SYM(K1_scaled)); + addGSLIntRealFunc<gsl_sf_bessel_Kn_scaled>(SYM(K_scaled)); + addGSLRealFunc<gsl_sf_bessel_j0>(SYM(j0)); + addGSLRealFunc<gsl_sf_bessel_j1>(SYM(j1)); + addGSLRealFunc<gsl_sf_bessel_j2>(SYM(j2)); + addGSLIntRealFunc<gsl_sf_bessel_jl>(SYM(j),SYM(l)); + addGSLRealFunc<gsl_sf_bessel_y0>(SYM(y0)); + addGSLRealFunc<gsl_sf_bessel_y1>(SYM(y1)); + addGSLRealFunc<gsl_sf_bessel_y2>(SYM(y2)); + addGSLIntRealFunc<gsl_sf_bessel_yl>(SYM(y),SYM(l)); + addGSLRealFunc<gsl_sf_bessel_i0_scaled>(SYM(i0_scaled)); + addGSLRealFunc<gsl_sf_bessel_i1_scaled>(SYM(i1_scaled)); + addGSLRealFunc<gsl_sf_bessel_i2_scaled>(SYM(i2_scaled)); + addGSLIntRealFunc<gsl_sf_bessel_il_scaled>(SYM(i_scaled),SYM(l)); + addGSLRealFunc<gsl_sf_bessel_k0_scaled>(SYM(k0_scaled)); + addGSLRealFunc<gsl_sf_bessel_k1_scaled>(SYM(k1_scaled)); + addGSLRealFunc<gsl_sf_bessel_k2_scaled>(SYM(k2_scaled)); + addGSLIntRealFunc<gsl_sf_bessel_kl_scaled>(SYM(k_scaled),SYM(l)); + addGSLRealRealFunc<gsl_sf_bessel_Jnu>(SYM(J)); + addGSLRealRealFunc<gsl_sf_bessel_Ynu>(SYM(Y)); + addGSLRealRealFunc<gsl_sf_bessel_Inu>(SYM(I)); + addGSLRealRealFunc<gsl_sf_bessel_Inu_scaled>(SYM(I_scaled)); + addGSLRealRealFunc<gsl_sf_bessel_Knu>(SYM(K)); + addGSLRealRealFunc<gsl_sf_bessel_lnKnu>(SYM(lnK)); + addGSLRealRealFunc<gsl_sf_bessel_Knu_scaled>(SYM(K_scaled)); + addGSLIntFunc<gsl_sf_bessel_zero_J0>(SYM(zero_J0)); + addGSLIntFunc<gsl_sf_bessel_zero_J1>(SYM(zero_J1)); + addGSLRealIntFunc<gsl_sf_bessel_zero_Jnu>(SYM(zero_J)); + + // Clausen functions + addGSLRealFunc<gsl_sf_clausen>(SYM(clausen)); + + // Coulomb functions + addGSLRealRealFunc<gsl_sf_hydrogenicR_1>(SYM(hydrogenicR_1),SYM(Z),SYM(r)); + addGSLIntIntRealRealFunc<gsl_sf_hydrogenicR>(SYM(hydrogenicR),SYM(n),SYM(l), + SYM(Z),SYM(r)); + // Missing: F_L(eta,x), G_L(eta,x), C_L(eta) + + // Coupling coefficients + addGSLIntIntIntIntIntIntFunc<gsl_sf_coupling_3j>(SYM(coupling_3j),SYM(two_ja), + SYM(two_jb),SYM(two_jc), + SYM(two_ma), + SYM(two_mb),SYM(two_mc)); + addGSLIntIntIntIntIntIntFunc<gsl_sf_coupling_6j>(SYM(coupling_6j),SYM(two_ja), + SYM(two_jb),SYM(two_jc), + SYM(two_jd), + SYM(two_je),SYM(two_jf)); + addGSLIntIntIntIntIntIntIntIntIntFunc<gsl_sf_coupling_9j>(SYM(coupling_9j), + SYM(two_ja), + SYM(two_jb), + SYM(two_jc), + SYM(two_jd), + SYM(two_je), + SYM(two_jf), + SYM(two_jg), + SYM(two_jh), + SYM(two_ji)); + // Dawson function + addGSLRealFunc<gsl_sf_dawson>(SYM(dawson)); + + // Debye functions + addGSLRealFunc<gsl_sf_debye_1>(SYM(debye_1)); + addGSLRealFunc<gsl_sf_debye_2>(SYM(debye_2)); + addGSLRealFunc<gsl_sf_debye_3>(SYM(debye_3)); + addGSLRealFunc<gsl_sf_debye_4>(SYM(debye_4)); + addGSLRealFunc<gsl_sf_debye_5>(SYM(debye_5)); + addGSLRealFunc<gsl_sf_debye_6>(SYM(debye_6)); + + // Dilogarithm + addGSLRealFunc<gsl_sf_dilog>(SYM(dilog)); + // Missing: complex dilogarithm + + // Elementary operations + // we don't support errors at the moment + + // Elliptic integrals + addGSLDOUBLEFunc<gsl_sf_ellint_Kcomp>(SYM(K),SYM(k)); + addGSLDOUBLEFunc<gsl_sf_ellint_Ecomp>(SYM(E),SYM(k)); + addGSLDOUBLE2Func<gsl_sf_ellint_Pcomp>(SYM(P),SYM(k),SYM(n)); + addGSLDOUBLE2Func<gsl_sf_ellint_F>(SYM(F)); + addGSLDOUBLE2Func<gsl_sf_ellint_E>(SYM(E)); + addGSLDOUBLE3Func<gsl_sf_ellint_P>(SYM(P),SYM(phi),SYM(k),SYM(n)); + addGSLDOUBLE3Func<gsl_sf_ellint_D>(SYM(D),SYM(phi),SYM(k),SYM(n)); + addGSLDOUBLE2Func<gsl_sf_ellint_RC>(SYM(RC),SYM(x),SYM(y)); + addGSLDOUBLE3Func<gsl_sf_ellint_RD>(SYM(RD),SYM(x),SYM(y),SYM(z)); + addGSLDOUBLE3Func<gsl_sf_ellint_RF>(SYM(RF),SYM(x),SYM(y),SYM(z)); + addGSLDOUBLE4Func<gsl_sf_ellint_RJ>(SYM(RJ),SYM(x),SYM(y),SYM(z),SYM(p)); + + // Elliptic functions (Jacobi) + // to be implemented + + // Error functions + addGSLRealFunc<gsl_sf_erf>(SYM(erf)); + addGSLRealFunc<gsl_sf_erfc>(SYM(erfc)); + addGSLRealFunc<gsl_sf_log_erfc>(SYM(log_erfc)); + addGSLRealFunc<gsl_sf_erf_Z>(SYM(erf_Z)); + addGSLRealFunc<gsl_sf_erf_Q>(SYM(erf_Q)); + addGSLRealFunc<gsl_sf_hazard>(SYM(hazard)); + + // Exponential functions + addGSLRealRealFunc<gsl_sf_exp_mult>(SYM(exp_mult),SYM(x),SYM(y)); +// addGSLRealFunc<gsl_sf_expm1>(SYM(expm1)); + addGSLRealFunc<gsl_sf_exprel>(SYM(exprel)); + addGSLRealFunc<gsl_sf_exprel_2>(SYM(exprel_2)); + addGSLIntRealFunc<gsl_sf_exprel_n>(SYM(exprel),SYM(n),SYM(x)); + + // Exponential integrals + addGSLRealFunc<gsl_sf_expint_E1>(SYM(E1)); + addGSLRealFunc<gsl_sf_expint_E2>(SYM(E2)); +// addGSLIntRealFunc<gsl_sf_expint_En>(SYM(En),SYM(n),SYM(x)); + addGSLRealFunc<gsl_sf_expint_Ei>(SYM(Ei)); + addGSLRealFunc<gsl_sf_Shi>(SYM(Shi)); + addGSLRealFunc<gsl_sf_Chi>(SYM(Chi)); + addGSLRealFunc<gsl_sf_expint_3>(SYM(Ei3)); + addGSLRealFunc<gsl_sf_Si>(SYM(Si)); + addGSLRealFunc<gsl_sf_Ci>(SYM(Ci)); + addGSLRealFunc<gsl_sf_atanint>(SYM(atanint)); + + // Fermi--Dirac function + addGSLRealFunc<gsl_sf_fermi_dirac_m1>(SYM(FermiDiracM1)); + addGSLRealFunc<gsl_sf_fermi_dirac_0>(SYM(FermiDirac0)); + addGSLRealFunc<gsl_sf_fermi_dirac_1>(SYM(FermiDirac1)); + addGSLRealFunc<gsl_sf_fermi_dirac_2>(SYM(FermiDirac2)); + addGSLIntRealFunc<gsl_sf_fermi_dirac_int>(SYM(FermiDirac),SYM(j),SYM(x)); + addGSLRealFunc<gsl_sf_fermi_dirac_mhalf>(SYM(FermiDiracMHalf)); + addGSLRealFunc<gsl_sf_fermi_dirac_half>(SYM(FermiDiracHalf)); + addGSLRealFunc<gsl_sf_fermi_dirac_3half>(SYM(FermiDirac3Half)); + addGSLRealRealFunc<gsl_sf_fermi_dirac_inc_0>(SYM(FermiDiracInc0),SYM(x), + SYM(b)); + + // Gamma and beta functions + addGSLRealFunc<gsl_sf_gamma>(SYM(gamma)); + addGSLRealFunc<gsl_sf_lngamma>(SYM(lngamma)); + addGSLRealFunc<gsl_sf_gammastar>(SYM(gammastar)); + addGSLRealFunc<gsl_sf_gammainv>(SYM(gammainv)); + addGSLIntFunc<gsl_sf_fact>(SYM(fact)); + addGSLIntFunc<gsl_sf_doublefact>(SYM(doublefact)); + addGSLIntFunc<gsl_sf_lnfact>(SYM(lnfact)); + addGSLIntFunc<gsl_sf_lndoublefact>(SYM(lndoublefact)); + addGSLUnsignedUnsignedFunc<gsl_sf_choose>(SYM(choose),SYM(n),SYM(m)); + addGSLUnsignedUnsignedFunc<gsl_sf_lnchoose>(SYM(lnchoose),SYM(n),SYM(m)); + addGSLIntRealFunc<gsl_sf_taylorcoeff>(SYM(taylorcoeff),SYM(n),SYM(x)); + addGSLRealRealFunc<gsl_sf_poch>(SYM(poch),SYM(a),SYM(x)); + addGSLRealRealFunc<gsl_sf_lnpoch>(SYM(lnpoch),SYM(a),SYM(x)); + addGSLRealRealFunc<gsl_sf_pochrel>(SYM(pochrel),SYM(a),SYM(x)); + addGSLRealRealFunc<gsl_sf_gamma_inc>(SYM(gamma),SYM(a),SYM(x)); + addGSLRealRealFunc<gsl_sf_gamma_inc_Q>(SYM(gamma_Q),SYM(a),SYM(x)); + addGSLRealRealFunc<gsl_sf_gamma_inc_P>(SYM(gamma_P),SYM(a),SYM(x)); + addGSLRealRealFunc<gsl_sf_beta>(SYM(beta),SYM(a),SYM(b)); + addGSLRealRealFunc<gsl_sf_lnbeta>(SYM(lnbeta),SYM(a),SYM(b)); + addGSLRealRealRealFunc<gsl_sf_beta_inc>(SYM(beta),SYM(a),SYM(b),SYM(x)); + + // Gegenbauer functions + addGSLRealRealFunc<gsl_sf_gegenpoly_1>(SYM(gegenpoly_1),SYM(lambda),SYM(x)); + addGSLRealRealFunc<gsl_sf_gegenpoly_2>(SYM(gegenpoly_2),SYM(lambda),SYM(x)); + addGSLRealRealFunc<gsl_sf_gegenpoly_3>(SYM(gegenpoly_3),SYM(lambda),SYM(x)); + addGSLIntRealRealFunc<gsl_sf_gegenpoly_n>(SYM(gegenpoly),SYM(n),SYM(lambda), + SYM(x)); + + // Hypergeometric functions + addGSLRealRealFunc<gsl_sf_hyperg_0F1>(SYM(hy0F1),SYM(c),SYM(x)); + addGSLIntIntRealFunc<gsl_sf_hyperg_1F1_int>(SYM(hy1F1),SYM(m),SYM(n),SYM(x)); + addGSLRealRealRealFunc<gsl_sf_hyperg_1F1>(SYM(hy1F1),SYM(a),SYM(b),SYM(x)); + addGSLIntIntRealFunc<gsl_sf_hyperg_U_int>(SYM(U),SYM(m),SYM(n),SYM(x)); + addGSLRealRealRealFunc<gsl_sf_hyperg_U>(SYM(U),SYM(a),SYM(b),SYM(x)); + addGSLRealRealRealRealFunc<gsl_sf_hyperg_2F1>(SYM(hy2F1),SYM(a),SYM(b),SYM(c), + SYM(x)); + addGSLRealRealRealRealFunc<gsl_sf_hyperg_2F1_conj>(SYM(hy2F1_conj),SYM(aR), + SYM(aI),SYM(c),SYM(x)); + addGSLRealRealRealRealFunc<gsl_sf_hyperg_2F1_renorm>(SYM(hy2F1_renorm),SYM(a), + SYM(b),SYM(c),SYM(x)); + addGSLRealRealRealRealFunc<gsl_sf_hyperg_2F1_conj_renorm> + (SYM(hy2F1_conj_renorm),SYM(aR),SYM(aI),SYM(c),SYM(x)); + addGSLRealRealRealFunc<gsl_sf_hyperg_2F0>(SYM(hy2F0),SYM(a),SYM(b),SYM(x)); + + // Laguerre functions + addGSLRealRealFunc<gsl_sf_laguerre_1>(SYM(L1),SYM(a),SYM(x)); + addGSLRealRealFunc<gsl_sf_laguerre_2>(SYM(L2),SYM(a),SYM(x)); + addGSLRealRealFunc<gsl_sf_laguerre_3>(SYM(L3),SYM(a),SYM(x)); + addGSLIntRealRealFunc<gsl_sf_laguerre_n>(SYM(L),SYM(n),SYM(a),SYM(x)); + + // Lambert W functions + addGSLRealFunc<gsl_sf_lambert_W0>(SYM(W0)); + addGSLRealFunc<gsl_sf_lambert_Wm1>(SYM(Wm1)); + + // Legendre functions and spherical harmonics + addGSLRealFunc<gsl_sf_legendre_P1>(SYM(P1)); + addGSLRealFunc<gsl_sf_legendre_P2>(SYM(P2)); + addGSLRealFunc<gsl_sf_legendre_P3>(SYM(P3)); + addGSLIntRealFunc<gsl_sf_legendre_Pl>(SYM(Pl),SYM(l)); + addGSLRealFunc<gsl_sf_legendre_Q0>(SYM(Q0)); + addGSLRealFunc<gsl_sf_legendre_Q1>(SYM(Q1)); + addGSLIntRealFunc<gsl_sf_legendre_Ql>(SYM(Ql),SYM(l)); + addGSLIntIntRealFunc<gsl_sf_legendre_Plm>(SYM(Plm),SYM(l),SYM(m),SYM(x)); + addGSLIntIntRealFunc<gsl_sf_legendre_sphPlm>(SYM(sphPlm),SYM(l),SYM(m), + SYM(x)); + addGSLRealRealFunc<gsl_sf_conicalP_half>(SYM(conicalP_half),SYM(lambda), + SYM(x)); + addGSLRealRealFunc<gsl_sf_conicalP_mhalf>(SYM(conicalP_mhalf),SYM(lambda), + SYM(x)); + addGSLRealRealFunc<gsl_sf_conicalP_0>(SYM(conicalP_0),SYM(lambda),SYM(x)); + addGSLRealRealFunc<gsl_sf_conicalP_1>(SYM(conicalP_1),SYM(lambda),SYM(x)); + addGSLIntRealRealFunc<gsl_sf_conicalP_sph_reg>(SYM(conicalP_sph_reg),SYM(l), + SYM(lambda),SYM(x)); + addGSLIntRealRealFunc<gsl_sf_conicalP_cyl_reg>(SYM(conicalP_cyl_reg),SYM(m), + SYM(lambda),SYM(x)); + addGSLRealRealFunc<gsl_sf_legendre_H3d_0>(SYM(H3d0),SYM(lambda),SYM(eta)); + addGSLRealRealFunc<gsl_sf_legendre_H3d_1>(SYM(H3d1),SYM(lambda),SYM(eta)); + addGSLIntRealRealFunc<gsl_sf_legendre_H3d>(SYM(H3d),SYM(l),SYM(lambda), + SYM(eta)); + + // Logarithm and related functions + addGSLRealFunc<gsl_sf_log_abs>(SYM(logabs)); +// addGSLRealFunc<gsl_sf_log_1plusx>(SYM(log1p)); + addGSLRealFunc<gsl_sf_log_1plusx_mx>(SYM(log1pm)); + + // Matthieu functions + // to be implemented + + // Power function + addGSLRealSignedFunc<gsl_sf_pow_int>(SYM(pow),SYM(x),SYM(n)); + + // Psi (digamma) function + addGSLSignedFunc<gsl_sf_psi_int>(SYM(psi),SYM(n)); + addGSLRealFunc<gsl_sf_psi>(SYM(psi)); + addGSLRealFunc<gsl_sf_psi_1piy>(SYM(psi_1piy),SYM(y)); + addGSLSignedFunc<gsl_sf_psi_1_int>(SYM(psi1),SYM(n)); + addGSLRealFunc<gsl_sf_psi_1>(SYM(psi1),SYM(x)); + addGSLIntRealFunc<gsl_sf_psi_n>(SYM(psi),SYM(n),SYM(x)); + + // Synchrotron functions + addGSLRealFunc<gsl_sf_synchrotron_1>(SYM(synchrotron_1)); + addGSLRealFunc<gsl_sf_synchrotron_2>(SYM(synchrotron_2)); + + // Transport functions + addGSLRealFunc<gsl_sf_transport_2>(SYM(transport_2)); + addGSLRealFunc<gsl_sf_transport_3>(SYM(transport_3)); + addGSLRealFunc<gsl_sf_transport_4>(SYM(transport_4)); + addGSLRealFunc<gsl_sf_transport_5>(SYM(transport_5)); + + // Trigonometric functions + addGSLRealFunc<gsl_sf_sinc>(SYM(sinc)); + addGSLRealFunc<gsl_sf_lnsinh>(SYM(lnsinh)); + addGSLRealFunc<gsl_sf_lncosh>(SYM(lncosh)); + + // Zeta functions + addGSLSignedFunc<gsl_sf_zeta_int>(SYM(zeta),SYM(n)); + addGSLRealFunc<gsl_sf_zeta>(SYM(zeta),SYM(s)); + addGSLSignedFunc<gsl_sf_zetam1_int>(SYM(zetam1),SYM(n)); + addGSLRealFunc<gsl_sf_zetam1>(SYM(zetam1),SYM(s)); + addGSLRealRealFunc<gsl_sf_hzeta>(SYM(hzeta),SYM(s),SYM(q)); + addGSLSignedFunc<gsl_sf_eta_int>(SYM(eta),SYM(n)); + addGSLRealFunc<gsl_sf_eta>(SYM(eta),SYM(s)); + + // Random number generation + gsl_rng_env_setup(); + addFunc(GSLModule->e.ve,GSLrngInit,primVoid(),SYM(rng_init), + formal(primString(),SYM(name),true,false)); + addFunc(GSLModule->e.ve,GSLrngList,stringArray(),SYM(rng_list)); + addFunc(GSLModule->e.ve,GSLrngSet,primVoid(),SYM(rng_set), + formal(primInt(),SYM(seed),true,false)); + addGSLrngVoidFuncString<gsl_rng_name>(SYM(rng_name)); + addGSLrngVoidFuncInt<gsl_rng_min>(SYM(rng_min)); + addGSLrngVoidFuncInt<gsl_rng_max>(SYM(rng_max)); + addGSLrngVoidFuncInt<gsl_rng_get>(SYM(rng_get)); + addGSLrngULongFuncInt<gsl_rng_uniform_int>(SYM(rng_uniform_int),SYM(n)); + addGSLrngVoidFunc<gsl_rng_uniform>(SYM(rng_uniform)); + addGSLrngVoidFunc<gsl_rng_uniform_pos>(SYM(rng_uniform_pos)); + + // Gaussian distribution + addFunc(GSLModule->e.ve,GSLrng_gaussian,primReal(),SYM(rng_gaussian), + formal(primReal(),SYM(mu),true,false), + formal(primReal(),SYM(sigma),true,false), + formal(primString(),SYM(method),true,false)); + addGSLgaussianrealRealRealRealFunc<gsl_ran_gaussian_pdf>(SYM(pdf_gaussian), + SYM(x)); + addGSLgaussianrealRealRealRealFunc<gsl_cdf_gaussian_P>(SYM(cdf_gaussian_P), + SYM(x)); + addGSLgaussianrealRealRealRealFunc<gsl_cdf_gaussian_Q>(SYM(cdf_gaussian_Q), + SYM(x)); + addGSLinvgaussianrealRealRealRealFunc<gsl_cdf_gaussian_Pinv> + (SYM(cdf_gaussian_Pinv),SYM(x)); + addGSLinvgaussianrealRealRealRealFunc<gsl_cdf_gaussian_Qinv> + (SYM(cdf_gaussian_Qinv),SYM(x)); + + // Gaussian tail distribution + addGSLrngRealRealFunc<gsl_ran_gaussian_tail>(SYM(rng_gaussian_tail),SYM(a), + SYM(sigma)); + addGSLRealRealRealFunc<gsl_ran_gaussian_tail_pdf>(SYM(pdf_gaussian_tail), + SYM(x),SYM(a),SYM(sigma)); + + // Bivariate Gaussian distribution + addFunc(GSLModule->e.ve,GSLrng_bivariate_gaussian,primPair(), + SYM(rng_bivariate_gaussian), + formal(primPair(),SYM(mu),true,true), + formal(primPair(),SYM(sigma),true,true), + formal(primReal(),SYM(rho),true,false)); + addFunc(GSLModule->e.ve,GSLpdf_bivariate_gaussian,primReal(), + SYM(pdf_bivariate_gaussian), + formal(primPair(),SYM(z),false,true), + formal(primPair(),SYM(mu),true,true), + formal(primPair(),SYM(sigma),true,true), + formal(primReal(),SYM(rho),true,false)); + +#define addGSLrealdist1param(NAME,ARG) \ + addGSLrngRealFunc<gsl_ran_##NAME> \ + (SYM(rng_##NAME),SYM(ARG)); \ + addGSLRealRealFunc<gsl_ran_##NAME##_pdf> \ + (SYM(pdf_##NAME),SYM(x),SYM(ARG)); \ + addGSLRealRealFunc<gsl_cdf_##NAME##_P> \ + (SYM(cdf_##NAME##_P),SYM(x),SYM(ARG)); \ + addGSLRealRealFunc<gsl_cdf_##NAME##_Q> \ + (SYM(cdf_##NAME##_Q),SYM(x),SYM(ARG)); \ + addGSLRealRealFunc<gsl_cdf_##NAME##_Pinv> \ + (SYM(cdf_##NAME##_Pinv),SYM(P),SYM(ARG)); \ + addGSLRealRealFunc<gsl_cdf_##NAME##_Qinv> \ + (SYM(cdf_##NAME##_Qinv),SYM(Q),SYM(ARG)) + + // Exponential, Laplace, Cauchy, Rayleigh, Chi-squared, t, + // and Logistic distribution + addGSLrealdist1param(exponential,mu); + addGSLrealdist1param(laplace,a); + addGSLrealdist1param(cauchy,a); + addGSLrealdist1param(rayleigh,mu); + addGSLrealdist1param(chisq,mu); + addGSLrealdist1param(tdist,mu); + addGSLrealdist1param(logistic,mu); +#undef addGSLrealdist1param + +#define addGSLrealdist2param(NAME,ARG1,ARG2) \ + addGSLrngRealRealFunc<gsl_ran_##NAME> \ + (SYM(rng_##NAME),SYM(ARG1),SYM(ARG2)); \ + addGSLRealRealRealFunc<gsl_ran_##NAME##_pdf> \ + (SYM(pdf_##NAME),SYM(x),SYM(ARG1),SYM(ARG2)); \ + addGSLRealRealRealFunc<gsl_cdf_##NAME##_P> \ + (SYM(cdf_##NAME##_P),SYM(x),SYM(ARG1),SYM(ARG2)); \ + addGSLRealRealRealFunc<gsl_cdf_##NAME##_Q> \ + (SYM(cdf_##NAME##_Q),SYM(x),SYM(ARG1),SYM(ARG2)); \ + addGSLRealRealRealFunc<gsl_cdf_##NAME##_Pinv> \ + (SYM(cdf_##NAME##_Pinv),SYM(P),SYM(ARG1),SYM(ARG2)); \ + addGSLRealRealRealFunc<gsl_cdf_##NAME##_Qinv> \ + (SYM(cdf_##NAME##_Qinv),SYM(Q),SYM(ARG1),SYM(ARG2)) + + // Uniform, log-normal, F, Beta, Pareto, Weibull, Type-1 Gumbel, + // and Type-2 Gumbel distribution + addGSLrealdist2param(flat,a,b); + addGSLrealdist2param(lognormal,zeta,sigma); + addGSLrealdist2param(fdist,nu1,nu2); + addGSLrealdist2param(beta,a,b); + addGSLrealdist2param(pareto,a,b); + addGSLrealdist2param(weibull,a,b); + addGSLrealdist2param(gumbel1,a,b); + addGSLrealdist2param(gumbel2,a,b); +#undef addGSLrealdist2param + + // Exponential power distribution + addGSLrngRealRealFunc<gsl_ran_exppow> + (SYM(rng_exppow),SYM(a),SYM(b)); + addGSLRealRealRealFunc<gsl_ran_exppow_pdf> + (SYM(pdf_exppow),SYM(x),SYM(a),SYM(b)); + addGSLRealRealRealFunc<gsl_cdf_exppow_P> + (SYM(cdf_exppow_P),SYM(x),SYM(a),SYM(b)); + addGSLRealRealRealFunc<gsl_cdf_exppow_Q> + (SYM(cdf_exppow_Q),SYM(x),SYM(a),SYM(b)); + + // Exponential power distribution + addGSLrngRealRealFunc<gsl_ran_rayleigh_tail> + (SYM(rng_rayleigh_tail),SYM(a),SYM(sigma)); + addGSLRealRealRealFunc<gsl_ran_rayleigh_tail_pdf> + (SYM(pdf_rayleigh_tail),SYM(x),SYM(a),SYM(sigma)); + + // Landau distribution + addGSLrngVoidFunc<gsl_ran_landau>(SYM(rng_landau)); + addGSLRealFunc<gsl_ran_landau_pdf>(SYM(pdf_landau),SYM(x)); + + // Levy skwew alpha-stable distribution + addFunc(GSLModule->e.ve,GSLrng_levy,primReal(),SYM(rng_levy), + formal(primReal(),SYM(c)), + formal(primReal(),SYM(alpha)), + formal(primReal(),SYM(beta),true,false)); + + // Gamma distribution + addFunc(GSLModule->e.ve,GSLrng_gamma,primReal(),SYM(rng_gamma), + formal(primReal(),SYM(a)), + formal(primReal(),SYM(b)), + formal(primString(),SYM(method),true,false)); + addGSLRealRealRealFunc<gsl_ran_gamma_pdf> + (SYM(pdf_gamma),SYM(x),SYM(a),SYM(b)); + addGSLRealRealRealFunc<gsl_cdf_gamma_P> + (SYM(cdf_gamma_P),SYM(x),SYM(a),SYM(b)); + addGSLRealRealRealFunc<gsl_cdf_gamma_Q> + (SYM(cdf_gamma_Q),SYM(x),SYM(a),SYM(b)); + addGSLRealRealRealFunc<gsl_cdf_gamma_Pinv> + (SYM(cdf_gamma_Pinv),SYM(P),SYM(a),SYM(b)); + addGSLRealRealRealFunc<gsl_cdf_gamma_Qinv> + (SYM(cdf_gamma_Qinv),SYM(Q),SYM(a),SYM(b)); + + // Sperical distributions + addFunc(GSLModule->e.ve,GSLrng_dir2d,primPair(),SYM(rng_dir2d), + formal(primString(),SYM(method),true,false)); + addFunc(GSLModule->e.ve,GSLrng_dir3d,primTriple(),SYM(rng_dir3d)); + addFunc(GSLModule->e.ve,GSLrng_dir,realArray(),SYM(rng_dir), + formal(primInt(),SYM(n))); + + // Dirirchlet distribution + addFunc(GSLModule->e.ve,GSLrng_dirichlet,realArray(),SYM(rng_dirichlet), + formal(realArray(),SYM(alpha))); + addFunc(GSLModule->e.ve,GSLpdf_dirichlet,primReal(),SYM(pdf_dirichlet), + formal(realArray(),SYM(alpha)), + formal(realArray(),SYM(theta))); + + // General discrete distributions + // to be implemented + +#define addGSLdiscdist1param(NAME,ARG,TYPE) \ + addGSLrng##TYPE##FuncInt<gsl_ran_##NAME> \ + (SYM(rng_##NAME),SYM(ARG)); \ + addGSLUInt##TYPE##Func<gsl_ran_##NAME##_pdf> \ + (SYM(pdf_##NAME),SYM(k),SYM(ARG)); \ + addGSLUInt##TYPE##Func<gsl_cdf_##NAME##_P> \ + (SYM(cdf_##NAME##_P),SYM(k),SYM(ARG)); \ + addGSLUInt##TYPE##Func<gsl_cdf_##NAME##_Q> \ + (SYM(cdf_##NAME##_Q),SYM(k),SYM(ARG)) + + // Poisson, geometric distributions + addGSLdiscdist1param(poisson,mu,Real); + addGSLdiscdist1param(geometric,p,Real); +#undef addGSLdiscdist1param + +#define addGSLdiscdist2param(NAME,ARG1,TYPE1,ARG2,TYPE2) \ + addGSLrng##TYPE1##TYPE2##FuncInt<gsl_ran_##NAME> \ + (SYM(rng_##NAME),SYM(ARG1),SYM(ARG2)); \ + addGSLUInt##TYPE1##TYPE2##Func<gsl_ran_##NAME##_pdf> \ + (SYM(pdf_##NAME),SYM(k),SYM(ARG1),SYM(ARG2)); \ + addGSLUInt##TYPE1##TYPE2##Func<gsl_cdf_##NAME##_P> \ + (SYM(cdf_##NAME##_P),SYM(k),SYM(ARG1),SYM(ARG2)); \ + addGSLUInt##TYPE1##TYPE2##Func<gsl_cdf_##NAME##_Q> \ + (SYM(cdf_##NAME##_Q),SYM(k),SYM(ARG1),SYM(ARG2)) + + // Binomial, negative binomial distributions + addGSLdiscdist2param(binomial,p,Real,n,UInt); + addGSLdiscdist2param(negative_binomial,p,Real,n,Real); +#undef addGSLdiscdist2param + + // Logarithmic distribution + addGSLrngRealFuncInt<gsl_ran_logarithmic>(SYM(rng_logarithmic),SYM(p)); + addGSLUIntRealFunc<gsl_ran_logarithmic_pdf>(SYM(pdf_logarithmic),SYM(k), + SYM(p)); + + // Bernoulli distribution + addGSLrngRealFuncInt<gsl_ran_bernoulli>(SYM(rng_bernoulli),SYM(p)); + addGSLUIntRealFunc<gsl_ran_bernoulli_pdf>(SYM(pdf_bernoulli),SYM(k),SYM(p)); + + // Multinomial distribution + addFunc(GSLModule->e.ve,GSLrng_multinomial,IntArray(),SYM(rng_multinomial), + formal(primInt(),SYM(n)), + formal(realArray(),SYM(p))); + addFunc(GSLModule->e.ve,GSLpdf_multinomial,primReal(),SYM(pdf_multinomial), + formal(realArray(),SYM(p)), + formal(IntArray(),SYM(n))); + + // Hypergeometric distribution + addGSLrngUIntUIntUIntFuncInt<gsl_ran_hypergeometric> + (SYM(rng_hypergeometric),SYM(n1),SYM(n2),SYM(t)); + addGSLUIntUIntUIntUIntFunc<gsl_ran_hypergeometric_pdf> + (SYM(pdf_hypergeometric),SYM(k),SYM(n1),SYM(n2),SYM(t)); + addGSLUIntUIntUIntUIntFunc<gsl_cdf_hypergeometric_P> + (SYM(cdf_hypergeometric_P),SYM(k),SYM(n1),SYM(n2),SYM(t)); + addGSLUIntUIntUIntUIntFunc<gsl_cdf_hypergeometric_Q> + (SYM(cdf_hypergeometric_Q),SYM(k),SYM(n1),SYM(n2),SYM(t)); +} + +} // namespace trans + +#endif diff --git a/Build/source/utils/asymptote/item.h b/Build/source/utils/asymptote/item.h index 27b8787df9d..9a42f8bf2e2 100644 --- a/Build/source/utils/asymptote/item.h +++ b/Build/source/utils/asymptote/item.h @@ -64,6 +64,8 @@ public: item& operator= (int a) { i=a; return *this; } + item& operator= (unsigned int a) + { i=a; return *this; } item& operator= (Int a) { i=a; return *this; } item& operator= (double a) @@ -108,6 +110,8 @@ public: item& operator= (int a) { kind=&typeid(Int); i=a; return *this; } + item& operator= (unsigned int a) + { kind=&typeid(Int); i=a; return *this; } item& operator= (Int a) { kind=&typeid(Int); i=a; return *this; } item& operator= (double a) diff --git a/Build/source/utils/asymptote/main.cc b/Build/source/utils/asymptote/main.cc index b17d4583564..bd07c34a537 100644 --- a/Build/source/utils/asymptote/main.cc +++ b/Build/source/utils/asymptote/main.cc @@ -164,6 +164,10 @@ void *asymain(void *A) int main(int argc, char *argv[]) { +#ifdef HAVE_LIBGSL + unsetenv("GSL_RNG_SEED"); + unsetenv("GSL_RNG_TYPE"); +#endif setsignal(signalHandler); try { diff --git a/Build/source/utils/asymptote/prc/writePRC.cc b/Build/source/utils/asymptote/prc/writePRC.cc index 1f3175053fc..8f1d7370f33 100644 --- a/Build/source/utils/asymptote/prc/writePRC.cc +++ b/Build/source/utils/asymptote/prc/writePRC.cc @@ -970,7 +970,9 @@ uint32_t makePRCID() void writeUnit(PRCbitStream &out,bool fromCAD,double unit) { - out << fromCAD << unit; + static const double inches=72; + static const double cm=inches/2.54; + out << fromCAD << 10.0/cm; // Use bp. } void writeEmptyMarkups(PRCbitStream &out) diff --git a/Build/source/utils/asymptote/runarray.cc b/Build/source/utils/asymptote/runarray.cc index 5ba123e8616..97df85c93d1 100644 --- a/Build/source/utils/asymptote/runarray.cc +++ b/Build/source/utils/asymptote/runarray.cc @@ -51,52 +51,6 @@ array *copyArray(array *a); array *copyArray2(array *a); array *copyArray3(array *a); -inline size_t checkdimension(const array *a, size_t dim) -{ - size_t size=checkArray(a); - if(dim && size != dim) { - ostringstream buf; - buf << "array of length " << dim << " expected"; - error(buf); - } - return size; -} - -template<class T> -void copyArrayC(T* &dest, const array *a, size_t dim=0, - GCPlacement placement=NoGC) -{ - size_t size=checkdimension(a,dim); - dest=(placement == NoGC) ? new T[size] : new(placement) T[size]; - for(size_t i=0; i < size; i++) - dest[i]=read<T>(a,i); -} - -template<class T> -void copyArray2C(T* &dest, const array *a, bool square=true, size_t dim2=0, - GCPlacement placement=NoGC) -{ - size_t n=checkArray(a); - size_t m=(square || n == 0) ? n : checkArray(read<array*>(a,0)); - if(n > 0 && dim2 && m != dim2) { - ostringstream buf; - buf << "second matrix dimension must be " << dim2; - error(buf); - } - - dest=(placement == NoGC) ? new T[n*m] : new(placement) T[n*m]; - for(size_t i=0; i < n; i++) { - array *ai=read<array*>(a,i); - size_t aisize=checkArray(ai); - if(aisize == m) { - T *desti=dest+i*m; - for(size_t j=0; j < m; j++) - desti[j]=read<T>(ai,j); - } else - error(square ? "matrix must be square" : "matrix must be rectangular"); - } -} - double *copyTripleArray2Components(array *a, bool square=true, size_t dim2=0, GCPlacement placement=NoGC); } @@ -536,8 +490,10 @@ void checkSize(Int n, Int depth) +#ifndef NOSYM #include "runarray.symbols.h" +#endif namespace run { // Create an empty array. #line 451 "runarray.in" @@ -1044,22 +1000,46 @@ void arrayFunction(stack *Stack) #line 809 "runarray.in" void arraySort(stack *Stack) { - callable * f=vm::pop<callable *>(Stack); + callable * less=vm::pop<callable *>(Stack); array * a=vm::pop<array *>(Stack); #line 810 "runarray.in" array *c=copyArray(a); - compareFunc=f; + compareFunc=less; FuncStack=Stack; stable_sort(c->begin(),c->end(),compareFunction); {Stack->push<array*>(c); return;} } #line 818 "runarray.in" +void arraySearch(stack *Stack) +{ + callable * less=vm::pop<callable *>(Stack); + item key=vm::pop(Stack); + array * a=vm::pop<array *>(Stack); +#line 819 "runarray.in" + size_t size=a->size(); + compareFunc=less; + FuncStack=Stack; + if(size == 0 || compareFunction(key,(*a)[0])) {Stack->push<Int>(-1); return;} + size_t u=size-1; + if(!compareFunction(key,(*a)[u])) {Stack->push<Int>(Intcast(u)); return;} + size_t l=0; + + while (l < u) { + size_t i=(l+u)/2; + if(compareFunction(key,(*a)[i])) u=i; + else if(compareFunction(key,(*a)[i+1])) {Stack->push<Int>(Intcast(i)); return;} + else l=i+1; + } + {Stack->push<Int>(0); return;} +} + +#line 837 "runarray.in" // bool all(boolarray *a); -void gen_runarray38(stack *Stack) +void gen_runarray39(stack *Stack) { boolarray * a=vm::pop<boolarray *>(Stack); -#line 819 "runarray.in" +#line 838 "runarray.in" size_t size=checkArray(a); bool c=true; for(size_t i=0; i < size; i++) @@ -1067,12 +1047,12 @@ void gen_runarray38(stack *Stack) {Stack->push<bool>(c); return;} } -#line 827 "runarray.in" +#line 846 "runarray.in" // boolarray* !(boolarray* a); -void gen_runarray39(stack *Stack) +void gen_runarray40(stack *Stack) { boolarray* a=vm::pop<boolarray*>(Stack); -#line 828 "runarray.in" +#line 847 "runarray.in" size_t size=checkArray(a); array *c=new array(size); for(size_t i=0; i < size; i++) @@ -1080,12 +1060,12 @@ void gen_runarray39(stack *Stack) {Stack->push<boolarray*>(c); return;} } -#line 836 "runarray.in" +#line 855 "runarray.in" // Int sum(boolarray *a); -void gen_runarray40(stack *Stack) +void gen_runarray41(stack *Stack) { boolarray * a=vm::pop<boolarray *>(Stack); -#line 837 "runarray.in" +#line 856 "runarray.in" size_t size=checkArray(a); Int sum=0; for(size_t i=0; i < size; i++) @@ -1093,19 +1073,19 @@ void gen_runarray40(stack *Stack) {Stack->push<Int>(sum); return;} } -#line 845 "runarray.in" +#line 864 "runarray.in" void arrayCopy(stack *Stack) { array * a=vm::pop<array *>(Stack); -#line 846 "runarray.in" +#line 865 "runarray.in" {Stack->push<array*>(copyArray(a)); return;} } -#line 850 "runarray.in" +#line 869 "runarray.in" void arrayConcat(stack *Stack) { array * a=vm::pop<array *>(Stack); -#line 851 "runarray.in" +#line 870 "runarray.in" // a is an array of arrays to be concatenated together. // The signature is // T[] concat(... T[][] a); @@ -1132,27 +1112,27 @@ void arrayConcat(stack *Stack) {Stack->push<array*>(result); return;} } -#line 878 "runarray.in" +#line 897 "runarray.in" void array2Copy(stack *Stack) { array * a=vm::pop<array *>(Stack); -#line 879 "runarray.in" +#line 898 "runarray.in" {Stack->push<array*>(copyArray2(a)); return;} } -#line 883 "runarray.in" +#line 902 "runarray.in" void array3Copy(stack *Stack) { array * a=vm::pop<array *>(Stack); -#line 884 "runarray.in" +#line 903 "runarray.in" {Stack->push<array*>(copyArray3(a)); return;} } -#line 888 "runarray.in" +#line 907 "runarray.in" void array2Transpose(stack *Stack) { array * a=vm::pop<array *>(Stack); -#line 889 "runarray.in" +#line 908 "runarray.in" size_t asize=checkArray(a); array *c=new array(0); for(size_t i=0; i < asize; i++) { @@ -1179,12 +1159,12 @@ void array2Transpose(stack *Stack) // permutation (021 or 120, etc; original is 012). // Transpose by sending respective members to the permutated locations: // return the array obtained by putting a[i][j][k] into position perm{ijk}. -#line 916 "runarray.in" +#line 935 "runarray.in" void array3Transpose(stack *Stack) { array * perm=vm::pop<array *>(Stack); array * a=vm::pop<array *>(Stack); -#line 917 "runarray.in" +#line 936 "runarray.in" const size_t DIM=3; if(checkArray(perm) != DIM) { @@ -1268,13 +1248,13 @@ void array3Transpose(stack *Stack) // In a boolean array, find the index of the nth true value or -1 if not found // If n is negative, search backwards. -#line 1001 "runarray.in" +#line 1020 "runarray.in" // Int find(boolarray *a, Int n=1); -void gen_runarray47(stack *Stack) +void gen_runarray48(stack *Stack) { Int n=vm::pop<Int>(Stack,1); boolarray * a=vm::pop<boolarray *>(Stack); -#line 1002 "runarray.in" +#line 1021 "runarray.in" size_t size=checkArray(a); Int j=-1; if(n > 0) @@ -1292,13 +1272,13 @@ void gen_runarray47(stack *Stack) // construct vector obtained by replacing those elements of b for which the // corresponding elements of a are false by the corresponding element of c. -#line 1020 "runarray.in" +#line 1039 "runarray.in" void arrayConditional(stack *Stack) { array * c=vm::pop<array *>(Stack); array * b=vm::pop<array *>(Stack); array * a=vm::pop<array *>(Stack); -#line 1021 "runarray.in" +#line 1040 "runarray.in" size_t size=checkArray(a); array *r=new array(size); if(b && c) { @@ -1322,22 +1302,22 @@ void arrayConditional(stack *Stack) } // Return an n x n identity matrix. -#line 1045 "runarray.in" +#line 1064 "runarray.in" // realarray2* identity(Int n); -void gen_runarray49(stack *Stack) +void gen_runarray50(stack *Stack) { Int n=vm::pop<Int>(Stack); -#line 1046 "runarray.in" +#line 1065 "runarray.in" {Stack->push<realarray2*>(Identity(n)); return;} } // Return the inverse of an n x n matrix a using Gauss-Jordan elimination. -#line 1051 "runarray.in" +#line 1070 "runarray.in" // realarray2* inverse(realarray2 *a); -void gen_runarray50(stack *Stack) +void gen_runarray51(stack *Stack) { realarray2 * a=vm::pop<realarray2 *>(Stack); -#line 1052 "runarray.in" +#line 1071 "runarray.in" a=copyArray2(a); size_t n=checkArray(a); checkSquare(a); @@ -1430,14 +1410,14 @@ void gen_runarray50(stack *Stack) // Solve the linear equation ax=b by LU decomposition, returning the // solution x, where a is an n x n matrix and b is an array of length n. // If no solution exists, return an empty array. -#line 1145 "runarray.in" +#line 1164 "runarray.in" // realarray* solve(realarray2 *a, realarray *b, bool warn=true); -void gen_runarray51(stack *Stack) +void gen_runarray52(stack *Stack) { bool warn=vm::pop<bool>(Stack,true); realarray * b=vm::pop<realarray *>(Stack); realarray2 * a=vm::pop<realarray2 *>(Stack); -#line 1146 "runarray.in" +#line 1165 "runarray.in" size_t n=checkArray(a); if(n == 0) {Stack->push<realarray*>(new array(0)); return;} @@ -1489,14 +1469,14 @@ void gen_runarray51(stack *Stack) // Solve the linear equation ax=b by LU decomposition, returning the // solution x, where a is an n x n matrix and b is an n x m matrix. // If no solution exists, return an empty array. -#line 1198 "runarray.in" +#line 1217 "runarray.in" // realarray2* solve(realarray2 *a, realarray2 *b, bool warn=true); -void gen_runarray52(stack *Stack) +void gen_runarray53(stack *Stack) { bool warn=vm::pop<bool>(Stack,true); realarray2 * b=vm::pop<realarray2 *>(Stack); realarray2 * a=vm::pop<realarray2 *>(Stack); -#line 1199 "runarray.in" +#line 1218 "runarray.in" size_t n=checkArray(a); if(n == 0) {Stack->push<realarray2*>(new array(0)); return;} @@ -1558,12 +1538,12 @@ void gen_runarray52(stack *Stack) } // Compute the determinant of an n x n matrix. -#line 1261 "runarray.in" +#line 1280 "runarray.in" // real determinant(realarray2 *a); -void gen_runarray53(stack *Stack) +void gen_runarray54(stack *Stack) { realarray2 * a=vm::pop<realarray2 *>(Stack); -#line 1262 "runarray.in" +#line 1281 "runarray.in" real *A; copyArray2C(A,a); size_t n=checkArray(a); @@ -1578,13 +1558,13 @@ void gen_runarray53(stack *Stack) {Stack->push<real>(det); return;} } -#line 1277 "runarray.in" +#line 1296 "runarray.in" // realarray* *(realarray2 *a, realarray *b); -void gen_runarray54(stack *Stack) +void gen_runarray55(stack *Stack) { realarray * b=vm::pop<realarray *>(Stack); realarray2 * a=vm::pop<realarray2 *>(Stack); -#line 1278 "runarray.in" +#line 1297 "runarray.in" size_t n=checkArray(a); size_t m=checkArray(b); array *c=new array(n); @@ -1602,13 +1582,13 @@ void gen_runarray54(stack *Stack) {Stack->push<realarray*>(c); return;} } -#line 1296 "runarray.in" +#line 1315 "runarray.in" // realarray* *(realarray *a, realarray2 *b); -void gen_runarray55(stack *Stack) +void gen_runarray56(stack *Stack) { realarray2 * b=vm::pop<realarray2 *>(Stack); realarray * a=vm::pop<realarray *>(Stack); -#line 1297 "runarray.in" +#line 1316 "runarray.in" size_t n=checkArray(a); if(n != checkArray(b)) error(incommensurate); real *A; @@ -1636,53 +1616,53 @@ void gen_runarray55(stack *Stack) {Stack->push<realarray*>(c); return;} } -#line 1325 "runarray.in" +#line 1344 "runarray.in" // Intarray2* *(Intarray2 *a, Intarray2 *b); -void gen_runarray56(stack *Stack) +void gen_runarray57(stack *Stack) { Intarray2 * b=vm::pop<Intarray2 *>(Stack); Intarray2 * a=vm::pop<Intarray2 *>(Stack); -#line 1326 "runarray.in" +#line 1345 "runarray.in" {Stack->push<Intarray2*>(mult<Int>(a,b)); return;} } -#line 1330 "runarray.in" +#line 1349 "runarray.in" // realarray2* *(realarray2 *a, realarray2 *b); -void gen_runarray57(stack *Stack) +void gen_runarray58(stack *Stack) { realarray2 * b=vm::pop<realarray2 *>(Stack); realarray2 * a=vm::pop<realarray2 *>(Stack); -#line 1331 "runarray.in" +#line 1350 "runarray.in" {Stack->push<realarray2*>(mult<real>(a,b)); return;} } -#line 1335 "runarray.in" +#line 1354 "runarray.in" // pairarray2* *(pairarray2 *a, pairarray2 *b); -void gen_runarray58(stack *Stack) +void gen_runarray59(stack *Stack) { pairarray2 * b=vm::pop<pairarray2 *>(Stack); pairarray2 * a=vm::pop<pairarray2 *>(Stack); -#line 1336 "runarray.in" +#line 1355 "runarray.in" {Stack->push<pairarray2*>(mult<pair>(a,b)); return;} } -#line 1340 "runarray.in" +#line 1359 "runarray.in" // triple *(realarray2 *t, triple v); -void gen_runarray59(stack *Stack) +void gen_runarray60(stack *Stack) { triple v=vm::pop<triple>(Stack); realarray2 * t=vm::pop<realarray2 *>(Stack); -#line 1341 "runarray.in" +#line 1360 "runarray.in" {Stack->push<triple>(*t*v); return;} } -#line 1345 "runarray.in" +#line 1364 "runarray.in" // pair project(triple v, realarray2 *t); -void gen_runarray60(stack *Stack) +void gen_runarray61(stack *Stack) { realarray2 * t=vm::pop<realarray2 *>(Stack); triple v=vm::pop<triple>(Stack); -#line 1346 "runarray.in" +#line 1365 "runarray.in" size_t n=checkArray(t); if(n != 4) error(incommensurate); array *t0=read<array*>(t,0); @@ -1707,13 +1687,13 @@ void gen_runarray60(stack *Stack) } // Compute the dot product of vectors a and b. -#line 1371 "runarray.in" +#line 1390 "runarray.in" // real dot(realarray *a, realarray *b); -void gen_runarray61(stack *Stack) +void gen_runarray62(stack *Stack) { realarray * b=vm::pop<realarray *>(Stack); realarray * a=vm::pop<realarray *>(Stack); -#line 1372 "runarray.in" +#line 1391 "runarray.in" size_t n=checkArrays(a,b); real sum=0.0; for(size_t i=0; i < n; ++i) @@ -1722,13 +1702,13 @@ void gen_runarray61(stack *Stack) } // Compute the complex dot product of vectors a and b. -#line 1381 "runarray.in" +#line 1400 "runarray.in" // pair dot(pairarray *a, pairarray *b); -void gen_runarray62(stack *Stack) +void gen_runarray63(stack *Stack) { pairarray * b=vm::pop<pairarray *>(Stack); pairarray * a=vm::pop<pairarray *>(Stack); -#line 1382 "runarray.in" +#line 1401 "runarray.in" size_t n=checkArrays(a,b); pair sum=zero; for(size_t i=0; i < n; ++i) @@ -1743,15 +1723,15 @@ void gen_runarray62(stack *Stack) // [ a[2] b[2] c[2] ] // [ ... ] // [ c[n-1] a[n-1] b[n-1] ] -#line 1397 "runarray.in" +#line 1416 "runarray.in" // realarray* tridiagonal(realarray *a, realarray *b, realarray *c, realarray *f); -void gen_runarray63(stack *Stack) +void gen_runarray64(stack *Stack) { realarray * f=vm::pop<realarray *>(Stack); realarray * c=vm::pop<realarray *>(Stack); realarray * b=vm::pop<realarray *>(Stack); realarray * a=vm::pop<realarray *>(Stack); -#line 1398 "runarray.in" +#line 1417 "runarray.in" size_t n=checkArrays(a,b); checkEqual(n,checkArray(c)); checkEqual(n,checkArray(f)); @@ -1848,16 +1828,16 @@ void gen_runarray63(stack *Stack) } // Root solve by Newton-Raphson -#line 1495 "runarray.in" +#line 1514 "runarray.in" // real newton(Int iterations=100, callableReal *f, callableReal *fprime, real x, bool verbose=false); -void gen_runarray64(stack *Stack) +void gen_runarray65(stack *Stack) { bool verbose=vm::pop<bool>(Stack,false); real x=vm::pop<real>(Stack); callableReal * fprime=vm::pop<callableReal *>(Stack); callableReal * f=vm::pop<callableReal *>(Stack); Int iterations=vm::pop<Int>(Stack,100); -#line 1497 "runarray.in" +#line 1516 "runarray.in" static const real fuzz=1000.0*DBL_EPSILON; Int i=0; size_t oldPrec=0; @@ -1903,9 +1883,9 @@ void gen_runarray64(stack *Stack) // Root solve by Newton-Raphson bisection // cf. routine rtsafe (Press et al., Numerical Recipes, 1991). -#line 1543 "runarray.in" +#line 1562 "runarray.in" // real newton(Int iterations=100, callableReal *f, callableReal *fprime, real x1, real x2, bool verbose=false); -void gen_runarray65(stack *Stack) +void gen_runarray66(stack *Stack) { bool verbose=vm::pop<bool>(Stack,false); real x2=vm::pop<real>(Stack); @@ -1913,7 +1893,7 @@ void gen_runarray65(stack *Stack) callableReal * fprime=vm::pop<callableReal *>(Stack); callableReal * f=vm::pop<callableReal *>(Stack); Int iterations=vm::pop<Int>(Stack,100); -#line 1545 "runarray.in" +#line 1564 "runarray.in" static const real fuzz=1000.0*DBL_EPSILON; size_t oldPrec=0; if(verbose) @@ -1991,16 +1971,16 @@ void gen_runarray65(stack *Stack) {Stack->push<real>((j == iterations) ? DBL_MAX : x); return;} } -#line 1623 "runarray.in" +#line 1642 "runarray.in" // real simpson(callableReal *f, real a, real b, real acc=DBL_EPSILON, real dxmax=0); -void gen_runarray66(stack *Stack) +void gen_runarray67(stack *Stack) { real dxmax=vm::pop<real>(Stack,0); real acc=vm::pop<real>(Stack,DBL_EPSILON); real b=vm::pop<real>(Stack); real a=vm::pop<real>(Stack); callableReal * f=vm::pop<callableReal *>(Stack); -#line 1625 "runarray.in" +#line 1644 "runarray.in" real integral; if(dxmax <= 0) dxmax=fabs(b-a); Func=f; @@ -2011,13 +1991,13 @@ void gen_runarray66(stack *Stack) } // Compute the fast Fourier transform of a pair array -#line 1636 "runarray.in" +#line 1655 "runarray.in" // pairarray* fft(pairarray *a, Int sign=1); -void gen_runarray67(stack *Stack) +void gen_runarray68(stack *Stack) { Int sign=vm::pop<Int>(Stack,1); pairarray * a=vm::pop<pairarray *>(Stack); -#line 1637 "runarray.in" +#line 1656 "runarray.in" unsigned n=(unsigned) checkArray(a); #ifdef HAVE_LIBFFTW3 array *c=new array(n); @@ -2046,12 +2026,12 @@ void gen_runarray67(stack *Stack) {Stack->push<pairarray*>(c); return;} } -#line 1666 "runarray.in" +#line 1685 "runarray.in" // Intarray2* triangulate(pairarray *z); -void gen_runarray68(stack *Stack) +void gen_runarray69(stack *Stack) { pairarray * z=vm::pop<pairarray *>(Stack); -#line 1667 "runarray.in" +#line 1686 "runarray.in" size_t nv=checkArray(z); // Call robust version of Gilles Dumoulin's port of Paul Bourke's // triangulation code. @@ -2085,12 +2065,12 @@ void gen_runarray68(stack *Stack) {Stack->push<Intarray2*>(t); return;} } -#line 1701 "runarray.in" +#line 1720 "runarray.in" // real norm(realarray *a); -void gen_runarray69(stack *Stack) +void gen_runarray70(stack *Stack) { realarray * a=vm::pop<realarray *>(Stack); -#line 1702 "runarray.in" +#line 1721 "runarray.in" size_t n=checkArray(a); real M=0.0; for(size_t i=0; i < n; ++i) { @@ -2100,12 +2080,12 @@ void gen_runarray69(stack *Stack) {Stack->push<real>(M); return;} } -#line 1712 "runarray.in" +#line 1731 "runarray.in" // real norm(realarray2 *a); -void gen_runarray70(stack *Stack) +void gen_runarray71(stack *Stack) { realarray2 * a=vm::pop<realarray2 *>(Stack); -#line 1713 "runarray.in" +#line 1732 "runarray.in" size_t n=checkArray(a); real M=0.0; for(size_t i=0; i < n; ++i) { @@ -2119,12 +2099,12 @@ void gen_runarray70(stack *Stack) {Stack->push<real>(M); return;} } -#line 1727 "runarray.in" +#line 1746 "runarray.in" // real norm(triplearray2 *a); -void gen_runarray71(stack *Stack) +void gen_runarray72(stack *Stack) { triplearray2 * a=vm::pop<triplearray2 *>(Stack); -#line 1728 "runarray.in" +#line 1747 "runarray.in" size_t n=checkArray(a); real M=0.0; for(size_t i=0; i < n; ++i) { @@ -2138,12 +2118,12 @@ void gen_runarray71(stack *Stack) {Stack->push<real>(sqrt(M)); return;} } -#line 1742 "runarray.in" +#line 1761 "runarray.in" // real change2(triplearray2 *a); -void gen_runarray72(stack *Stack) +void gen_runarray73(stack *Stack) { triplearray2 * a=vm::pop<triplearray2 *>(Stack); -#line 1743 "runarray.in" +#line 1762 "runarray.in" size_t n=checkArray(a); if(n == 0) {Stack->push<real>(0.0); return;} @@ -2164,13 +2144,13 @@ void gen_runarray72(stack *Stack) {Stack->push<real>(M); return;} } -#line 1764 "runarray.in" +#line 1783 "runarray.in" // triple minbezier(triplearray2 *P, triple b); -void gen_runarray73(stack *Stack) +void gen_runarray74(stack *Stack) { triple b=vm::pop<triple>(Stack); triplearray2 * P=vm::pop<triplearray2 *>(Stack); -#line 1765 "runarray.in" +#line 1784 "runarray.in" real *A=copyTripleArray2Components(P,true,4); b=triple(bound(A,::min,b.getx(),sqrtFuzz*norm(A,16)), bound(A+16,::min,b.gety(),sqrtFuzz*norm(A+16,16)), @@ -2179,13 +2159,13 @@ void gen_runarray73(stack *Stack) {Stack->push<triple>(b); return;} } -#line 1774 "runarray.in" +#line 1793 "runarray.in" // triple maxbezier(triplearray2 *P, triple b); -void gen_runarray74(stack *Stack) +void gen_runarray75(stack *Stack) { triple b=vm::pop<triple>(Stack); triplearray2 * P=vm::pop<triplearray2 *>(Stack); -#line 1775 "runarray.in" +#line 1794 "runarray.in" real *A=copyTripleArray2Components(P,true,4); b=triple(bound(A,::max,b.getx(),sqrtFuzz*norm(A,16)), bound(A+16,::max,b.gety(),sqrtFuzz*norm(A+16,16)), @@ -2194,13 +2174,13 @@ void gen_runarray74(stack *Stack) {Stack->push<triple>(b); return;} } -#line 1784 "runarray.in" +#line 1803 "runarray.in" // pair minratio(triplearray2 *P, pair b); -void gen_runarray75(stack *Stack) +void gen_runarray76(stack *Stack) { pair b=vm::pop<pair>(Stack); triplearray2 * P=vm::pop<triplearray2 *>(Stack); -#line 1785 "runarray.in" +#line 1804 "runarray.in" triple *A; copyArray2C(A,P,true,4); real fuzz=sqrtFuzz*norm(A,16); @@ -2210,13 +2190,13 @@ void gen_runarray75(stack *Stack) {Stack->push<pair>(b); return;} } -#line 1795 "runarray.in" +#line 1814 "runarray.in" // pair maxratio(triplearray2 *P, pair b); -void gen_runarray76(stack *Stack) +void gen_runarray77(stack *Stack) { pair b=vm::pop<pair>(Stack); triplearray2 * P=vm::pop<triplearray2 *>(Stack); -#line 1796 "runarray.in" +#line 1815 "runarray.in" triple *A; copyArray2C(A,P,true,4); real fuzz=sqrtFuzz*norm(A,16); @@ -2226,11 +2206,11 @@ void gen_runarray76(stack *Stack) {Stack->push<pair>(b); return;} } -#line 1806 "runarray.in" +#line 1825 "runarray.in" // realarray* _projection(); -void gen_runarray77(stack *Stack) +void gen_runarray78(stack *Stack) { -#line 1807 "runarray.in" +#line 1826 "runarray.in" #ifdef HAVE_GL array *a=new array(14); gl::projection P=gl::camera(); @@ -2344,85 +2324,87 @@ void gen_runarray_venv(venv &ve) #line 809 "runarray.in" REGISTER_BLTIN(run::arraySort,"arraySort"); #line 818 "runarray.in" - addFunc(ve, run::gen_runarray38, primBoolean(), SYM(all), formal(booleanArray(), SYM(a), false, false)); -#line 827 "runarray.in" - addFunc(ve, run::gen_runarray39, booleanArray(), SYM_LOGNOT, formal(booleanArray(), SYM(a), false, false)); -#line 836 "runarray.in" - addFunc(ve, run::gen_runarray40, primInt(), SYM(sum), formal(booleanArray(), SYM(a), false, false)); -#line 845 "runarray.in" + REGISTER_BLTIN(run::arraySearch,"arraySearch"); +#line 837 "runarray.in" + addFunc(ve, run::gen_runarray39, primBoolean(), SYM(all), formal(booleanArray(), SYM(a), false, false)); +#line 846 "runarray.in" + addFunc(ve, run::gen_runarray40, booleanArray(), SYM_LOGNOT, formal(booleanArray(), SYM(a), false, false)); +#line 855 "runarray.in" + addFunc(ve, run::gen_runarray41, primInt(), SYM(sum), formal(booleanArray(), SYM(a), false, false)); +#line 864 "runarray.in" REGISTER_BLTIN(run::arrayCopy,"arrayCopy"); -#line 850 "runarray.in" +#line 869 "runarray.in" REGISTER_BLTIN(run::arrayConcat,"arrayConcat"); -#line 878 "runarray.in" +#line 897 "runarray.in" REGISTER_BLTIN(run::array2Copy,"array2Copy"); -#line 883 "runarray.in" +#line 902 "runarray.in" REGISTER_BLTIN(run::array3Copy,"array3Copy"); -#line 888 "runarray.in" +#line 907 "runarray.in" REGISTER_BLTIN(run::array2Transpose,"array2Transpose"); -#line 912 "runarray.in" +#line 931 "runarray.in" REGISTER_BLTIN(run::array3Transpose,"array3Transpose"); -#line 999 "runarray.in" - addFunc(ve, run::gen_runarray47, primInt(), SYM(find), formal(booleanArray(), SYM(a), false, false), formal(primInt(), SYM(n), true, false)); #line 1018 "runarray.in" + addFunc(ve, run::gen_runarray48, primInt(), SYM(find), formal(booleanArray(), SYM(a), false, false), formal(primInt(), SYM(n), true, false)); +#line 1037 "runarray.in" REGISTER_BLTIN(run::arrayConditional,"arrayConditional"); -#line 1044 "runarray.in" - addFunc(ve, run::gen_runarray49, realArray2(), SYM(identity), formal(primInt(), SYM(n), false, false)); -#line 1050 "runarray.in" - addFunc(ve, run::gen_runarray50, realArray2(), SYM(inverse), formal(realArray2(), SYM(a), false, false)); -#line 1142 "runarray.in" - addFunc(ve, run::gen_runarray51, realArray(), SYM(solve), formal(realArray2(), SYM(a), false, false), formal(realArray(), SYM(b), false, false), formal(primBoolean(), SYM(warn), true, false)); -#line 1195 "runarray.in" - addFunc(ve, run::gen_runarray52, realArray2(), SYM(solve), formal(realArray2(), SYM(a), false, false), formal(realArray2(), SYM(b), false, false), formal(primBoolean(), SYM(warn), true, false)); -#line 1260 "runarray.in" - addFunc(ve, run::gen_runarray53, primReal(), SYM(determinant), formal(realArray2(), SYM(a), false, false)); -#line 1277 "runarray.in" - addFunc(ve, run::gen_runarray54, realArray(), SYM_TIMES, formal(realArray2(), SYM(a), false, false), formal(realArray(), SYM(b), false, false)); +#line 1063 "runarray.in" + addFunc(ve, run::gen_runarray50, realArray2(), SYM(identity), formal(primInt(), SYM(n), false, false)); +#line 1069 "runarray.in" + addFunc(ve, run::gen_runarray51, realArray2(), SYM(inverse), formal(realArray2(), SYM(a), false, false)); +#line 1161 "runarray.in" + addFunc(ve, run::gen_runarray52, realArray(), SYM(solve), formal(realArray2(), SYM(a), false, false), formal(realArray(), SYM(b), false, false), formal(primBoolean(), SYM(warn), true, false)); +#line 1214 "runarray.in" + addFunc(ve, run::gen_runarray53, realArray2(), SYM(solve), formal(realArray2(), SYM(a), false, false), formal(realArray2(), SYM(b), false, false), formal(primBoolean(), SYM(warn), true, false)); +#line 1279 "runarray.in" + addFunc(ve, run::gen_runarray54, primReal(), SYM(determinant), formal(realArray2(), SYM(a), false, false)); #line 1296 "runarray.in" - addFunc(ve, run::gen_runarray55, realArray(), SYM_TIMES, formal(realArray(), SYM(a), false, false), formal(realArray2(), SYM(b), false, false)); -#line 1325 "runarray.in" - addFunc(ve, run::gen_runarray56, IntArray2(), SYM_TIMES, formal(IntArray2(), SYM(a), false, false), formal(IntArray2(), SYM(b), false, false)); -#line 1330 "runarray.in" - addFunc(ve, run::gen_runarray57, realArray2(), SYM_TIMES, formal(realArray2(), SYM(a), false, false), formal(realArray2(), SYM(b), false, false)); -#line 1335 "runarray.in" - addFunc(ve, run::gen_runarray58, pairArray2(), SYM_TIMES, formal(pairArray2(), SYM(a), false, false), formal(pairArray2(), SYM(b), false, false)); -#line 1340 "runarray.in" - addFunc(ve, run::gen_runarray59, primTriple(), SYM_TIMES, formal(realArray2(), SYM(t), false, false), formal(primTriple(), SYM(v), false, false)); -#line 1345 "runarray.in" - addFunc(ve, run::gen_runarray60, primPair(), SYM(project), formal(primTriple(), SYM(v), false, false), formal(realArray2(), SYM(t), false, false)); -#line 1370 "runarray.in" - addFunc(ve, run::gen_runarray61, primReal(), SYM(dot), formal(realArray(), SYM(a), false, false), formal(realArray(), SYM(b), false, false)); -#line 1380 "runarray.in" - addFunc(ve, run::gen_runarray62, primPair(), SYM(dot), formal(pairArray(), SYM(a), false, false), formal(pairArray(), SYM(b), false, false)); -#line 1390 "runarray.in" - addFunc(ve, run::gen_runarray63, realArray(), SYM(tridiagonal), formal(realArray(), SYM(a), false, false), formal(realArray(), SYM(b), false, false), formal(realArray(), SYM(c), false, false), formal(realArray(), SYM(f), false, false)); -#line 1494 "runarray.in" - addFunc(ve, run::gen_runarray64, primReal(), SYM(newton), formal(primInt(), SYM(iterations), true, false), formal(realRealFunction(), SYM(f), false, false), formal(realRealFunction(), SYM(fprime), false, false), formal(primReal(), SYM(x), false, false), formal(primBoolean(), SYM(verbose), true, false)); -#line 1541 "runarray.in" - addFunc(ve, run::gen_runarray65, primReal(), SYM(newton), formal(primInt(), SYM(iterations), true, false), formal(realRealFunction(), SYM(f), false, false), formal(realRealFunction(), SYM(fprime), false, false), formal(primReal(), SYM(x1), false, false), formal(primReal(), SYM(x2), false, false), formal(primBoolean(), SYM(verbose), true, false)); -#line 1623 "runarray.in" - addFunc(ve, run::gen_runarray66, primReal(), SYM(simpson), formal(realRealFunction(), SYM(f), false, false), formal(primReal(), SYM(a), false, false), formal(primReal(), SYM(b), false, false), formal(primReal(), SYM(acc), true, false), formal(primReal(), SYM(dxmax), true, false)); -#line 1635 "runarray.in" - addFunc(ve, run::gen_runarray67, pairArray(), SYM(fft), formal(pairArray(), SYM(a), false, false), formal(primInt(), SYM(sign), true, false)); -#line 1666 "runarray.in" - addFunc(ve, run::gen_runarray68, IntArray2(), SYM(triangulate), formal(pairArray(), SYM(z), false, false)); -#line 1701 "runarray.in" - addFunc(ve, run::gen_runarray69, primReal(), SYM(norm), formal(realArray(), SYM(a), false, false)); -#line 1712 "runarray.in" - addFunc(ve, run::gen_runarray70, primReal(), SYM(norm), formal(realArray2(), SYM(a), false, false)); -#line 1727 "runarray.in" - addFunc(ve, run::gen_runarray71, primReal(), SYM(norm), formal(tripleArray2(), SYM(a), false, false)); -#line 1742 "runarray.in" - addFunc(ve, run::gen_runarray72, primReal(), SYM(change2), formal(tripleArray2(), SYM(a), false, false)); -#line 1764 "runarray.in" - addFunc(ve, run::gen_runarray73, primTriple(), SYM(minbezier), formal(tripleArray2(), SYM(p), false, false), formal(primTriple(), SYM(b), false, false)); -#line 1774 "runarray.in" - addFunc(ve, run::gen_runarray74, primTriple(), SYM(maxbezier), formal(tripleArray2(), SYM(p), false, false), formal(primTriple(), SYM(b), false, false)); -#line 1784 "runarray.in" - addFunc(ve, run::gen_runarray75, primPair(), SYM(minratio), formal(tripleArray2(), SYM(p), false, false), formal(primPair(), SYM(b), false, false)); -#line 1795 "runarray.in" - addFunc(ve, run::gen_runarray76, primPair(), SYM(maxratio), formal(tripleArray2(), SYM(p), false, false), formal(primPair(), SYM(b), false, false)); -#line 1806 "runarray.in" - addFunc(ve, run::gen_runarray77, realArray(), SYM(_projection)); + addFunc(ve, run::gen_runarray55, realArray(), SYM_TIMES, formal(realArray2(), SYM(a), false, false), formal(realArray(), SYM(b), false, false)); +#line 1315 "runarray.in" + addFunc(ve, run::gen_runarray56, realArray(), SYM_TIMES, formal(realArray(), SYM(a), false, false), formal(realArray2(), SYM(b), false, false)); +#line 1344 "runarray.in" + addFunc(ve, run::gen_runarray57, IntArray2(), SYM_TIMES, formal(IntArray2(), SYM(a), false, false), formal(IntArray2(), SYM(b), false, false)); +#line 1349 "runarray.in" + addFunc(ve, run::gen_runarray58, realArray2(), SYM_TIMES, formal(realArray2(), SYM(a), false, false), formal(realArray2(), SYM(b), false, false)); +#line 1354 "runarray.in" + addFunc(ve, run::gen_runarray59, pairArray2(), SYM_TIMES, formal(pairArray2(), SYM(a), false, false), formal(pairArray2(), SYM(b), false, false)); +#line 1359 "runarray.in" + addFunc(ve, run::gen_runarray60, primTriple(), SYM_TIMES, formal(realArray2(), SYM(t), false, false), formal(primTriple(), SYM(v), false, false)); +#line 1364 "runarray.in" + addFunc(ve, run::gen_runarray61, primPair(), SYM(project), formal(primTriple(), SYM(v), false, false), formal(realArray2(), SYM(t), false, false)); +#line 1389 "runarray.in" + addFunc(ve, run::gen_runarray62, primReal(), SYM(dot), formal(realArray(), SYM(a), false, false), formal(realArray(), SYM(b), false, false)); +#line 1399 "runarray.in" + addFunc(ve, run::gen_runarray63, primPair(), SYM(dot), formal(pairArray(), SYM(a), false, false), formal(pairArray(), SYM(b), false, false)); +#line 1409 "runarray.in" + addFunc(ve, run::gen_runarray64, realArray(), SYM(tridiagonal), formal(realArray(), SYM(a), false, false), formal(realArray(), SYM(b), false, false), formal(realArray(), SYM(c), false, false), formal(realArray(), SYM(f), false, false)); +#line 1513 "runarray.in" + addFunc(ve, run::gen_runarray65, primReal(), SYM(newton), formal(primInt(), SYM(iterations), true, false), formal(realRealFunction(), SYM(f), false, false), formal(realRealFunction(), SYM(fprime), false, false), formal(primReal(), SYM(x), false, false), formal(primBoolean(), SYM(verbose), true, false)); +#line 1560 "runarray.in" + addFunc(ve, run::gen_runarray66, primReal(), SYM(newton), formal(primInt(), SYM(iterations), true, false), formal(realRealFunction(), SYM(f), false, false), formal(realRealFunction(), SYM(fprime), false, false), formal(primReal(), SYM(x1), false, false), formal(primReal(), SYM(x2), false, false), formal(primBoolean(), SYM(verbose), true, false)); +#line 1642 "runarray.in" + addFunc(ve, run::gen_runarray67, primReal(), SYM(simpson), formal(realRealFunction(), SYM(f), false, false), formal(primReal(), SYM(a), false, false), formal(primReal(), SYM(b), false, false), formal(primReal(), SYM(acc), true, false), formal(primReal(), SYM(dxmax), true, false)); +#line 1654 "runarray.in" + addFunc(ve, run::gen_runarray68, pairArray(), SYM(fft), formal(pairArray(), SYM(a), false, false), formal(primInt(), SYM(sign), true, false)); +#line 1685 "runarray.in" + addFunc(ve, run::gen_runarray69, IntArray2(), SYM(triangulate), formal(pairArray(), SYM(z), false, false)); +#line 1720 "runarray.in" + addFunc(ve, run::gen_runarray70, primReal(), SYM(norm), formal(realArray(), SYM(a), false, false)); +#line 1731 "runarray.in" + addFunc(ve, run::gen_runarray71, primReal(), SYM(norm), formal(realArray2(), SYM(a), false, false)); +#line 1746 "runarray.in" + addFunc(ve, run::gen_runarray72, primReal(), SYM(norm), formal(tripleArray2(), SYM(a), false, false)); +#line 1761 "runarray.in" + addFunc(ve, run::gen_runarray73, primReal(), SYM(change2), formal(tripleArray2(), SYM(a), false, false)); +#line 1783 "runarray.in" + addFunc(ve, run::gen_runarray74, primTriple(), SYM(minbezier), formal(tripleArray2(), SYM(p), false, false), formal(primTriple(), SYM(b), false, false)); +#line 1793 "runarray.in" + addFunc(ve, run::gen_runarray75, primTriple(), SYM(maxbezier), formal(tripleArray2(), SYM(p), false, false), formal(primTriple(), SYM(b), false, false)); +#line 1803 "runarray.in" + addFunc(ve, run::gen_runarray76, primPair(), SYM(minratio), formal(tripleArray2(), SYM(p), false, false), formal(primPair(), SYM(b), false, false)); +#line 1814 "runarray.in" + addFunc(ve, run::gen_runarray77, primPair(), SYM(maxratio), formal(tripleArray2(), SYM(p), false, false), formal(primPair(), SYM(b), false, false)); +#line 1825 "runarray.in" + addFunc(ve, run::gen_runarray78, realArray(), SYM(_projection)); } } // namespace trans diff --git a/Build/source/utils/asymptote/runarray.h b/Build/source/utils/asymptote/runarray.h index 2d3c928c331..1ac5833e747 100644 --- a/Build/source/utils/asymptote/runarray.h +++ b/Build/source/utils/asymptote/runarray.h @@ -39,6 +39,7 @@ void arrayIntArray(vm::stack *); void arraySequence(vm::stack *); void arrayFunction(vm::stack *); void arraySort(vm::stack *); +void arraySearch(vm::stack *); void arrayCopy(vm::stack *); void arrayConcat(vm::stack *); void array2Copy(vm::stack *); diff --git a/Build/source/utils/asymptote/runarray.in b/Build/source/utils/asymptote/runarray.in index 83064a05dd2..31bb2aebe4c 100644 --- a/Build/source/utils/asymptote/runarray.in +++ b/Build/source/utils/asymptote/runarray.in @@ -806,15 +806,34 @@ array* :arrayFunction(callable *f, array *a) return b; } -array* :arraySort(array *a, callable *f) +array* :arraySort(array *a, callable *less) { array *c=copyArray(a); - compareFunc=f; + compareFunc=less; FuncStack=Stack; stable_sort(c->begin(),c->end(),compareFunction); return c; } +Int :arraySearch(array *a, item key, callable *less) +{ + size_t size=a->size(); + compareFunc=less; + FuncStack=Stack; + if(size == 0 || compareFunction(key,(*a)[0])) return -1; + size_t u=size-1; + if(!compareFunction(key,(*a)[u])) return Intcast(u); + size_t l=0; + + while (l < u) { + size_t i=(l+u)/2; + if(compareFunction(key,(*a)[i])) u=i; + else if(compareFunction(key,(*a)[i+1])) return Intcast(i); + else l=i+1; + } + return 0; +} + bool all(boolarray *a) { size_t size=checkArray(a); diff --git a/Build/source/utils/asymptote/runarray.symbols.h b/Build/source/utils/asymptote/runarray.symbols.h deleted file mode 100644 index 65d6033053e..00000000000 --- a/Build/source/utils/asymptote/runarray.symbols.h +++ /dev/null @@ -1,59 +0,0 @@ -/***** - * This file is automatically generated by findsym.pl - * Changes will be overwritten. - *****/ - -// If the ADDSYMBOL macro is not already defined, define it with the default -// purpose of referring to an external pre-translated symbol, such that -// SYM(name) also refers to that symbol. -#ifndef ADDSYMBOL - #define ADDSYMBOL(name) extern sym::symbol PRETRANSLATED_SYMBOL_##name - #ifdef PRESYM - #define SYM(name) PRETRANSLATED_SYMBOL_##name - #else - #define SYM(name) sym::symbol::trans(#name) - #endif -#endif - -ADDSYMBOL(_projection); -ADDSYMBOL(a); -ADDSYMBOL(acc); -ADDSYMBOL(all); -ADDSYMBOL(b); -ADDSYMBOL(c); -ADDSYMBOL(change2); -ADDSYMBOL(complement); -ADDSYMBOL(determinant); -ADDSYMBOL(dot); -ADDSYMBOL(dxmax); -ADDSYMBOL(f); -ADDSYMBOL(fft); -ADDSYMBOL(find); -ADDSYMBOL(fprime); -ADDSYMBOL(identity); -ADDSYMBOL(inverse); -ADDSYMBOL(iterations); -ADDSYMBOL(maxbezier); -ADDSYMBOL(maxratio); -ADDSYMBOL(minbezier); -ADDSYMBOL(minratio); -ADDSYMBOL(n); -ADDSYMBOL(newton); -ADDSYMBOL(norm); -ADDSYMBOL(p); -ADDSYMBOL(project); -ADDSYMBOL(sequence); -ADDSYMBOL(sign); -ADDSYMBOL(simpson); -ADDSYMBOL(solve); -ADDSYMBOL(sum); -ADDSYMBOL(t); -ADDSYMBOL(triangulate); -ADDSYMBOL(tridiagonal); -ADDSYMBOL(v); -ADDSYMBOL(verbose); -ADDSYMBOL(warn); -ADDSYMBOL(x); -ADDSYMBOL(x1); -ADDSYMBOL(x2); -ADDSYMBOL(z); diff --git a/Build/source/utils/asymptote/runbacktrace.cc b/Build/source/utils/asymptote/runbacktrace.cc index 9e99d5f4864..6b2d621b3fc 100644 --- a/Build/source/utils/asymptote/runbacktrace.cc +++ b/Build/source/utils/asymptote/runbacktrace.cc @@ -52,52 +52,6 @@ array *copyArray(array *a); array *copyArray2(array *a); array *copyArray3(array *a); -inline size_t checkdimension(const array *a, size_t dim) -{ - size_t size=checkArray(a); - if(dim && size != dim) { - ostringstream buf; - buf << "array of length " << dim << " expected"; - error(buf); - } - return size; -} - -template<class T> -void copyArrayC(T* &dest, const array *a, size_t dim=0, - GCPlacement placement=NoGC) -{ - size_t size=checkdimension(a,dim); - dest=(placement == NoGC) ? new T[size] : new(placement) T[size]; - for(size_t i=0; i < size; i++) - dest[i]=read<T>(a,i); -} - -template<class T> -void copyArray2C(T* &dest, const array *a, bool square=true, size_t dim2=0, - GCPlacement placement=NoGC) -{ - size_t n=checkArray(a); - size_t m=(square || n == 0) ? n : checkArray(read<array*>(a,0)); - if(n > 0 && dim2 && m != dim2) { - ostringstream buf; - buf << "second matrix dimension must be " << dim2; - error(buf); - } - - dest=(placement == NoGC) ? new T[n*m] : new(placement) T[n*m]; - for(size_t i=0; i < n; i++) { - array *ai=read<array*>(a,i); - size_t aisize=checkArray(ai); - if(aisize == m) { - T *desti=dest+i*m; - for(size_t j=0; j < m; j++) - desti[j]=read<T>(ai,j); - } else - error(square ? "matrix must be square" : "matrix must be rectangular"); - } -} - double *copyTripleArray2Components(array *a, bool square=true, size_t dim2=0, GCPlacement placement=NoGC); } @@ -113,8 +67,10 @@ function *realRealFunction(); +#ifndef NOSYM #include "runbacktrace.symbols.h" +#endif namespace run { #line 16 "runbacktrace.in" // void generate_random_backtrace(); diff --git a/Build/source/utils/asymptote/runbacktrace.symbols.h b/Build/source/utils/asymptote/runbacktrace.symbols.h deleted file mode 100644 index f5b1168d61f..00000000000 --- a/Build/source/utils/asymptote/runbacktrace.symbols.h +++ /dev/null @@ -1,20 +0,0 @@ -/***** - * This file is automatically generated by findsym.pl - * Changes will be overwritten. - *****/ - -// If the ADDSYMBOL macro is not already defined, define it with the default -// purpose of referring to an external pre-translated symbol, such that -// SYM(name) also refers to that symbol. -#ifndef ADDSYMBOL - #define ADDSYMBOL(name) extern sym::symbol PRETRANSLATED_SYMBOL_##name - #ifdef PRESYM - #define SYM(name) PRETRANSLATED_SYMBOL_##name - #else - #define SYM(name) sym::symbol::trans(#name) - #endif -#endif - -ADDSYMBOL(generate_random_backtrace); -ADDSYMBOL(n); -ADDSYMBOL(print_random_addresses); diff --git a/Build/source/utils/asymptote/runfile.cc b/Build/source/utils/asymptote/runfile.cc index 6cf0636413a..efd0dd51e8b 100644 --- a/Build/source/utils/asymptote/runfile.cc +++ b/Build/source/utils/asymptote/runfile.cc @@ -51,52 +51,6 @@ array *copyArray(array *a); array *copyArray2(array *a); array *copyArray3(array *a); -inline size_t checkdimension(const array *a, size_t dim) -{ - size_t size=checkArray(a); - if(dim && size != dim) { - ostringstream buf; - buf << "array of length " << dim << " expected"; - error(buf); - } - return size; -} - -template<class T> -void copyArrayC(T* &dest, const array *a, size_t dim=0, - GCPlacement placement=NoGC) -{ - size_t size=checkdimension(a,dim); - dest=(placement == NoGC) ? new T[size] : new(placement) T[size]; - for(size_t i=0; i < size; i++) - dest[i]=read<T>(a,i); -} - -template<class T> -void copyArray2C(T* &dest, const array *a, bool square=true, size_t dim2=0, - GCPlacement placement=NoGC) -{ - size_t n=checkArray(a); - size_t m=(square || n == 0) ? n : checkArray(read<array*>(a,0)); - if(n > 0 && dim2 && m != dim2) { - ostringstream buf; - buf << "second matrix dimension must be " << dim2; - error(buf); - } - - dest=(placement == NoGC) ? new T[n*m] : new(placement) T[n*m]; - for(size_t i=0; i < n; i++) { - array *ai=read<array*>(a,i); - size_t aisize=checkArray(ai); - if(aisize == m) { - T *desti=dest+i*m; - for(size_t j=0; j < m; j++) - desti[j]=read<T>(ai,j); - } else - error(square ? "matrix must be square" : "matrix must be rectangular"); - } -} - double *copyTripleArray2Components(array *a, bool square=true, size_t dim2=0, GCPlacement placement=NoGC); } @@ -121,8 +75,10 @@ string commentchar="#"; +#ifndef NOSYM #include "runfile.symbols.h" +#endif namespace run { #line 24 "runfile.in" // bool ==(file *a, file *b); diff --git a/Build/source/utils/asymptote/runfile.symbols.h b/Build/source/utils/asymptote/runfile.symbols.h deleted file mode 100644 index 1c182287108..00000000000 --- a/Build/source/utils/asymptote/runfile.symbols.h +++ /dev/null @@ -1,48 +0,0 @@ -/***** - * This file is automatically generated by findsym.pl - * Changes will be overwritten. - *****/ - -// If the ADDSYMBOL macro is not already defined, define it with the default -// purpose of referring to an external pre-translated symbol, such that -// SYM(name) also refers to that symbol. -#ifndef ADDSYMBOL - #define ADDSYMBOL(name) extern sym::symbol PRETRANSLATED_SYMBOL_##name - #ifdef PRESYM - #define SYM(name) PRETRANSLATED_SYMBOL_##name - #else - #define SYM(name) sym::symbol::trans(#name) - #endif -#endif - -ADDSYMBOL(a); -ADDSYMBOL(b); -ADDSYMBOL(binput); -ADDSYMBOL(boutput); -ADDSYMBOL(check); -ADDSYMBOL(clear); -ADDSYMBOL(close); -ADDSYMBOL(comment); -ADDSYMBOL(delete); -ADDSYMBOL(digits); -ADDSYMBOL(eof); -ADDSYMBOL(eol); -ADDSYMBOL(error); -ADDSYMBOL(f); -ADDSYMBOL(flush); -ADDSYMBOL(from); -ADDSYMBOL(getc); -ADDSYMBOL(input); -ADDSYMBOL(name); -ADDSYMBOL(output); -ADDSYMBOL(pos); -ADDSYMBOL(precision); -ADDSYMBOL(rename); -ADDSYMBOL(s); -ADDSYMBOL(seek); -ADDSYMBOL(seekeof); -ADDSYMBOL(tell); -ADDSYMBOL(to); -ADDSYMBOL(update); -ADDSYMBOL(xinput); -ADDSYMBOL(xoutput); diff --git a/Build/source/utils/asymptote/runhistory.cc b/Build/source/utils/asymptote/runhistory.cc index 6e81b00df37..6b38e49f4a9 100644 --- a/Build/source/utils/asymptote/runhistory.cc +++ b/Build/source/utils/asymptote/runhistory.cc @@ -51,52 +51,6 @@ array *copyArray(array *a); array *copyArray2(array *a); array *copyArray3(array *a); -inline size_t checkdimension(const array *a, size_t dim) -{ - size_t size=checkArray(a); - if(dim && size != dim) { - ostringstream buf; - buf << "array of length " << dim << " expected"; - error(buf); - } - return size; -} - -template<class T> -void copyArrayC(T* &dest, const array *a, size_t dim=0, - GCPlacement placement=NoGC) -{ - size_t size=checkdimension(a,dim); - dest=(placement == NoGC) ? new T[size] : new(placement) T[size]; - for(size_t i=0; i < size; i++) - dest[i]=read<T>(a,i); -} - -template<class T> -void copyArray2C(T* &dest, const array *a, bool square=true, size_t dim2=0, - GCPlacement placement=NoGC) -{ - size_t n=checkArray(a); - size_t m=(square || n == 0) ? n : checkArray(read<array*>(a,0)); - if(n > 0 && dim2 && m != dim2) { - ostringstream buf; - buf << "second matrix dimension must be " << dim2; - error(buf); - } - - dest=(placement == NoGC) ? new T[n*m] : new(placement) T[n*m]; - for(size_t i=0; i < n; i++) { - array *ai=read<array*>(a,i); - size_t aisize=checkArray(ai); - if(aisize == m) { - T *desti=dest+i*m; - for(size_t j=0; j < m; j++) - desti[j]=read<T>(ai,j); - } else - error(square ? "matrix must be square" : "matrix must be rectangular"); - } -} - double *copyTripleArray2Components(array *a, bool square=true, size_t dim2=0, GCPlacement placement=NoGC); } @@ -109,6 +63,7 @@ function *realRealFunction(); #include "array.h" #include "mathop.h" +#include "builtin.h" using namespace camp; using namespace settings; @@ -189,6 +144,9 @@ void cleanup() } history_set_history_state(&history_save); #endif +#ifdef HAVE_LIBGSL + trans::GSLrngFree(); +#endif } } @@ -196,17 +154,19 @@ void cleanup() +#ifndef NOSYM #include "runhistory.symbols.h" +#endif namespace run { // Return the last n lines of the history named name. -#line 102 "runhistory.in" +#line 106 "runhistory.in" // stringarray* history(string name, Int n=1); void gen_runhistory0(stack *Stack) { Int n=vm::pop<Int>(Stack,1); string name=vm::pop<string>(Stack); -#line 103 "runhistory.in" +#line 107 "runhistory.in" #if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBCURSES) bool newhistory=historyMap.find(name) == historyMap.end(); @@ -238,12 +198,12 @@ void gen_runhistory0(stack *Stack) } // Return the last n lines of the interactive history. -#line 135 "runhistory.in" +#line 139 "runhistory.in" // stringarray* history(Int n=0); void gen_runhistory1(stack *Stack) { Int n=vm::pop<Int>(Stack,0); -#line 136 "runhistory.in" +#line 140 "runhistory.in" #if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBCURSES) {Stack->push<stringarray*>(get_history(n)); return;} #else @@ -254,14 +214,14 @@ void gen_runhistory1(stack *Stack) // Prompt for a string using prompt, the GNU readline library, and a // local history named name. -#line 147 "runhistory.in" +#line 151 "runhistory.in" // string readline(string prompt=emptystring, string name=emptystring, bool tabcompletion=false); void gen_runhistory2(stack *Stack) { bool tabcompletion=vm::pop<bool>(Stack,false); string name=vm::pop<string>(Stack,emptystring); string prompt=vm::pop<string>(Stack,emptystring); -#line 149 "runhistory.in" +#line 153 "runhistory.in" if(!(isatty(STDIN_FILENO) || getSetting<bool>("interactive"))) {Stack->push<string>(emptystring); return;} #if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBCURSES) @@ -303,14 +263,14 @@ void gen_runhistory2(stack *Stack) // Save a string in a local history named name. // If store=true, store the local history in the file historyfilename(name). -#line 191 "runhistory.in" +#line 195 "runhistory.in" // void saveline(string name, string value, bool store=true); void gen_runhistory3(stack *Stack) { bool store=vm::pop<bool>(Stack,true); string value=vm::pop<string>(Stack); string name=vm::pop<string>(Stack); -#line 192 "runhistory.in" +#line 196 "runhistory.in" #if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBCURSES) store_history(&history_save); bool newhistory=historyMap.find(name) == historyMap.end(); @@ -343,13 +303,13 @@ namespace trans { void gen_runhistory_venv(venv &ve) { -#line 101 "runhistory.in" +#line 105 "runhistory.in" addFunc(ve, run::gen_runhistory0, stringArray(), SYM(history), formal(primString() , SYM(name), false, false), formal(primInt(), SYM(n), true, false)); -#line 134 "runhistory.in" +#line 138 "runhistory.in" addFunc(ve, run::gen_runhistory1, stringArray(), SYM(history), formal(primInt(), SYM(n), true, false)); -#line 145 "runhistory.in" +#line 149 "runhistory.in" addFunc(ve, run::gen_runhistory2, primString() , SYM(readline), formal(primString() , SYM(prompt), true, false), formal(primString() , SYM(name), true, false), formal(primBoolean(), SYM(tabcompletion), true, false)); -#line 189 "runhistory.in" +#line 193 "runhistory.in" addFunc(ve, run::gen_runhistory3, primVoid(), SYM(saveline), formal(primString() , SYM(name), false, false), formal(primString() , SYM(value), false, false), formal(primBoolean(), SYM(store), true, false)); } diff --git a/Build/source/utils/asymptote/runhistory.in b/Build/source/utils/asymptote/runhistory.in index 51fd99cb8c5..b4bbb1e39dc 100644 --- a/Build/source/utils/asymptote/runhistory.in +++ b/Build/source/utils/asymptote/runhistory.in @@ -12,6 +12,7 @@ stringarray* => stringArray() #include "array.h" #include "mathop.h" +#include "builtin.h" using namespace camp; using namespace settings; @@ -92,6 +93,9 @@ void cleanup() } history_set_history_state(&history_save); #endif +#ifdef HAVE_LIBGSL + trans::GSLrngFree(); +#endif } } diff --git a/Build/source/utils/asymptote/runhistory.symbols.h b/Build/source/utils/asymptote/runhistory.symbols.h deleted file mode 100644 index 3e17f6858af..00000000000 --- a/Build/source/utils/asymptote/runhistory.symbols.h +++ /dev/null @@ -1,26 +0,0 @@ -/***** - * This file is automatically generated by findsym.pl - * Changes will be overwritten. - *****/ - -// If the ADDSYMBOL macro is not already defined, define it with the default -// purpose of referring to an external pre-translated symbol, such that -// SYM(name) also refers to that symbol. -#ifndef ADDSYMBOL - #define ADDSYMBOL(name) extern sym::symbol PRETRANSLATED_SYMBOL_##name - #ifdef PRESYM - #define SYM(name) PRETRANSLATED_SYMBOL_##name - #else - #define SYM(name) sym::symbol::trans(#name) - #endif -#endif - -ADDSYMBOL(history); -ADDSYMBOL(n); -ADDSYMBOL(name); -ADDSYMBOL(prompt); -ADDSYMBOL(readline); -ADDSYMBOL(saveline); -ADDSYMBOL(store); -ADDSYMBOL(tabcompletion); -ADDSYMBOL(value); diff --git a/Build/source/utils/asymptote/runlabel.cc b/Build/source/utils/asymptote/runlabel.cc index 0288aa16c87..5d797e8cb7f 100644 --- a/Build/source/utils/asymptote/runlabel.cc +++ b/Build/source/utils/asymptote/runlabel.cc @@ -51,52 +51,6 @@ array *copyArray(array *a); array *copyArray2(array *a); array *copyArray3(array *a); -inline size_t checkdimension(const array *a, size_t dim) -{ - size_t size=checkArray(a); - if(dim && size != dim) { - ostringstream buf; - buf << "array of length " << dim << " expected"; - error(buf); - } - return size; -} - -template<class T> -void copyArrayC(T* &dest, const array *a, size_t dim=0, - GCPlacement placement=NoGC) -{ - size_t size=checkdimension(a,dim); - dest=(placement == NoGC) ? new T[size] : new(placement) T[size]; - for(size_t i=0; i < size; i++) - dest[i]=read<T>(a,i); -} - -template<class T> -void copyArray2C(T* &dest, const array *a, bool square=true, size_t dim2=0, - GCPlacement placement=NoGC) -{ - size_t n=checkArray(a); - size_t m=(square || n == 0) ? n : checkArray(read<array*>(a,0)); - if(n > 0 && dim2 && m != dim2) { - ostringstream buf; - buf << "second matrix dimension must be " << dim2; - error(buf); - } - - dest=(placement == NoGC) ? new T[n*m] : new(placement) T[n*m]; - for(size_t i=0; i < n; i++) { - array *ai=read<array*>(a,i); - size_t aisize=checkArray(ai); - if(aisize == m) { - T *desti=dest+i*m; - for(size_t j=0; j < m; j++) - desti[j]=read<T>(ai,j); - } else - error(square ? "matrix must be square" : "matrix must be rectangular"); - } -} - double *copyTripleArray2Components(array *a, bool square=true, size_t dim2=0, GCPlacement placement=NoGC); } @@ -105,19 +59,26 @@ function *realRealFunction(); #define CURRENTPEN processData().currentpen -#line 16 "runlabel.in" +#line 19 "runlabel.in" #include "picture.h" #include "drawlabel.h" +#include "locate.h" -using namespace camp; + using namespace camp; using namespace vm; using namespace settings; typedef array realarray; +typedef array stringarray; +typedef array penarray; typedef array patharray; +typedef array patharray2; using types::realArray; +using types::stringArray; +using types::penArray; using types::pathArray; +using types::pathArray2; void cannotread(const string& s) { @@ -165,11 +126,10 @@ array *readpath(const string& psname, bool keep, double hscale=1.0, double vsign=1.0) { double vscale=vsign*hscale; - array *P=new array(0); + array *PP=new array(0); mem::vector<string> cmd; cmd.push_back(getSetting<string>("gs")); cmd.push_back("-q"); - cmd.push_back("-dNOPAUSE"); cmd.push_back("-dBATCH"); if(safe) cmd.push_back("-dSAFER"); #ifdef __CYGWIN__ @@ -181,97 +141,112 @@ array *readpath(const string& psname, bool keep, cmd.push_back("-sOutputFile="+null); cmd.push_back(psname); iopipestream gs(cmd,"gs","Ghostscript"); - stringstream buf; while(true) { - string out; - gs >> out; - if(out.empty() && !gs.running()) break; - buf << out; - } - if(verbose > 2) cout << endl; + stringstream buf; + while(true) { + string out; + gs >> out; + if(out.empty() && !gs.running()) break; + buf << out; + if(out[out.size()-1] == '\n') { + gs << newl; + break; + } + } + if(!gs.running()) break; - mem::vector<solvedKnot> nodes; - solvedKnot node; - bool cyclic=false; - bool active=false; + if(verbose > 2) cout << endl; + + mem::vector<solvedKnot> nodes; + solvedKnot node; + bool cyclic=false; + bool active=false; - while(!buf.eof()) { - char c; - buf >> c; - switch(c) { - case 'M': - { - if(active) { - if(cyclic) { - if(node.point == nodes[0].point) - nodes[0].pre=node.pre; - else { - pair delta=(nodes[0].point-node.point)*third; - node.post=node.point+delta; - nodes[0].pre=nodes[0].point-delta; - node.straight=true; + array *P=new array(0); + PP->push(P); + + while(!buf.eof()) { + char c; + buf >> c; + if(c == '>') break; + + switch(c) { + case 'M': + { + if(active) { + if(cyclic) { + if(node.point == nodes[0].point) + nodes[0].pre=node.pre; + else { + pair delta=(nodes[0].point-node.point)*third; + node.post=node.point+delta; + nodes[0].pre=nodes[0].point-delta; + node.straight=true; + nodes.push_back(node); + } + } else { + node.post=node.point; + node.straight=false; nodes.push_back(node); } - } else { - node.post=node.point; - node.straight=false; - nodes.push_back(node); + if(cyclic) // Discard noncyclic paths. + P->push(path(nodes,nodes.size(),cyclic)); + nodes.clear(); } - if(cyclic) // Discard noncyclic paths. - P->push(path(nodes,nodes.size(),cyclic)); - nodes.clear(); + active=false; + cyclic=false; + node.pre=node.point=readpair(buf,hscale,vscale); + node.straight=false; + break; + } + case 'L': + { + pair point=readpair(buf,hscale,vscale); + pair delta=(point-node.point)*third; + node.post=node.point+delta; + node.straight=true; + nodes.push_back(node); + active=true; + node.pre=point-delta; + node.point=point; + break; + } + case 'C': + { + pair point=readpair(buf,hscale,vscale); + pair pre=readpair(buf,hscale,vscale); + node.post=readpair(buf,hscale,vscale); + node.straight=false; + nodes.push_back(node); + active=true; + node.pre=pre; + node.point=point; + break; + } + case 'c': + { + cyclic=true; + break; } - active=false; - cyclic=false; - node.pre=node.point=readpair(buf,hscale,vscale); - node.straight=false; - break; - } - case 'L': - { - pair point=readpair(buf,hscale,vscale); - pair delta=(point-node.point)*third; - node.post=node.point+delta; - node.straight=true; - nodes.push_back(node); - active=true; - node.pre=point-delta; - node.point=point; - break; - } - case 'C': - { - pair point=readpair(buf,hscale,vscale); - pair pre=readpair(buf,hscale,vscale); - node.post=readpair(buf,hscale,vscale); - node.straight=false; - nodes.push_back(node); - active=true; - node.pre=pre; - node.point=point; - break; - } - case 'c': - { - cyclic=true; - break; } } } if(!keep) unlink(psname.c_str()); - return P; + return PP; } // Autogenerated routines: +#ifndef NOSYM #include "runlabel.symbols.h" +#endif namespace run { -#line 177 "runlabel.in" +#line 199 "runlabel.in" // void label(picture *f, string *s, string *size, transform t, pair position, pair align, pen p); void gen_runlabel0(stack *Stack) { @@ -282,26 +257,26 @@ void gen_runlabel0(stack *Stack) string * size=vm::pop<string *>(Stack); string * s=vm::pop<string *>(Stack); picture * f=vm::pop<picture *>(Stack); -#line 179 "runlabel.in" +#line 201 "runlabel.in" f->append(new drawLabel(*s,*size,t,position,align,p)); } -#line 183 "runlabel.in" +#line 205 "runlabel.in" // bool labels(picture *f); void gen_runlabel1(stack *Stack) { picture * f=vm::pop<picture *>(Stack); -#line 184 "runlabel.in" +#line 206 "runlabel.in" {Stack->push<bool>(f->havelabels()); return;} } -#line 188 "runlabel.in" +#line 210 "runlabel.in" // realarray* texsize(string *s, pen p=CURRENTPEN); void gen_runlabel2(stack *Stack) { pen p=vm::pop<pen>(Stack,CURRENTPEN); string * s=vm::pop<string *>(Stack); -#line 189 "runlabel.in" +#line 211 "runlabel.in" texinit(); processDataStruct &pd=processData(); @@ -311,7 +286,7 @@ void gen_runlabel2(stack *Stack) double width,height,depth; if(!texbounds(width,height,depth,pd.tex,*s,abort,false,true)) - {Stack->push<realarray*>(new array(0)); return;} + {Stack->push<realarray*>(new array(0)); return;} array *t=new array(3); (*t)[0]=width; @@ -320,15 +295,15 @@ void gen_runlabel2(stack *Stack) {Stack->push<realarray*>(t); return;} } -#line 208 "runlabel.in" -// patharray* _texpath(string *s, pen p=CURRENTPEN); +#line 230 "runlabel.in" +// patharray2* _texpath(stringarray *s, penarray *p); void gen_runlabel3(stack *Stack) { - pen p=vm::pop<pen>(Stack,CURRENTPEN); - string * s=vm::pop<string *>(Stack); -#line 209 "runlabel.in" - array *P=new array(0); - if(s->empty()) {Stack->push<patharray*>(P); return;} + penarray * p=vm::pop<penarray *>(Stack); + stringarray * s=vm::pop<stringarray *>(Stack); +#line 231 "runlabel.in" + size_t n=checkArrays(s,p); + if(n == 0) {Stack->push<patharray2*>(new array(0)); return;} string prefix=cleanpath(outname()); string psname=auxname(prefix,"ps"); @@ -339,19 +314,24 @@ void gen_runlabel3(stack *Stack) bool pdf=settings::pdf(texengine); texfile tex(texname,b,true); tex.miniprologue(); - tex.setfont(p); - if(!pdf) { - tex.verbatimline("\\special{ps:"); - tex.verbatimline(ASYx); - tex.verbatimline(ASYy); - tex.verbatimline("/ASY1 true def"); - tex.verbatimline("/v {"+ASY1+"neg exch 4 copy 4 2 roll 2 copy 6 2 roll 2 copy (M) print ASYy ASYx (L) print ASYy add ASYx (L) print add ASYy add ASYx (L) print add ASYy ASYx (c) print} bind def"); - tex.verbatimline("/show {"+ASY1+ - "currentpoint newpath moveto false charpath "+ - pathforall+"} bind def}"); + for(size_t i=0; i < n; ++i) { + tex.setfont(read<pen>(p,i)); + if(i != 0) + tex.verbatimline("\\newpage"); + if(!pdf) { + tex.verbatimline("\\special{ps:"); + tex.verbatimline(ASYx); + tex.verbatimline(ASYy); + tex.verbatimline("/ASY1 true def"); + tex.verbatimline("/v {"+ASY1+"neg exch 4 copy 4 2 roll 2 copy 6 2 roll 2 copy (M) print ASYy ASYx (L) print ASYy add ASYx (L) print add ASYy add ASYx (L) print add ASYy ASYx (c) print} bind def"); + tex.verbatimline("/show {"+ASY1+ + "currentpoint newpath moveto false charpath "+ + pathforall+"} bind def}"); + } + tex.verbatimline(read<string>(s,i)+"%"); } - tex.verbatimline(*s+"%"); + tex.epilogue(true); tex.close(); @@ -361,6 +341,7 @@ void gen_runlabel3(stack *Stack) if(!status) { if(pdf) { pdfname=auxname(prefix,"pdf"); + if(!fs::exists(pdfname)) {Stack->push<patharray2*>(new array(n)); return;} std::ofstream ps(psname.c_str()); if(!ps) cannotwrite(psname); @@ -387,6 +368,7 @@ void gen_runlabel3(stack *Stack) } ps.close(); } else { + if(!fs::exists(dviname)) {Stack->push<patharray2*>(new array(n)); return;} mem::vector<string> dcmd; dcmd.push_back(getSetting<string>("dvips")); dcmd.push_back("-R"); @@ -419,18 +401,18 @@ void gen_runlabel3(stack *Stack) unlink(auxname(prefix,"tui").c_str()); } } - {Stack->push<patharray*>(pdf ? readpath(psname,keep,0.1) : readpath(psname,keep,0.12,-1.0)); return;} + {Stack->push<patharray2*>(pdf ? readpath(psname,keep,0.1) : readpath(psname,keep,0.12,-1.0)); return;} } -#line 305 "runlabel.in" -// patharray* textpath(string *s, pen p=CURRENTPEN); +#line 334 "runlabel.in" +// patharray2* textpath(stringarray *s, penarray *p); void gen_runlabel4(stack *Stack) { - pen p=vm::pop<pen>(Stack,CURRENTPEN); - string * s=vm::pop<string *>(Stack); -#line 306 "runlabel.in" - array *P=new array(0); - if(s->empty()) {Stack->push<patharray*>(P); return;} + penarray * p=vm::pop<penarray *>(Stack); + stringarray * s=vm::pop<stringarray *>(Stack); +#line 335 "runlabel.in" + size_t n=checkArrays(s,p); + if(n == 0) {Stack->push<patharray2*>(new array(0)); return;} string prefix=cleanpath(outname()); string outputname=auxname(prefix,getSetting<string>("textoutformat")); @@ -440,10 +422,12 @@ void gen_runlabel4(stack *Stack) if(!text) cannotwrite(textname); - text << getSetting<string>("textprologue") << newl - << p.Font() << newl - << *s << newl - << getSetting<string>("textepilogue") << endl; + for(size_t i=0; i < n; ++i) { + text << getSetting<string>("textprologue") << newl + << read<pen>(p,i).Font() << newl + << read<string>(s,i) << newl + << getSetting<string>("textepilogue") << endl; + } text.close(); string psname=auxname(prefix,"ps"); @@ -494,16 +478,16 @@ void gen_runlabel4(stack *Stack) bool keep=getSetting<bool>("keep"); if(!keep) // Delete temporary files. unlink(textname.c_str()); - {Stack->push<patharray*>(readpath(psname,keep,0.1)); return;} + {Stack->push<patharray2*>(readpath(psname,keep,0.1)); return;} } -#line 375 "runlabel.in" +#line 406 "runlabel.in" // patharray* _strokepath(path g, pen p=CURRENTPEN); void gen_runlabel5(stack *Stack) { pen p=vm::pop<pen>(Stack,CURRENTPEN); path g=vm::pop<path>(Stack); -#line 376 "runlabel.in" +#line 407 "runlabel.in" array *P=new array(0); if(g.size() == 0) {Stack->push<patharray*>(P); return;} @@ -523,7 +507,8 @@ void gen_runlabel5(stack *Stack) ps.verbatimline("(M) "+currentpoint); ps.epilogue(); ps.close(); - {Stack->push<patharray*>(readpath(psname,getSetting<bool>("keep"))); return;} + array *a=readpath(psname,getSetting<bool>("keep")); + {Stack->push<patharray*>(a->size() > 0 ? read<array *>(a,0) : a); return;} } } // namespace run @@ -532,18 +517,18 @@ namespace trans { void gen_runlabel_venv(venv &ve) { -#line 177 "runlabel.in" +#line 199 "runlabel.in" addFunc(ve, run::gen_runlabel0, primVoid(), SYM(label), formal(primPicture(), SYM(f), false, false), formal(primString(), SYM(s), false, false), formal(primString(), SYM(size), false, false), formal(primTransform(), SYM(t), false, false), formal(primPair(), SYM(position), false, false), formal(primPair(), SYM(align), false, false), formal(primPen(), SYM(p), false, false)); -#line 183 "runlabel.in" +#line 205 "runlabel.in" addFunc(ve, run::gen_runlabel1, primBoolean(), SYM(labels), formal(primPicture(), SYM(f), false, false)); -#line 188 "runlabel.in" +#line 210 "runlabel.in" addFunc(ve, run::gen_runlabel2, realArray(), SYM(texsize), formal(primString(), SYM(s), false, false), formal(primPen(), SYM(p), true, false)); -#line 208 "runlabel.in" - addFunc(ve, run::gen_runlabel3, pathArray() , SYM(_texpath), formal(primString(), SYM(s), false, false), formal(primPen(), SYM(p), true, false)); -#line 305 "runlabel.in" - addFunc(ve, run::gen_runlabel4, pathArray() , SYM(textpath), formal(primString(), SYM(s), false, false), formal(primPen(), SYM(p), true, false)); -#line 375 "runlabel.in" - addFunc(ve, run::gen_runlabel5, pathArray() , SYM(_strokepath), formal(primPath(), SYM(g), false, false), formal(primPen(), SYM(p), true, false)); +#line 230 "runlabel.in" + addFunc(ve, run::gen_runlabel3, pathArray2() , SYM(_texpath), formal(stringArray() , SYM(s), false, false), formal(penArray() , SYM(p), false, false)); +#line 334 "runlabel.in" + addFunc(ve, run::gen_runlabel4, pathArray2() , SYM(textpath), formal(stringArray() , SYM(s), false, false), formal(penArray() , SYM(p), false, false)); +#line 406 "runlabel.in" + addFunc(ve, run::gen_runlabel5, pathArray() , SYM(_strokepath), formal(primPath(), SYM(g), false, false), formal(primPen(), SYM(p), true, false)); } } // namespace trans diff --git a/Build/source/utils/asymptote/runlabel.in b/Build/source/utils/asymptote/runlabel.in index cee146b48bf..b1279a900f9 100644 --- a/Build/source/utils/asymptote/runlabel.in +++ b/Build/source/utils/asymptote/runlabel.in @@ -6,25 +6,35 @@ *****/ pen => primPen() -pair => primPair() -path => primPath() -picture* => primPicture() -transform => primTransform() -realarray* => realArray() -patharray* => pathArray() + pair => primPair() + path => primPath() + picture* => primPicture() + transform => primTransform() + realarray* => realArray() + stringarray* => stringArray() + penarray* => penArray() + patharray* => pathArray() + patharray2* => pathArray2() #include "picture.h" #include "drawlabel.h" +#include "locate.h" -using namespace camp; + using namespace camp; using namespace vm; using namespace settings; typedef array realarray; +typedef array stringarray; +typedef array penarray; typedef array patharray; +typedef array patharray2; using types::realArray; +using types::stringArray; +using types::penArray; using types::pathArray; +using types::pathArray2; void cannotread(const string& s) { @@ -72,11 +82,10 @@ array *readpath(const string& psname, bool keep, double hscale=1.0, double vsign=1.0) { double vscale=vsign*hscale; - array *P=new array(0); + array *PP=new array(0); mem::vector<string> cmd; cmd.push_back(getSetting<string>("gs")); cmd.push_back("-q"); - cmd.push_back("-dNOPAUSE"); cmd.push_back("-dBATCH"); if(safe) cmd.push_back("-dSAFER"); #ifdef __CYGWIN__ @@ -88,87 +97,100 @@ array *readpath(const string& psname, bool keep, cmd.push_back("-sOutputFile="+null); cmd.push_back(psname); iopipestream gs(cmd,"gs","Ghostscript"); - stringstream buf; while(true) { - string out; - gs >> out; - if(out.empty() && !gs.running()) break; - buf << out; - } - if(verbose > 2) cout << endl; + stringstream buf; + while(true) { + string out; + gs >> out; + if(out.empty() && !gs.running()) break; + buf << out; + if(out[out.size()-1] == '\n') { + gs << newl; + break; + } + } + if(!gs.running()) break; - mem::vector<solvedKnot> nodes; - solvedKnot node; - bool cyclic=false; - bool active=false; + if(verbose > 2) cout << endl; - while(!buf.eof()) { - char c; - buf >> c; - switch(c) { - case 'M': - { - if(active) { - if(cyclic) { - if(node.point == nodes[0].point) - nodes[0].pre=node.pre; - else { - pair delta=(nodes[0].point-node.point)*third; - node.post=node.point+delta; - nodes[0].pre=nodes[0].point-delta; - node.straight=true; + mem::vector<solvedKnot> nodes; + solvedKnot node; + bool cyclic=false; + bool active=false; + + array *P=new array(0); + PP->push(P); + + while(!buf.eof()) { + char c; + buf >> c; + if(c == '>') break; + + switch(c) { + case 'M': + { + if(active) { + if(cyclic) { + if(node.point == nodes[0].point) + nodes[0].pre=node.pre; + else { + pair delta=(nodes[0].point-node.point)*third; + node.post=node.point+delta; + nodes[0].pre=nodes[0].point-delta; + node.straight=true; + nodes.push_back(node); + } + } else { + node.post=node.point; + node.straight=false; nodes.push_back(node); } - } else { - node.post=node.point; - node.straight=false; - nodes.push_back(node); + if(cyclic) // Discard noncyclic paths. + P->push(path(nodes,nodes.size(),cyclic)); + nodes.clear(); } - if(cyclic) // Discard noncyclic paths. - P->push(path(nodes,nodes.size(),cyclic)); - nodes.clear(); + active=false; + cyclic=false; + node.pre=node.point=readpair(buf,hscale,vscale); + node.straight=false; + break; + } + case 'L': + { + pair point=readpair(buf,hscale,vscale); + pair delta=(point-node.point)*third; + node.post=node.point+delta; + node.straight=true; + nodes.push_back(node); + active=true; + node.pre=point-delta; + node.point=point; + break; + } + case 'C': + { + pair point=readpair(buf,hscale,vscale); + pair pre=readpair(buf,hscale,vscale); + node.post=readpair(buf,hscale,vscale); + node.straight=false; + nodes.push_back(node); + active=true; + node.pre=pre; + node.point=point; + break; + } + case 'c': + { + cyclic=true; + break; } - active=false; - cyclic=false; - node.pre=node.point=readpair(buf,hscale,vscale); - node.straight=false; - break; - } - case 'L': - { - pair point=readpair(buf,hscale,vscale); - pair delta=(point-node.point)*third; - node.post=node.point+delta; - node.straight=true; - nodes.push_back(node); - active=true; - node.pre=point-delta; - node.point=point; - break; - } - case 'C': - { - pair point=readpair(buf,hscale,vscale); - pair pre=readpair(buf,hscale,vscale); - node.post=readpair(buf,hscale,vscale); - node.straight=false; - nodes.push_back(node); - active=true; - node.pre=pre; - node.point=point; - break; - } - case 'c': - { - cyclic=true; - break; } } } if(!keep) unlink(psname.c_str()); - return P; + return PP; } // Autogenerated routines: @@ -196,7 +218,7 @@ realarray *texsize(string *s, pen p=CURRENTPEN) double width,height,depth; if(!texbounds(width,height,depth,pd.tex,*s,abort,false,true)) - return new array(0); + return new array(0); array *t=new array(3); (*t)[0]=width; @@ -205,10 +227,10 @@ realarray *texsize(string *s, pen p=CURRENTPEN) return t; } -patharray *_texpath(string *s, pen p=CURRENTPEN) +patharray2 *_texpath(stringarray *s, penarray *p) { - array *P=new array(0); - if(s->empty()) return P; + size_t n=checkArrays(s,p); + if(n == 0) return new array(0); string prefix=cleanpath(outname()); string psname=auxname(prefix,"ps"); @@ -219,19 +241,24 @@ patharray *_texpath(string *s, pen p=CURRENTPEN) bool pdf=settings::pdf(texengine); texfile tex(texname,b,true); tex.miniprologue(); - tex.setfont(p); - if(!pdf) { - tex.verbatimline("\\special{ps:"); - tex.verbatimline(ASYx); - tex.verbatimline(ASYy); - tex.verbatimline("/ASY1 true def"); - tex.verbatimline("/v {"+ASY1+"neg exch 4 copy 4 2 roll 2 copy 6 2 roll 2 copy (M) print ASYy ASYx (L) print ASYy add ASYx (L) print add ASYy add ASYx (L) print add ASYy ASYx (c) print} bind def"); - tex.verbatimline("/show {"+ASY1+ - "currentpoint newpath moveto false charpath "+ - pathforall+"} bind def}"); + for(size_t i=0; i < n; ++i) { + tex.setfont(read<pen>(p,i)); + if(i != 0) + tex.verbatimline("\\newpage"); + if(!pdf) { + tex.verbatimline("\\special{ps:"); + tex.verbatimline(ASYx); + tex.verbatimline(ASYy); + tex.verbatimline("/ASY1 true def"); + tex.verbatimline("/v {"+ASY1+"neg exch 4 copy 4 2 roll 2 copy 6 2 roll 2 copy (M) print ASYy ASYx (L) print ASYy add ASYx (L) print add ASYy add ASYx (L) print add ASYy ASYx (c) print} bind def"); + tex.verbatimline("/show {"+ASY1+ + "currentpoint newpath moveto false charpath "+ + pathforall+"} bind def}"); + } + tex.verbatimline(read<string>(s,i)+"%"); } - tex.verbatimline(*s+"%"); + tex.epilogue(true); tex.close(); @@ -241,6 +268,7 @@ patharray *_texpath(string *s, pen p=CURRENTPEN) if(!status) { if(pdf) { pdfname=auxname(prefix,"pdf"); + if(!fs::exists(pdfname)) return new array(n); std::ofstream ps(psname.c_str()); if(!ps) cannotwrite(psname); @@ -267,6 +295,7 @@ patharray *_texpath(string *s, pen p=CURRENTPEN) } ps.close(); } else { + if(!fs::exists(dviname)) return new array(n); mem::vector<string> dcmd; dcmd.push_back(getSetting<string>("dvips")); dcmd.push_back("-R"); @@ -302,10 +331,10 @@ patharray *_texpath(string *s, pen p=CURRENTPEN) return pdf ? readpath(psname,keep,0.1) : readpath(psname,keep,0.12,-1.0); } -patharray *textpath(string *s, pen p=CURRENTPEN) +patharray2 *textpath(stringarray *s, penarray *p) { - array *P=new array(0); - if(s->empty()) return P; + size_t n=checkArrays(s,p); + if(n == 0) return new array(0); string prefix=cleanpath(outname()); string outputname=auxname(prefix,getSetting<string>("textoutformat")); @@ -315,10 +344,12 @@ patharray *textpath(string *s, pen p=CURRENTPEN) if(!text) cannotwrite(textname); - text << getSetting<string>("textprologue") << newl - << p.Font() << newl - << *s << newl - << getSetting<string>("textepilogue") << endl; + for(size_t i=0; i < n; ++i) { + text << getSetting<string>("textprologue") << newl + << read<pen>(p,i).Font() << newl + << read<string>(s,i) << newl + << getSetting<string>("textepilogue") << endl; + } text.close(); string psname=auxname(prefix,"ps"); @@ -393,5 +424,6 @@ patharray *_strokepath(path g, pen p=CURRENTPEN) ps.verbatimline("(M) "+currentpoint); ps.epilogue(); ps.close(); - return readpath(psname,getSetting<bool>("keep")); + array *a=readpath(psname,getSetting<bool>("keep")); + return a->size() > 0 ? read<array *>(a,0) : a; } diff --git a/Build/source/utils/asymptote/runlabel.symbols.h b/Build/source/utils/asymptote/runlabel.symbols.h deleted file mode 100644 index 460b024ad50..00000000000 --- a/Build/source/utils/asymptote/runlabel.symbols.h +++ /dev/null @@ -1,31 +0,0 @@ -/***** - * This file is automatically generated by findsym.pl - * Changes will be overwritten. - *****/ - -// If the ADDSYMBOL macro is not already defined, define it with the default -// purpose of referring to an external pre-translated symbol, such that -// SYM(name) also refers to that symbol. -#ifndef ADDSYMBOL - #define ADDSYMBOL(name) extern sym::symbol PRETRANSLATED_SYMBOL_##name - #ifdef PRESYM - #define SYM(name) PRETRANSLATED_SYMBOL_##name - #else - #define SYM(name) sym::symbol::trans(#name) - #endif -#endif - -ADDSYMBOL(_strokepath); -ADDSYMBOL(_texpath); -ADDSYMBOL(align); -ADDSYMBOL(f); -ADDSYMBOL(g); -ADDSYMBOL(label); -ADDSYMBOL(labels); -ADDSYMBOL(p); -ADDSYMBOL(position); -ADDSYMBOL(s); -ADDSYMBOL(size); -ADDSYMBOL(t); -ADDSYMBOL(texsize); -ADDSYMBOL(textpath); diff --git a/Build/source/utils/asymptote/runmath.cc b/Build/source/utils/asymptote/runmath.cc index c15450389dd..adaa5519c01 100644 --- a/Build/source/utils/asymptote/runmath.cc +++ b/Build/source/utils/asymptote/runmath.cc @@ -51,52 +51,6 @@ array *copyArray(array *a); array *copyArray2(array *a); array *copyArray3(array *a); -inline size_t checkdimension(const array *a, size_t dim) -{ - size_t size=checkArray(a); - if(dim && size != dim) { - ostringstream buf; - buf << "array of length " << dim << " expected"; - error(buf); - } - return size; -} - -template<class T> -void copyArrayC(T* &dest, const array *a, size_t dim=0, - GCPlacement placement=NoGC) -{ - size_t size=checkdimension(a,dim); - dest=(placement == NoGC) ? new T[size] : new(placement) T[size]; - for(size_t i=0; i < size; i++) - dest[i]=read<T>(a,i); -} - -template<class T> -void copyArray2C(T* &dest, const array *a, bool square=true, size_t dim2=0, - GCPlacement placement=NoGC) -{ - size_t n=checkArray(a); - size_t m=(square || n == 0) ? n : checkArray(read<array*>(a,0)); - if(n > 0 && dim2 && m != dim2) { - ostringstream buf; - buf << "second matrix dimension must be " << dim2; - error(buf); - } - - dest=(placement == NoGC) ? new T[n*m] : new(placement) T[n*m]; - for(size_t i=0; i < n; i++) { - array *ai=read<array*>(a,i); - size_t aisize=checkArray(ai); - if(aisize == m) { - T *desti=dest+i*m; - for(size_t j=0; j < m; j++) - desti[j]=read<T>(ai,j); - } else - error(square ? "matrix must be square" : "matrix must be rectangular"); - } -} - double *copyTripleArray2Components(array *a, bool square=true, size_t dim2=0, GCPlacement placement=NoGC); } @@ -170,8 +124,10 @@ void Srand(Int seed) +#ifndef NOSYM #include "runmath.symbols.h" +#endif namespace run { #line 75 "runmath.in" // real ^(real x, Int y); diff --git a/Build/source/utils/asymptote/runmath.symbols.h b/Build/source/utils/asymptote/runmath.symbols.h deleted file mode 100644 index e9c8aa8ef13..00000000000 --- a/Build/source/utils/asymptote/runmath.symbols.h +++ /dev/null @@ -1,58 +0,0 @@ -/***** - * This file is automatically generated by findsym.pl - * Changes will be overwritten. - *****/ - -// If the ADDSYMBOL macro is not already defined, define it with the default -// purpose of referring to an external pre-translated symbol, such that -// SYM(name) also refers to that symbol. -#ifndef ADDSYMBOL - #define ADDSYMBOL(name) extern sym::symbol PRETRANSLATED_SYMBOL_##name - #ifdef PRESYM - #define SYM(name) PRETRANSLATED_SYMBOL_##name - #else - #define SYM(name) sym::symbol::trans(#name) - #endif -#endif - -ADDSYMBOL(AND); -ADDSYMBOL(CLZ); -ADDSYMBOL(CTZ); -ADDSYMBOL(Ceil); -ADDSYMBOL(Floor); -ADDSYMBOL(Jn); -ADDSYMBOL(NOT); -ADDSYMBOL(OR); -ADDSYMBOL(Round); -ADDSYMBOL(XOR); -ADDSYMBOL(Yn); -ADDSYMBOL(a); -ADDSYMBOL(abs); -ADDSYMBOL(atan2); -ADDSYMBOL(b); -ADDSYMBOL(c); -ADDSYMBOL(ceil); -ADDSYMBOL(choose); -ADDSYMBOL(cubicroots); -ADDSYMBOL(d); -ADDSYMBOL(erf); -ADDSYMBOL(erfc); -ADDSYMBOL(factorial); -ADDSYMBOL(floor); -ADDSYMBOL(fmod); -ADDSYMBOL(gamma); -ADDSYMBOL(hypot); -ADDSYMBOL(k); -ADDSYMBOL(n); -ADDSYMBOL(quadraticroots); -ADDSYMBOL(quotient); -ADDSYMBOL(rand); -ADDSYMBOL(remainder); -ADDSYMBOL(round); -ADDSYMBOL(seed); -ADDSYMBOL(sgn); -ADDSYMBOL(srand); -ADDSYMBOL(unitrand); -ADDSYMBOL(x); -ADDSYMBOL(y); -ADDSYMBOL(z); diff --git a/Build/source/utils/asymptote/runpair.cc b/Build/source/utils/asymptote/runpair.cc index 89eec01aedf..0fdcc20790a 100644 --- a/Build/source/utils/asymptote/runpair.cc +++ b/Build/source/utils/asymptote/runpair.cc @@ -51,52 +51,6 @@ array *copyArray(array *a); array *copyArray2(array *a); array *copyArray3(array *a); -inline size_t checkdimension(const array *a, size_t dim) -{ - size_t size=checkArray(a); - if(dim && size != dim) { - ostringstream buf; - buf << "array of length " << dim << " expected"; - error(buf); - } - return size; -} - -template<class T> -void copyArrayC(T* &dest, const array *a, size_t dim=0, - GCPlacement placement=NoGC) -{ - size_t size=checkdimension(a,dim); - dest=(placement == NoGC) ? new T[size] : new(placement) T[size]; - for(size_t i=0; i < size; i++) - dest[i]=read<T>(a,i); -} - -template<class T> -void copyArray2C(T* &dest, const array *a, bool square=true, size_t dim2=0, - GCPlacement placement=NoGC) -{ - size_t n=checkArray(a); - size_t m=(square || n == 0) ? n : checkArray(read<array*>(a,0)); - if(n > 0 && dim2 && m != dim2) { - ostringstream buf; - buf << "second matrix dimension must be " << dim2; - error(buf); - } - - dest=(placement == NoGC) ? new T[n*m] : new(placement) T[n*m]; - for(size_t i=0; i < n; i++) { - array *ai=read<array*>(a,i); - size_t aisize=checkArray(ai); - if(aisize == m) { - T *desti=dest+i*m; - for(size_t j=0; j < m; j++) - desti[j]=read<T>(ai,j); - } else - error(square ? "matrix must be square" : "matrix must be rectangular"); - } -} - double *copyTripleArray2Components(array *a, bool square=true, size_t dim2=0, GCPlacement placement=NoGC); } @@ -146,8 +100,10 @@ pair gamma(pair z) +#ifndef NOSYM #include "runpair.symbols.h" +#endif namespace run { #line 49 "runpair.in" void pairZero(stack *Stack) diff --git a/Build/source/utils/asymptote/runpair.symbols.h b/Build/source/utils/asymptote/runpair.symbols.h deleted file mode 100644 index 59057fb118d..00000000000 --- a/Build/source/utils/asymptote/runpair.symbols.h +++ /dev/null @@ -1,57 +0,0 @@ -/***** - * This file is automatically generated by findsym.pl - * Changes will be overwritten. - *****/ - -// If the ADDSYMBOL macro is not already defined, define it with the default -// purpose of referring to an external pre-translated symbol, such that -// SYM(name) also refers to that symbol. -#ifndef ADDSYMBOL - #define ADDSYMBOL(name) extern sym::symbol PRETRANSLATED_SYMBOL_##name - #ifdef PRESYM - #define SYM(name) PRETRANSLATED_SYMBOL_##name - #else - #define SYM(name) sym::symbol::trans(#name) - #endif -#endif - -ADDSYMBOL(Cos); -ADDSYMBOL(Degrees); -ADDSYMBOL(Sin); -ADDSYMBOL(Tan); -ADDSYMBOL(a); -ADDSYMBOL(aCos); -ADDSYMBOL(aSin); -ADDSYMBOL(aTan); -ADDSYMBOL(abs); -ADDSYMBOL(angle); -ADDSYMBOL(b); -ADDSYMBOL(bezier); -ADDSYMBOL(bezierP); -ADDSYMBOL(bezierPP); -ADDSYMBOL(bezierPPP); -ADDSYMBOL(c); -ADDSYMBOL(conj); -ADDSYMBOL(cos); -ADDSYMBOL(d); -ADDSYMBOL(deg); -ADDSYMBOL(degrees); -ADDSYMBOL(dir); -ADDSYMBOL(dot); -ADDSYMBOL(exp); -ADDSYMBOL(expi); -ADDSYMBOL(gamma); -ADDSYMBOL(length); -ADDSYMBOL(log); -ADDSYMBOL(radians); -ADDSYMBOL(realmult); -ADDSYMBOL(sin); -ADDSYMBOL(sqrt); -ADDSYMBOL(t); -ADDSYMBOL(unit); -ADDSYMBOL(w); -ADDSYMBOL(warn); -ADDSYMBOL(x); -ADDSYMBOL(xpart); -ADDSYMBOL(ypart); -ADDSYMBOL(z); diff --git a/Build/source/utils/asymptote/runpath.cc b/Build/source/utils/asymptote/runpath.cc index 00a0a7ab8e7..7c69fde4fb8 100644 --- a/Build/source/utils/asymptote/runpath.cc +++ b/Build/source/utils/asymptote/runpath.cc @@ -51,52 +51,6 @@ array *copyArray(array *a); array *copyArray2(array *a); array *copyArray3(array *a); -inline size_t checkdimension(const array *a, size_t dim) -{ - size_t size=checkArray(a); - if(dim && size != dim) { - ostringstream buf; - buf << "array of length " << dim << " expected"; - error(buf); - } - return size; -} - -template<class T> -void copyArrayC(T* &dest, const array *a, size_t dim=0, - GCPlacement placement=NoGC) -{ - size_t size=checkdimension(a,dim); - dest=(placement == NoGC) ? new T[size] : new(placement) T[size]; - for(size_t i=0; i < size; i++) - dest[i]=read<T>(a,i); -} - -template<class T> -void copyArray2C(T* &dest, const array *a, bool square=true, size_t dim2=0, - GCPlacement placement=NoGC) -{ - size_t n=checkArray(a); - size_t m=(square || n == 0) ? n : checkArray(read<array*>(a,0)); - if(n > 0 && dim2 && m != dim2) { - ostringstream buf; - buf << "second matrix dimension must be " << dim2; - error(buf); - } - - dest=(placement == NoGC) ? new T[n*m] : new(placement) T[n*m]; - for(size_t i=0; i < n; i++) { - array *ai=read<array*>(a,i); - size_t aisize=checkArray(ai); - if(aisize == m) { - T *desti=dest+i*m; - for(size_t j=0; j < m; j++) - desti[j]=read<T>(ai,j); - } else - error(square ? "matrix must be square" : "matrix must be rectangular"); - } -} - double *copyTripleArray2Components(array *a, bool square=true, size_t dim2=0, GCPlacement placement=NoGC); } @@ -134,8 +88,10 @@ Int windingnumber(array *p, camp::pair z) +#ifndef NOSYM #include "runpath.symbols.h" +#endif namespace run { #line 43 "runpath.in" void nullPath(stack *Stack) diff --git a/Build/source/utils/asymptote/runpath.symbols.h b/Build/source/utils/asymptote/runpath.symbols.h deleted file mode 100644 index 9e2f6a569af..00000000000 --- a/Build/source/utils/asymptote/runpath.symbols.h +++ /dev/null @@ -1,73 +0,0 @@ -/***** - * This file is automatically generated by findsym.pl - * Changes will be overwritten. - *****/ - -// If the ADDSYMBOL macro is not already defined, define it with the default -// purpose of referring to an external pre-translated symbol, such that -// SYM(name) also refers to that symbol. -#ifndef ADDSYMBOL - #define ADDSYMBOL(name) extern sym::symbol PRETRANSLATED_SYMBOL_##name - #ifdef PRESYM - #define SYM(name) PRETRANSLATED_SYMBOL_##name - #else - #define SYM(name) sym::symbol::trans(#name) - #endif -#endif - -ADDSYMBOL(a); -ADDSYMBOL(accel); -ADDSYMBOL(arclength); -ADDSYMBOL(arctime); -ADDSYMBOL(atleast); -ADDSYMBOL(b); -ADDSYMBOL(c); -ADDSYMBOL(cyclic); -ADDSYMBOL(d); -ADDSYMBOL(dir); -ADDSYMBOL(dirtime); -ADDSYMBOL(dval); -ADDSYMBOL(extension); -ADDSYMBOL(fillrule); -ADDSYMBOL(fuzz); -ADDSYMBOL(g); -ADDSYMBOL(incircle); -ADDSYMBOL(inside); -ADDSYMBOL(intersect); -ADDSYMBOL(intersections); -ADDSYMBOL(length); -ADDSYMBOL(m); -ADDSYMBOL(max); -ADDSYMBOL(maxtimes); -ADDSYMBOL(min); -ADDSYMBOL(mintimes); -ADDSYMBOL(normalize); -ADDSYMBOL(nurb); -ADDSYMBOL(p); -ADDSYMBOL(phi); -ADDSYMBOL(piecewisestraight); -ADDSYMBOL(point); -ADDSYMBOL(postcontrol); -ADDSYMBOL(precontrol); -ADDSYMBOL(q); -ADDSYMBOL(radius); -ADDSYMBOL(relativedistance); -ADDSYMBOL(reverse); -ADDSYMBOL(side); -ADDSYMBOL(sign); -ADDSYMBOL(size); -ADDSYMBOL(straight); -ADDSYMBOL(subpath); -ADDSYMBOL(t); -ADDSYMBOL(theta); -ADDSYMBOL(unstraighten); -ADDSYMBOL(w0); -ADDSYMBOL(w1); -ADDSYMBOL(w2); -ADDSYMBOL(w3); -ADDSYMBOL(windingnumber); -ADDSYMBOL(z); -ADDSYMBOL(z0); -ADDSYMBOL(z1); -ADDSYMBOL(z2); -ADDSYMBOL(z3); diff --git a/Build/source/utils/asymptote/runpath3d.cc b/Build/source/utils/asymptote/runpath3d.cc index 1b70db7c7c8..9cdf644ee41 100644 --- a/Build/source/utils/asymptote/runpath3d.cc +++ b/Build/source/utils/asymptote/runpath3d.cc @@ -51,52 +51,6 @@ array *copyArray(array *a); array *copyArray2(array *a); array *copyArray3(array *a); -inline size_t checkdimension(const array *a, size_t dim) -{ - size_t size=checkArray(a); - if(dim && size != dim) { - ostringstream buf; - buf << "array of length " << dim << " expected"; - error(buf); - } - return size; -} - -template<class T> -void copyArrayC(T* &dest, const array *a, size_t dim=0, - GCPlacement placement=NoGC) -{ - size_t size=checkdimension(a,dim); - dest=(placement == NoGC) ? new T[size] : new(placement) T[size]; - for(size_t i=0; i < size; i++) - dest[i]=read<T>(a,i); -} - -template<class T> -void copyArray2C(T* &dest, const array *a, bool square=true, size_t dim2=0, - GCPlacement placement=NoGC) -{ - size_t n=checkArray(a); - size_t m=(square || n == 0) ? n : checkArray(read<array*>(a,0)); - if(n > 0 && dim2 && m != dim2) { - ostringstream buf; - buf << "second matrix dimension must be " << dim2; - error(buf); - } - - dest=(placement == NoGC) ? new T[n*m] : new(placement) T[n*m]; - for(size_t i=0; i < n; i++) { - array *ai=read<array*>(a,i); - size_t aisize=checkArray(ai); - if(aisize == m) { - T *desti=dest+i*m; - for(size_t j=0; j < m; j++) - desti[j]=read<T>(ai,j); - } else - error(square ? "matrix must be square" : "matrix must be rectangular"); - } -} - double *copyTripleArray2Components(array *a, bool square=true, size_t dim2=0, GCPlacement placement=NoGC); } @@ -129,8 +83,10 @@ using types::tripleArray2; +#ifndef NOSYM #include "runpath3d.symbols.h" +#endif namespace run { #line 39 "runpath3d.in" // path3 path3(triplearray *pre, triplearray *point, triplearray *post, boolarray *straight, bool cyclic); diff --git a/Build/source/utils/asymptote/runpath3d.symbols.h b/Build/source/utils/asymptote/runpath3d.symbols.h deleted file mode 100644 index 7953c25fc1e..00000000000 --- a/Build/source/utils/asymptote/runpath3d.symbols.h +++ /dev/null @@ -1,59 +0,0 @@ -/***** - * This file is automatically generated by findsym.pl - * Changes will be overwritten. - *****/ - -// If the ADDSYMBOL macro is not already defined, define it with the default -// purpose of referring to an external pre-translated symbol, such that -// SYM(name) also refers to that symbol. -#ifndef ADDSYMBOL - #define ADDSYMBOL(name) extern sym::symbol PRETRANSLATED_SYMBOL_##name - #ifdef PRESYM - #define SYM(name) PRETRANSLATED_SYMBOL_##name - #else - #define SYM(name) sym::symbol::trans(#name) - #endif -#endif - -ADDSYMBOL(a); -ADDSYMBOL(accel); -ADDSYMBOL(arclength); -ADDSYMBOL(arctime); -ADDSYMBOL(b); -ADDSYMBOL(c0); -ADDSYMBOL(c1); -ADDSYMBOL(cyclic); -ADDSYMBOL(dir); -ADDSYMBOL(dval); -ADDSYMBOL(fuzz); -ADDSYMBOL(g); -ADDSYMBOL(intersect); -ADDSYMBOL(intersections); -ADDSYMBOL(length); -ADDSYMBOL(max); -ADDSYMBOL(maxratio); -ADDSYMBOL(maxtimes); -ADDSYMBOL(min); -ADDSYMBOL(minratio); -ADDSYMBOL(mintimes); -ADDSYMBOL(normalize); -ADDSYMBOL(p); -ADDSYMBOL(path3); -ADDSYMBOL(piecewisestraight); -ADDSYMBOL(point); -ADDSYMBOL(post); -ADDSYMBOL(postcontrol); -ADDSYMBOL(pre); -ADDSYMBOL(precontrol); -ADDSYMBOL(q); -ADDSYMBOL(radius); -ADDSYMBOL(reverse); -ADDSYMBOL(sign); -ADDSYMBOL(size); -ADDSYMBOL(straight); -ADDSYMBOL(straightness); -ADDSYMBOL(subpath); -ADDSYMBOL(t); -ADDSYMBOL(unstraighten); -ADDSYMBOL(z0); -ADDSYMBOL(z1); diff --git a/Build/source/utils/asymptote/runpicture.cc b/Build/source/utils/asymptote/runpicture.cc index acc56601bd4..f8f58b33ae4 100644 --- a/Build/source/utils/asymptote/runpicture.cc +++ b/Build/source/utils/asymptote/runpicture.cc @@ -51,52 +51,6 @@ array *copyArray(array *a); array *copyArray2(array *a); array *copyArray3(array *a); -inline size_t checkdimension(const array *a, size_t dim) -{ - size_t size=checkArray(a); - if(dim && size != dim) { - ostringstream buf; - buf << "array of length " << dim << " expected"; - error(buf); - } - return size; -} - -template<class T> -void copyArrayC(T* &dest, const array *a, size_t dim=0, - GCPlacement placement=NoGC) -{ - size_t size=checkdimension(a,dim); - dest=(placement == NoGC) ? new T[size] : new(placement) T[size]; - for(size_t i=0; i < size; i++) - dest[i]=read<T>(a,i); -} - -template<class T> -void copyArray2C(T* &dest, const array *a, bool square=true, size_t dim2=0, - GCPlacement placement=NoGC) -{ - size_t n=checkArray(a); - size_t m=(square || n == 0) ? n : checkArray(read<array*>(a,0)); - if(n > 0 && dim2 && m != dim2) { - ostringstream buf; - buf << "second matrix dimension must be " << dim2; - error(buf); - } - - dest=(placement == NoGC) ? new T[n*m] : new(placement) T[n*m]; - for(size_t i=0; i < n; i++) { - array *ai=read<array*>(a,i); - size_t aisize=checkArray(ai); - if(aisize == m) { - T *desti=dest+i*m; - for(size_t j=0; j < m; j++) - desti[j]=read<T>(ai,j); - } else - error(square ? "matrix must be square" : "matrix must be rectangular"); - } -} - double *copyTripleArray2Components(array *a, bool square=true, size_t dim2=0, GCPlacement placement=NoGC); } @@ -174,8 +128,10 @@ triple Zero; +#ifndef NOSYM #include "runpicture.symbols.h" +#endif namespace run { #line 94 "runpicture.in" void newPicture(stack *Stack) diff --git a/Build/source/utils/asymptote/runpicture.symbols.h b/Build/source/utils/asymptote/runpicture.symbols.h deleted file mode 100644 index 109ba51b06e..00000000000 --- a/Build/source/utils/asymptote/runpicture.symbols.h +++ /dev/null @@ -1,136 +0,0 @@ -/***** - * This file is automatically generated by findsym.pl - * Changes will be overwritten. - *****/ - -// If the ADDSYMBOL macro is not already defined, define it with the default -// purpose of referring to an external pre-translated symbol, such that -// SYM(name) also refers to that symbol. -#ifndef ADDSYMBOL - #define ADDSYMBOL(name) extern sym::symbol PRETRANSLATED_SYMBOL_##name - #ifdef PRESYM - #define SYM(name) PRETRANSLATED_SYMBOL_##name - #else - #define SYM(name) sym::symbol::trans(#name) - #endif -#endif - -ADDSYMBOL(_begingroup3); -ADDSYMBOL(_draw); -ADDSYMBOL(_image); -ADDSYMBOL(_labelpath); -ADDSYMBOL(a); -ADDSYMBOL(add); -ADDSYMBOL(ambient); -ADDSYMBOL(angle); -ADDSYMBOL(antialias); -ADDSYMBOL(axialshade); -ADDSYMBOL(b); -ADDSYMBOL(background); -ADDSYMBOL(beginclip); -ADDSYMBOL(begingroup); -ADDSYMBOL(center); -ADDSYMBOL(clip); -ADDSYMBOL(closed); -ADDSYMBOL(colors); -ADDSYMBOL(compression); -ADDSYMBOL(copy); -ADDSYMBOL(data); -ADDSYMBOL(deconstruct); -ADDSYMBOL(deletepreamble); -ADDSYMBOL(dest); -ADDSYMBOL(diffuse); -ADDSYMBOL(dobreak); -ADDSYMBOL(draw); -ADDSYMBOL(drawPRCcylinder); -ADDSYMBOL(drawPRCdisk); -ADDSYMBOL(drawPRCsphere); -ADDSYMBOL(drawPRCtube); -ADDSYMBOL(edges); -ADDSYMBOL(empty); -ADDSYMBOL(endclip); -ADDSYMBOL(endgroup); -ADDSYMBOL(endgroup3); -ADDSYMBOL(erase); -ADDSYMBOL(f); -ADDSYMBOL(fill); -ADDSYMBOL(fillrule); -ADDSYMBOL(final); -ADDSYMBOL(format); -ADDSYMBOL(functionshade); -ADDSYMBOL(g); -ADDSYMBOL(gouraudshade); -ADDSYMBOL(granularity); -ADDSYMBOL(grestore); -ADDSYMBOL(gsave); -ADDSYMBOL(half); -ADDSYMBOL(height); -ADDSYMBOL(index); -ADDSYMBOL(initial); -ADDSYMBOL(interaction); -ADDSYMBOL(is3D); -ADDSYMBOL(justify); -ADDSYMBOL(knot); -ADDSYMBOL(latex); -ADDSYMBOL(latticeshade); -ADDSYMBOL(layer); -ADDSYMBOL(lighton); -ADDSYMBOL(lights); -ADDSYMBOL(m); -ADDSYMBOL(magnification); -ADDSYMBOL(max); -ADDSYMBOL(max3); -ADDSYMBOL(maxratio); -ADDSYMBOL(min); -ADDSYMBOL(min3); -ADDSYMBOL(minratio); -ADDSYMBOL(name); -ADDSYMBOL(nativeformat); -ADDSYMBOL(newpage); -ADDSYMBOL(nobreak); -ADDSYMBOL(normal); -ADDSYMBOL(offset); -ADDSYMBOL(opacity); -ADDSYMBOL(p); -ADDSYMBOL(palette); -ADDSYMBOL(pdf); -ADDSYMBOL(pena); -ADDSYMBOL(penb); -ADDSYMBOL(postscript); -ADDSYMBOL(prc); -ADDSYMBOL(prcshininess); -ADDSYMBOL(preamble); -ADDSYMBOL(prefix); -ADDSYMBOL(prepend); -ADDSYMBOL(ra); -ADDSYMBOL(radialshade); -ADDSYMBOL(rb); -ADDSYMBOL(s); -ADDSYMBOL(shader); -ADDSYMBOL(shift); -ADDSYMBOL(shininess); -ADDSYMBOL(shipout); -ADDSYMBOL(shipout3); -ADDSYMBOL(size); -ADDSYMBOL(size3); -ADDSYMBOL(specular); -ADDSYMBOL(src); -ADDSYMBOL(straight); -ADDSYMBOL(stroke); -ADDSYMBOL(t); -ADDSYMBOL(tensorshade); -ADDSYMBOL(tessellate); -ADDSYMBOL(tex); -ADDSYMBOL(texpreamble); -ADDSYMBOL(texreset); -ADDSYMBOL(type); -ADDSYMBOL(uknot); -ADDSYMBOL(view); -ADDSYMBOL(viewportlighting); -ADDSYMBOL(vknot); -ADDSYMBOL(wait); -ADDSYMBOL(weights); -ADDSYMBOL(width); -ADDSYMBOL(xform); -ADDSYMBOL(z); -ADDSYMBOL(zoom); diff --git a/Build/source/utils/asymptote/runstring.cc b/Build/source/utils/asymptote/runstring.cc index e251957a4e9..6cd52f658ea 100644 --- a/Build/source/utils/asymptote/runstring.cc +++ b/Build/source/utils/asymptote/runstring.cc @@ -51,52 +51,6 @@ array *copyArray(array *a); array *copyArray2(array *a); array *copyArray3(array *a); -inline size_t checkdimension(const array *a, size_t dim) -{ - size_t size=checkArray(a); - if(dim && size != dim) { - ostringstream buf; - buf << "array of length " << dim << " expected"; - error(buf); - } - return size; -} - -template<class T> -void copyArrayC(T* &dest, const array *a, size_t dim=0, - GCPlacement placement=NoGC) -{ - size_t size=checkdimension(a,dim); - dest=(placement == NoGC) ? new T[size] : new(placement) T[size]; - for(size_t i=0; i < size; i++) - dest[i]=read<T>(a,i); -} - -template<class T> -void copyArray2C(T* &dest, const array *a, bool square=true, size_t dim2=0, - GCPlacement placement=NoGC) -{ - size_t n=checkArray(a); - size_t m=(square || n == 0) ? n : checkArray(read<array*>(a,0)); - if(n > 0 && dim2 && m != dim2) { - ostringstream buf; - buf << "second matrix dimension must be " << dim2; - error(buf); - } - - dest=(placement == NoGC) ? new T[n*m] : new(placement) T[n*m]; - for(size_t i=0; i < n; i++) { - array *ai=read<array*>(a,i); - size_t aisize=checkArray(ai); - if(aisize == m) { - T *desti=dest+i*m; - for(size_t j=0; j < m; j++) - desti[j]=read<T>(ai,j); - } else - error(square ? "matrix must be square" : "matrix must be rectangular"); - } -} - double *copyTripleArray2Components(array *a, bool square=true, size_t dim2=0, GCPlacement placement=NoGC); } @@ -208,8 +162,10 @@ void checkformat(const char *ptr, bool intformat) +#ifndef NOSYM #include "runstring.symbols.h" +#endif namespace run { // String operations #line 112 "runstring.in" diff --git a/Build/source/utils/asymptote/runstring.symbols.h b/Build/source/utils/asymptote/runstring.symbols.h deleted file mode 100644 index a020945d30a..00000000000 --- a/Build/source/utils/asymptote/runstring.symbols.h +++ /dev/null @@ -1,40 +0,0 @@ -/***** - * This file is automatically generated by findsym.pl - * Changes will be overwritten. - *****/ - -// If the ADDSYMBOL macro is not already defined, define it with the default -// purpose of referring to an external pre-translated symbol, such that -// SYM(name) also refers to that symbol. -#ifndef ADDSYMBOL - #define ADDSYMBOL(name) extern sym::symbol PRETRANSLATED_SYMBOL_##name - #ifdef PRESYM - #define SYM(name) PRETRANSLATED_SYMBOL_##name - #else - #define SYM(name) sym::symbol::trans(#name) - #endif -#endif - -ADDSYMBOL(digits); -ADDSYMBOL(downcase); -ADDSYMBOL(erase); -ADDSYMBOL(find); -ADDSYMBOL(format); -ADDSYMBOL(hex); -ADDSYMBOL(insert); -ADDSYMBOL(length); -ADDSYMBOL(locale); -ADDSYMBOL(n); -ADDSYMBOL(pos); -ADDSYMBOL(replace); -ADDSYMBOL(reverse); -ADDSYMBOL(rfind); -ADDSYMBOL(s); -ADDSYMBOL(seconds); -ADDSYMBOL(string); -ADDSYMBOL(substr); -ADDSYMBOL(t); -ADDSYMBOL(time); -ADDSYMBOL(translate); -ADDSYMBOL(upcase); -ADDSYMBOL(x); diff --git a/Build/source/utils/asymptote/runsystem.cc b/Build/source/utils/asymptote/runsystem.cc index 20681335883..9cc29f0dd9e 100644 --- a/Build/source/utils/asymptote/runsystem.cc +++ b/Build/source/utils/asymptote/runsystem.cc @@ -51,52 +51,6 @@ array *copyArray(array *a); array *copyArray2(array *a); array *copyArray3(array *a); -inline size_t checkdimension(const array *a, size_t dim) -{ - size_t size=checkArray(a); - if(dim && size != dim) { - ostringstream buf; - buf << "array of length " << dim << " expected"; - error(buf); - } - return size; -} - -template<class T> -void copyArrayC(T* &dest, const array *a, size_t dim=0, - GCPlacement placement=NoGC) -{ - size_t size=checkdimension(a,dim); - dest=(placement == NoGC) ? new T[size] : new(placement) T[size]; - for(size_t i=0; i < size; i++) - dest[i]=read<T>(a,i); -} - -template<class T> -void copyArray2C(T* &dest, const array *a, bool square=true, size_t dim2=0, - GCPlacement placement=NoGC) -{ - size_t n=checkArray(a); - size_t m=(square || n == 0) ? n : checkArray(read<array*>(a,0)); - if(n > 0 && dim2 && m != dim2) { - ostringstream buf; - buf << "second matrix dimension must be " << dim2; - error(buf); - } - - dest=(placement == NoGC) ? new T[n*m] : new(placement) T[n*m]; - for(size_t i=0; i < n; i++) { - array *ai=read<array*>(a,i); - size_t aisize=checkArray(ai); - if(aisize == m) { - T *desti=dest+i*m; - for(size_t j=0; j < m; j++) - desti[j]=read<T>(ai,j); - } else - error(square ? "matrix must be square" : "matrix must be rectangular"); - } -} - double *copyTripleArray2Components(array *a, bool square=true, size_t dim2=0, GCPlacement placement=NoGC); } @@ -203,8 +157,10 @@ void exitFunction(stack *Stack) // Autogenerated routines: +#ifndef NOSYM #include "runsystem.symbols.h" +#endif namespace run { #line 108 "runsystem.in" // string outname(); diff --git a/Build/source/utils/asymptote/runsystem.symbols.h b/Build/source/utils/asymptote/runsystem.symbols.h deleted file mode 100644 index e0744d363f2..00000000000 --- a/Build/source/utils/asymptote/runsystem.symbols.h +++ /dev/null @@ -1,44 +0,0 @@ -/***** - * This file is automatically generated by findsym.pl - * Changes will be overwritten. - *****/ - -// If the ADDSYMBOL macro is not already defined, define it with the default -// purpose of referring to an external pre-translated symbol, such that -// SYM(name) also refers to that symbol. -#ifndef ADDSYMBOL - #define ADDSYMBOL(name) extern sym::symbol PRETRANSLATED_SYMBOL_##name - #ifdef PRESYM - #define SYM(name) PRETRANSLATED_SYMBOL_##name - #else - #define SYM(name) sym::symbol::trans(#name) - #endif -#endif - -ADDSYMBOL(animate); -ADDSYMBOL(args); -ADDSYMBOL(atbreakpoint); -ADDSYMBOL(atexit); -ADDSYMBOL(atupdate); -ADDSYMBOL(breakpoint); -ADDSYMBOL(breakpoints); -ADDSYMBOL(clear); -ADDSYMBOL(convert); -ADDSYMBOL(divisor); -ADDSYMBOL(f); -ADDSYMBOL(file); -ADDSYMBOL(format); -ADDSYMBOL(line); -ADDSYMBOL(locatefile); -ADDSYMBOL(nowarn); -ADDSYMBOL(outname); -ADDSYMBOL(position); -ADDSYMBOL(purge); -ADDSYMBOL(s); -ADDSYMBOL(stop); -ADDSYMBOL(stripdirectory); -ADDSYMBOL(stripextension); -ADDSYMBOL(stripfile); -ADDSYMBOL(t); -ADDSYMBOL(warn); -ADDSYMBOL(warning); diff --git a/Build/source/utils/asymptote/runtime.cc b/Build/source/utils/asymptote/runtime.cc index 85a95180771..1fb85676c60 100644 --- a/Build/source/utils/asymptote/runtime.cc +++ b/Build/source/utils/asymptote/runtime.cc @@ -63,52 +63,6 @@ array *copyArray(array *a); array *copyArray2(array *a); array *copyArray3(array *a); -inline size_t checkdimension(const array *a, size_t dim) -{ - size_t size=checkArray(a); - if(dim && size != dim) { - ostringstream buf; - buf << "array of length " << dim << " expected"; - error(buf); - } - return size; -} - -template<class T> -void copyArrayC(T* &dest, const array *a, size_t dim=0, - GCPlacement placement=NoGC) -{ - size_t size=checkdimension(a,dim); - dest=(placement == NoGC) ? new T[size] : new(placement) T[size]; - for(size_t i=0; i < size; i++) - dest[i]=read<T>(a,i); -} - -template<class T> -void copyArray2C(T* &dest, const array *a, bool square=true, size_t dim2=0, - GCPlacement placement=NoGC) -{ - size_t n=checkArray(a); - size_t m=(square || n == 0) ? n : checkArray(read<array*>(a,0)); - if(n > 0 && dim2 && m != dim2) { - ostringstream buf; - buf << "second matrix dimension must be " << dim2; - error(buf); - } - - dest=(placement == NoGC) ? new T[n*m] : new(placement) T[n*m]; - for(size_t i=0; i < n; i++) { - array *ai=read<array*>(a,i); - size_t aisize=checkArray(ai); - if(aisize == m) { - T *desti=dest+i*m; - for(size_t j=0; j < m; j++) - desti[j]=read<T>(ai,j); - } else - error(square ? "matrix must be square" : "matrix must be rectangular"); - } -} - double *copyTripleArray2Components(array *a, bool square=true, size_t dim2=0, GCPlacement placement=NoGC); } @@ -279,8 +233,10 @@ void unused(void *) +#ifndef NOSYM #include "runtime.symbols.h" +#endif namespace run { // Initializers diff --git a/Build/source/utils/asymptote/runtime.pl b/Build/source/utils/asymptote/runtime.pl index 26330bf48f4..5724b40f8e3 100755 --- a/Build/source/utils/asymptote/runtime.pl +++ b/Build/source/utils/asymptote/runtime.pl @@ -174,7 +174,9 @@ $header = <>; print $header; $source_line += ($header =~ tr/\n//);; +print "\n#ifndef NOSYM"; print "\n#include \"$prefix.symbols.h\"\n"; +print "\n#endif"; print "\nnamespace run {\n"; read_types($basetypes, "runtimebase.in", $basesource_type_line); diff --git a/Build/source/utils/asymptote/runtime.symbols.h b/Build/source/utils/asymptote/runtime.symbols.h deleted file mode 100644 index dc8c4c347ce..00000000000 --- a/Build/source/utils/asymptote/runtime.symbols.h +++ /dev/null @@ -1,116 +0,0 @@ -/***** - * This file is automatically generated by findsym.pl - * Changes will be overwritten. - *****/ - -// If the ADDSYMBOL macro is not already defined, define it with the default -// purpose of referring to an external pre-translated symbol, such that -// SYM(name) also refers to that symbol. -#ifndef ADDSYMBOL - #define ADDSYMBOL(name) extern sym::symbol PRETRANSLATED_SYMBOL_##name - #ifdef PRESYM - #define SYM(name) PRETRANSLATED_SYMBOL_##name - #else - #define SYM(name) sym::symbol::trans(#name) - #endif -#endif - -ADDSYMBOL(_cputime); -ADDSYMBOL(_eval); -ADDSYMBOL(a); -ADDSYMBOL(abort); -ADDSYMBOL(adjust); -ADDSYMBOL(angle); -ADDSYMBOL(arclength); -ADDSYMBOL(assert); -ADDSYMBOL(asydir); -ADDSYMBOL(atleast); -ADDSYMBOL(b); -ADDSYMBOL(basealign); -ADDSYMBOL(blend); -ADDSYMBOL(byte); -ADDSYMBOL(c); -ADDSYMBOL(cd); -ADDSYMBOL(cmyk); -ADDSYMBOL(colorless); -ADDSYMBOL(colors); -ADDSYMBOL(colorspace); -ADDSYMBOL(controlSpecifier); -ADDSYMBOL(curlSpecifier); -ADDSYMBOL(cyclic); -ADDSYMBOL(defaultpen); -ADDSYMBOL(dirSpecifier); -ADDSYMBOL(embedded); -ADDSYMBOL(exit); -ADDSYMBOL(f); -ADDSYMBOL(fillrule); -ADDSYMBOL(font); -ADDSYMBOL(fontcommand); -ADDSYMBOL(fontsize); -ADDSYMBOL(g); -ADDSYMBOL(gamma); -ADDSYMBOL(gray); -ADDSYMBOL(hex); -ADDSYMBOL(identity); -ADDSYMBOL(imports); -ADDSYMBOL(interactive); -ADDSYMBOL(interactivewrite); -ADDSYMBOL(interp); -ADDSYMBOL(inverse); -ADDSYMBOL(invisible); -ADDSYMBOL(k); -ADDSYMBOL(length); -ADDSYMBOL(linecap); -ADDSYMBOL(linejoin); -ADDSYMBOL(lineskip); -ADDSYMBOL(linetype); -ADDSYMBOL(linewidth); -ADDSYMBOL(list); -ADDSYMBOL(locale); -ADDSYMBOL(location); -ADDSYMBOL(m); -ADDSYMBOL(makepen); -ADDSYMBOL(max); -ADDSYMBOL(microseconds); -ADDSYMBOL(min); -ADDSYMBOL(miterlimit); -ADDSYMBOL(n); -ADDSYMBOL(nib); -ADDSYMBOL(offset); -ADDSYMBOL(opacity); -ADDSYMBOL(overwrite); -ADDSYMBOL(p); -ADDSYMBOL(pattern); -ADDSYMBOL(point); -ADDSYMBOL(r); -ADDSYMBOL(reflect); -ADDSYMBOL(resetdefaultpen); -ADDSYMBOL(reverse); -ADDSYMBOL(rgb); -ADDSYMBOL(rotate); -ADDSYMBOL(s); -ADDSYMBOL(scale); -ADDSYMBOL(seconds); -ADDSYMBOL(shift); -ADDSYMBOL(shiftless); -ADDSYMBOL(size); -ADDSYMBOL(slant); -ADDSYMBOL(sleep); -ADDSYMBOL(spec); -ADDSYMBOL(system); -ADDSYMBOL(t); -ADDSYMBOL(tensionSpecifier); -ADDSYMBOL(tin); -ADDSYMBOL(tok); -ADDSYMBOL(tout); -ADDSYMBOL(transform); -ADDSYMBOL(uptodate); -ADDSYMBOL(usleep); -ADDSYMBOL(view); -ADDSYMBOL(x); -ADDSYMBOL(xscale); -ADDSYMBOL(y); -ADDSYMBOL(yscale); -ADDSYMBOL(z); -ADDSYMBOL(zin); -ADDSYMBOL(zout); diff --git a/Build/source/utils/asymptote/runtimebase.in b/Build/source/utils/asymptote/runtimebase.in index 44d7dbe802b..228c01199d5 100644 --- a/Build/source/utils/asymptote/runtimebase.in +++ b/Build/source/utils/asymptote/runtimebase.in @@ -52,52 +52,6 @@ array *copyArray(array *a); array *copyArray2(array *a); array *copyArray3(array *a); -inline size_t checkdimension(const array *a, size_t dim) -{ - size_t size=checkArray(a); - if(dim && size != dim) { - ostringstream buf; - buf << "array of length " << dim << " expected"; - error(buf); - } - return size; -} - -template<class T> -void copyArrayC(T* &dest, const array *a, size_t dim=0, - GCPlacement placement=NoGC) -{ - size_t size=checkdimension(a,dim); - dest=(placement == NoGC) ? new T[size] : new(placement) T[size]; - for(size_t i=0; i < size; i++) - dest[i]=read<T>(a,i); -} - -template<class T> -void copyArray2C(T* &dest, const array *a, bool square=true, size_t dim2=0, - GCPlacement placement=NoGC) -{ - size_t n=checkArray(a); - size_t m=(square || n == 0) ? n : checkArray(read<array*>(a,0)); - if(n > 0 && dim2 && m != dim2) { - ostringstream buf; - buf << "second matrix dimension must be " << dim2; - error(buf); - } - - dest=(placement == NoGC) ? new T[n*m] : new(placement) T[n*m]; - for(size_t i=0; i < n; i++) { - array *ai=read<array*>(a,i); - size_t aisize=checkArray(ai); - if(aisize == m) { - T *desti=dest+i*m; - for(size_t j=0; j < m; j++) - desti[j]=read<T>(ai,j); - } else - error(square ? "matrix must be square" : "matrix must be rectangular"); - } -} - double *copyTripleArray2Components(array *a, bool square=true, size_t dim2=0, GCPlacement placement=NoGC); } diff --git a/Build/source/utils/asymptote/runtriple.cc b/Build/source/utils/asymptote/runtriple.cc index 2383d6d2c7d..9d3ffb37ad3 100644 --- a/Build/source/utils/asymptote/runtriple.cc +++ b/Build/source/utils/asymptote/runtriple.cc @@ -51,52 +51,6 @@ array *copyArray(array *a); array *copyArray2(array *a); array *copyArray3(array *a); -inline size_t checkdimension(const array *a, size_t dim) -{ - size_t size=checkArray(a); - if(dim && size != dim) { - ostringstream buf; - buf << "array of length " << dim << " expected"; - error(buf); - } - return size; -} - -template<class T> -void copyArrayC(T* &dest, const array *a, size_t dim=0, - GCPlacement placement=NoGC) -{ - size_t size=checkdimension(a,dim); - dest=(placement == NoGC) ? new T[size] : new(placement) T[size]; - for(size_t i=0; i < size; i++) - dest[i]=read<T>(a,i); -} - -template<class T> -void copyArray2C(T* &dest, const array *a, bool square=true, size_t dim2=0, - GCPlacement placement=NoGC) -{ - size_t n=checkArray(a); - size_t m=(square || n == 0) ? n : checkArray(read<array*>(a,0)); - if(n > 0 && dim2 && m != dim2) { - ostringstream buf; - buf << "second matrix dimension must be " << dim2; - error(buf); - } - - dest=(placement == NoGC) ? new T[n*m] : new(placement) T[n*m]; - for(size_t i=0; i < n; i++) { - array *ai=read<array*>(a,i); - size_t aisize=checkArray(ai); - if(aisize == m) { - T *desti=dest+i*m; - for(size_t j=0; j < m; j++) - desti[j]=read<T>(ai,j); - } else - error(square ? "matrix must be square" : "matrix must be rectangular"); - } -} - double *copyTripleArray2Components(array *a, bool square=true, size_t dim2=0, GCPlacement placement=NoGC); } @@ -115,8 +69,10 @@ using namespace camp; +#ifndef NOSYM #include "runtriple.symbols.h" +#endif namespace run { #line 18 "runtriple.in" void tripleZero(stack *Stack) diff --git a/Build/source/utils/asymptote/runtriple.symbols.h b/Build/source/utils/asymptote/runtriple.symbols.h deleted file mode 100644 index a6cf5896d2e..00000000000 --- a/Build/source/utils/asymptote/runtriple.symbols.h +++ /dev/null @@ -1,48 +0,0 @@ -/***** - * This file is automatically generated by findsym.pl - * Changes will be overwritten. - *****/ - -// If the ADDSYMBOL macro is not already defined, define it with the default -// purpose of referring to an external pre-translated symbol, such that -// SYM(name) also refers to that symbol. -#ifndef ADDSYMBOL - #define ADDSYMBOL(name) extern sym::symbol PRETRANSLATED_SYMBOL_##name - #ifdef PRESYM - #define SYM(name) PRETRANSLATED_SYMBOL_##name - #else - #define SYM(name) sym::symbol::trans(#name) - #endif -#endif - -ADDSYMBOL(a); -ADDSYMBOL(abs); -ADDSYMBOL(azimuth); -ADDSYMBOL(b); -ADDSYMBOL(bezier); -ADDSYMBOL(bezierP); -ADDSYMBOL(bezierPP); -ADDSYMBOL(bezierPPP); -ADDSYMBOL(c); -ADDSYMBOL(colatitude); -ADDSYMBOL(cross); -ADDSYMBOL(d); -ADDSYMBOL(dir); -ADDSYMBOL(dot); -ADDSYMBOL(expi); -ADDSYMBOL(latitude); -ADDSYMBOL(length); -ADDSYMBOL(longitude); -ADDSYMBOL(perp); -ADDSYMBOL(polar); -ADDSYMBOL(realmult); -ADDSYMBOL(t); -ADDSYMBOL(u); -ADDSYMBOL(unit); -ADDSYMBOL(v); -ADDSYMBOL(warn); -ADDSYMBOL(x); -ADDSYMBOL(xpart); -ADDSYMBOL(ypart); -ADDSYMBOL(z); -ADDSYMBOL(zpart); diff --git a/Build/source/utils/asymptote/settings.cc b/Build/source/utils/asymptote/settings.cc index 2a8e723e308..ca26418e691 100644 --- a/Build/source/utils/asymptote/settings.cc +++ b/Build/source/utils/asymptote/settings.cc @@ -1283,7 +1283,7 @@ void initSettings() { addOption(new envSetting("textoutformat", "ps")); addOption(new envSetting("textprologue", ".EQ\ndelim $$\n.EN")); addOption(new envSetting("textinitialfont", ".fam T\n.ps 12")); - addOption(new envSetting("textepilogue", "")); + addOption(new envSetting("textepilogue", ".bp")); } // Access the arguments once options have been parsed. diff --git a/Build/source/utils/asymptote/tests/Makefile b/Build/source/utils/asymptote/tests/Makefile index d05ae0a2169..3372c7a6268 100644 --- a/Build/source/utils/asymptote/tests/Makefile +++ b/Build/source/utils/asymptote/tests/Makefile @@ -1,11 +1,20 @@ +.NOTPARALLEL: + TESTDIRS = string arith frames types imp array +EXTRADIRS = gsl test: $(TESTDIRS) +all: $(TESTDIRS) $(EXTRADIRS) + $(TESTDIRS):: @echo ../asy -dir ../base $@/*.asy +$(EXTRADIRS):: + @echo + ../asy -dir ../base $@/*.asy + clean: FORCE rm -f *.eps diff --git a/Build/source/utils/asymptote/tests/array/sort.asy b/Build/source/utils/asymptote/tests/array/sort.asy new file mode 100644 index 00000000000..03c585b717d --- /dev/null +++ b/Build/source/utils/asymptote/tests/array/sort.asy @@ -0,0 +1,39 @@ +import TestLib; +import math; + +string[] a={"bob","alice","pete","alice"}; +string[] b={"alice","alice","bob","pete"}; + +StartTest("sort"); + +assert(all(sort(a) == b)); + +EndTest(); + +StartTest("search"); + +assert(search(b,"a") == -1); +assert(search(b,"bob") == 2); +assert(search(b,"z") == b.length-1); + +EndTest(); + +StartTest("sort2"); + +string[][] a={{"bob","9"},{"alice","5"},{"pete","7"},{"alice","4"}}; +string[][] b={{"alice","4"},{"alice","5"},{"bob","9"},{"pete","7"}}; + +assert(sort(a) == b); + +EndTest(); + +pair[] a={(2,1),(0,0),(1,1),(1,0)}; +pair[] b={(0,0),(1,0),(1,1),(2,1)}; + +StartTest("lexicographical sort"); +assert(all(sort(a,lexorder) == b)); +EndTest(); + +StartTest("lexicographical search"); +assert(search(b,(1,0),lexorder) == 1); +EndTest(); diff --git a/Build/source/utils/asymptote/tests/gsl/random.asy b/Build/source/utils/asymptote/tests/gsl/random.asy new file mode 100644 index 00000000000..2418ad93e72 --- /dev/null +++ b/Build/source/utils/asymptote/tests/gsl/random.asy @@ -0,0 +1,338 @@ +import TestLib; +import gsl; + +StartTest("random number generators"); +rng_init(); +assert(rng_min() == 0); +assert(rng_max() == 4294967295); +assert(rng_get() == 4293858116); +rng_init("taus2"); +assert(rng_min() == 0); +assert(rng_max() == 4294967295); +assert(rng_get() == 802792108); +rng_init("gfsr4"); +assert(rng_min() == 0); +assert(rng_max() == 4294967295); +assert(rng_get() == 2901276280); +string[] list = rng_list(); +for(string name: list) +{ + rng_init(name); + rng_min(); + rng_max(); + rng_get(); +} +assert(list.length >= 62); +rng_init(); +rng_set(1); +assert(rng_get() == 1791095845); +rng_set(1); +assert(rng_get() == 1791095845); +EndTest(); + +StartTest("Bernoulli distribution"); +assert(close(pdf_bernoulli(0,0.3), 0.7)); +assert(close(pdf_bernoulli(1,0.3), 0.3)); +//rng_init(); +//assert(rng_bernoulli(0.3) == 0); +EndTest(); + +StartTest("beta distribution"); +assert(close(cdf_beta_P(0.3,5,5), 0.09880866)); +assert(close(cdf_beta_Q(0.3,5,5) + cdf_beta_P(0.3,5,5), 1)); +assert(close(cdf_beta_Pinv(cdf_beta_P(0.3,5,5),5,5), 0.3)); +assert(close(cdf_beta_Qinv(cdf_beta_Q(0.3,5,5),5,5), 0.3)); +assert(close(pdf_beta(0.3,5,5), 1.2252303)); +//rng_init(); +//assert(close(rng_beta(5,5), 0.533021338130471)); +EndTest(); + +StartTest("binomial distribution"); +assert(close(cdf_binomial_P(5,0.3,10), 0.9526510126)); +assert(close(cdf_binomial_P(5,0.3,10) + cdf_binomial_Q(5,0.3,10), 1)); +assert(close(pdf_binomial(5,0.3,10), 0.1029193452)); +//rng_init(); +//assert(rng_binomial(0.3,10) == 8); +EndTest(); + +StartTest("bivariate Gaussian distribution"); +assert(close(pdf_bivariate_gaussian((1,1),(0,2),(4,6),0.5), + 0.00675758392382108)); +//rng_init(); +//pair z = (-0.260388644979556,2.50057001628669); +//pair r = rng_bivariate_gaussian((0,2),(4,6),0.5); +//assert(close(length(r - z), 0)); +EndTest(); + +StartTest("cauchy distribution"); +assert(close(cdf_cauchy_P(1,3), 0.602416382349567)); +assert(close(cdf_cauchy_P(1,3) + cdf_cauchy_Q(1,3), 1)); +assert(close(cdf_cauchy_Pinv(cdf_cauchy_P(1,3),3), 1)); +assert(close(cdf_cauchy_Qinv(cdf_cauchy_Q(1,3),3), 1)); +assert(close(pdf_cauchy(1,3), 0.0954929658551372)); +//rng_init(); +//assert(close(rng_cauchy(3), -0.0024339597467863)); +EndTest(); + +StartTest("chi-squared distribution"); +assert(close(cdf_chisq_P(4,6), 0.323323583816936)); +assert(close(cdf_chisq_P(4,6) + cdf_chisq_Q(4, 6), 1)); +assert(close(cdf_chisq_Pinv(cdf_chisq_P(4,6),6), 4)); +assert(close(cdf_chisq_Qinv(cdf_chisq_Q(4,6),6), 4)); +assert(close(pdf_chisq(4,6), 0.135335283236613)); +//rng_init(); +//assert(close(rng_chisq(6), 8.24171826270279)); +EndTest(); + +StartTest("Dirichlet distribution"); +real[] alpha = {1,2,3,4}; +real[] theta = {0.1,0.2,0.3,0.4}; +assert(close(pdf_dirichlet(alpha,theta), 34.83648)); +//rng_init(); +//real[] z = {0.124480735441317, +// 0.191823537067349, +// 0.460543885448264, +// 0.22315184204307}; +//real[] r = rng_dirichlet(alpha); +//assert(close(norm(r - z), 0)); +EndTest(); + +StartTest("exponential distribution"); +assert(close(cdf_exponential_P(2,3), 0.486582880967408)); +assert(close(cdf_exponential_P(2,3) + cdf_exponential_Q(2,3), 1)); +assert(close(cdf_exponential_Pinv(cdf_exponential_P(2,3),3), 2)); +assert(close(cdf_exponential_Qinv(cdf_exponential_Q(2,3),3), 2)); +assert(close(pdf_exponential(2,3), 0.171139039677531)); +//rng_init(); +//assert(close(rng_exponential(3), 24.7847346491112)); +EndTest(); + +StartTest("exponential power distribution"); +assert(close(cdf_exppow_P(2,3,2), 0.82711070692442)); +assert(close(cdf_exppow_P(2,3,2) + cdf_exppow_Q(2,3,2), 1)); +assert(close(pdf_exppow(2,3,2), 0.120582432109095)); +//rng_init(); +//assert(close(rng_exppow(3,2), 0.284084267783339)); +EndTest(); + +StartTest("F-distribution"); +assert(close(cdf_fdist_P(1,5,4), 0.485657196759213)); +assert(close(cdf_fdist_P(1,5,4) + cdf_fdist_Q(1,5,4), 1)); +//rng_init(); +//assert(close(rng_fdist(5,4), 1.20570928490019)); +EndTest(); + +StartTest("flat (uniform) distribution"); +assert(close(cdf_flat_P(2,0,5), 0.4)); +assert(close(cdf_flat_P(2,0,5) + cdf_flat_Q(2,0,5), 1)); +assert(close(cdf_flat_Pinv(cdf_flat_P(2,0,5),0,5), 2)); +assert(close(cdf_flat_Qinv(cdf_flat_Q(2,0,5),0,5), 2)); +assert(close(pdf_flat(2,0,5), 0.2)); +//rng_init(); +//assert(close(rng_flat(0,5), 4.99870874453336)); +EndTest(); + +StartTest("Gamma-distribution"); +assert(close(cdf_gamma_P(6,5,1), 0.71494349968337)); +assert(close(cdf_gamma_P(6,5,1) + cdf_gamma_Q(6,5,1), 1)); +assert(close(cdf_gamma_Pinv(cdf_gamma_P(6,5,1),5,1), 6)); +assert(close(cdf_gamma_Qinv(cdf_gamma_Q(6,5,1),5,1), 6)); +assert(close(pdf_gamma(6,5,1), 0.133852617539983)); +//rng_init(); +//assert(close(rng_gamma(5,1), 6.52166444209317)); +//assert(close(rng_gamma(5,1,"mt"), 5.71361391461836)); +//assert(close(rng_gamma(5,1,"knuth"), 1.53054227085541)); +EndTest(); + +StartTest("Gaussian distribution"); +assert(close(cdf_gaussian_P(1,0,1), 0.841344746068543)); +assert(close(cdf_gaussian_P(1,0,1) + cdf_gaussian_Q(1,0,1), 1)); +assert(close(cdf_gaussian_Pinv(cdf_gaussian_P(1,0,1),0,1), 1)); +assert(close(cdf_gaussian_Qinv(cdf_gaussian_Q(1,0,1),0,1), 1)); +assert(close(pdf_gaussian(1,0,1), 0.241970724519143)); +//rng_init(); +//assert(close(rng_gaussian(0,1), 0.133918608118676)); +//assert(close(rng_gaussian(1,2,"ziggurat"), 1.90467233084303)); +//assert(close(rng_gaussian(1,2,"ratio"), 4.04779517509342)); +//assert(close(rng_gaussian(1,2,"polar"), 1.54245166575101)); +EndTest(); + +StartTest("Gaussian tail distribution"); +assert(close(pdf_gaussian_tail(2,1,1), 0.34030367841782)); +//rng_init(); +//assert(close(rng_gaussian_tail(1,1), 1.0528474462339)); +EndTest(); + +StartTest("geometric distribution"); +assert(close(cdf_geometric_P(6,0.1), 0.468559)); +assert(close(cdf_geometric_P(6,0.1) + cdf_geometric_Q(6,0.1), 1)); +assert(close(pdf_geometric(6,0.1), 0.059049)); +//rng_init(); +//assert(rng_geometric(0.1) == 1); +EndTest(); + +StartTest("Gumbel1 distribution"); +assert(close(cdf_gumbel1_P(1,3,8), 0.671462877871127)); +assert(close(cdf_gumbel1_P(1,3,8) + cdf_gumbel1_Q(1,3,8), 1)); +assert(close(cdf_gumbel1_Pinv(cdf_gumbel1_P(1,3,8),3,8), 1)); +assert(close(cdf_gumbel1_Qinv(cdf_gumbel1_Q(1,3,8),3,8), 1)); +assert(close(pdf_gumbel1(1,3,8), 0.80232403696926)); +//rng_init(); +//assert(close(rng_gumbel1(3,8), 3.44696353953564)); +EndTest(); + +StartTest("Gumbel2 distribution"); +assert(close(cdf_gumbel2_P(2,2,3), 0.472366552741015)); +assert(close(cdf_gumbel2_P(2,2,3) + cdf_gumbel2_Q(2,2,3), 1)); +assert(close(cdf_gumbel2_Pinv(cdf_gumbel2_P(2,2,3),2,3), 2)); +assert(close(cdf_gumbel2_Qinv(cdf_gumbel2_Q(2,2,3),2,3), 2)); +assert(close(pdf_gumbel2(2,2,3), 0.354274914555761)); +//rng_init(); +//assert(close(rng_gumbel2(2,3), 107.773379309453)); +EndTest(); + +StartTest("hypergeometric distribution"); +assert(close(cdf_hypergeometric_P(4,10,10,8), 0.675041676589664)); +assert(close(cdf_hypergeometric_P(4,10,10,8) + + cdf_hypergeometric_Q(4,10,10,8), 1)); +assert(close(pdf_hypergeometric(4,10,10,8), 0.350083353179329)); +//rng_init(); +//assert(rng_hypergeometric(10,10,8) == 3); +EndTest(); + +StartTest("Laplace distribution"); +assert(close(cdf_laplace_P(1,2), 0.696734670143683)); +assert(close(cdf_laplace_P(1,2) + cdf_laplace_Q(1,2), 1)); +assert(close(cdf_laplace_Pinv(cdf_laplace_P(1,2),2), 1)); +assert(close(cdf_laplace_Qinv(cdf_laplace_Q(1,2),2), 1)); +assert(close(pdf_laplace(1,2), 0.151632664928158)); +//rng_init(); +//assert(close(rng_laplace(2), 0.00103327123971616)); +EndTest(); + +StartTest("Landau distribution"); +assert(close(pdf_landau(1), 0.145206637130862)); +//rng_init(); +//assert(close(rng_landau(), 3880.0374262546)); +EndTest(); + +//StartTest("Levy stable distribution"); +//rng_init(); +//assert(close(rng_levy(1,1,0), 1232.55941432972)); +//assert(close(rng_levy(1,1,1), -0.13781830409645)); +//EndTest(); + +StartTest("logistic distribution"); +assert(close(cdf_logistic_P(1,2), 0.622459331201855)); +assert(close(cdf_logistic_P(1,2) + cdf_logistic_Q(1,2), 1)); +assert(close(cdf_logistic_Pinv(cdf_logistic_P(1,2),2), 1)); +assert(close(cdf_logistic_Qinv(cdf_logistic_Q(1,2),2), 1)); +assert(close(pdf_logistic(1,2), 0.117501856100797)); +//rng_init(); +//assert(close(rng_logistic(2), 16.522639863849)); +EndTest(); + +StartTest("lognormal distribution"); +assert(close(cdf_lognormal_P(6,2,1), 0.417520581602749)); +assert(close(cdf_lognormal_P(6,2,1) + cdf_lognormal_Q(6,2,1), 1)); +assert(close(cdf_lognormal_Pinv(cdf_lognormal_P(6,2,1),2,1), 6)); +assert(close(cdf_lognormal_Qinv(cdf_lognormal_Q(6,2,1),2,1), 6)); +assert(close(pdf_lognormal(6,2,1), 0.0650642483079156)); +//rng_init(); +//assert(close(rng_lognormal(2,1), 6.92337133931968)); +EndTest(); + +StartTest("multinomial distribution"); +real[] p = {0.1,0.2,0.3,0.4}; +int[] n = {1,2,3,4}; +assert(close(pdf_multinomial(p,n), 0.03483648)); +//rng_init(); +//int[] r = {5, 0, 1, 4}; +//assert(all(rng_multinomial(10,p) == r)); +EndTest(); + +StartTest("negative binomial distribution"); +assert(close(cdf_negative_binomial_P(6,0.5,10), 0.227249145507813)); +assert(close(cdf_negative_binomial_P(6,0.5,10) + + cdf_negative_binomial_Q(6,0.5,10), 1)); +assert(close(pdf_negative_binomial(6,0.5,10), 0.076370239257812)); +//rng_init(); +//assert(rng_negative_binomial(0.5,10) == 15); +EndTest(); + +StartTest("Pareto distribution"); +assert(close(cdf_pareto_P(4,2,2), 0.75)); +assert(close(cdf_pareto_P(4,2,2) + cdf_pareto_Q(4,2,2), 1)); +assert(close(cdf_pareto_Pinv(cdf_pareto_P(4,2,2),2,2), 4)); +assert(close(cdf_pareto_Qinv(cdf_pareto_Q(4,2,2),2,2), 4)); +assert(close(pdf_pareto(4,2,2), 0.125)); +//rng_init(); +//assert(close(rng_pareto(2,2), 2.00025830112432)); +EndTest(); + +StartTest("Poisson distribution"); +assert(close(cdf_poisson_P(5,6), 0.445679641364611)); +assert(close(cdf_poisson_P(5,6) + cdf_poisson_Q(5,6), 1)); +assert(close(pdf_poisson(5,6), 0.16062314104798)); +//rng_init(); +//assert(rng_poisson(6) == 8); +EndTest(); + +StartTest("Rayleigh distribution"); +assert(close(cdf_rayleigh_P(3,2), 0.67534753264165)); +assert(close(cdf_rayleigh_P(3,2) + cdf_rayleigh_Q(3,2), 1)); +assert(close(cdf_rayleigh_Pinv(cdf_rayleigh_P(3,2),2), 3)); +assert(close(cdf_rayleigh_Qinv(cdf_rayleigh_Q(3,2),2), 3)); +assert(close(pdf_rayleigh(3,2), 0.243489350518762)); +//rng_init(); +//assert(close(rng_rayleigh(2), 0.0454563039310455)); +EndTest(); + +StartTest("Rayleigh tail distribution"); +assert(close(pdf_rayleigh_tail(5,4,1), 0.0555449826912115)); +//rng_init(); +//assert(close(rng_rayleigh_tail(4,1), 4.0000645705903)); +EndTest(); + +//StartTest("spherical distributions"); +//rng_init(); +//pair z = (-0.617745613497854,-0.786377998804748); +//pair r = rng_dir2d(); +//assert(close(length(r - z), 0)); +//pair z = (0.993748310886084,0.111643605329884); +//pair r = rng_dir2d("neumann"); +//assert(close(length(r - z), 0)); +//pair z = (0.964519203132591,-0.264012701945327); +//pair r = rng_dir2d("trig"); +//assert(close(length(r - z), 0)); +//triple z = (0.849028025629996,0.139162687752509,-0.509691237939527); +//triple r = rng_dir3d(); +//assert(close(length(r - z), 0)); +//real[] z = {0.420990368676528, +// -0.626782975357296, +// 0.0441585572224004, +// -0.0458388920727644, +// -0.652578753164271}; +//real[] r = rng_dir(5); +//assert(close(norm(r - z), 0)); +//EndTest(); + +StartTest("t-distribution"); +assert(close(cdf_tdist_P(0.6,2), 0.695283366471236)); +assert(close(cdf_tdist_P(0.6,2) + cdf_tdist_Q(0.6,2), 1)); +assert(close(cdf_tdist_Pinv(cdf_tdist_P(0.6,2),2), 0.6)); +assert(close(cdf_tdist_Qinv(cdf_tdist_Q(0.6,2),2), 0.6)); +assert(close(pdf_tdist(0.6,2), 0.275823963942424)); +//rng_init(); +//assert(close(rng_tdist(2), 0.127201714006725)); +EndTest(); + +StartTest("Weibull distribution"); +assert(close(cdf_weibull_P(1,2,2), 0.221199216928595)); +assert(close(cdf_weibull_P(1,2,2) + cdf_weibull_Q(1,2,2), 1)); +assert(close(cdf_weibull_Pinv(cdf_weibull_P(1,2,2),2,2), 1)); +assert(close(cdf_weibull_Qinv(cdf_weibull_Q(1,2,2),2,2), 1)); +assert(close(pdf_weibull(1,2,2), 0.389400391535702)); +//rng_init(); +//assert(close(rng_weibull(2,2), 0.032142460757319)); +EndTest(); diff --git a/Build/source/utils/asymptote/texfile.cc b/Build/source/utils/asymptote/texfile.cc index 3f5de393c50..5df087e8013 100644 --- a/Build/source/utils/asymptote/texfile.cc +++ b/Build/source/utils/asymptote/texfile.cc @@ -55,7 +55,7 @@ void texfile::miniprologue() *out << "\\setuppagenumbering[location=]" << newl << "\\usetypescript[modern]" << newl << "\\starttext\\hbox{%" << newl; - } + } else *out << "\\nopagenumbers" << newl; } void texfile::prologue() diff --git a/Build/source/utils/asymptote/types.cc b/Build/source/utils/asymptote/types.cc index 83ac6f5a597..6efb04bf630 100644 --- a/Build/source/utils/asymptote/types.cc +++ b/Build/source/utils/asymptote/types.cc @@ -20,7 +20,9 @@ #include "virtualfieldaccess.h" // For pre-translated symbols. +#ifndef NOSYM #include "types.symbols.h" +#endif namespace types { diff --git a/Build/source/utils/asymptote/types.symbols.h b/Build/source/utils/asymptote/types.symbols.h deleted file mode 100644 index 216487411c9..00000000000 --- a/Build/source/utils/asymptote/types.symbols.h +++ /dev/null @@ -1,55 +0,0 @@ -/***** - * This file is automatically generated by findsym.pl - * Changes will be overwritten. - *****/ - -// If the ADDSYMBOL macro is not already defined, define it with the default -// purpose of referring to an external pre-translated symbol, such that -// SYM(name) also refers to that symbol. -#ifndef ADDSYMBOL - #define ADDSYMBOL(name) extern sym::symbol PRETRANSLATED_SYMBOL_##name - #ifdef PRESYM - #define SYM(name) PRETRANSLATED_SYMBOL_##name - #else - #define SYM(name) sym::symbol::trans(#name) - #endif -#endif - -ADDSYMBOL(a); -ADDSYMBOL(append); -ADDSYMBOL(atLeast); -ADDSYMBOL(b); -ADDSYMBOL(csv); -ADDSYMBOL(cyclic); -ADDSYMBOL(delete); -ADDSYMBOL(dimension); -ADDSYMBOL(i); -ADDSYMBOL(in); -ADDSYMBOL(initialized); -ADDSYMBOL(insert); -ADDSYMBOL(j); -ADDSYMBOL(keys); -ADDSYMBOL(length); -ADDSYMBOL(line); -ADDSYMBOL(mode); -ADDSYMBOL(name); -ADDSYMBOL(nx); -ADDSYMBOL(ny); -ADDSYMBOL(nz); -ADDSYMBOL(out); -ADDSYMBOL(pop); -ADDSYMBOL(push); -ADDSYMBOL(read); -ADDSYMBOL(side); -ADDSYMBOL(signedint); -ADDSYMBOL(singleint); -ADDSYMBOL(singlereal); -ADDSYMBOL(value); -ADDSYMBOL(word); -ADDSYMBOL(x); -ADDSYMBOL(xx); -ADDSYMBOL(xy); -ADDSYMBOL(y); -ADDSYMBOL(yx); -ADDSYMBOL(yy); -ADDSYMBOL(z); diff --git a/Build/source/utils/asymptote/util.h b/Build/source/utils/asymptote/util.h index 3a0241e53c9..4feb9f517a7 100644 --- a/Build/source/utils/asymptote/util.h +++ b/Build/source/utils/asymptote/util.h @@ -105,6 +105,7 @@ extern "C" int snprintf(char *str, size_t size, const char *format,...); extern "C" int fileno(FILE *); extern "C" char *strptime(const char *s, const char *format, struct tm *tm); extern "C" int setenv(const char *name, const char *value, int overwrite); +extern "C" int unsetenv(const char *name); #endif extern bool False; |