@pawells/math-extended 1.1.1 → 2.0.0

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 (97) hide show
  1. package/build/angles.d.ts +28 -18
  2. package/build/angles.d.ts.map +1 -1
  3. package/build/angles.js +28 -18
  4. package/build/angles.js.map +1 -1
  5. package/build/clamp.d.ts +5 -3
  6. package/build/clamp.d.ts.map +1 -1
  7. package/build/clamp.js +5 -3
  8. package/build/clamp.js.map +1 -1
  9. package/build/interpolation.d.ts +158 -96
  10. package/build/interpolation.d.ts.map +1 -1
  11. package/build/interpolation.js +158 -96
  12. package/build/interpolation.js.map +1 -1
  13. package/build/matrices/_exports.d.ts +13 -0
  14. package/build/matrices/_exports.d.ts.map +1 -0
  15. package/build/matrices/_exports.js +13 -0
  16. package/build/matrices/_exports.js.map +1 -0
  17. package/build/matrices/arithmetic.d.ts +170 -181
  18. package/build/matrices/arithmetic.d.ts.map +1 -1
  19. package/build/matrices/arithmetic.js +192 -202
  20. package/build/matrices/arithmetic.js.map +1 -1
  21. package/build/matrices/asserts.d.ts +240 -109
  22. package/build/matrices/asserts.d.ts.map +1 -1
  23. package/build/matrices/asserts.js +287 -87
  24. package/build/matrices/asserts.js.map +1 -1
  25. package/build/matrices/core.d.ts +29 -29
  26. package/build/matrices/core.js +1 -1
  27. package/build/matrices/decompositions.d.ts +102 -104
  28. package/build/matrices/decompositions.d.ts.map +1 -1
  29. package/build/matrices/decompositions.js +87 -89
  30. package/build/matrices/decompositions.js.map +1 -1
  31. package/build/matrices/index.d.ts +3 -2
  32. package/build/matrices/index.d.ts.map +1 -1
  33. package/build/matrices/index.js +5 -2
  34. package/build/matrices/index.js.map +1 -1
  35. package/build/matrices/linear-algebra.d.ts +12 -12
  36. package/build/matrices/linear-algebra.js +4 -4
  37. package/build/matrices/normalization.d.ts +8 -8
  38. package/build/matrices/transformations.d.ts +184 -165
  39. package/build/matrices/transformations.d.ts.map +1 -1
  40. package/build/matrices/transformations.js +99 -80
  41. package/build/matrices/transformations.js.map +1 -1
  42. package/build/matrices/types.d.ts +12 -12
  43. package/build/matrices/types.d.ts.map +1 -1
  44. package/build/quaternions/_exports.d.ts +11 -0
  45. package/build/quaternions/_exports.d.ts.map +1 -0
  46. package/build/quaternions/_exports.js +11 -0
  47. package/build/quaternions/_exports.js.map +1 -0
  48. package/build/quaternions/asserts.d.ts +115 -7
  49. package/build/quaternions/asserts.d.ts.map +1 -1
  50. package/build/quaternions/asserts.js +162 -8
  51. package/build/quaternions/asserts.js.map +1 -1
  52. package/build/quaternions/conversions.d.ts +31 -21
  53. package/build/quaternions/conversions.d.ts.map +1 -1
  54. package/build/quaternions/conversions.js +28 -18
  55. package/build/quaternions/conversions.js.map +1 -1
  56. package/build/quaternions/core.d.ts +67 -39
  57. package/build/quaternions/core.d.ts.map +1 -1
  58. package/build/quaternions/core.js +67 -39
  59. package/build/quaternions/core.js.map +1 -1
  60. package/build/quaternions/index.d.ts +3 -2
  61. package/build/quaternions/index.d.ts.map +1 -1
  62. package/build/quaternions/index.js +5 -2
  63. package/build/quaternions/index.js.map +1 -1
  64. package/build/quaternions/interpolation.d.ts +15 -9
  65. package/build/quaternions/interpolation.d.ts.map +1 -1
  66. package/build/quaternions/interpolation.js +15 -9
  67. package/build/quaternions/interpolation.js.map +1 -1
  68. package/build/quaternions/predefined.d.ts +9 -3
  69. package/build/quaternions/predefined.d.ts.map +1 -1
  70. package/build/quaternions/predefined.js +9 -3
  71. package/build/quaternions/predefined.js.map +1 -1
  72. package/build/quaternions/types.d.ts +3 -3
  73. package/build/vectors/_exports.d.ts +10 -0
  74. package/build/vectors/_exports.d.ts.map +1 -0
  75. package/build/vectors/_exports.js +10 -0
  76. package/build/vectors/_exports.js.map +1 -0
  77. package/build/vectors/asserts.d.ts +153 -49
  78. package/build/vectors/asserts.d.ts.map +1 -1
  79. package/build/vectors/asserts.js +202 -52
  80. package/build/vectors/asserts.js.map +1 -1
  81. package/build/vectors/core.d.ts +216 -137
  82. package/build/vectors/core.d.ts.map +1 -1
  83. package/build/vectors/core.js +212 -149
  84. package/build/vectors/core.js.map +1 -1
  85. package/build/vectors/index.d.ts +1 -0
  86. package/build/vectors/index.d.ts.map +1 -1
  87. package/build/vectors/index.js +3 -0
  88. package/build/vectors/index.js.map +1 -1
  89. package/build/vectors/interpolation.d.ts +39 -27
  90. package/build/vectors/interpolation.d.ts.map +1 -1
  91. package/build/vectors/interpolation.js +39 -27
  92. package/build/vectors/interpolation.js.map +1 -1
  93. package/build/vectors/predefined.d.ts +48 -24
  94. package/build/vectors/predefined.d.ts.map +1 -1
  95. package/build/vectors/predefined.js +38 -18
  96. package/build/vectors/predefined.js.map +1 -1
  97. package/package.json +3 -3
@@ -1,4 +1,4 @@
1
- import { IMatrix, IMatrix1, IMatrix2, IMatrix3, IMatrix4, TMatrixResult } from './types.js';
1
+ import { TMatrix, TMatrix1, TMatrix2, TMatrix3, TMatrix4, TMatrixResult } from './types.js';
2
2
  import { TVector, TVector2, TVector3, TVector4 } from '../vectors/types.js';
3
3
  /**
4
4
  * Performs element-wise addition of two matrices.
@@ -19,27 +19,27 @@ import { TVector, TVector2, TVector3, TVector4 } from '../vectors/types.js';
19
19
  * **Time Complexity:** O(m×n) where m and n are the matrix dimensions
20
20
  * **Space Complexity:** O(m×n) for the result matrix
21
21
  *
22
- * @template T - The matrix type extending IMatrix interface
22
+ * @template T - The matrix type extending TMatrix interface
23
23
  * @param a - First matrix (addend) - must have same dimensions as b
24
24
  * @param b - Second matrix (addend) - must have same dimensions as a
25
25
  * @returns {TMatrixResult<T>} A new matrix where each element is the sum of corresponding elements
26
26
  * @throws {Error} If matrices have different dimensions or contain invalid values
27
27
  *
28
28
  * @example
29
- * ```typescript
30
- * // Adding 2×2 matrices
31
- * MatrixAdd([[1, 2], [3, 4]], [[5, 6], [7, 8]]) // Returns [[6, 8], [10, 12]]
32
- *
33
- * // Adding 1×3 row vectors
34
- * MatrixAdd([[1, 2, 3]], [[4, 5, 6]]) // Returns [[5, 7, 9]]
35
- *
36
- * // Type-safe matrix addition with specific matrix types
37
- * const matrixA: IMatrix2 = [[1, 2], [3, 4]];
38
- * const matrixB: IMatrix2 = [[5, 6], [7, 8]];
39
- * const result: IMatrix2 = MatrixAdd(matrixA, matrixB);
40
- * ```
29
+ * ```typescript
30
+ * ```typescript
31
+ * // Adding 2×2 matrices
32
+ * MatrixAdd([[1, 2], [3, 4]], [[5, 6], [7, 8]]) // Returns [[6, 8], [10, 12]]
33
+ * // Adding 1×3 row vectors
34
+ * MatrixAdd([[1, 2, 3]], [[4, 5, 6]]) // Returns [[5, 7, 9]]
35
+ * // Type-safe matrix addition with specific matrix types
36
+ * const matrixA: TMatrix2 = [[1, 2], [3, 4]];
37
+ * const matrixB: TMatrix2 = [[5, 6], [7, 8]];
38
+ * const result: TMatrix2 = MatrixAdd(matrixA, matrixB);
39
+ * ```
40
+ * ```
41
41
  */
42
- export declare function MatrixAdd<T extends IMatrix>(a: T, b: T): TMatrixResult<T>;
42
+ export declare function MatrixAdd<T extends TMatrix>(a: T, b: T): TMatrixResult<T>;
43
43
  /**
44
44
  * Performs element-wise subtraction of two matrices (a - b).
45
45
  *
@@ -59,26 +59,26 @@ export declare function MatrixAdd<T extends IMatrix>(a: T, b: T): TMatrixResult<
59
59
  * **Time Complexity:** O(m×n) where m and n are the matrix dimensions
60
60
  * **Space Complexity:** O(m×n) for the result matrix
61
61
  *
62
- * @template T - The matrix type extending IMatrix interface
62
+ * @template T - The matrix type extending TMatrix interface
63
63
  * @param a - First matrix (minuend) - the matrix being subtracted from
64
64
  * @param b - Second matrix (subtrahend) - the matrix being subtracted
65
65
  * @returns {TMatrixResult<T>} A new matrix where each element is the difference of corresponding elements
66
66
  * @throws {Error} If matrices have different dimensions or contain invalid values
67
67
  *
68
68
  * @example
69
- * ```typescript
70
- * // Subtracting 2×2 matrices
71
- * MatrixSubtract([[10, 8], [6, 4]], [[3, 2], [1, 1]]) // Returns [[7, 6], [5, 3]]
72
- *
73
- * // Order matters: A - B ≠ B - A
74
- * MatrixSubtract([[1, 2]], [[3, 4]]) // Returns [[-2, -2]]
75
- * MatrixSubtract([[3, 4]], [[1, 2]]) // Returns [[2, 2]]
76
- *
77
- * // Self-subtraction produces zero matrix
78
- * MatrixSubtract([[5, 6]], [[5, 6]]) // Returns [[0, 0]]
79
- * ```
69
+ * ```typescript
70
+ * ```typescript
71
+ * // Subtracting 2×2 matrices
72
+ * MatrixSubtract([[10, 8], [6, 4]], [[3, 2], [1, 1]]) // Returns [[7, 6], [5, 3]]
73
+ * // Order matters: A - B ≠ B - A
74
+ * MatrixSubtract([[1, 2]], [[3, 4]]) // Returns [[-2, -2]]
75
+ * MatrixSubtract([[3, 4]], [[1, 2]]) // Returns [[2, 2]]
76
+ * // Self-subtraction produces zero matrix
77
+ * MatrixSubtract([[5, 6]], [[5, 6]]) // Returns [[0, 0]]
78
+ * ```
79
+ * ```
80
80
  */
81
- export declare function MatrixSubtract<T extends IMatrix>(a: T, b: T): TMatrixResult<T>;
81
+ export declare function MatrixSubtract<T extends TMatrix>(a: T, b: T): TMatrixResult<T>;
82
82
  /**
83
83
  * Performs matrix multiplication with comprehensive type-safe overloads for matrices, vectors, and scalars.
84
84
  *
@@ -89,24 +89,24 @@ export declare function MatrixSubtract<T extends IMatrix>(a: T, b: T): TMatrixRe
89
89
  *
90
90
  * **Type-Safe Overloads:**
91
91
  * - **Scalar Multiplication:**
92
- * - `IMatrix1 × number → IMatrix1` (1×1 matrix scalar multiplication)
93
- * - `IMatrix2 × number → IMatrix2` (2×2 matrix scalar multiplication)
94
- * - `IMatrix3 × number → IMatrix3` (3×3 matrix scalar multiplication)
95
- * - `IMatrix4 × number → IMatrix4` (4×4 matrix scalar multiplication)
96
- * - `IMatrix × number → IMatrix` (general matrix scalar multiplication)
92
+ * - `TMatrix1 × number → TMatrix1` (1×1 matrix scalar multiplication)
93
+ * - `TMatrix2 × number → TMatrix2` (2×2 matrix scalar multiplication)
94
+ * - `TMatrix3 × number → TMatrix3` (3×3 matrix scalar multiplication)
95
+ * - `TMatrix4 × number → TMatrix4` (4×4 matrix scalar multiplication)
96
+ * - `TMatrix × number → TMatrix` (general matrix scalar multiplication)
97
97
  *
98
98
  * - **Vector Multiplication:**
99
- * - `IMatrix2 × TVector2 → TVector2` (2×2 matrix × 2D vector)
100
- * - `IMatrix3 × TVector3 → TVector3` (3×3 matrix × 3D vector)
101
- * - `IMatrix4 × TVector4 → TVector4` (4×4 matrix × 4D vector)
102
- * - `IMatrix × TVector → TVector` (general matrix × vector)
99
+ * - `TMatrix2 × TVector2 → TVector2` (2×2 matrix × 2D vector)
100
+ * - `TMatrix3 × TVector3 → TVector3` (3×3 matrix × 3D vector)
101
+ * - `TMatrix4 × TVector4 → TVector4` (4×4 matrix × 4D vector)
102
+ * - `TMatrix × TVector → TVector` (general matrix × vector)
103
103
  *
104
104
  * - **Matrix Multiplication:**
105
- * - `IMatrix1 × IMatrix1IMatrix1` (1×1 matrix multiplication)
106
- * - `IMatrix2 × IMatrix2IMatrix2` (2×2 matrix multiplication)
107
- * - `IMatrix3 × IMatrix3IMatrix3` (3×3 matrix multiplication)
108
- * - `IMatrix4 × IMatrix4IMatrix4` (4×4 matrix multiplication)
109
- * - `IMatrix × IMatrixIMatrix` (general matrix multiplication)
105
+ * - `TMatrix1 × TMatrix1TMatrix1` (1×1 matrix multiplication)
106
+ * - `TMatrix2 × TMatrix2TMatrix2` (2×2 matrix multiplication)
107
+ * - `TMatrix3 × TMatrix3TMatrix3` (3×3 matrix multiplication)
108
+ * - `TMatrix4 × TMatrix4TMatrix4` (4×4 matrix multiplication)
109
+ * - `TMatrix × TMatrixTMatrix` (general matrix multiplication)
110
110
  *
111
111
  * **Operation Types:**
112
112
  * - **Matrix × Scalar:** Element-wise multiplication by scalar value
@@ -126,59 +126,55 @@ export declare function MatrixSubtract<T extends IMatrix>(a: T, b: T): TMatrixRe
126
126
  *
127
127
  * @param a - First matrix (left operand) with dimensions m×n
128
128
  * @param b - Second operand: matrix (n×p), vector (n elements), or scalar number
129
- * @returns {IMatrix | TVector} The product result:
129
+ * @returns {TMatrix | TVector} The product result:
130
130
  * - For scalar: m×n matrix with each element multiplied by scalar
131
131
  * - For vector: m×1 column vector matrix
132
132
  * - For matrix: m×p product matrix
133
133
  * @throws {Error} If matrix dimensions are incompatible for multiplication
134
134
  *
135
135
  * @example
136
- * ```typescript
137
- * // Type-safe scalar multiplication with specific matrix types
138
- * const matrix2: IMatrix2 = [[1, 2], [3, 4]];
139
- * const scalar2Result: IMatrix2 = MatrixMultiply(matrix2, 2); // [[2, 4], [6, 8]]
140
- *
141
- * const matrix3: IMatrix3 = [[1, 0, 0], [0, 1, 0], [0, 0, 1]];
142
- * const scalar3Result: IMatrix3 = MatrixMultiply(matrix3, 5); // Identity × 5
143
- *
144
- * // Type-safe vector multiplication with specific matrix/vector types
145
- * const matrix2x2: IMatrix2 = [[1, 2], [3, 4]];
146
- * const vector2: TVector2 = [5, 6];
147
- * const vectorResult: TVector2 = MatrixMultiply(matrix2x2, vector2); // [17, 39]
148
- *
149
- * const matrix4x4: IMatrix4 = [[1,0,0,0], [0,1,0,0], [0,0,1,0], [0,0,0,1]];
150
- * const vector4: TVector4 = [1, 2, 3, 4];
151
- * const vector4Result: TVector4 = MatrixMultiply(matrix4x4, vector4); // [1, 2, 3, 4]
152
- *
153
- * // Type-safe matrix multiplication with specific matrix types
154
- * const matrixA: IMatrix2 = [[1, 2], [3, 4]];
155
- * const matrixB: IMatrix2 = [[5, 6], [7, 8]];
156
- * const matrixResult: IMatrix2 = MatrixMultiply(matrixA, matrixB); // [[19, 22], [43, 50]]
157
- *
158
- * // General matrix operations (fallback to generic types)
159
- * MatrixMultiply([[1, 2]], [[3], [4]]) // Returns [[11]]
160
- * MatrixMultiply([[1], [2]], [[3, 4]]) // Returns [[3, 4], [6, 8]]
161
- *
162
- * // Type detection is automatic - no need to specify operation type
163
- * const scalarResult = MatrixMultiply(matrixA, 5); // Scalar multiplication
164
- * const vectorResult2 = MatrixMultiply(matrixA, vector2); // Vector multiplication
165
- * const matrixResult2 = MatrixMultiply(matrixA, matrixB); // Matrix multiplication
166
- * ```
136
+ * ```typescript
137
+ * ```typescript
138
+ * // Type-safe scalar multiplication with specific matrix types
139
+ * const matrix2: TMatrix2 = [[1, 2], [3, 4]];
140
+ * const scalar2Result: TMatrix2 = MatrixMultiply(matrix2, 2); // [[2, 4], [6, 8]]
141
+ * const matrix3: TMatrix3 = [[1, 0, 0], [0, 1, 0], [0, 0, 1]];
142
+ * const scalar3Result: TMatrix3 = MatrixMultiply(matrix3, 5); // Identity × 5
143
+ * // Type-safe vector multiplication with specific matrix/vector types
144
+ * const matrix2x2: TMatrix2 = [[1, 2], [3, 4]];
145
+ * const vector2: TVector2 = [5, 6];
146
+ * const vectorResult: TVector2 = MatrixMultiply(matrix2x2, vector2); // [17, 39]
147
+ * const matrix4x4: TMatrix4 = [[1,0,0,0], [0,1,0,0], [0,0,1,0], [0,0,0,1]];
148
+ * const vector4: TVector4 = [1, 2, 3, 4];
149
+ * const vector4Result: TVector4 = MatrixMultiply(matrix4x4, vector4); // [1, 2, 3, 4]
150
+ * // Type-safe matrix multiplication with specific matrix types
151
+ * const matrixA: TMatrix2 = [[1, 2], [3, 4]];
152
+ * const matrixB: TMatrix2 = [[5, 6], [7, 8]];
153
+ * const matrixResult: TMatrix2 = MatrixMultiply(matrixA, matrixB); // [[19, 22], [43, 50]]
154
+ * // General matrix operations (fallback to generic types)
155
+ * MatrixMultiply([[1, 2]], [[3], [4]]) // Returns [[11]]
156
+ * MatrixMultiply([[1], [2]], [[3, 4]]) // Returns [[3, 4], [6, 8]]
157
+ * // Type detection is automatic - no need to specify operation type
158
+ * const scalarResult = MatrixMultiply(matrixA, 5); // Scalar multiplication
159
+ * const vectorResult2 = MatrixMultiply(matrixA, vector2); // Vector multiplication
160
+ * const matrixResult2 = MatrixMultiply(matrixA, matrixB); // Matrix multiplication
161
+ * ```
162
+ * ```
167
163
  */
168
- export declare function MatrixMultiply(a: IMatrix1, b: number): IMatrix1;
169
- export declare function MatrixMultiply(a: IMatrix2, b: number): IMatrix2;
170
- export declare function MatrixMultiply(a: IMatrix3, b: number): IMatrix3;
171
- export declare function MatrixMultiply(a: IMatrix4, b: number): IMatrix4;
172
- export declare function MatrixMultiply(a: IMatrix2, b: TVector2): TVector2;
173
- export declare function MatrixMultiply(a: IMatrix3, b: TVector3): TVector3;
174
- export declare function MatrixMultiply(a: IMatrix4, b: TVector4): TVector4;
175
- export declare function MatrixMultiply(a: IMatrix1, b: IMatrix1): IMatrix1;
176
- export declare function MatrixMultiply(a: IMatrix2, b: IMatrix2): IMatrix2;
177
- export declare function MatrixMultiply(a: IMatrix3, b: IMatrix3): IMatrix3;
178
- export declare function MatrixMultiply(a: IMatrix4, b: IMatrix4): IMatrix4;
179
- export declare function MatrixMultiply(a: IMatrix, b: TVector): TVector;
180
- export declare function MatrixMultiply(a: IMatrix, b: IMatrix): IMatrix;
181
- export declare function MatrixMultiply(a: IMatrix, b: number): IMatrix;
164
+ export declare function MatrixMultiply(a: TMatrix1, b: number): TMatrix1;
165
+ export declare function MatrixMultiply(a: TMatrix2, b: number): TMatrix2;
166
+ export declare function MatrixMultiply(a: TMatrix3, b: number): TMatrix3;
167
+ export declare function MatrixMultiply(a: TMatrix4, b: number): TMatrix4;
168
+ export declare function MatrixMultiply(a: TMatrix2, b: TVector2): TVector2;
169
+ export declare function MatrixMultiply(a: TMatrix3, b: TVector3): TVector3;
170
+ export declare function MatrixMultiply(a: TMatrix4, b: TVector4): TVector4;
171
+ export declare function MatrixMultiply(a: TMatrix1, b: TMatrix1): TMatrix1;
172
+ export declare function MatrixMultiply(a: TMatrix2, b: TMatrix2): TMatrix2;
173
+ export declare function MatrixMultiply(a: TMatrix3, b: TMatrix3): TMatrix3;
174
+ export declare function MatrixMultiply(a: TMatrix4, b: TMatrix4): TMatrix4;
175
+ export declare function MatrixMultiply(a: TMatrix, b: TVector): TVector;
176
+ export declare function MatrixMultiply(a: TMatrix, b: TMatrix): TMatrix;
177
+ export declare function MatrixMultiply(a: TMatrix, b: number): TMatrix;
182
178
  /**
183
179
  * Extracts a rectangular submatrix from a larger matrix.
184
180
  *
@@ -219,37 +215,34 @@ export declare function MatrixMultiply(a: IMatrix, b: number): IMatrix;
219
215
  * @param startRow - Starting row index (0-based, inclusive) — note reversed order
220
216
  * @param width - Number of columns to extract (must be positive)
221
217
  * @param height - Number of rows to extract (must be positive)
222
- * @returns {IMatrix} The extracted submatrix with dimensions height×width
218
+ * @returns {TMatrix} The extracted submatrix with dimensions height×width
223
219
  * @throws {Error} If extraction bounds exceed matrix dimensions or contain invalid values
224
220
  * @example
225
- * ```typescript
226
- * const matrix = [
227
- * [1, 2, 3, 4],
228
- * [5, 6, 7, 8],
229
- * [9, 10, 11, 12]
230
- * ]; // 3×4 matrix
231
- *
232
- * // Extract 2×2 submatrix from top-left corner
233
- * MatrixSubmatrix(matrix, 0, 0, 2, 2) // Returns [[1, 2], [5, 6]]
234
- *
235
- * // Extract 2×2 submatrix from center-right region
236
- * MatrixSubmatrix(matrix, 2, 1, 2, 2) // Returns [[7, 8], [11, 12]]
237
- *
238
- * // Extract single column (column vector)
239
- * MatrixSubmatrix(matrix, 1, 0, 1, 3) // Returns [[2], [6], [10]]
240
- *
241
- * // Extract single row (row vector)
242
- * MatrixSubmatrix(matrix, 0, 1, 4, 1) // Returns [[5, 6, 7, 8]]
243
- *
244
- * // Block matrix partitioning for algorithms
245
- * const large = MatrixCreate(8, 8); // 8×8 matrix
246
- * const topLeft = MatrixSubmatrix(large, 0, 0, 4, 4); // Top-left 4×4 block
247
- * const topRight = MatrixSubmatrix(large, 4, 0, 4, 4); // Top-right 4×4 block
248
- * const bottomLeft = MatrixSubmatrix(large, 0, 4, 4, 4); // Bottom-left 4×4 block
249
- * const bottomRight = MatrixSubmatrix(large, 4, 4, 4, 4); // Bottom-right 4×4 block
250
- * ```
221
+ * ```typescript
222
+ * ```typescript
223
+ * const matrix = [
224
+ * [1, 2, 3, 4],
225
+ * [5, 6, 7, 8],
226
+ * [9, 10, 11, 12]
227
+ * ]; // 3×4 matrix
228
+ * // Extract 2×2 submatrix from top-left corner
229
+ * MatrixSubmatrix(matrix, 0, 0, 2, 2) // Returns [[1, 2], [5, 6]]
230
+ * // Extract 2×2 submatrix from center-right region
231
+ * MatrixSubmatrix(matrix, 2, 1, 2, 2) // Returns [[7, 8], [11, 12]]
232
+ * // Extract single column (column vector)
233
+ * MatrixSubmatrix(matrix, 1, 0, 1, 3) // Returns [[2], [6], [10]]
234
+ * // Extract single row (row vector)
235
+ * MatrixSubmatrix(matrix, 0, 1, 4, 1) // Returns [[5, 6, 7, 8]]
236
+ * // Block matrix partitioning for algorithms
237
+ * const large = MatrixCreate(8, 8); // 8×8 matrix
238
+ * const topLeft = MatrixSubmatrix(large, 0, 0, 4, 4); // Top-left 4×4 block
239
+ * const topRight = MatrixSubmatrix(large, 4, 0, 4, 4); // Top-right 4×4 block
240
+ * const bottomLeft = MatrixSubmatrix(large, 0, 4, 4, 4); // Bottom-left 4×4 block
241
+ * const bottomRight = MatrixSubmatrix(large, 4, 4, 4, 4); // Bottom-right 4×4 block
242
+ * ```
243
+ * ```
251
244
  */
252
- export declare function MatrixSubmatrix(matrix: IMatrix, startCol: number, startRow: number, width: number, height: number): IMatrix;
245
+ export declare function MatrixSubmatrix(matrix: TMatrix, startCol: number, startRow: number, width: number, height: number): TMatrix;
253
246
  /**
254
247
  * Pads a matrix with zeros to reach the specified dimensions.
255
248
  *
@@ -288,41 +281,38 @@ export declare function MatrixSubmatrix(matrix: IMatrix, startCol: number, start
288
281
  * @param matrix - Source matrix to pad
289
282
  * @param newRows - Target number of rows (must be ≥ current rows)
290
283
  * @param newCols - Target number of columns (must be ≥ current columns)
291
- * @returns {IMatrix} The padded matrix with dimensions newRows×newCols
284
+ * @returns {TMatrix} The padded matrix with dimensions newRows×newCols
292
285
  * @throws {Error} If new dimensions are smaller than current dimensions
293
286
  * @example
294
- * ```typescript
295
- * const matrix = [[1, 2], [3, 4]]; // 2×2 matrix
296
- *
297
- * // Pad to 4×4 matrix (symmetric padding)
298
- * MatrixPad(matrix, 4, 4)
299
- * // Returns:
300
- * // [[1, 2, 0, 0],
301
- * // [3, 4, 0, 0],
302
- * // [0, 0, 0, 0],
303
- * // [0, 0, 0, 0]]
304
- *
305
- * // Pad to 3×4 matrix (asymmetric padding)
306
- * MatrixPad(matrix, 3, 4)
307
- * // Returns:
308
- * // [[1, 2, 0, 0],
309
- * // [3, 4, 0, 0],
310
- * // [0, 0, 0, 0]]
311
- *
312
- * // Prepare for power-of-2 algorithm (e.g., FFT-based convolution)
313
- * const data = [[1, 2, 3], [4, 5, 6]]; // 2×3 matrix
314
- * const powerOf2 = MatrixPad(data, 4, 4); // Pad to 4×4 for FFT
315
- *
316
- * // Batch size alignment in machine learning
317
- * const features = MatrixCreate(7, 10); // 7 samples, 10 features
318
- * const aligned = MatrixPad(features, 8, 10); // Align to batch size 8
319
- *
320
- * // Image border padding for convolution
321
- * const image = MatrixCreate(28, 28); // 28×28 image
322
- * const padded = MatrixPad(image, 32, 32); // Add border for valid convolution
323
- * ```
287
+ * ```typescript
288
+ * ```typescript
289
+ * const matrix = [[1, 2], [3, 4]]; // 2×2 matrix
290
+ * // Pad to 4×4 matrix (symmetric padding)
291
+ * MatrixPad(matrix, 4, 4)
292
+ * // Returns:
293
+ * // [[1, 2, 0, 0],
294
+ * // [3, 4, 0, 0],
295
+ * // [0, 0, 0, 0],
296
+ * // [0, 0, 0, 0]]
297
+ * // Pad to 3×4 matrix (asymmetric padding)
298
+ * MatrixPad(matrix, 3, 4)
299
+ * // Returns:
300
+ * // [[1, 2, 0, 0],
301
+ * // [3, 4, 0, 0],
302
+ * // [0, 0, 0, 0]]
303
+ * // Prepare for power-of-2 algorithm (e.g., FFT-based convolution)
304
+ * const data = [[1, 2, 3], [4, 5, 6]]; // 2×3 matrix
305
+ * const powerOf2 = MatrixPad(data, 4, 4); // Pad to 4×4 for FFT
306
+ * // Batch size alignment in machine learning
307
+ * const features = MatrixCreate(7, 10); // 7 samples, 10 features
308
+ * const aligned = MatrixPad(features, 8, 10); // Align to batch size 8
309
+ * // Image border padding for convolution
310
+ * const image = MatrixCreate(28, 28); // 28×28 image
311
+ * const padded = MatrixPad(image, 32, 32); // Add border for valid convolution
312
+ * ```
313
+ * ```
324
314
  */
325
- export declare function MatrixPad(matrix: IMatrix, newRows: number, newCols: number): IMatrix;
315
+ export declare function MatrixPad(matrix: TMatrix, newRows: number, newCols: number): TMatrix;
326
316
  /**
327
317
  * Combines four square submatrices into a single matrix (2×2 block structure).
328
318
  *
@@ -371,41 +361,40 @@ export declare function MatrixPad(matrix: IMatrix, newRows: number, newCols: num
371
361
  * @param c12 - Top-right quadrant (upper-right block)
372
362
  * @param c21 - Bottom-left quadrant (lower-left block)
373
363
  * @param c22 - Bottom-right quadrant (lower-right block)
374
- * @returns {IMatrix} The combined matrix with dimensions 2n×2n (where each input is n×n)
364
+ * @returns {TMatrix} The combined matrix with dimensions 2n×2n (where each input is n×n)
375
365
  * @throws {Error} If quadrants have mismatched dimensions or invalid values
376
366
  *
377
367
  * @example
378
- * ```typescript
379
- * // Basic 2×2 quadrant combination
380
- * const topLeft = [[1, 2], [3, 4]];
381
- * const topRight = [[5, 6], [7, 8]];
382
- * const bottomLeft = [[9, 10], [11, 12]];
383
- * const bottomRight = [[13, 14], [15, 16]];
384
- *
385
- * MatrixCombine(topLeft, topRight, bottomLeft, bottomRight)
386
- * // Returns:
387
- * // [[1, 2, 5, 6],
388
- * // [3, 4, 7, 8],
389
- * // [9, 10, 13, 14],
390
- * // [11,12, 15, 16]]
391
- *
392
- * // Strassen algorithm result reconstruction
393
- * const m1 = computeStrassenProduct1(); // Computed Strassen intermediate results
394
- * const m2 = computeStrassenProduct2();
395
- * const m3 = computeStrassenProduct3();
396
- * const m4 = computeStrassenProduct4();
397
- * const finalResult = MatrixCombine(m1, m2, m3, m4); // Assemble final result
398
- *
399
- * // Image processing: combining processed quadrants
400
- * const processedTopLeft = processImageQuadrant(imageTopLeft);
401
- * const processedTopRight = processImageQuadrant(imageTopRight);
402
- * const processedBottomLeft = processImageQuadrant(imageBottomLeft);
403
- * const processedBottomRight = processImageQuadrant(imageBottomRight);
404
- * const reconstructedImage = MatrixCombine(
405
- * processedTopLeft, processedTopRight,
406
- * processedBottomLeft, processedBottomRight
407
- * );
408
- * ```
368
+ * ```typescript
369
+ * ```typescript
370
+ * // Basic 2×2 quadrant combination
371
+ * const topLeft = [[1, 2], [3, 4]];
372
+ * const topRight = [[5, 6], [7, 8]];
373
+ * const bottomLeft = [[9, 10], [11, 12]];
374
+ * const bottomRight = [[13, 14], [15, 16]];
375
+ * MatrixCombine(topLeft, topRight, bottomLeft, bottomRight)
376
+ * // Returns:
377
+ * // [[1, 2, 5, 6],
378
+ * // [3, 4, 7, 8],
379
+ * // [9, 10, 13, 14],
380
+ * // [11,12, 15, 16]]
381
+ * // Strassen algorithm result reconstruction
382
+ * const m1 = computeStrassenProduct1(); // Computed Strassen intermediate results
383
+ * const m2 = computeStrassenProduct2();
384
+ * const m3 = computeStrassenProduct3();
385
+ * const m4 = computeStrassenProduct4();
386
+ * const finalResult = MatrixCombine(m1, m2, m3, m4); // Assemble final result
387
+ * // Image processing: combining processed quadrants
388
+ * const processedTopLeft = processImageQuadrant(imageTopLeft);
389
+ * const processedTopRight = processImageQuadrant(imageTopRight);
390
+ * const processedBottomLeft = processImageQuadrant(imageBottomLeft);
391
+ * const processedBottomRight = processImageQuadrant(imageBottomRight);
392
+ * const reconstructedImage = MatrixCombine(
393
+ * processedTopLeft, processedTopRight,
394
+ * processedBottomLeft, processedBottomRight
395
+ * );
396
+ * ```
397
+ * ```
409
398
  */
410
- export declare function MatrixCombine(c11: IMatrix, c12: IMatrix, c21: IMatrix, c22: IMatrix): IMatrix;
399
+ export declare function MatrixCombine(c11: TMatrix, c12: TMatrix, c21: TMatrix, c22: TMatrix): TMatrix;
411
400
  //# sourceMapping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