@lakuna/umath 1.3.5 → 1.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/LICENSE +1 -1
  2. package/dist/algorithms/combinations.d.ts +7 -0
  3. package/dist/algorithms/combinations.d.ts.map +1 -1
  4. package/dist/algorithms/combinations.js +7 -0
  5. package/dist/algorithms/combinations.js.map +1 -1
  6. package/dist/algorithms/degreesToRadians.d.ts +7 -0
  7. package/dist/algorithms/degreesToRadians.d.ts.map +1 -1
  8. package/dist/algorithms/degreesToRadians.js +7 -0
  9. package/dist/algorithms/degreesToRadians.js.map +1 -1
  10. package/dist/algorithms/factorial.d.ts +6 -0
  11. package/dist/algorithms/factorial.d.ts.map +1 -1
  12. package/dist/algorithms/factorial.js +8 -1
  13. package/dist/algorithms/factorial.js.map +1 -1
  14. package/dist/algorithms/fibonacci.d.ts +6 -1
  15. package/dist/algorithms/fibonacci.d.ts.map +1 -1
  16. package/dist/algorithms/fibonacci.js +5 -0
  17. package/dist/algorithms/fibonacci.js.map +1 -1
  18. package/dist/algorithms/greatestCommonDivisor.d.ts +14 -0
  19. package/dist/algorithms/greatestCommonDivisor.d.ts.map +1 -1
  20. package/dist/algorithms/greatestCommonDivisor.js +2 -0
  21. package/dist/algorithms/greatestCommonDivisor.js.map +1 -1
  22. package/dist/algorithms/hypergeometricPmf.d.ts +9 -0
  23. package/dist/algorithms/hypergeometricPmf.d.ts.map +1 -1
  24. package/dist/algorithms/hypergeometricPmf.js +9 -0
  25. package/dist/algorithms/hypergeometricPmf.js.map +1 -1
  26. package/dist/algorithms/isPrime.d.ts +6 -0
  27. package/dist/algorithms/isPrime.d.ts.map +1 -1
  28. package/dist/algorithms/isPrime.js +7 -0
  29. package/dist/algorithms/isPrime.js.map +1 -1
  30. package/dist/algorithms/permutations.d.ts +7 -0
  31. package/dist/algorithms/permutations.d.ts.map +1 -1
  32. package/dist/algorithms/permutations.js +7 -0
  33. package/dist/algorithms/permutations.js.map +1 -1
  34. package/dist/algorithms/primeFactorization.d.ts +6 -0
  35. package/dist/algorithms/primeFactorization.d.ts.map +1 -1
  36. package/dist/algorithms/primeFactorization.js +6 -0
  37. package/dist/algorithms/primeFactorization.js.map +1 -1
  38. package/dist/algorithms/radiansToDegrees.d.ts +7 -0
  39. package/dist/algorithms/radiansToDegrees.d.ts.map +1 -1
  40. package/dist/algorithms/radiansToDegrees.js +7 -0
  41. package/dist/algorithms/radiansToDegrees.js.map +1 -1
  42. package/dist/algorithms/summation.d.ts +8 -0
  43. package/dist/algorithms/summation.d.ts.map +1 -1
  44. package/dist/algorithms/summation.js +9 -0
  45. package/dist/algorithms/summation.js.map +1 -1
  46. package/dist/linalg/DualQuaternion.d.ts +410 -27
  47. package/dist/linalg/DualQuaternion.d.ts.map +1 -1
  48. package/dist/linalg/DualQuaternion.js +429 -54
  49. package/dist/linalg/DualQuaternion.js.map +1 -1
  50. package/dist/linalg/Matrix.d.ts +67 -0
  51. package/dist/linalg/Matrix.d.ts.map +1 -1
  52. package/dist/linalg/Matrix2.d.ts +309 -20
  53. package/dist/linalg/Matrix2.d.ts.map +1 -1
  54. package/dist/linalg/Matrix2.js +321 -40
  55. package/dist/linalg/Matrix2.js.map +1 -1
  56. package/dist/linalg/Matrix3.d.ts +424 -26
  57. package/dist/linalg/Matrix3.d.ts.map +1 -1
  58. package/dist/linalg/Matrix3.js +437 -52
  59. package/dist/linalg/Matrix3.js.map +1 -1
  60. package/dist/linalg/Matrix4.d.ts +766 -42
  61. package/dist/linalg/Matrix4.d.ts.map +1 -1
  62. package/dist/linalg/Matrix4.js +789 -84
  63. package/dist/linalg/Matrix4.js.map +1 -1
  64. package/dist/linalg/Quaternion.d.ts +359 -21
  65. package/dist/linalg/Quaternion.d.ts.map +1 -1
  66. package/dist/linalg/Quaternion.js +380 -42
  67. package/dist/linalg/Quaternion.js.map +1 -1
  68. package/dist/linalg/SlowMatrix.d.ts +70 -0
  69. package/dist/linalg/SlowMatrix.d.ts.map +1 -1
  70. package/dist/linalg/SlowMatrix.js +71 -0
  71. package/dist/linalg/SlowMatrix.js.map +1 -1
  72. package/dist/linalg/SlowSquareMatrix.d.ts +55 -0
  73. package/dist/linalg/SlowSquareMatrix.d.ts.map +1 -1
  74. package/dist/linalg/SlowSquareMatrix.js +58 -0
  75. package/dist/linalg/SlowSquareMatrix.js.map +1 -1
  76. package/dist/linalg/SquareMatrix.d.ts +23 -0
  77. package/dist/linalg/SquareMatrix.d.ts.map +1 -1
  78. package/dist/linalg/Vector.d.ts +123 -0
  79. package/dist/linalg/Vector.d.ts.map +1 -1
  80. package/dist/linalg/Vector2.d.ts +450 -33
  81. package/dist/linalg/Vector2.d.ts.map +1 -1
  82. package/dist/linalg/Vector2.js +480 -66
  83. package/dist/linalg/Vector2.js.map +1 -1
  84. package/dist/linalg/Vector3.d.ts +542 -38
  85. package/dist/linalg/Vector3.d.ts.map +1 -1
  86. package/dist/linalg/Vector3.js +579 -76
  87. package/dist/linalg/Vector3.js.map +1 -1
  88. package/dist/linalg/Vector4.d.ts +416 -30
  89. package/dist/linalg/Vector4.d.ts.map +1 -1
  90. package/dist/linalg/Vector4.js +441 -60
  91. package/dist/linalg/Vector4.js.map +1 -1
  92. package/dist/types/AxisAngle.d.ts +3 -0
  93. package/dist/types/AxisAngle.d.ts.map +1 -1
  94. package/dist/types/FieldOfView.d.ts +5 -0
  95. package/dist/types/FieldOfView.d.ts.map +1 -1
  96. package/dist/utility/BigNumber.d.ts +36 -0
  97. package/dist/utility/BigNumber.d.ts.map +1 -1
  98. package/dist/utility/BigNumber.js +42 -0
  99. package/dist/utility/BigNumber.js.map +1 -1
  100. package/dist/utility/MagnitudeError.d.ts +5 -0
  101. package/dist/utility/MagnitudeError.d.ts.map +1 -1
  102. package/dist/utility/MagnitudeError.js +5 -0
  103. package/dist/utility/MagnitudeError.js.map +1 -1
  104. package/dist/utility/MatrixSizeError.d.ts +5 -0
  105. package/dist/utility/MatrixSizeError.d.ts.map +1 -1
  106. package/dist/utility/MatrixSizeError.js +5 -0
  107. package/dist/utility/MatrixSizeError.js.map +1 -1
  108. package/dist/utility/PartialMatrixError.d.ts +5 -0
  109. package/dist/utility/PartialMatrixError.d.ts.map +1 -1
  110. package/dist/utility/PartialMatrixError.js +5 -0
  111. package/dist/utility/PartialMatrixError.js.map +1 -1
  112. package/dist/utility/SingularMatrixError.d.ts +8 -0
  113. package/dist/utility/SingularMatrixError.d.ts.map +1 -1
  114. package/dist/utility/SingularMatrixError.js +8 -0
  115. package/dist/utility/SingularMatrixError.js.map +1 -1
  116. package/dist/utility/epsilon.d.ts +1 -0
  117. package/dist/utility/epsilon.d.ts.map +1 -1
  118. package/dist/utility/epsilon.js +1 -0
  119. package/dist/utility/epsilon.js.map +1 -1
  120. package/package.json +1 -1
  121. package/src/algorithms/combinations.ts +1 -1
  122. package/src/algorithms/degreesToRadians.ts +1 -1
  123. package/src/algorithms/factorial.ts +1 -1
  124. package/src/algorithms/fibonacci.ts +1 -1
  125. package/src/algorithms/hypergeometricPmf.ts +1 -1
  126. package/src/algorithms/isPrime.ts +1 -1
  127. package/src/algorithms/permutations.ts +1 -1
  128. package/src/algorithms/primeFactorization.ts +1 -1
  129. package/src/algorithms/radiansToDegrees.ts +1 -1
  130. package/src/algorithms/summation.ts +1 -1
  131. package/src/linalg/DualQuaternion.ts +115 -109
  132. package/src/linalg/Matrix2.ts +83 -70
  133. package/src/linalg/Matrix3.ts +107 -94
  134. package/src/linalg/Matrix4.ts +171 -155
  135. package/src/linalg/Quaternion.ts +96 -92
  136. package/src/linalg/SlowMatrix.ts +13 -13
  137. package/src/linalg/SlowSquareMatrix.ts +11 -11
  138. package/src/linalg/Vector2.ts +130 -116
  139. package/src/linalg/Vector3.ts +152 -135
  140. package/src/linalg/Vector4.ts +121 -104
  141. package/src/utility/BigNumber.ts +7 -7
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 Travis Martin
3
+ Copyright (c) 2024 Travis Martin
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,2 +1,9 @@
1
+ /**
2
+ * Calculate the number of combinations.
3
+ * @param n - The total number of units.
4
+ * @param r - The number of units taken at a time.
5
+ * @returns The number of combinations.
6
+ * @see [Combination](https://en.wikipedia.org/wiki/Combination)
7
+ */
1
8
  export default function combinations(n: number, r: number): number;
2
9
  //# sourceMappingURL=combinations.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"combinations.d.ts","sourceRoot":"","sources":["../../src/algorithms/combinations.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,UAExD"}
1
+ {"version":3,"file":"combinations.d.ts","sourceRoot":"","sources":["../../src/algorithms/combinations.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAEjE"}
@@ -1,4 +1,11 @@
1
1
  import factorial from "./factorial.js";
2
+ /**
3
+ * Calculate the number of combinations.
4
+ * @param n - The total number of units.
5
+ * @param r - The number of units taken at a time.
6
+ * @returns The number of combinations.
7
+ * @see [Combination](https://en.wikipedia.org/wiki/Combination)
8
+ */
2
9
  export default function combinations(n, r) {
3
10
  return factorial(n) / (factorial(r) * factorial(n - r));
4
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"combinations.js","sourceRoot":"","sources":["../../src/algorithms/combinations.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,gBAAgB,CAAC;AASvC,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,CAAS,EAAE,CAAS;IACxD,OAAO,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACzD,CAAC"}
1
+ {"version":3,"file":"combinations.js","sourceRoot":"","sources":["../../src/algorithms/combinations.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,gBAAgB,CAAC;AAEvC;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,CAAS,EAAE,CAAS;IACxD,OAAO,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACzD,CAAC"}
@@ -1,2 +1,9 @@
1
+ /**
2
+ * Convert a number of degrees to an equivalent number of radians.
3
+ * @param degrees - The number of degrees.
4
+ * @returns A number of radians.
5
+ * @see [Degree](https://en.wikipedia.org/wiki/Degree_(angle))
6
+ * @see [Radian](https://en.wikipedia.org/wiki/Radian)
7
+ */
1
8
  export default function degreesToRadians(degrees: number): number;
2
9
  //# sourceMappingURL=degreesToRadians.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"degreesToRadians.d.ts","sourceRoot":"","sources":["../../src/algorithms/degreesToRadians.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,OAAO,EAAE,MAAM,UAEvD"}
1
+ {"version":3,"file":"degreesToRadians.d.ts","sourceRoot":"","sources":["../../src/algorithms/degreesToRadians.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEhE"}
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Convert a number of degrees to an equivalent number of radians.
3
+ * @param degrees - The number of degrees.
4
+ * @returns A number of radians.
5
+ * @see [Degree](https://en.wikipedia.org/wiki/Degree_(angle))
6
+ * @see [Radian](https://en.wikipedia.org/wiki/Radian)
7
+ */
1
8
  export default function degreesToRadians(degrees) {
2
9
  return (degrees * Math.PI) / 180;
3
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"degreesToRadians.js","sourceRoot":"","sources":["../../src/algorithms/degreesToRadians.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,OAAe;IACvD,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;AAClC,CAAC"}
1
+ {"version":3,"file":"degreesToRadians.js","sourceRoot":"","sources":["../../src/algorithms/degreesToRadians.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,OAAe;IACvD,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;AAClC,CAAC"}
@@ -1,2 +1,8 @@
1
+ /**
2
+ * Calculate the factorial of a number.
3
+ * @param n - The number.
4
+ * @returns The factorial.
5
+ * @see [Factorial](https://en.wikipedia.org/wiki/Factorial)
6
+ */
1
7
  export default function factorial(n: number): number;
2
8
  //# sourceMappingURL=factorial.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"factorial.d.ts","sourceRoot":"","sources":["../../src/algorithms/factorial.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,CAAC,EAAE,MAAM,UAW1C"}
1
+ {"version":3,"file":"factorial.d.ts","sourceRoot":"","sources":["../../src/algorithms/factorial.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAWnD"}
@@ -1,7 +1,14 @@
1
+ /**
2
+ * Calculate the factorial of a number.
3
+ * @param n - The number.
4
+ * @returns The factorial.
5
+ * @see [Factorial](https://en.wikipedia.org/wiki/Factorial)
6
+ */
1
7
  export default function factorial(n) {
2
8
  if (n < 0) {
3
- return n % 2 ? Infinity : -Infinity;
9
+ return n % 2 ? Infinity : -Infinity; // Division by zero returns `Infinity` in JavaScript.
4
10
  }
11
+ // Not recursive in order to avoid exceeding the maximum call stack size.
5
12
  let out = 1;
6
13
  for (let i = 2; i <= n; i++) {
7
14
  out *= i;
@@ -1 +1 @@
1
- {"version":3,"file":"factorial.js","sourceRoot":"","sources":["../../src/algorithms/factorial.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,CAAS;IAC1C,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IACrC,CAAC;IAGD,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC7B,GAAG,IAAI,CAAC,CAAC;IACV,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC"}
1
+ {"version":3,"file":"factorial.js","sourceRoot":"","sources":["../../src/algorithms/factorial.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,CAAS;IAC1C,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,qDAAqD;IAC3F,CAAC;IAED,yEAAyE;IACzE,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC7B,GAAG,IAAI,CAAC,CAAC;IACV,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC"}
@@ -1,2 +1,7 @@
1
- export default function fibonacci(): Generator<number, void, unknown>;
1
+ /**
2
+ * Calculate numbers in the Fibonacci sequence.
3
+ * @returns The next value in the Fibonacci sequence.
4
+ * @see [Fibonacci sequence](https://en.wikipedia.org/wiki/Fibonacci_sequence)
5
+ */
6
+ export default function fibonacci(): Generator<number, void>;
2
7
  //# sourceMappingURL=fibonacci.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fibonacci.d.ts","sourceRoot":"","sources":["../../src/algorithms/fibonacci.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,OAAO,UAAW,SAAS,qCAQjC"}
1
+ {"version":3,"file":"fibonacci.d.ts","sourceRoot":"","sources":["../../src/algorithms/fibonacci.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAW,SAAS,IAAI,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAQ5D"}
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Calculate numbers in the Fibonacci sequence.
3
+ * @returns The next value in the Fibonacci sequence.
4
+ * @see [Fibonacci sequence](https://en.wikipedia.org/wiki/Fibonacci_sequence)
5
+ */
1
6
  export default function* fibonacci() {
2
7
  let a = 0;
3
8
  let b = 1;
@@ -1 +1 @@
1
- {"version":3,"file":"fibonacci.js","sourceRoot":"","sources":["../../src/algorithms/fibonacci.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,OAAO,SAAS,CAAC,CAAC,SAAS;IACjC,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,IAAI,CAAC,GAAG,CAAC,CAAC;IAEV,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACf,MAAM,CAAC,CAAC;QACR,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACrB,CAAC;AACF,CAAC"}
1
+ {"version":3,"file":"fibonacci.js","sourceRoot":"","sources":["../../src/algorithms/fibonacci.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,OAAO,SAAS,CAAC,CAAC,SAAS;IACjC,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,IAAI,CAAC,GAAG,CAAC,CAAC;IAEV,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACf,MAAM,CAAC,CAAC;QACR,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACrB,CAAC;AACF,CAAC"}
@@ -1,3 +1,17 @@
1
+ /**
2
+ * Determine the greatest common divisor of two integers.
3
+ * @param a - The first integer.
4
+ * @param b - The second integer.
5
+ * @returns The greatest common divisor.
6
+ * @see [Greatest common divisor](https://en.wikipedia.org/wiki/Greatest_common_divisor)
7
+ */
1
8
  export default function greatestCommonDivisor(a: bigint, b: bigint): bigint;
9
+ /**
10
+ * Determine the greatest common divisor of two integers.
11
+ * @param a - The first integer.
12
+ * @param b - The second integer.
13
+ * @returns The greatest common divisor.
14
+ * @see [Greatest common divisor](https://en.wikipedia.org/wiki/Greatest_common_divisor)
15
+ */
2
16
  export default function greatestCommonDivisor(a: number, b: number): number;
3
17
  //# sourceMappingURL=greatestCommonDivisor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"greatestCommonDivisor.d.ts","sourceRoot":"","sources":["../../src/algorithms/greatestCommonDivisor.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;AAS5E,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC"}
1
+ {"version":3,"file":"greatestCommonDivisor.d.ts","sourceRoot":"","sources":["../../src/algorithms/greatestCommonDivisor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;AAE5E;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC"}
@@ -1,6 +1,8 @@
1
1
  export default function greatestCommonDivisor(a, b) {
2
+ // Ensure that both of the integers are positive.
2
3
  let c = a < 0 ? -a : a;
3
4
  let d = b < 0 ? -b : b;
5
+ // Apply the Euclidean algorithm.
4
6
  while (d) {
5
7
  [c, d] = [d, c % d];
6
8
  }
@@ -1 +1 @@
1
- {"version":3,"file":"greatestCommonDivisor.js","sourceRoot":"","sources":["../../src/algorithms/greatestCommonDivisor.ts"],"names":[],"mappings":"AAkBA,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAC5C,CAAkB,EAClB,CAAkB;IAGlB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACvB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAGvB,OAAO,CAAC,EAAE,CAAC;QACV,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAG,CAAY,GAAI,CAAY,CAAC,CAAC;IAC7C,CAAC;IAED,OAAO,CAAC,CAAC;AACV,CAAC"}
1
+ {"version":3,"file":"greatestCommonDivisor.js","sourceRoot":"","sources":["../../src/algorithms/greatestCommonDivisor.ts"],"names":[],"mappings":"AAkBA,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAC5C,CAAkB,EAClB,CAAkB;IAElB,iDAAiD;IACjD,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACvB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEvB,iCAAiC;IACjC,OAAO,CAAC,EAAE,CAAC;QACV,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAG,CAAY,GAAI,CAAY,CAAC,CAAC;IAC7C,CAAC;IAED,OAAO,CAAC,CAAC;AACV,CAAC"}
@@ -1,2 +1,11 @@
1
+ /**
2
+ * The probability mass function for the hypergeometric distribution.
3
+ * @param N - The size of the finite population.
4
+ * @param K - The number of objects with the desired feature in the finite population.
5
+ * @param n - The number of draws without replacement.
6
+ * @param k - The desired number of successes.
7
+ * @see [Hypergeometric distribution](https://en.wikipedia.org/wiki/Hypergeometric_distribution)
8
+ * @see [Probability mass function](https://en.wikipedia.org/wiki/Probability_mass_function)
9
+ */
1
10
  export default function hypergeometricPmf(N: number, K: number, n: number, k: number): number;
2
11
  //# sourceMappingURL=hypergeometricPmf.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hypergeometricPmf.d.ts","sourceRoot":"","sources":["../../src/algorithms/hypergeometricPmf.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACxC,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,UAGT"}
1
+ {"version":3,"file":"hypergeometricPmf.d.ts","sourceRoot":"","sources":["../../src/algorithms/hypergeometricPmf.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACxC,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,GACP,MAAM,CAER"}
@@ -1,4 +1,13 @@
1
1
  import combinations from "./combinations.js";
2
+ /**
3
+ * The probability mass function for the hypergeometric distribution.
4
+ * @param N - The size of the finite population.
5
+ * @param K - The number of objects with the desired feature in the finite population.
6
+ * @param n - The number of draws without replacement.
7
+ * @param k - The desired number of successes.
8
+ * @see [Hypergeometric distribution](https://en.wikipedia.org/wiki/Hypergeometric_distribution)
9
+ * @see [Probability mass function](https://en.wikipedia.org/wiki/Probability_mass_function)
10
+ */
2
11
  export default function hypergeometricPmf(N, K, n, k) {
3
12
  return (combinations(K, k) * combinations(N - K, n - k)) / combinations(N, n);
4
13
  }
@@ -1 +1 @@
1
- {"version":3,"file":"hypergeometricPmf.js","sourceRoot":"","sources":["../../src/algorithms/hypergeometricPmf.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,mBAAmB,CAAC;AAW7C,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACxC,CAAS,EACT,CAAS,EACT,CAAS,EACT,CAAS;IAET,OAAO,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC/E,CAAC"}
1
+ {"version":3,"file":"hypergeometricPmf.js","sourceRoot":"","sources":["../../src/algorithms/hypergeometricPmf.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,mBAAmB,CAAC;AAE7C;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACxC,CAAS,EACT,CAAS,EACT,CAAS,EACT,CAAS;IAET,OAAO,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC/E,CAAC"}
@@ -1,2 +1,8 @@
1
+ /**
2
+ * Returns whether or not a number is prime.
3
+ * @param n - The number.
4
+ * @returns Whether or not the number is prime.
5
+ * @see [Prime number](https://en.wikipedia.org/wiki/Prime_number)
6
+ */
1
7
  export default function isPrime(n: number): boolean;
2
8
  //# sourceMappingURL=isPrime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"isPrime.d.ts","sourceRoot":"","sources":["../../src/algorithms/isPrime.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,CAAC,EAAE,MAAM,WAaxC"}
1
+ {"version":3,"file":"isPrime.d.ts","sourceRoot":"","sources":["../../src/algorithms/isPrime.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAalD"}
@@ -1,4 +1,11 @@
1
+ /**
2
+ * Returns whether or not a number is prime.
3
+ * @param n - The number.
4
+ * @returns Whether or not the number is prime.
5
+ * @see [Prime number](https://en.wikipedia.org/wiki/Prime_number)
6
+ */
1
7
  export default function isPrime(n) {
8
+ // Negatives, zero, and one can't be prime.
2
9
  if (n < 2) {
3
10
  return false;
4
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"isPrime.js","sourceRoot":"","sources":["../../src/algorithms/isPrime.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,CAAS;IAExC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACX,OAAO,KAAK,CAAC;IACd,CAAC;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACjC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YACjB,OAAO,KAAK,CAAC;QACd,CAAC;IACF,CAAC;IAED,OAAO,IAAI,CAAC;AACb,CAAC"}
1
+ {"version":3,"file":"isPrime.js","sourceRoot":"","sources":["../../src/algorithms/isPrime.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,CAAS;IACxC,2CAA2C;IAC3C,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACX,OAAO,KAAK,CAAC;IACd,CAAC;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACjC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YACjB,OAAO,KAAK,CAAC;QACd,CAAC;IACF,CAAC;IAED,OAAO,IAAI,CAAC;AACb,CAAC"}
@@ -1,2 +1,9 @@
1
+ /**
2
+ * Calculate the number of permutations.
3
+ * @param n - The total number of units.
4
+ * @param r - The number of units taken at a time.
5
+ * @returns The number of permutations.
6
+ * @see [Permutation](https://en.wikipedia.org/wiki/Permutation)
7
+ */
1
8
  export default function permutations(n: number, r: number): number;
2
9
  //# sourceMappingURL=permutations.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"permutations.d.ts","sourceRoot":"","sources":["../../src/algorithms/permutations.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,UAExD"}
1
+ {"version":3,"file":"permutations.d.ts","sourceRoot":"","sources":["../../src/algorithms/permutations.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAEjE"}
@@ -1,4 +1,11 @@
1
1
  import factorial from "./factorial.js";
2
+ /**
3
+ * Calculate the number of permutations.
4
+ * @param n - The total number of units.
5
+ * @param r - The number of units taken at a time.
6
+ * @returns The number of permutations.
7
+ * @see [Permutation](https://en.wikipedia.org/wiki/Permutation)
8
+ */
2
9
  export default function permutations(n, r) {
3
10
  return factorial(n) / factorial(n - r);
4
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"permutations.js","sourceRoot":"","sources":["../../src/algorithms/permutations.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,gBAAgB,CAAC;AASvC,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,CAAS,EAAE,CAAS;IACxD,OAAO,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AACxC,CAAC"}
1
+ {"version":3,"file":"permutations.js","sourceRoot":"","sources":["../../src/algorithms/permutations.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,gBAAgB,CAAC;AAEvC;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,CAAS,EAAE,CAAS;IACxD,OAAO,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AACxC,CAAC"}
@@ -1,2 +1,8 @@
1
+ /**
2
+ * Factor a number into a list of prime numbers.
3
+ * @param n - The number to factor.
4
+ * @returns A list of prime number factors of the number.
5
+ * @see [Integer factorization](https://en.wikipedia.org/wiki/Integer_factorization)
6
+ */
1
7
  export default function primeFactorization(n: number): number[];
2
8
  //# sourceMappingURL=primeFactorization.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"primeFactorization.d.ts","sourceRoot":"","sources":["../../src/algorithms/primeFactorization.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,CAAC,EAAE,MAAM,YAcnD"}
1
+ {"version":3,"file":"primeFactorization.d.ts","sourceRoot":"","sources":["../../src/algorithms/primeFactorization.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAc9D"}
@@ -1,3 +1,9 @@
1
+ /**
2
+ * Factor a number into a list of prime numbers.
3
+ * @param n - The number to factor.
4
+ * @returns A list of prime number factors of the number.
5
+ * @see [Integer factorization](https://en.wikipedia.org/wiki/Integer_factorization)
6
+ */
1
7
  export default function primeFactorization(n) {
2
8
  let m = n;
3
9
  const out = [];
@@ -1 +1 @@
1
- {"version":3,"file":"primeFactorization.js","sourceRoot":"","sources":["../../src/algorithms/primeFactorization.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,CAAS;IACnD,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,MAAM,GAAG,GAAG,EAAE,CAAC;IACf,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACf,IAAI,CAAC,GAAG,OAAO,KAAK,CAAC,EAAE,CAAC;YACvB,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAClB,CAAC,IAAI,OAAO,CAAC;QACd,CAAC;aAAM,CAAC;YACP,OAAO,EAAE,CAAC;QACX,CAAC;IACF,CAAC;IAED,OAAO,GAAG,CAAC;AACZ,CAAC"}
1
+ {"version":3,"file":"primeFactorization.js","sourceRoot":"","sources":["../../src/algorithms/primeFactorization.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,CAAS;IACnD,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,MAAM,GAAG,GAAG,EAAE,CAAC;IACf,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACf,IAAI,CAAC,GAAG,OAAO,KAAK,CAAC,EAAE,CAAC;YACvB,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAClB,CAAC,IAAI,OAAO,CAAC;QACd,CAAC;aAAM,CAAC;YACP,OAAO,EAAE,CAAC;QACX,CAAC;IACF,CAAC;IAED,OAAO,GAAG,CAAC;AACZ,CAAC"}
@@ -1,2 +1,9 @@
1
+ /**
2
+ * Convert a number of radians to an equivalent number of degrees.
3
+ * @param radians - The number of radians.
4
+ * @returns A number of degrees.
5
+ * @see [Degree](https://en.wikipedia.org/wiki/Degree_(angle))
6
+ * @see [Radian](https://en.wikipedia.org/wiki/Radian)
7
+ */
1
8
  export default function radiansToDegrees(radians: number): number;
2
9
  //# sourceMappingURL=radiansToDegrees.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"radiansToDegrees.d.ts","sourceRoot":"","sources":["../../src/algorithms/radiansToDegrees.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,OAAO,EAAE,MAAM,UAEvD"}
1
+ {"version":3,"file":"radiansToDegrees.d.ts","sourceRoot":"","sources":["../../src/algorithms/radiansToDegrees.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEhE"}
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Convert a number of radians to an equivalent number of degrees.
3
+ * @param radians - The number of radians.
4
+ * @returns A number of degrees.
5
+ * @see [Degree](https://en.wikipedia.org/wiki/Degree_(angle))
6
+ * @see [Radian](https://en.wikipedia.org/wiki/Radian)
7
+ */
1
8
  export default function radiansToDegrees(radians) {
2
9
  return (radians * 180) / Math.PI;
3
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"radiansToDegrees.js","sourceRoot":"","sources":["../../src/algorithms/radiansToDegrees.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,OAAe;IACvD,OAAO,CAAC,OAAO,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC;AAClC,CAAC"}
1
+ {"version":3,"file":"radiansToDegrees.js","sourceRoot":"","sources":["../../src/algorithms/radiansToDegrees.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,OAAe;IACvD,OAAO,CAAC,OAAO,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC;AAClC,CAAC"}
@@ -1,2 +1,10 @@
1
+ /**
2
+ * Perform a summation.
3
+ * @param min - The lower bound (inclusive) of the index of summation.
4
+ * @param max - The upper bound (inclusive) of the index of summation.
5
+ * @param term - The function used to generate each term.
6
+ * @returns The sum.
7
+ * @see [Summation](https://en.wikipedia.org/wiki/Summation)
8
+ */
1
9
  export default function summation(min: number, max: number, term: (i: number) => number): number;
2
10
  //# sourceMappingURL=summation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"summation.d.ts","sourceRoot":"","sources":["../../src/algorithms/summation.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,OAAO,UAAU,SAAS,CAChC,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,UAS3B"}
1
+ {"version":3,"file":"summation.d.ts","sourceRoot":"","sources":["../../src/algorithms/summation.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAChC,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,GACzB,MAAM,CAQR"}
@@ -1,4 +1,13 @@
1
+ /**
2
+ * Perform a summation.
3
+ * @param min - The lower bound (inclusive) of the index of summation.
4
+ * @param max - The upper bound (inclusive) of the index of summation.
5
+ * @param term - The function used to generate each term.
6
+ * @returns The sum.
7
+ * @see [Summation](https://en.wikipedia.org/wiki/Summation)
8
+ */
1
9
  export default function summation(min, max, term) {
10
+ // Not recursive in order to avoid exceeding the maximum call stack size.
2
11
  let out = 0;
3
12
  for (let i = min; i <= max; i++) {
4
13
  out += term(i);
@@ -1 +1 @@
1
- {"version":3,"file":"summation.js","sourceRoot":"","sources":["../../src/algorithms/summation.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,OAAO,UAAU,SAAS,CAChC,GAAW,EACX,GAAW,EACX,IAA2B;IAG3B,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,KAAK,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;QACjC,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;IAChB,CAAC;IAED,OAAO,GAAG,CAAC;AACZ,CAAC"}
1
+ {"version":3,"file":"summation.js","sourceRoot":"","sources":["../../src/algorithms/summation.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAChC,GAAW,EACX,GAAW,EACX,IAA2B;IAE3B,yEAAyE;IACzE,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,KAAK,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;QACjC,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;IAChB,CAAC;IAED,OAAO,GAAG,CAAC;AACZ,CAAC"}