bool2x2.gen.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. //------------------------------------------------------------------------------
  2. // <auto-generated>
  3. // This code was generated by a tool.
  4. //
  5. // Changes to this file may cause incorrect behavior and will be lost if
  6. // the code is regenerated.
  7. // </auto-generated>
  8. //------------------------------------------------------------------------------
  9. using System;
  10. using System.Runtime.CompilerServices;
  11. #pragma warning disable 0660, 0661
  12. namespace Unity.Mathematics
  13. {
  14. [System.Serializable]
  15. public partial struct bool2x2 : System.IEquatable<bool2x2>
  16. {
  17. public bool2 c0;
  18. public bool2 c1;
  19. /// <summary>Constructs a bool2x2 matrix from two bool2 vectors.</summary>
  20. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  21. public bool2x2(bool2 c0, bool2 c1)
  22. {
  23. this.c0 = c0;
  24. this.c1 = c1;
  25. }
  26. /// <summary>Constructs a bool2x2 matrix from 4 bool values given in row-major order.</summary>
  27. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  28. public bool2x2(bool m00, bool m01,
  29. bool m10, bool m11)
  30. {
  31. this.c0 = new bool2(m00, m10);
  32. this.c1 = new bool2(m01, m11);
  33. }
  34. /// <summary>Constructs a bool2x2 matrix from a single bool value by assigning it to every component.</summary>
  35. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  36. public bool2x2(bool v)
  37. {
  38. this.c0 = v;
  39. this.c1 = v;
  40. }
  41. /// <summary>Implicitly converts a single bool value to a bool2x2 matrix by assigning it to every component.</summary>
  42. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  43. public static implicit operator bool2x2(bool v) { return new bool2x2(v); }
  44. /// <summary>Returns the result of a componentwise equality operation on two bool2x2 matrices.</summary>
  45. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  46. public static bool2x2 operator == (bool2x2 lhs, bool2x2 rhs) { return new bool2x2 (lhs.c0 == rhs.c0, lhs.c1 == rhs.c1); }
  47. /// <summary>Returns the result of a componentwise equality operation on a bool2x2 matrix and a bool value.</summary>
  48. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  49. public static bool2x2 operator == (bool2x2 lhs, bool rhs) { return new bool2x2 (lhs.c0 == rhs, lhs.c1 == rhs); }
  50. /// <summary>Returns the result of a componentwise equality operation on a bool value and a bool2x2 matrix.</summary>
  51. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  52. public static bool2x2 operator == (bool lhs, bool2x2 rhs) { return new bool2x2 (lhs == rhs.c0, lhs == rhs.c1); }
  53. /// <summary>Returns the result of a componentwise not equal operation on two bool2x2 matrices.</summary>
  54. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  55. public static bool2x2 operator != (bool2x2 lhs, bool2x2 rhs) { return new bool2x2 (lhs.c0 != rhs.c0, lhs.c1 != rhs.c1); }
  56. /// <summary>Returns the result of a componentwise not equal operation on a bool2x2 matrix and a bool value.</summary>
  57. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  58. public static bool2x2 operator != (bool2x2 lhs, bool rhs) { return new bool2x2 (lhs.c0 != rhs, lhs.c1 != rhs); }
  59. /// <summary>Returns the result of a componentwise not equal operation on a bool value and a bool2x2 matrix.</summary>
  60. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  61. public static bool2x2 operator != (bool lhs, bool2x2 rhs) { return new bool2x2 (lhs != rhs.c0, lhs != rhs.c1); }
  62. /// <summary>Returns the result of a componentwise not operation on a bool2x2 matrix.</summary>
  63. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  64. public static bool2x2 operator ! (bool2x2 val) { return new bool2x2 (!val.c0, !val.c1); }
  65. /// <summary>Returns the result of a componentwise bitwise and operation on two bool2x2 matrices.</summary>
  66. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  67. public static bool2x2 operator & (bool2x2 lhs, bool2x2 rhs) { return new bool2x2 (lhs.c0 & rhs.c0, lhs.c1 & rhs.c1); }
  68. /// <summary>Returns the result of a componentwise bitwise and operation on a bool2x2 matrix and a bool value.</summary>
  69. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  70. public static bool2x2 operator & (bool2x2 lhs, bool rhs) { return new bool2x2 (lhs.c0 & rhs, lhs.c1 & rhs); }
  71. /// <summary>Returns the result of a componentwise bitwise and operation on a bool value and a bool2x2 matrix.</summary>
  72. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  73. public static bool2x2 operator & (bool lhs, bool2x2 rhs) { return new bool2x2 (lhs & rhs.c0, lhs & rhs.c1); }
  74. /// <summary>Returns the result of a componentwise bitwise or operation on two bool2x2 matrices.</summary>
  75. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  76. public static bool2x2 operator | (bool2x2 lhs, bool2x2 rhs) { return new bool2x2 (lhs.c0 | rhs.c0, lhs.c1 | rhs.c1); }
  77. /// <summary>Returns the result of a componentwise bitwise or operation on a bool2x2 matrix and a bool value.</summary>
  78. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  79. public static bool2x2 operator | (bool2x2 lhs, bool rhs) { return new bool2x2 (lhs.c0 | rhs, lhs.c1 | rhs); }
  80. /// <summary>Returns the result of a componentwise bitwise or operation on a bool value and a bool2x2 matrix.</summary>
  81. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  82. public static bool2x2 operator | (bool lhs, bool2x2 rhs) { return new bool2x2 (lhs | rhs.c0, lhs | rhs.c1); }
  83. /// <summary>Returns the result of a componentwise bitwise exclusive or operation on two bool2x2 matrices.</summary>
  84. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  85. public static bool2x2 operator ^ (bool2x2 lhs, bool2x2 rhs) { return new bool2x2 (lhs.c0 ^ rhs.c0, lhs.c1 ^ rhs.c1); }
  86. /// <summary>Returns the result of a componentwise bitwise exclusive or operation on a bool2x2 matrix and a bool value.</summary>
  87. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  88. public static bool2x2 operator ^ (bool2x2 lhs, bool rhs) { return new bool2x2 (lhs.c0 ^ rhs, lhs.c1 ^ rhs); }
  89. /// <summary>Returns the result of a componentwise bitwise exclusive or operation on a bool value and a bool2x2 matrix.</summary>
  90. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  91. public static bool2x2 operator ^ (bool lhs, bool2x2 rhs) { return new bool2x2 (lhs ^ rhs.c0, lhs ^ rhs.c1); }
  92. /// <summary>Returns the bool2 element at a specified index.</summary>
  93. unsafe public ref bool2 this[int index]
  94. {
  95. get
  96. {
  97. #if ENABLE_UNITY_COLLECTIONS_CHECKS
  98. if ((uint)index >= 2)
  99. throw new System.ArgumentException("index must be between[0...1]");
  100. #endif
  101. fixed (bool2x2* array = &this) { return ref ((bool2*)array)[index]; }
  102. }
  103. }
  104. /// <summary>Returns true if the bool2x2 is equal to a given bool2x2, false otherwise.</summary>
  105. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  106. public bool Equals(bool2x2 rhs) { return c0.Equals(rhs.c0) && c1.Equals(rhs.c1); }
  107. /// <summary>Returns true if the bool2x2 is equal to a given bool2x2, false otherwise.</summary>
  108. public override bool Equals(object o) { return Equals((bool2x2)o); }
  109. /// <summary>Returns a hash code for the bool2x2.</summary>
  110. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  111. public override int GetHashCode() { return (int)math.hash(this); }
  112. /// <summary>Returns a string representation of the bool2x2.</summary>
  113. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  114. public override string ToString()
  115. {
  116. return string.Format("bool2x2({0}, {1}, {2}, {3})", c0.x, c1.x, c0.y, c1.y);
  117. }
  118. }
  119. public static partial class math
  120. {
  121. /// <summary>Returns a bool2x2 matrix constructed from two bool2 vectors.</summary>
  122. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  123. public static bool2x2 bool2x2(bool2 c0, bool2 c1) { return new bool2x2(c0, c1); }
  124. /// <summary>Returns a bool2x2 matrix constructed from from 4 bool values given in row-major order.</summary>
  125. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  126. public static bool2x2 bool2x2(bool m00, bool m01,
  127. bool m10, bool m11)
  128. {
  129. return new bool2x2(m00, m01,
  130. m10, m11);
  131. }
  132. /// <summary>Returns a bool2x2 matrix constructed from a single bool value by assigning it to every component.</summary>
  133. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  134. public static bool2x2 bool2x2(bool v) { return new bool2x2(v); }
  135. /// <summary>Return the bool2x2 transpose of a bool2x2 matrix.</summary>
  136. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  137. public static bool2x2 transpose(bool2x2 v)
  138. {
  139. return bool2x2(
  140. v.c0.x, v.c0.y,
  141. v.c1.x, v.c1.y);
  142. }
  143. /// <summary>Returns a uint hash code of a bool2x2 vector.</summary>
  144. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  145. public static uint hash(bool2x2 v)
  146. {
  147. return csum(select(uint2(0x7AF32C49u, 0xAE131389u), uint2(0x5D1B165Bu, 0x87096CD7u), v.c0) +
  148. select(uint2(0x4C7F6DD1u, 0x4822A3E9u), uint2(0xAAC3C25Du, 0xD21D0945u), v.c1));
  149. }
  150. /// <summary>
  151. /// Returns a uint2 vector hash code of a bool2x2 vector.
  152. /// When multiple elements are to be hashes together, it can more efficient to calculate and combine wide hash
  153. /// that are only reduced to a narrow uint hash at the very end instead of at every step.
  154. /// </summary>
  155. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  156. public static uint2 hashwide(bool2x2 v)
  157. {
  158. return (select(uint2(0x88FCAB2Du, 0x614DA60Du), uint2(0x5BA2C50Bu, 0x8C455ACBu), v.c0) +
  159. select(uint2(0xCD266C89u, 0xF1852A33u), uint2(0x77E35E77u, 0x863E3729u), v.c1));
  160. }
  161. }
  162. }