summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/runpair.in
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2009-09-11 00:21:50 +0000
committerKarl Berry <karl@freefriends.org>2009-09-11 00:21:50 +0000
commitf06a2c99f2a8bbd8f641712c772179e8ed9ce14f (patch)
treefcf4f2b9d0492da04d9bf3761fbce51fb316024f /Build/source/utils/asymptote/runpair.in
parentd4c54e52fe8e42b8ce9b160c70d897bb1d06eee7 (diff)
asymptote 1.86
git-svn-id: svn://tug.org/texlive/trunk@15218 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/asymptote/runpair.in')
-rw-r--r--Build/source/utils/asymptote/runpair.in233
1 files changed, 233 insertions, 0 deletions
diff --git a/Build/source/utils/asymptote/runpair.in b/Build/source/utils/asymptote/runpair.in
new file mode 100644
index 00000000000..43554902ed6
--- /dev/null
+++ b/Build/source/utils/asymptote/runpair.in
@@ -0,0 +1,233 @@
+/*****
+ * runpair.in
+ *
+ * Runtime functions for pair operations.
+ *
+ *****/
+
+pair => primPair()
+
+#include "pair.h"
+
+using namespace camp;
+
+namespace run {
+extern pair zero;
+}
+
+pair sin(pair z)
+{
+ return pair(sin(z.getx())*cosh(z.gety()),cos(z.getx())*sinh(z.gety()));
+}
+
+pair exp(pair z)
+{
+ return exp(z.getx())*expi(z.gety());
+}
+
+pair gamma(pair z)
+{
+ static double p[]={0.99999999999980993,676.5203681218851,-1259.1392167224028,
+ 771.32342877765313,-176.61502916214059,12.507343278686905,
+ -0.13857109526572012,9.9843695780195716e-6,
+ 1.5056327351493116e-7};
+ static int n=sizeof(p)/sizeof(double);
+ static double root2pi=sqrt(2*PI);
+ if(z.getx() < 0.5)
+ return PI/(sin(PI*z)*gamma(1.0-z));
+ z -= 1.0;
+ pair x=p[0];
+ for(int i=1; i < n; ++i)
+ x += p[i]/(z+i);
+ pair t=n-1.5+z;
+ return root2pi*pow(t,z+0.5)*exp(-t)*x;
+}
+
+// Autogenerated routines:
+
+
+pair :pairZero()
+{
+ return zero;
+}
+
+pair :realRealToPair(real x, real y)
+{
+ return pair(x,y);
+}
+
+pair :pairNegate(pair z)
+{
+ return -z;
+}
+
+real xpart:pairXPart(pair z)
+{
+ return z.getx();
+}
+
+real ypart:pairYPart(pair z)
+{
+ return z.gety();
+}
+
+real length(pair z)
+{
+ return z.length();
+}
+
+real abs(pair z)
+{
+ return z.length();
+}
+
+pair sqrt(explicit pair z)
+{
+ return Sqrt(z);
+}
+
+// Return the angle of z in radians.
+real angle(pair z, bool warn=true)
+{
+ if(!warn && z.getx() == 0.0 && z.gety() == 0.0) return 0.0;
+ return z.angle();
+}
+
+// Return the angle of z in degrees in the interval [0,360).
+real degrees(pair z, bool warn=true)
+{
+ if(!warn && z.getx() == 0.0 && z.gety() == 0.0) return 0.0;
+ return principalBranch(degrees(z.angle()));
+}
+
+// Convert degrees to radians.
+real radians(real degrees)
+{
+ return radians(degrees);
+}
+
+// Convert radians to degrees.
+real degrees(real radians)
+{
+ return degrees(radians);
+}
+
+// Convert radians to degrees in [0,360).
+real Degrees(real radians)
+{
+ return principalBranch(degrees(radians));
+}
+
+real Sin(real deg)
+{
+ return sin(radians(deg));
+}
+
+real Cos(real deg)
+{
+ return cos(radians(deg));
+}
+
+real Tan(real deg)
+{
+ return tan(radians(deg));
+}
+
+real aSin(real x)
+{
+ return degrees(asin(x));
+}
+
+real aCos(real x)
+{
+ return degrees(acos(x));
+}
+
+real aTan(real x)
+{
+ return degrees(atan(x));
+}
+
+pair unit(pair z)
+{
+ return unit(z);
+}
+
+pair dir(real degrees)
+{
+ return expi(radians(degrees));
+}
+
+pair dir(explicit pair z)
+{
+ return unit(z);
+}
+
+pair expi(real angle)
+{
+ return expi(angle);
+}
+
+pair exp(explicit pair z)
+{
+ return exp(z);
+}
+
+pair log(explicit pair z)
+{
+ return pair(log(z.length()),z.angle());
+}
+
+pair sin(explicit pair z)
+{
+ return sin(z);
+}
+
+pair cos(explicit pair z)
+{
+ return pair(cos(z.getx())*cosh(z.gety()),-sin(z.getx())*sinh(z.gety()));
+}
+
+// Complex Gamma function
+pair gamma(explicit pair z)
+{
+ return gamma(z);
+}
+
+pair conj(pair z)
+{
+ return conj(z);
+}
+
+pair realmult(pair z, pair w)
+{
+ return pair (z.getx()*w.getx(),z.gety()*w.gety());
+}
+
+// To avoid confusion, a dot product requires explicit pair arguments.
+real dot(explicit pair z, explicit pair w)
+{
+ return dot(z,w);
+}
+
+pair bezier(pair a, pair b, pair c, pair d, real t)
+{
+ real onemt=1-t;
+ real onemt2=onemt*onemt;
+ return onemt2*onemt*a+t*(3.0*(onemt2*b+t*onemt*c)+t*t*d);
+}
+
+pair bezierP(pair a, pair b, pair c, pair d, real t)
+{
+ return 3.0*(t*t*(d-a+3.0*(b-c))+t*(2.0*(a+c)-4.0*b)+b-a);
+}
+
+pair bezierPP(pair a, pair b, pair c, pair d, real t)
+{
+ return 6.0*(t*(d-a+3.0*(b-c))+a+c-2.0*b);
+}
+
+pair bezierPPP(pair a, pair b, pair c, pair d)
+{
+ return 6.0*(d-a+3.0*(b-c));
+}