mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-19 21:29:38 +02:00
3 lines
28 KiB
JavaScript
3 lines
28 KiB
JavaScript
|
const c=11102230246251565e-32;const s=134217729;const t=(3+8*c)*c;function sum(c,s,t,n,e){let o,a,l,i;let r=s[0];let f=n[0];let u=0;let d=0;if(f>r===f>-r){o=r;r=s[++u]}else{o=f;f=n[++d]}let v=0;if(u<c&&d<t){if(f>r===f>-r){a=r+o;l=o-(a-r);r=s[++u]}else{a=f+o;l=o-(a-f);f=n[++d]}o=a;0!==l&&(e[v++]=l);while(u<c&&d<t){if(f>r===f>-r){a=o+r;i=a-o;l=o-(a-i)+(r-i);r=s[++u]}else{a=o+f;i=a-o;l=o-(a-i)+(f-i);f=n[++d]}o=a;0!==l&&(e[v++]=l)}}while(u<c){a=o+r;i=a-o;l=o-(a-i)+(r-i);r=s[++u];o=a;0!==l&&(e[v++]=l)}while(d<t){a=o+f;i=a-o;l=o-(a-i)+(f-i);f=n[++d];o=a;0!==l&&(e[v++]=l)}0===o&&0!==v||(e[v++]=o);return v}function sum_three(c,s,t,n,e,o,a,l){return sum(sum(c,s,t,n,a),a,e,o,l)}function scale(c,t,n,e){let o,a,l,i,r;let f,u,d,v,h,m;u=s*n;h=u-(u-n);m=n-h;let _=t[0];o=_*n;u=s*_;d=u-(u-_);v=_-d;l=v*m-(o-d*h-v*h-d*m);let b=0;0!==l&&(e[b++]=l);for(let M=1;M<c;M++){_=t[M];i=_*n;u=s*_;d=u-(u-_);v=_-d;r=v*m-(i-d*h-v*h-d*m);a=o+r;f=a-o;l=o-(a-f)+(r-f);0!==l&&(e[b++]=l);o=i+a;l=a-(o-i);0!==l&&(e[b++]=l)}0===o&&0!==b||(e[b++]=o);return b}function negate(c,s){for(let t=0;t<c;t++)s[t]=-s[t];return c}function estimate(c,s){let t=s[0];for(let n=1;n<c;n++)t+=s[n];return t}function vec(c){return new Float64Array(c)}const n=(3+16*c)*c;const e=(2+12*c)*c;const o=(9+64*c)*c*c;const a=vec(4);const l=vec(8);const i=vec(12);const r=vec(16);const f=vec(4);function orient2dadapt(c,n,u,d,v,h,m){let _,b,M,p;let $,x,g,w,y,A,F,j,k,q,z,B,C,D;const E=c-v;const G=u-v;const H=n-h;const I=d-h;q=E*I;x=s*E;g=x-(x-E);w=E-g;x=s*I;y=x-(x-I);A=I-y;z=w*A-(q-g*y-w*y-g*A);B=H*G;x=s*H;g=x-(x-H);w=H-g;x=s*G;y=x-(x-G);A=G-y;C=w*A-(B-g*y-w*y-g*A);F=z-C;$=z-F;a[0]=z-(F+$)+($-C);j=q+F;$=j-q;k=q-(j-$)+(F-$);F=k-B;$=k-F;a[1]=k-(F+$)+($-B);D=j+F;$=D-j;a[2]=j-(D-$)+(F-$);a[3]=D;let J=estimate(4,a);let K=e*m;if(J>=K||-J>=K)return J;$=c-E;_=c-(E+$)+($-v);$=u-G;M=u-(G+$)+($-v);$=n-H;b=n-(H+$)+($-h);$=d-I;p=d-(I+$)+($-h);if(0===_&&0===b&&0===M&&0===p)return J;K=o*m+t*Math.abs(J);J+=E*p+I*_-(H*M+G*b);if(J>=K||-J>=K)return J;q=_*I;x=s*_;g=x-(x-_);w=_-g;x=s*I;y=x-(x-I);A=I-y;z=w*A-(q-g*y-w*y-g*A);B=b*G;x=s*b;g=x-(x-b);w=b-g;x=s*G;y=x-(x-G);A=G-y;C=w*A-(B-g*y-w*y-g*A);F=z-C;$=z-F;f[0]=z-(F+$)+($-C);j=q+F;$=j-q;k=q-(j-$)+(F-$);F=k-B;$=k-F;f[1]=k-(F+$)+($-B);D=j+F;$=D-j;f[2]=j-(D-$)+(F-$);f[3]=D;const L=sum(4,a,4,f,l);q=E*p;x=s*E;g=x-(x-E);w=E-g;x=s*p;y=x-(x-p);A=p-y;z=w*A-(q-g*y-w*y-g*A);B=H*M;x=s*H;g=x-(x-H);w=H-g;x=s*M;y=x-(x-M);A=M-y;C=w*A-(B-g*y-w*y-g*A);F=z-C;$=z-F;f[0]=z-(F+$)+($-C);j=q+F;$=j-q;k=q-(j-$)+(F-$);F=k-B;$=k-F;f[1]=k-(F+$)+($-B);D=j+F;$=D-j;f[2]=j-(D-$)+(F-$);f[3]=D;const N=sum(L,l,4,f,i);q=_*p;x=s*_;g=x-(x-_);w=_-g;x=s*p;y=x-(x-p);A=p-y;z=w*A-(q-g*y-w*y-g*A);B=b*M;x=s*b;g=x-(x-b);w=b-g;x=s*M;y=x-(x-M);A=M-y;C=w*A-(B-g*y-w*y-g*A);F=z-C;$=z-F;f[0]=z-(F+$)+($-C);j=q+F;$=j-q;k=q-(j-$)+(F-$);F=k-B;$=k-F;f[1]=k-(F+$)+($-B);D=j+F;$=D-j;f[2]=j-(D-$)+(F-$);f[3]=D;const O=sum(N,i,4,f,r);return r[O-1]}function orient2d(c,s,t,e,o,a){const l=(s-a)*(t-o);const i=(c-o)*(e-a);const r=l-i;const f=Math.abs(l+i);return Math.abs(r)>=n*f?r:-orient2dadapt(c,s,t,e,o,a,f)}function orient2dfast(c,s,t,n,e,o){return(s-o)*(t-e)-(c-e)*(n-o)}const u=(7+56*c)*c;const d=(3+28*c)*c;const v=(26+288*c)*c*c;const h=vec(4);const m=vec(4);const _=vec(4);const b=vec(4);const M=vec(4);const p=vec(4);const $=vec(4);const x=vec(4);const g=vec(4);const w=vec(8);const y=vec(8);const A=vec(8);const F=vec(4);const j=vec(8);const k=vec(8);const q=vec(8);const z=vec(12);let B=vec(192);let C=vec(192);function finadd$1(c,s,t){c=sum(c,B,s,t,C);const n=B;B=C;C=n;return c}function tailinit(c,t,n,e,o,a,l,i){let r,f,u,d,v,h,m,_,b,M,p,$,x,g,w;if(0===c){if(0===t){l[0]=0;i[0]=0;return 1}w=-t;M=w*n;f=s*w;u=f-(f-w);d=w-u;f=s*n;v=f-(f-n);h=n-v;l[0]=d*h-(M-u*v-d*v-u*h);l[1]=M;M=t*o;f=s*t;u=f-(f-t);d=t-u;f=s*o;v=f-(f-o);h=o-v;i[0]=d*h-(M-u*v-d*v-u*h);i[1]=M;return 2}if(0===t){M=c*e;f=s*c;u=f-(f-c);d=c-u;f=s*e;v=f-(f-e);h=e-v;l[0]=d*h-(M-u*v-d*v-u*h);l[1]=M;w=-c;M=w*a;f=s*w;u=f-(f-w);d=w-u;f=s*a;v=f-(f-a);h=a-v;i[0]=d*h-(M-u*v-d*v-u*h);i[1]=M;return 2}M=c*e;f=s*c;u=f-(f-c);d=c-u;f=s*e;v=f-(f-e);h=e-v;p=d*h-(M-u*v-d*v-u*h);$=t*n;f=s*t;u
|
||
|
|