a.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #define Zi static unsigned
  2. #define Ze static float
  3. #define Zu static u // ubcieE [paieEtnNs][ax] [rax][ucieE] w[ucieE] //clang -Os -oa a.c -lm
  4. typedef unsigned long(*_)(),u;Zi lt[]={3,0,0,2,2,3,3},O,T;Zu Q=128,U[26],ys();Ze pi=3.1415927;
  5. static char b[64];Zu __attribute((naked))ut(){asm(".quad 0xd53be04031420aeb,0xc148310fd65f03c0,0xc3d0094820e2");}
  6. #define ty x(y,tx)
  7. #define xx *(u*)x
  8. #define txx y(xx,ty)
  9. #define q(z) ux=z;Q(x)
  10. #define T0(z) _x(R(0,nx,i(nx,ru=z)))
  11. #define r1(n,z) R(1,n,i(n,sr[i]=z))
  12. #define r3(n,z) R(3,n,i(n,ri=z))
  13. #define r4(n,z) R(4,n,i(n,re=z))
  14. #define r5(n,z) R(5,n,i(n,rE=_(z)))
  15. #define T(t,c,h,e,E) _x(R(t,nx,C4(t-2,i(nx,sr[i]=c),i(nx,ri=h),i(nx,re=e),i(nx,rE=E))))
  16. #define t(t,i,e,E) c4(t-2,tc(i),ti(i),te(e),tE(E))
  17. #define ue(t,z) _(x=t>ax?Ua(t,x):x;z)
  18. #define uE(t,z) _(x=t>tx?Ut(t,x):x;z)
  19. #define uu(e) _(if(aa!=ax){if(aa<ax)a=Ua(ax,a);else x=Ua(aa,x);}e)
  20. #define UU(e) _a(it=aa?:ta;if(t!=tx){if(t<tx)a=aa?Ua(tx,a):Ut(tx,a);else x=Ut(t,x);}e)
  21. #define _(e) ({e;})
  22. #define f(g,e) u(g,e,ux)
  23. #define i(n,e) {unsigned $n=n;ii=0;for(;i<$n;++i){e;}}
  24. #define l(a,e) _(typeof(e)e_=e;(a)<e_?(a):e_)
  25. #define m(a,e) _(typeof(e)e_=e;(a)>e_?(a):e_)
  26. #define r(a,e) _(typeof(a)r=a;e;r)
  27. #define u(g,e,x...) Zu g(x){return _(e);}
  28. #define x(a,e) _(typeof(a)x=a;e)
  29. #define y(a,e) _(typeof(a)y=a;e)
  30. #define F(g,e) u(g,e,ua,ux)
  31. #define G(g,e) u(g,e,uf,ua,ux)
  32. #define Q(e) if(Q==(e))return Q;
  33. #define N(e) i(nx,e)
  34. #define P(b,e) if(b)return _(e);
  35. #define W(z) while(z)
  36. #define ii unsigned i
  37. #define in unsigned n
  38. #define ss char*s
  39. #define us(g,e) u(g,e,ss)
  40. #define ns(g,e) u(g,e,in,ss)
  41. #define _a(e) r(_(e),_r(a))
  42. #define _x(e) r(_(e),_r(x))
  43. #define _ax(e) _a(_x(e))
  44. #define n3(z) ((7+(z))>>3)
  45. #define ex (*(float*)&x)
  46. #define Ex (*(Float*)&x)
  47. #define ax l(5,x>>51)
  48. #define pax (px||ax)
  49. #define xc sx[i]
  50. #define sx ((char*)x)
  51. #define px (31>x)
  52. #define xE ((Float*)x)[i]
  53. #define aE x(a,ax?Ex:xE)
  54. #define Ea x(a,Ex)
  55. #define ci (lx?xi:sx[i])
  56. #define ix (unsigned)x
  57. #define lx lt[tx]
  58. #define Nx (nx<<lx)
  59. #define tx sx[-5]
  60. #define xr ((unsigned*)x)[-2]
  61. #define nx ((unsigned*)x)[-1]
  62. #define xi ((unsigned*)x)[i]
  63. #define xe ((float*)x)[i]
  64. #define xu ((u*)x)[i]
  65. #define iu(g,e) u(g,e,ii,ux)
  66. #define nu(g,e) u(g,e,in,ux)
  67. #define tu(g,e) u(g,e,it,ux)
  68. #define Qs(e,s) if(e)return err((u)__func__,(u)s);
  69. #define Qz(e) Qs(e,"nyi")
  70. #define Qr(e) Qs(e,"rank")
  71. #define Qt(e) Qs(e,"type")
  72. #define Qd(e) Qs(e,"domain")
  73. #define QZ Qz(1)0
  74. #define oo w((u)"oo\n")
  75. #define uf u f
  76. #define ua u a
  77. #define ux u x
  78. #define st char*t
  79. #define it unsigned t
  80. #define EE Float E
  81. #define ee float e
  82. #define nxu ((unsigned*)xu)[-1]
  83. #define sxu ((char*)xu)
  84. #define si s[i]
  85. #define sr x(r,sx)
  86. #define nr x(r,nx)
  87. #define Nr x(r,Nx)
  88. #define ai x(a,ax?ix:xi)
  89. #define ae x(a,ax?ex:xe)
  90. #define ea x(a,ex)
  91. #define sa x(a,sx)
  92. #define la x(a,lx)
  93. #define pa x(a,px)
  94. #define aa x(a,ax)
  95. #define ia x(a,ix)
  96. #define na x(a,nx)
  97. #define ta x(a,tx)
  98. #define Na x(a,Nx)
  99. #define c4(z,a,b,c,d) _(unsigned o=z;!o?a:1==o?b:2==o?c:_(d))
  100. #define C4(z,a,b,c,d) unsigned o=z;if(!o)_(a);else if(1==o)_(b);else if(2==o)_(c);else _(d);
  101. #define Z_ static _
  102. #define Zs static char*
  103. #define ZE static Float
  104. #define l2(z) (64-bu(clzl)(z))
  105. #define R1(z) _x(r1(nx,z))
  106. #define R3(z) _x(r3(nx,z))
  107. #define R4(z) _x(r4(nx,z))
  108. #define R5(z) _x(r5(nx,z))
  109. #define tb(z) (1l<<51|(z))
  110. #define tc(z) (2l<<51|(char)(z))
  111. #define ti(z) (3l<<51|(unsigned)(z))
  112. #define te(z) (4l<<51|_(float _=z;*(unsigned*)&_))
  113. #define ru ((u*)r)[i]
  114. #define ri ((unsigned*)r)[i]
  115. #define re ((float*)r)[i]
  116. #define rE ((Float*)r)[i]
  117. #define wu(z) r((u)(z),nw(sprintf(b,"%lx\n",r),b))
  118. #define wi(z) r((int)(z),nw(sprintf(b,"%d\n",r),b))
  119. #define we(z) r((float)(z),nw(sprintf(b,"%g\n",r),b))
  120. #define wE(z) r((Float)(z),float*a=&r;nw(sprintf(b,"%g:%g\n",*a,a[1]),b))
  121. #define bu(o) __builtin_##o
  122. us(sl,ii=0;W(si)++i;i)ns(is,i(sl(s),P(n==si,i+1))0)
  123. #if __arm64
  124. static void __builtin_ia32_ldmxcsr(int x){asm("msr fpcr,%0"::"r"(3l<<23));}
  125. #endif
  126. #include<complex.h>