暫無描述
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

090-Vectors-Maths.cs 53KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674
  1. using Burst.Compiler.IL.Tests.Helpers;
  2. using NUnit.Framework;
  3. using Unity.Mathematics;
  4. namespace Burst.Compiler.IL.Tests
  5. {
  6. [TestFixture]
  7. internal partial class VectorsMaths
  8. {
  9. [TestCompiler]
  10. public static ulong HalfToFloatAndDouble()
  11. {
  12. return math.asuint(new half {value = 0x0000})
  13. + math.asulong(new half {value = 0x1000});
  14. }
  15. // ---------------------------------------------------------
  16. // asfloat
  17. // ---------------------------------------------------------
  18. [TestCompiler(DataRange.Standard)]
  19. public static float AsFloatInt4(ref int4 a)
  20. {
  21. return Vectors.ConvertToFloat(math.asfloat(a));
  22. }
  23. [TestCompiler(DataRange.Standard)]
  24. public static float AsFloatInt3(ref int3 a)
  25. {
  26. return Vectors.ConvertToFloat(math.asfloat(a));
  27. }
  28. [TestCompiler(DataRange.Standard)]
  29. public static float AsFloatInt2(ref int2 a)
  30. {
  31. return Vectors.ConvertToFloat(math.asfloat(a));
  32. }
  33. [TestCompiler(DataRange.Standard)]
  34. public static float AsFloatUInt4(ref uint4 a)
  35. {
  36. return Vectors.ConvertToFloat(math.asfloat(a));
  37. }
  38. // ---------------------------------------------------------
  39. // asint
  40. // ---------------------------------------------------------
  41. [TestCompiler(DataRange.Standard)]
  42. public static int AsIntFloat4(ref float4 a)
  43. {
  44. return Vectors.ConvertToInt(math.asint(a));
  45. }
  46. [TestCompiler(DataRange.Standard)]
  47. public static int AsIntFloat3(ref float3 a)
  48. {
  49. return Vectors.ConvertToInt(math.asint(a));
  50. }
  51. [TestCompiler(DataRange.Standard)]
  52. public static int AsIntFloat2(ref float2 a)
  53. {
  54. return Vectors.ConvertToInt(math.asint(a));
  55. }
  56. // ---------------------------------------------------------
  57. // asuint
  58. // ---------------------------------------------------------
  59. [TestCompiler(DataRange.Standard)]
  60. public static int AsUIntFloat4(ref float4 a)
  61. {
  62. return Vectors.ConvertToInt(math.asuint(a));
  63. }
  64. [TestCompiler(DataRange.Standard)]
  65. public static int AsUIntFloat3(ref float3 a)
  66. {
  67. return Vectors.ConvertToInt(math.asuint(a));
  68. }
  69. [TestCompiler(DataRange.Standard)]
  70. public static int AsUIntFloat2(ref float2 a)
  71. {
  72. return Vectors.ConvertToInt(math.asuint(a));
  73. }
  74. // ---------------------------------------------------------
  75. // compress
  76. // ---------------------------------------------------------
  77. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  78. public static unsafe int CompressInt4(ref int4 value, ref bool4 mask)
  79. {
  80. var temp = default(TestCompressInt4);
  81. var ptr = &temp.Value0;
  82. var count = math.compress(ptr, 0, value, mask);
  83. int result = 0;
  84. for (int i = 0; i < count; i++)
  85. {
  86. result = result * 397 + ptr[i];
  87. }
  88. return result;
  89. }
  90. // ---------------------------------------------------------
  91. // count_bits
  92. // ---------------------------------------------------------
  93. [TestCompiler(DataRange.Standard)]
  94. public static int CountBitsInt(int value)
  95. {
  96. return math.countbits(value);
  97. }
  98. [TestCompiler(DataRange.Standard)]
  99. public static int CountBitsInt2(ref int2 value)
  100. {
  101. return Vectors.ConvertToInt(math.countbits(value));
  102. }
  103. [TestCompiler(DataRange.Standard)]
  104. public static int CountBitsInt3(ref int3 value)
  105. {
  106. return Vectors.ConvertToInt(math.countbits(value));
  107. }
  108. [TestCompiler(DataRange.Standard)]
  109. public static int CountBitsInt4(ref int4 value)
  110. {
  111. return Vectors.ConvertToInt(math.countbits(value));
  112. }
  113. [TestCompiler(DataRange.Standard)]
  114. public static int CountBitsUInt(uint value)
  115. {
  116. return math.countbits(value);
  117. }
  118. [TestCompiler(DataRange.Standard)]
  119. public static int CountBitsUInt2(ref uint2 value)
  120. {
  121. return Vectors.ConvertToInt(math.countbits(value));
  122. }
  123. [TestCompiler(DataRange.Standard)]
  124. public static int CountBitsUInt3(ref uint3 value)
  125. {
  126. return Vectors.ConvertToInt(math.countbits(value));
  127. }
  128. [TestCompiler(DataRange.Standard)]
  129. public static int CountBitsUInt4(ref uint4 value)
  130. {
  131. return Vectors.ConvertToInt(math.countbits(value));
  132. }
  133. [TestCompiler(DataRange.Standard)]
  134. public static int CountBitsLong(long value)
  135. {
  136. return math.countbits(value);
  137. }
  138. [TestCompiler(DataRange.Standard)]
  139. public static int CountBitsULong(ulong value)
  140. {
  141. return math.countbits(value);
  142. }
  143. // ---------------------------------------------------------
  144. // lzcnt
  145. // ---------------------------------------------------------
  146. [TestCompiler(DataRange.Standard)]
  147. public static int LzCntInt(int value)
  148. {
  149. return math.lzcnt(value);
  150. }
  151. [TestCompiler(DataRange.Standard)]
  152. public static int LzCntInt2(ref int2 value)
  153. {
  154. return Vectors.ConvertToInt(math.lzcnt(value));
  155. }
  156. [TestCompiler(DataRange.Standard)]
  157. public static int LzCntInt3(ref int3 value)
  158. {
  159. return Vectors.ConvertToInt(math.lzcnt(value));
  160. }
  161. [TestCompiler(DataRange.Standard)]
  162. public static int LzCntInt4(ref int4 value)
  163. {
  164. return Vectors.ConvertToInt(math.lzcnt(value));
  165. }
  166. [TestCompiler(DataRange.Standard)]
  167. public static int LzCntUInt(uint value)
  168. {
  169. return math.lzcnt(value);
  170. }
  171. [TestCompiler(DataRange.Standard)]
  172. public static int LzCntUInt2(ref uint2 value)
  173. {
  174. return Vectors.ConvertToInt(math.lzcnt(value));
  175. }
  176. [TestCompiler(DataRange.Standard)]
  177. public static int LzCntUInt3(ref uint3 value)
  178. {
  179. return Vectors.ConvertToInt(math.lzcnt(value));
  180. }
  181. [TestCompiler(DataRange.Standard)]
  182. public static int LzCntUInt4(ref uint4 value)
  183. {
  184. return Vectors.ConvertToInt(math.lzcnt(value));
  185. }
  186. [TestCompiler(DataRange.Standard)]
  187. public static int LzCntLong(long value)
  188. {
  189. return math.lzcnt(value);
  190. }
  191. [TestCompiler(DataRange.Standard)]
  192. public static int LzCntULong(ulong value)
  193. {
  194. return math.lzcnt(value);
  195. }
  196. // ---------------------------------------------------------
  197. // tzcnt
  198. // ---------------------------------------------------------
  199. [TestCompiler(DataRange.Standard)]
  200. public static int TzCntInt(int value)
  201. {
  202. return math.tzcnt(value);
  203. }
  204. [TestCompiler(DataRange.Standard)]
  205. public static int TzCntInt2(ref int2 value)
  206. {
  207. return Vectors.ConvertToInt(math.tzcnt(value));
  208. }
  209. [TestCompiler(DataRange.Standard)]
  210. public static int TzCntInt3(ref int3 value)
  211. {
  212. return Vectors.ConvertToInt(math.tzcnt(value));
  213. }
  214. [TestCompiler(DataRange.Standard)]
  215. public static int TzCntInt4(ref int4 value)
  216. {
  217. return Vectors.ConvertToInt(math.tzcnt(value));
  218. }
  219. [TestCompiler(DataRange.Standard)]
  220. public static int TzCntUInt(uint value)
  221. {
  222. return math.tzcnt(value);
  223. }
  224. [TestCompiler(DataRange.Standard)]
  225. public static int TzCntUInt2(ref uint2 value)
  226. {
  227. return Vectors.ConvertToInt(math.tzcnt(value));
  228. }
  229. [TestCompiler(DataRange.Standard)]
  230. public static int TzCntUInt3(ref uint3 value)
  231. {
  232. return Vectors.ConvertToInt(math.tzcnt(value));
  233. }
  234. [TestCompiler(DataRange.Standard)]
  235. public static int TzCntUInt4(ref uint4 value)
  236. {
  237. return Vectors.ConvertToInt(math.tzcnt(value));
  238. }
  239. [TestCompiler(DataRange.Standard)]
  240. public static int TzCntLong(long value)
  241. {
  242. return math.tzcnt(value);
  243. }
  244. [TestCompiler(DataRange.Standard)]
  245. public static int TzCntULong(ulong value)
  246. {
  247. return math.tzcnt(value);
  248. }
  249. // ---------------------------------------------------------
  250. // min
  251. // ---------------------------------------------------------
  252. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  253. public static float Min4(ref float4 a, ref float4 b)
  254. {
  255. return Vectors.ConvertToFloat(math.min(a, b));
  256. }
  257. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  258. public static float Min3(ref float3 a, ref float3 b)
  259. {
  260. return Vectors.ConvertToFloat(math.min(a, b));
  261. }
  262. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  263. public static float Min2(ref float2 a, ref float2 b)
  264. {
  265. return Vectors.ConvertToFloat(math.min(a, b));
  266. }
  267. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  268. public static float Min(float a, float b)
  269. {
  270. return math.min(a, b);
  271. }
  272. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  273. public static int MinInt4(ref int4 a, ref int4 b)
  274. {
  275. return Vectors.ConvertToInt(math.min(a, b));
  276. }
  277. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  278. public static int MinInt3(ref int3 a, ref int3 b)
  279. {
  280. return Vectors.ConvertToInt(math.min(a, b));
  281. }
  282. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  283. public static int MinInt2(ref int2 a, ref int2 b)
  284. {
  285. return Vectors.ConvertToInt(math.min(a, b));
  286. }
  287. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  288. public static int MinInt(int a, int b)
  289. {
  290. return math.min(a, b);
  291. }
  292. // ---------------------------------------------------------
  293. // max
  294. // ---------------------------------------------------------
  295. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  296. public static float Max4(ref float4 a, ref float4 b)
  297. {
  298. return Vectors.ConvertToFloat(math.max(a, b));
  299. }
  300. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  301. public static float Max3(ref float3 a, ref float3 b)
  302. {
  303. return Vectors.ConvertToFloat(math.max(a, b));
  304. }
  305. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  306. public static float Max2(ref float2 a, ref float2 b)
  307. {
  308. return Vectors.ConvertToFloat(math.max(a, b));
  309. }
  310. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  311. public static float Max(float a, float b)
  312. {
  313. return math.max(a, b);
  314. }
  315. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  316. public static int MaxInt4(ref int4 a, ref int4 b)
  317. {
  318. return Vectors.ConvertToInt(math.max(a, b));
  319. }
  320. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  321. public static int MaxInt3(ref int3 a, ref int3 b)
  322. {
  323. return Vectors.ConvertToInt(math.max(a, b));
  324. }
  325. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  326. public static int MaxInt2(ref int2 a, ref int2 b)
  327. {
  328. return Vectors.ConvertToInt(math.max(a, b));
  329. }
  330. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  331. public static float MaxInt(int a, int b)
  332. {
  333. return math.max(a, b);
  334. }
  335. // ---------------------------------------------------------
  336. // lerp
  337. // ---------------------------------------------------------
  338. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.ZeroExclusiveToOneInclusive|DataRange.Zero)]
  339. public static float Lerp4(ref float4 a, ref float4 b, float w)
  340. {
  341. return Vectors.ConvertToFloat(math.lerp(a, b, w));
  342. }
  343. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.ZeroExclusiveToOneInclusive | DataRange.Zero)]
  344. public static float Lerp3(ref float3 a, ref float3 b, float w)
  345. {
  346. return Vectors.ConvertToFloat(math.lerp(a, b, w));
  347. }
  348. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.ZeroExclusiveToOneInclusive | DataRange.Zero)]
  349. public static float Lerp2(ref float2 a, ref float2 b, float w)
  350. {
  351. return Vectors.ConvertToFloat(math.lerp(a, b, w));
  352. }
  353. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.ZeroExclusiveToOneInclusive | DataRange.Zero)]
  354. public static float Lerp(float a, float b, float w)
  355. {
  356. return math.lerp(a, b, w);
  357. }
  358. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.ZeroExclusiveToOneInclusive | DataRange.Zero)]
  359. public static float Lerp4_4(ref float4 a, ref float4 b, ref float4 w)
  360. {
  361. return Vectors.ConvertToFloat(math.lerp(a, b, w));
  362. }
  363. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.ZeroExclusiveToOneInclusive | DataRange.Zero)]
  364. public static float Lerp3_3(ref float3 a, ref float3 b, ref float3 w)
  365. {
  366. return Vectors.ConvertToFloat(math.lerp(a, b, w));
  367. }
  368. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.ZeroExclusiveToOneInclusive | DataRange.Zero)]
  369. public static float Lerp2_2(ref float2 a, ref float2 b, ref float2 w)
  370. {
  371. return Vectors.ConvertToFloat(math.lerp(a, b, w));
  372. }
  373. // ---------------------------------------------------------
  374. // mad
  375. // ---------------------------------------------------------
  376. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.Standard)]
  377. public static float Mad4(ref float4 a, ref float4 b, ref float4 c)
  378. {
  379. return Vectors.ConvertToFloat(math.mad(a, b, c));
  380. }
  381. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.Standard)]
  382. public static float Mad3(ref float3 a, ref float3 b, ref float3 c)
  383. {
  384. return Vectors.ConvertToFloat(math.mad(a, b, c));
  385. }
  386. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.Standard)]
  387. public static float Mad2(ref float2 a, ref float2 b, ref float2 c)
  388. {
  389. return Vectors.ConvertToFloat(math.mad(a, b, c));
  390. }
  391. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.Standard)]
  392. public static float Mad(float a, float b, float c)
  393. {
  394. return math.mad(a, b, c);
  395. }
  396. // ---------------------------------------------------------
  397. // clamp
  398. // ---------------------------------------------------------
  399. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.Standard)]
  400. public static float Clamp4(ref float4 x, ref float4 a, ref float4 b)
  401. {
  402. return Vectors.ConvertToFloat(math.clamp(x, a, b));
  403. }
  404. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.Standard)]
  405. public static float Clamp3(ref float3 x, ref float3 a, ref float3 b)
  406. {
  407. return Vectors.ConvertToFloat(math.clamp(x, a, b));
  408. }
  409. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.Standard)]
  410. public static float Clamp2(ref float2 x, ref float2 a, ref float2 b)
  411. {
  412. return Vectors.ConvertToFloat(math.clamp(x, a, b));
  413. }
  414. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.Standard)]
  415. public static float Clamp(float x, float a, float b)
  416. {
  417. return math.clamp(x, a, b);
  418. }
  419. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.Standard)]
  420. public static int ClampInt4(ref int4 x, ref int4 a, ref int4 b)
  421. {
  422. return Vectors.ConvertToInt(math.clamp(x, a, b));
  423. }
  424. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.Standard)]
  425. public static int ClampInt3(ref int3 x, ref int3 a, ref int3 b)
  426. {
  427. return Vectors.ConvertToInt(math.clamp(x, a, b));
  428. }
  429. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.Standard)]
  430. public static int ClampInt2(ref int2 x, ref int2 a, ref int2 b)
  431. {
  432. return Vectors.ConvertToInt(math.clamp(x, a, b));
  433. }
  434. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.Standard)]
  435. public static int ClampInt(int x, int a, int b)
  436. {
  437. return math.clamp(x, a, b);
  438. }
  439. // ---------------------------------------------------------
  440. // saturate
  441. // ---------------------------------------------------------
  442. [TestCompiler(DataRange.Standard)]
  443. public static float Saturate4(ref float4 x)
  444. {
  445. return Vectors.ConvertToFloat(math.saturate(x));
  446. }
  447. [TestCompiler(DataRange.Standard)]
  448. public static float Saturate3(ref float3 x)
  449. {
  450. return Vectors.ConvertToFloat(math.saturate(x));
  451. }
  452. [TestCompiler(DataRange.Standard)]
  453. public static float Saturate2(ref float2 x)
  454. {
  455. return Vectors.ConvertToFloat(math.saturate(x));
  456. }
  457. [TestCompiler(DataRange.Standard)]
  458. public static float Saturate(float x)
  459. {
  460. return math.saturate(x);
  461. }
  462. // ---------------------------------------------------------
  463. // abs
  464. // ---------------------------------------------------------
  465. [TestCompiler(DataRange.Standard)]
  466. public static float Abs4(ref float4 x)
  467. {
  468. return Vectors.ConvertToFloat(math.abs(x));
  469. }
  470. [TestCompiler(DataRange.Standard)]
  471. public static float Abs3(ref float3 x)
  472. {
  473. return Vectors.ConvertToFloat(math.abs(x));
  474. }
  475. [TestCompiler(DataRange.Standard)]
  476. public static float Abs2(ref float2 x)
  477. {
  478. return Vectors.ConvertToFloat(math.abs(x));
  479. }
  480. [TestCompiler(DataRange.Standard)]
  481. public static float Abs(float x)
  482. {
  483. return math.abs(x);
  484. }
  485. [TestCompiler(DataRange.Standard)]
  486. public static double AbsDouble4(ref double4 x)
  487. {
  488. return Vectors.ConvertToDouble(math.abs(x));
  489. }
  490. [TestCompiler(DataRange.Standard)]
  491. public static double AbsDouble3(ref double3 x)
  492. {
  493. return Vectors.ConvertToDouble(math.abs(x));
  494. }
  495. [TestCompiler(DataRange.Standard)]
  496. public static double AbsDouble2(ref double2 x)
  497. {
  498. return Vectors.ConvertToDouble(math.abs(x));
  499. }
  500. [TestCompiler(DataRange.Standard)]
  501. public static double AbsDouble(double x)
  502. {
  503. return math.abs(x);
  504. }
  505. [TestCompiler(DataRange.Standard)]
  506. public static int AbsInt4(ref int4 x)
  507. {
  508. return Vectors.ConvertToInt(math.abs(x));
  509. }
  510. [TestCompiler(DataRange.Standard)]
  511. public static int AbsInt3(ref int3 x)
  512. {
  513. return Vectors.ConvertToInt(math.abs(x));
  514. }
  515. [TestCompiler(DataRange.Standard)]
  516. public static int AbsInt2(ref int2 x)
  517. {
  518. return Vectors.ConvertToInt(math.abs(x));
  519. }
  520. [TestCompiler(DataRange.Standard)]
  521. public static int AbsInt(int x)
  522. {
  523. return math.abs(x);
  524. }
  525. // ---------------------------------------------------------
  526. // dot
  527. // ---------------------------------------------------------
  528. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  529. public static float Dot4(ref float4 a, ref float4 b)
  530. {
  531. return math.dot(a, b);
  532. }
  533. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  534. public static float Dot3(ref float3 a, ref float3 b)
  535. {
  536. return math.dot(a, b);
  537. }
  538. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  539. public static float Dot2(ref float2 a, ref float2 b)
  540. {
  541. return math.dot(a, b);
  542. }
  543. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  544. public static float Dot(float a, float b)
  545. {
  546. return math.dot(a, b);
  547. }
  548. // ---------------------------------------------------------
  549. // cmin
  550. // ---------------------------------------------------------
  551. [TestCompiler(DataRange.Standard & ~DataRange.NaN)] // TODO: Does no handle NaN correctly
  552. public static float CMin4(ref float4 input)
  553. {
  554. return math.cmin(input);
  555. }
  556. [TestCompiler(DataRange.Standard & ~DataRange.NaN)] // TODO: Does no handle NaN correctly
  557. public static float CMin3(ref float3 input)
  558. {
  559. return math.cmin(input);
  560. }
  561. [TestCompiler(DataRange.Standard & ~DataRange.NaN)] // TODO: Does no handle NaN correctly
  562. public static float CMin2(ref float2 input)
  563. {
  564. return math.cmin(input);
  565. }
  566. [TestCompiler(DataRange.Standard)]
  567. public static float CMinInt4(ref int4 input)
  568. {
  569. return math.cmin(input);
  570. }
  571. [TestCompiler(DataRange.Standard)]
  572. public static float CMinInt3(ref int3 input)
  573. {
  574. return math.cmin(input);
  575. }
  576. [TestCompiler(DataRange.Standard)]
  577. public static float CMinInt2(ref int2 input)
  578. {
  579. return math.cmin(input);
  580. }
  581. // ---------------------------------------------------------
  582. // cmax
  583. // ---------------------------------------------------------
  584. [TestCompiler(DataRange.Standard & ~DataRange.NaN)] // TODO: Does no handle NaN correctly
  585. public static float CMax4(ref float4 input)
  586. {
  587. return math.cmax(input);
  588. }
  589. [TestCompiler(DataRange.Standard & ~DataRange.NaN)] // TODO: Does no handle NaN correctly
  590. public static float CMax3(ref float3 input)
  591. {
  592. return math.cmax(input);
  593. }
  594. [TestCompiler(DataRange.Standard & ~DataRange.NaN)] // TODO: Does no handle NaN correctly
  595. public static float CMax2(ref float2 input)
  596. {
  597. return math.cmax(input);
  598. }
  599. [TestCompiler(DataRange.Standard)]
  600. public static float CMaxInt4(ref int4 input)
  601. {
  602. return math.cmax(input);
  603. }
  604. [TestCompiler(DataRange.Standard)]
  605. public static float CMaxInt3(ref int3 input)
  606. {
  607. return math.cmax(input);
  608. }
  609. [TestCompiler(DataRange.Standard)]
  610. public static float CMaxInt2(ref int2 input)
  611. {
  612. return math.cmax(input);
  613. }
  614. // ---------------------------------------------------------
  615. // csum
  616. // ---------------------------------------------------------
  617. [TestCompiler(DataRange.Standard)]
  618. public static double CSum4d(ref double4 input)
  619. {
  620. return math.csum(input);
  621. }
  622. [TestCompiler(DataRange.Standard)]
  623. public static float CSum4(ref float4 input)
  624. {
  625. return math.csum(input);
  626. }
  627. [TestCompiler(DataRange.Standard)]
  628. public static float CSum3(ref float3 input)
  629. {
  630. return math.csum(input);
  631. }
  632. [TestCompiler(DataRange.Standard)]
  633. public static float CSum2(ref float2 input)
  634. {
  635. return math.csum(input);
  636. }
  637. [TestCompiler(DataRange.Standard)]
  638. public static float CSumInt4(ref int4 input)
  639. {
  640. return math.csum(input);
  641. }
  642. [TestCompiler(DataRange.Standard)]
  643. public static float CSumInt3(ref int3 input)
  644. {
  645. return math.csum(input);
  646. }
  647. [TestCompiler(DataRange.Standard)]
  648. public static float CSumInt2(ref int2 input)
  649. {
  650. return math.csum(input);
  651. }
  652. // ---------------------------------------------------------
  653. // acos
  654. // ---------------------------------------------------------
  655. [TestCompiler(DataRange.MinusOneInclusiveToOneInclusive)]
  656. public static float ACos4(ref float4 input)
  657. {
  658. return Vectors.ConvertToFloat(math.acos(input));
  659. }
  660. [TestCompiler(DataRange.MinusOneInclusiveToOneInclusive)]
  661. public static float ACos3(ref float3 input)
  662. {
  663. return Vectors.ConvertToFloat(math.acos(input));
  664. }
  665. [TestCompiler(DataRange.MinusOneInclusiveToOneInclusive)]
  666. public static float ACos2(ref float2 input)
  667. {
  668. return Vectors.ConvertToFloat(math.acos(input));
  669. }
  670. [TestCompiler(DataRange.MinusOneInclusiveToOneInclusive)]
  671. public static float ACos(float input)
  672. {
  673. return math.acos(input);
  674. }
  675. // ---------------------------------------------------------
  676. // asin
  677. // ---------------------------------------------------------
  678. [TestCompiler(DataRange.MinusOneInclusiveToOneInclusive)]
  679. public static float ASin4(ref float4 input)
  680. {
  681. return Vectors.ConvertToFloat(math.asin(input));
  682. }
  683. [TestCompiler(DataRange.MinusOneInclusiveToOneInclusive)]
  684. public static float ASin3(ref float3 input)
  685. {
  686. return Vectors.ConvertToFloat(math.asin(input));
  687. }
  688. [TestCompiler(DataRange.MinusOneInclusiveToOneInclusive)]
  689. public static float ASin2(ref float2 input)
  690. {
  691. return Vectors.ConvertToFloat(math.asin(input));
  692. }
  693. [TestCompiler(DataRange.MinusOneInclusiveToOneInclusive)]
  694. public static float ASin(float input)
  695. {
  696. return math.asin(input);
  697. }
  698. // ---------------------------------------------------------
  699. // atan
  700. // ---------------------------------------------------------
  701. [TestCompiler(DataRange.MinusOneInclusiveToOneInclusive)]
  702. public static float ATan_4(ref float4 input)
  703. {
  704. return Vectors.ConvertToFloat(math.atan(input));
  705. }
  706. [TestCompiler(DataRange.MinusOneInclusiveToOneInclusive)]
  707. public static float ATan_3(ref float3 input)
  708. {
  709. return Vectors.ConvertToFloat(math.atan(input));
  710. }
  711. [TestCompiler(DataRange.MinusOneInclusiveToOneInclusive)]
  712. public static float ATan_2(ref float2 input)
  713. {
  714. return Vectors.ConvertToFloat(math.atan(input));
  715. }
  716. [TestCompiler(DataRange.MinusOneInclusiveToOneInclusive)]
  717. public static float ATan(float input)
  718. {
  719. return math.atan(input);
  720. }
  721. // ---------------------------------------------------------
  722. // atan2
  723. // ---------------------------------------------------------
  724. [TestCompiler(DataRange.MinusOneInclusiveToOneInclusive, DataRange.MinusOneInclusiveToOneInclusive)]
  725. public static float ATan2_4(ref float4 a, ref float4 b)
  726. {
  727. return Vectors.ConvertToFloat(math.atan2(a, b));
  728. }
  729. [TestCompiler(DataRange.MinusOneInclusiveToOneInclusive, DataRange.MinusOneInclusiveToOneInclusive)]
  730. public static float ATan2_3(ref float3 a, ref float3 b)
  731. {
  732. return Vectors.ConvertToFloat(math.atan2(a, b));
  733. }
  734. [TestCompiler(DataRange.MinusOneInclusiveToOneInclusive, DataRange.MinusOneInclusiveToOneInclusive)]
  735. public static float ATan2_2(ref float2 a, ref float2 b)
  736. {
  737. return Vectors.ConvertToFloat(math.atan2(a, b));
  738. }
  739. [TestCompiler(DataRange.MinusOneInclusiveToOneInclusive, DataRange.MinusOneInclusiveToOneInclusive)]
  740. public static float ATan2(float a, float b)
  741. {
  742. return math.atan2(a, b);
  743. }
  744. // ---------------------------------------------------------
  745. // cos
  746. // ---------------------------------------------------------
  747. [TestCompiler(DataRange.Standard)]
  748. public static double Cos4d(ref double4 input)
  749. {
  750. return Vectors.ConvertToDouble(math.cos(input));
  751. }
  752. [TestCompiler(DataRange.Standard)]
  753. public static float Cos4(ref float4 input)
  754. {
  755. return Vectors.ConvertToFloat(math.cos(input));
  756. }
  757. [TestCompiler(DataRange.Standard)]
  758. public static float Cos3(ref float3 input)
  759. {
  760. return Vectors.ConvertToFloat(math.cos(input));
  761. }
  762. [TestCompiler(DataRange.Standard)]
  763. public static float Cos2(ref float2 input)
  764. {
  765. return Vectors.ConvertToFloat(math.cos(input));
  766. }
  767. [TestCompiler(DataRange.Standard)]
  768. public static float Cos(float input)
  769. {
  770. return math.cos(input);
  771. }
  772. // ---------------------------------------------------------
  773. // cosh
  774. // ---------------------------------------------------------
  775. [TestCompiler(DataRange.Standard)]
  776. public static double Cosh4d(ref double4 input)
  777. {
  778. return Vectors.ConvertToDouble(math.cosh(input));
  779. }
  780. [TestCompiler(DataRange.Standard)]
  781. public static float Cosh4(ref float4 input)
  782. {
  783. return Vectors.ConvertToFloat(math.cosh(input));
  784. }
  785. [TestCompiler(DataRange.Standard)]
  786. public static float Cosh3(ref float3 input)
  787. {
  788. return Vectors.ConvertToFloat(math.cosh(input));
  789. }
  790. [TestCompiler(DataRange.Standard)]
  791. public static float Cosh2(ref float2 input)
  792. {
  793. return Vectors.ConvertToFloat(math.cosh(input));
  794. }
  795. [TestCompiler(DataRange.Standard)]
  796. public static float Cosh(float input)
  797. {
  798. return math.cosh(input);
  799. }
  800. // ---------------------------------------------------------
  801. // sin
  802. // ---------------------------------------------------------
  803. [TestCompiler(DataRange.Standard)]
  804. public static double Sin4d(ref double4 input)
  805. {
  806. return Vectors.ConvertToDouble(math.sin(input));
  807. }
  808. [TestCompiler(DataRange.Standard)]
  809. public static float Sin4(ref float4 input)
  810. {
  811. return Vectors.ConvertToFloat(math.sin(input));
  812. }
  813. [TestCompiler(DataRange.Standard)]
  814. public static float Sin3(ref float3 input)
  815. {
  816. return Vectors.ConvertToFloat(math.sin(input));
  817. }
  818. [TestCompiler(DataRange.Standard)]
  819. public static float Sin2(ref float2 input)
  820. {
  821. return Vectors.ConvertToFloat(math.sin(input));
  822. }
  823. [TestCompiler(DataRange.Standard)]
  824. public static float Sin(float input)
  825. {
  826. return math.sin(input);
  827. }
  828. // ---------------------------------------------------------
  829. // sinh
  830. // ---------------------------------------------------------
  831. [TestCompiler(DataRange.Standard)]
  832. public static float Sinh4(ref float4 input)
  833. {
  834. return Vectors.ConvertToFloat(math.sinh(input));
  835. }
  836. [TestCompiler(DataRange.Standard)]
  837. public static float Sinh3(ref float3 input)
  838. {
  839. return Vectors.ConvertToFloat(math.sinh(input));
  840. }
  841. [TestCompiler(DataRange.Standard)]
  842. public static float Sinh2(ref float2 input)
  843. {
  844. return Vectors.ConvertToFloat(math.sinh(input));
  845. }
  846. [TestCompiler(DataRange.Standard)]
  847. public static float Sinh(float input)
  848. {
  849. return math.sinh(input);
  850. }
  851. // ---------------------------------------------------------
  852. // sincos
  853. // ---------------------------------------------------------
  854. [TestCompiler(DataRange.Standard)]
  855. public static float SinCos4(ref float4 input)
  856. {
  857. float4 sina, cosa;
  858. math.sincos(input, out sina, out cosa);
  859. return Vectors.ConvertToFloat(sina) + Vectors.ConvertToFloat(cosa) * 7.1f;
  860. }
  861. [TestCompiler(DataRange.Standard)]
  862. public static float SinCos3(ref float3 input)
  863. {
  864. float3 sina, cosa;
  865. math.sincos(input, out sina, out cosa);
  866. return Vectors.ConvertToFloat(sina) + Vectors.ConvertToFloat(cosa) * 7.1f;
  867. }
  868. [TestCompiler(DataRange.Standard)]
  869. public static float SinCos2(ref float2 input)
  870. {
  871. float2 sina, cosa;
  872. math.sincos(input, out sina, out cosa);
  873. return Vectors.ConvertToFloat(sina) + Vectors.ConvertToFloat(cosa) * 7.1f;
  874. }
  875. [TestCompiler(DataRange.Standard)]
  876. public static float SinCos(float input)
  877. {
  878. float sina, cosa;
  879. math.sincos(input, out sina, out cosa);
  880. return sina + cosa * 7.1f;
  881. }
  882. // ---------------------------------------------------------
  883. // tanh
  884. // ---------------------------------------------------------
  885. [TestCompiler(DataRange.Standard)]
  886. public static float Tanh4(ref float4 input)
  887. {
  888. return Vectors.ConvertToFloat(math.tanh(input));
  889. }
  890. [TestCompiler(DataRange.Standard)]
  891. public static float Tanh3(ref float3 input)
  892. {
  893. return Vectors.ConvertToFloat(math.tanh(input));
  894. }
  895. [TestCompiler(DataRange.Standard)]
  896. public static float Tanh2(ref float2 input)
  897. {
  898. return Vectors.ConvertToFloat(math.tanh(input));
  899. }
  900. [TestCompiler(DataRange.Standard)]
  901. public static float Tanh(float input)
  902. {
  903. return math.tanh(input);
  904. }
  905. // ---------------------------------------------------------
  906. // sqrt
  907. // ---------------------------------------------------------
  908. [TestCompiler(DataRange.Standard)]
  909. public static float Sqrt4(ref float4 input)
  910. {
  911. return Vectors.ConvertToFloat(math.sqrt(input));
  912. }
  913. [TestCompiler(DataRange.Standard)]
  914. public static float Sqrt3(ref float3 input)
  915. {
  916. return Vectors.ConvertToFloat(math.sqrt(input));
  917. }
  918. [TestCompiler(DataRange.Standard)]
  919. public static float Sqrt2(ref float2 input)
  920. {
  921. return Vectors.ConvertToFloat(math.sqrt(input));
  922. }
  923. [TestCompiler(DataRange.Standard)]
  924. public static float Sqrt(float input)
  925. {
  926. return math.sqrt(input);
  927. }
  928. // ---------------------------------------------------------
  929. // rsqrt
  930. // ---------------------------------------------------------
  931. [TestCompiler(DataRange.Standard)]
  932. public static float RSqrt4(ref float4 input)
  933. {
  934. return Vectors.ConvertToFloat(math.rsqrt(input));
  935. }
  936. [TestCompiler(DataRange.Standard)]
  937. public static float RSqrt3(ref float3 input)
  938. {
  939. return Vectors.ConvertToFloat(math.rsqrt(input));
  940. }
  941. [TestCompiler(DataRange.Standard)]
  942. public static float RSqrt2(ref float2 input)
  943. {
  944. return Vectors.ConvertToFloat(math.rsqrt(input));
  945. }
  946. [TestCompiler(DataRange.Standard)]
  947. public static float RSqrt(float input)
  948. {
  949. return math.rsqrt(input);
  950. }
  951. // ---------------------------------------------------------
  952. // floor
  953. // ---------------------------------------------------------
  954. [TestCompiler(DataRange.Standard)]
  955. public static float Floor4(ref float4 input)
  956. {
  957. return Vectors.ConvertToFloat(math.floor(input));
  958. }
  959. [TestCompiler(DataRange.Standard)]
  960. public static float Floor3(ref float3 input)
  961. {
  962. return Vectors.ConvertToFloat(math.floor(input));
  963. }
  964. [TestCompiler(DataRange.Standard)]
  965. public static float Floor2(ref float2 input)
  966. {
  967. return Vectors.ConvertToFloat(math.floor(input));
  968. }
  969. [TestCompiler(DataRange.Standard)]
  970. public static float Floor(float input)
  971. {
  972. return math.floor(input);
  973. }
  974. // ---------------------------------------------------------
  975. // ceil
  976. // ---------------------------------------------------------
  977. [TestCompiler(DataRange.Standard)]
  978. public static float Ceil4(ref float4 input)
  979. {
  980. return Vectors.ConvertToFloat(math.ceil(input));
  981. }
  982. [TestCompiler(DataRange.Standard)]
  983. public static float Ceil3(ref float3 input)
  984. {
  985. return Vectors.ConvertToFloat(math.ceil(input));
  986. }
  987. [TestCompiler(DataRange.Standard)]
  988. public static float Ceil2(ref float2 input)
  989. {
  990. return Vectors.ConvertToFloat(math.ceil(input));
  991. }
  992. [TestCompiler(DataRange.Standard)]
  993. public static float Ceil(float input)
  994. {
  995. return math.ceil(input);
  996. }
  997. // ---------------------------------------------------------
  998. // round
  999. // ---------------------------------------------------------
  1000. [TestCompiler(DataRange.Standard)]
  1001. public static float Round4(ref float4 input)
  1002. {
  1003. return Vectors.ConvertToFloat(math.round(input));
  1004. }
  1005. [TestCompiler(DataRange.Standard)]
  1006. public static float Round3(ref float3 input)
  1007. {
  1008. return Vectors.ConvertToFloat(math.round(input));
  1009. }
  1010. [TestCompiler(DataRange.Standard)]
  1011. public static float Round2(ref float2 input)
  1012. {
  1013. return Vectors.ConvertToFloat(math.round(input));
  1014. }
  1015. [TestCompiler(DataRange.Standard)]
  1016. public static float Round(float input)
  1017. {
  1018. return math.round(input);
  1019. }
  1020. // ---------------------------------------------------------
  1021. // frac
  1022. // ---------------------------------------------------------
  1023. [TestCompiler(DataRange.Standard)]
  1024. public static float Frac4(ref float4 input)
  1025. {
  1026. return Vectors.ConvertToFloat(math.frac(input));
  1027. }
  1028. [TestCompiler(DataRange.Standard)]
  1029. public static float Frac3(ref float3 input)
  1030. {
  1031. return Vectors.ConvertToFloat(math.frac(input));
  1032. }
  1033. [TestCompiler(DataRange.Standard)]
  1034. public static float Frac2(ref float2 input)
  1035. {
  1036. return Vectors.ConvertToFloat(math.frac(input));
  1037. }
  1038. [TestCompiler(DataRange.Standard)]
  1039. public static float Frac(float input)
  1040. {
  1041. return math.frac(input);
  1042. }
  1043. // ---------------------------------------------------------
  1044. // rcp
  1045. // ---------------------------------------------------------
  1046. [TestCompiler(DataRange.Standard)]
  1047. public static float Rcp4(ref float4 input)
  1048. {
  1049. return Vectors.ConvertToFloat(math.rcp(input));
  1050. }
  1051. [TestCompiler(DataRange.Standard)]
  1052. public static float Rcp3(ref float3 input)
  1053. {
  1054. return Vectors.ConvertToFloat(math.rcp(input));
  1055. }
  1056. [TestCompiler(DataRange.Standard)]
  1057. public static float Rcp2(ref float2 input)
  1058. {
  1059. return Vectors.ConvertToFloat(math.rcp(input));
  1060. }
  1061. [TestCompiler(DataRange.Standard)]
  1062. public static float Rcp(float input)
  1063. {
  1064. return math.rcp(input);
  1065. }
  1066. // ---------------------------------------------------------
  1067. // sign
  1068. // ---------------------------------------------------------
  1069. [TestCompiler(DataRange.Standard)]
  1070. public static float Sign4(ref float4 input)
  1071. {
  1072. return Vectors.ConvertToFloat(math.sign(input));
  1073. }
  1074. [TestCompiler(DataRange.Standard)]
  1075. public static float Sign3(ref float3 input)
  1076. {
  1077. return Vectors.ConvertToFloat(math.sign(input));
  1078. }
  1079. [TestCompiler(DataRange.Standard)]
  1080. public static float Sign2(ref float2 input)
  1081. {
  1082. return Vectors.ConvertToFloat(math.sign(input));
  1083. }
  1084. [TestCompiler(DataRange.Standard)]
  1085. public static float Sign(float input)
  1086. {
  1087. return math.sign(input);
  1088. }
  1089. // ---------------------------------------------------------
  1090. // pow
  1091. // ---------------------------------------------------------
  1092. [TestCompiler(DataRange.Standard & ~(DataRange.NaN | DataRange.Zero), DataRange.Standard)]
  1093. [TestCompiler(DataRange.Standard & ~(DataRange.NaN), DataRange.Standard & ~(DataRange.Zero))]
  1094. public static float Pow4(ref float4 a, ref float4 b)
  1095. {
  1096. return Vectors.ConvertToFloat(math.pow(a, b));
  1097. }
  1098. [TestCompiler(DataRange.Standard & ~(DataRange.NaN | DataRange.Zero), DataRange.Standard)]
  1099. [TestCompiler(DataRange.Standard & ~(DataRange.NaN), DataRange.Standard & ~(DataRange.Zero))]
  1100. public static float Pow3(ref float3 a, ref float3 b)
  1101. {
  1102. return Vectors.ConvertToFloat(math.pow(a, b));
  1103. }
  1104. [TestCompiler(DataRange.Standard & ~(DataRange.NaN | DataRange.Zero), DataRange.Standard)]
  1105. [TestCompiler(DataRange.Standard & ~(DataRange.NaN), DataRange.Standard & ~(DataRange.Zero))]
  1106. public static float Pow2(ref float2 a, ref float2 b)
  1107. {
  1108. return Vectors.ConvertToFloat(math.pow(a, b));
  1109. }
  1110. [TestCompiler(DataRange.Standard & ~(DataRange.NaN | DataRange.Zero), DataRange.Standard)]
  1111. [TestCompiler(DataRange.Standard & ~(DataRange.NaN), DataRange.Standard & ~(DataRange.Zero))]
  1112. public static float Pow(float a, float b)
  1113. {
  1114. return math.pow(a, b);
  1115. }
  1116. // ---------------------------------------------------------
  1117. // exp
  1118. // ---------------------------------------------------------
  1119. [TestCompiler(DataRange.Standard)]
  1120. public static float Exp4(ref float4 input)
  1121. {
  1122. return Vectors.ConvertToFloat(math.exp(input));
  1123. }
  1124. [TestCompiler(DataRange.Standard)]
  1125. public static float Exp3(ref float3 input)
  1126. {
  1127. return Vectors.ConvertToFloat(math.exp(input));
  1128. }
  1129. [TestCompiler(DataRange.Standard)]
  1130. public static float Exp2(ref float2 input)
  1131. {
  1132. return Vectors.ConvertToFloat(math.exp(input));
  1133. }
  1134. [TestCompiler(DataRange.Standard)]
  1135. public static float Exp(float input)
  1136. {
  1137. return math.exp(input);
  1138. }
  1139. // ---------------------------------------------------------
  1140. // mod
  1141. // ---------------------------------------------------------
  1142. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  1143. public static float Mod4(ref float4 a, ref float4 b)
  1144. {
  1145. return Vectors.ConvertToFloat(math.fmod(a, b));
  1146. }
  1147. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  1148. public static float Mod3(ref float3 a, ref float3 b)
  1149. {
  1150. return Vectors.ConvertToFloat(math.fmod(a, b));
  1151. }
  1152. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  1153. public static float Mod2(ref float2 a, ref float2 b)
  1154. {
  1155. return Vectors.ConvertToFloat(math.fmod(a, b));
  1156. }
  1157. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  1158. public static float Mod(float a, float b)
  1159. {
  1160. return math.fmod(a, b);
  1161. }
  1162. // ---------------------------------------------------------
  1163. // normalize
  1164. // ---------------------------------------------------------
  1165. [TestCompiler(DataRange.Standard)]
  1166. public static float Normalize4(ref float4 input)
  1167. {
  1168. return Vectors.ConvertToFloat(math.normalize(input));
  1169. }
  1170. [TestCompiler(DataRange.Standard)]
  1171. public static float Normalize3(ref float3 input)
  1172. {
  1173. return Vectors.ConvertToFloat(math.normalize(input));
  1174. }
  1175. [TestCompiler(DataRange.Standard)]
  1176. public static float Normalize2(ref float2 input)
  1177. {
  1178. return Vectors.ConvertToFloat(math.normalize(input));
  1179. }
  1180. // ---------------------------------------------------------
  1181. // length
  1182. // ---------------------------------------------------------
  1183. [TestCompiler(DataRange.Standard)]
  1184. public static float Length4(ref float4 input)
  1185. {
  1186. return math.length(input);
  1187. }
  1188. [TestCompiler(DataRange.Standard)]
  1189. public static float Length3(ref float3 input)
  1190. {
  1191. return math.length(input);
  1192. }
  1193. [TestCompiler(DataRange.Standard)]
  1194. public static float Length2(ref float2 input)
  1195. {
  1196. return math.length(input);
  1197. }
  1198. [TestCompiler(DataRange.Standard)]
  1199. public static float Length(float input)
  1200. {
  1201. return math.length(input);
  1202. }
  1203. // ---------------------------------------------------------
  1204. // distance
  1205. // ---------------------------------------------------------
  1206. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  1207. public static float Distance4(ref float4 a, ref float4 b)
  1208. {
  1209. return math.distance(a, b);
  1210. }
  1211. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  1212. public static float Distance3(ref float3 a, ref float3 b)
  1213. {
  1214. return math.distance(a, b);
  1215. }
  1216. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  1217. public static float Distance2(ref float2 a, ref float2 b)
  1218. {
  1219. return math.distance(a, b);
  1220. }
  1221. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  1222. public static float Distance(float a, float b)
  1223. {
  1224. return math.distance(a, b);
  1225. }
  1226. // ---------------------------------------------------------
  1227. // cross
  1228. // ---------------------------------------------------------
  1229. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  1230. public static float Cross3(ref float3 a, ref float3 b)
  1231. {
  1232. return Vectors.ConvertToFloat(math.cross(a, b));
  1233. }
  1234. // ---------------------------------------------------------
  1235. // smoothstep
  1236. // ---------------------------------------------------------
  1237. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.ZeroExclusiveToOneInclusive | DataRange.Zero)]
  1238. public static float Smoothstep4(ref float4 a, ref float4 b, float w)
  1239. {
  1240. return Vectors.ConvertToFloat(math.smoothstep(a, b, w));
  1241. }
  1242. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.ZeroExclusiveToOneInclusive | DataRange.Zero)]
  1243. public static float Smoothstep3(ref float3 a, ref float3 b, float w)
  1244. {
  1245. return Vectors.ConvertToFloat(math.smoothstep(a, b, w));
  1246. }
  1247. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.ZeroExclusiveToOneInclusive | DataRange.Zero)]
  1248. public static float Smoothstep2(ref float2 a, ref float2 b, float w)
  1249. {
  1250. return Vectors.ConvertToFloat(math.smoothstep(a, b, w));
  1251. }
  1252. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.ZeroExclusiveToOneInclusive | DataRange.Zero)]
  1253. public static float Smoothstep(float a, float b, float w)
  1254. {
  1255. return math.smoothstep(a, b, w);
  1256. }
  1257. // ---------------------------------------------------------
  1258. // any
  1259. // ---------------------------------------------------------
  1260. [TestCompiler(DataRange.Standard)]
  1261. public static bool Any4(ref float4 input)
  1262. {
  1263. return math.any(input);
  1264. }
  1265. [TestCompiler(DataRange.Standard)]
  1266. public static bool Any32(ref float3 input)
  1267. {
  1268. return math.any(input);
  1269. }
  1270. [TestCompiler(DataRange.Standard)]
  1271. public static bool Any(ref float2 input)
  1272. {
  1273. return math.any(input);
  1274. }
  1275. [TestCompiler(DataRange.Standard)]
  1276. public static bool AnyInt4(ref int4 input)
  1277. {
  1278. return math.any(input);
  1279. }
  1280. [TestCompiler(DataRange.Standard)]
  1281. public static bool AnyInt3(ref int3 input)
  1282. {
  1283. return math.any(input);
  1284. }
  1285. [TestCompiler(DataRange.Standard)]
  1286. public static bool AnyInt2(ref int2 input)
  1287. {
  1288. return math.any(input);
  1289. }
  1290. [TestCompiler(DataRange.Standard)]
  1291. public static bool AnyBool4(ref bool4 input)
  1292. {
  1293. return math.any(input);
  1294. }
  1295. [TestCompiler(DataRange.Standard)]
  1296. public static bool AnyBool3(ref bool3 input)
  1297. {
  1298. return math.any(input);
  1299. }
  1300. [TestCompiler(DataRange.Standard)]
  1301. public static bool AnyBool2(ref bool2 input)
  1302. {
  1303. return math.any(input);
  1304. }
  1305. // ---------------------------------------------------------
  1306. // all
  1307. // ---------------------------------------------------------
  1308. [TestCompiler(DataRange.Standard)]
  1309. public static bool All4(ref float4 input)
  1310. {
  1311. return math.all(input);
  1312. }
  1313. [TestCompiler(DataRange.Standard)]
  1314. public static bool All3(ref float3 input)
  1315. {
  1316. return math.all(input);
  1317. }
  1318. [TestCompiler(DataRange.Standard)]
  1319. public static bool All2(ref float2 input)
  1320. {
  1321. return math.all(input);
  1322. }
  1323. [TestCompiler(DataRange.Standard)]
  1324. public static bool AllInt4(ref int4 input)
  1325. {
  1326. return math.all(input);
  1327. }
  1328. [TestCompiler(DataRange.Standard)]
  1329. public static bool AllInt3(ref int3 input)
  1330. {
  1331. return math.all(input);
  1332. }
  1333. [TestCompiler(DataRange.Standard)]
  1334. public static bool AllInt2(ref int2 input)
  1335. {
  1336. return math.all(input);
  1337. }
  1338. [TestCompiler(DataRange.Standard)]
  1339. public static bool AllBool4(ref bool4 input)
  1340. {
  1341. return math.all(input);
  1342. }
  1343. [TestCompiler(DataRange.Standard)]
  1344. public static bool AllBool3(ref bool3 input)
  1345. {
  1346. return math.all(input);
  1347. }
  1348. [TestCompiler(DataRange.Standard)]
  1349. public static bool AllBool2(ref bool2 input)
  1350. {
  1351. return math.all(input);
  1352. }
  1353. // ---------------------------------------------------------
  1354. // select
  1355. // ---------------------------------------------------------
  1356. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.Standard)]
  1357. public static float Select4(ref bool4 c, ref float4 a, ref float4 b)
  1358. {
  1359. return Vectors.ConvertToFloat(math.select(a, b, c));
  1360. }
  1361. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.Standard)]
  1362. public static float Select3(ref bool3 c, ref float3 a, ref float3 b)
  1363. {
  1364. return Vectors.ConvertToFloat(math.select(a, b, c));
  1365. }
  1366. [TestCompiler(DataRange.Standard, DataRange.Standard, DataRange.Standard)]
  1367. public static float Select(ref bool2 c, ref float2 a, ref float2 b)
  1368. {
  1369. return Vectors.ConvertToFloat(math.select(a, b, c));
  1370. }
  1371. // ---------------------------------------------------------
  1372. // step
  1373. // ---------------------------------------------------------
  1374. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  1375. public static float Step4(ref float4 a, ref float4 b)
  1376. {
  1377. return Vectors.ConvertToFloat(math.step(a, b));
  1378. }
  1379. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  1380. public static float Step3(ref float3 a, ref float3 b)
  1381. {
  1382. return Vectors.ConvertToFloat(math.step(a, b));
  1383. }
  1384. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  1385. public static float Step2(ref float2 a, ref float2 b)
  1386. {
  1387. return Vectors.ConvertToFloat(math.step(a, b));
  1388. }
  1389. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  1390. public static float Step(float a, float b)
  1391. {
  1392. return math.step(a, b);
  1393. }
  1394. // ---------------------------------------------------------
  1395. // reflect
  1396. // ---------------------------------------------------------
  1397. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  1398. public static float Reflect4(ref float4 a, ref float4 b)
  1399. {
  1400. return Vectors.ConvertToFloat(math.reflect(a, b));
  1401. }
  1402. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  1403. public static float Reflect3(ref float3 a, ref float3 b)
  1404. {
  1405. return Vectors.ConvertToFloat(math.reflect(a, b));
  1406. }
  1407. [TestCompiler(DataRange.Standard, DataRange.Standard)]
  1408. public static float Reflect2(ref float2 a, ref float2 b)
  1409. {
  1410. return Vectors.ConvertToFloat(math.reflect(a, b));
  1411. }
  1412. struct TestCompressInt4
  1413. {
  1414. #pragma warning disable 0649
  1415. public int Value0;
  1416. public int Value1;
  1417. public int Value2;
  1418. public int Value3;
  1419. #pragma warning restore 0649
  1420. }
  1421. }
  1422. }