@pawells/math-extended 1.0.1
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.
- package/LICENSE +21 -0
- package/README.md +319 -0
- package/build/angles.d.ts +31 -0
- package/build/angles.d.ts.map +1 -0
- package/build/angles.js +85 -0
- package/build/angles.js.map +1 -0
- package/build/angles.spec.d.ts +2 -0
- package/build/angles.spec.d.ts.map +1 -0
- package/build/angles.spec.js +147 -0
- package/build/angles.spec.js.map +1 -0
- package/build/clamp.d.ts +17 -0
- package/build/clamp.d.ts.map +1 -0
- package/build/clamp.js +19 -0
- package/build/clamp.js.map +1 -0
- package/build/clamp.spec.d.ts +2 -0
- package/build/clamp.spec.d.ts.map +1 -0
- package/build/clamp.spec.js +19 -0
- package/build/clamp.spec.js.map +1 -0
- package/build/documentation-validation.spec.d.ts +11 -0
- package/build/documentation-validation.spec.d.ts.map +1 -0
- package/build/documentation-validation.spec.js +401 -0
- package/build/documentation-validation.spec.js.map +1 -0
- package/build/index.d.ts +8 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +8 -0
- package/build/index.js.map +1 -0
- package/build/interpolation.d.ts +175 -0
- package/build/interpolation.d.ts.map +1 -0
- package/build/interpolation.js +369 -0
- package/build/interpolation.js.map +1 -0
- package/build/interpolation.spec.d.ts +2 -0
- package/build/interpolation.spec.d.ts.map +1 -0
- package/build/interpolation.spec.js +480 -0
- package/build/interpolation.spec.js.map +1 -0
- package/build/matrices/arithmetic.d.ts +411 -0
- package/build/matrices/arithmetic.d.ts.map +1 -0
- package/build/matrices/arithmetic.js +954 -0
- package/build/matrices/arithmetic.js.map +1 -0
- package/build/matrices/arithmetic.spec.d.ts +2 -0
- package/build/matrices/arithmetic.spec.d.ts.map +1 -0
- package/build/matrices/arithmetic.spec.js +915 -0
- package/build/matrices/arithmetic.spec.js.map +1 -0
- package/build/matrices/asserts.d.ts +306 -0
- package/build/matrices/asserts.d.ts.map +1 -0
- package/build/matrices/asserts.js +396 -0
- package/build/matrices/asserts.js.map +1 -0
- package/build/matrices/asserts.spec.d.ts +2 -0
- package/build/matrices/asserts.spec.d.ts.map +1 -0
- package/build/matrices/asserts.spec.js +565 -0
- package/build/matrices/asserts.spec.js.map +1 -0
- package/build/matrices/core.d.ts +168 -0
- package/build/matrices/core.d.ts.map +1 -0
- package/build/matrices/core.js +457 -0
- package/build/matrices/core.js.map +1 -0
- package/build/matrices/core.spec.d.ts +2 -0
- package/build/matrices/core.spec.d.ts.map +1 -0
- package/build/matrices/core.spec.js +634 -0
- package/build/matrices/core.spec.js.map +1 -0
- package/build/matrices/decompositions.d.ts +326 -0
- package/build/matrices/decompositions.d.ts.map +1 -0
- package/build/matrices/decompositions.js +816 -0
- package/build/matrices/decompositions.js.map +1 -0
- package/build/matrices/decompositions.spec.d.ts +2 -0
- package/build/matrices/decompositions.spec.d.ts.map +1 -0
- package/build/matrices/decompositions.spec.js +195 -0
- package/build/matrices/decompositions.spec.js.map +1 -0
- package/build/matrices/index.d.ts +9 -0
- package/build/matrices/index.d.ts.map +1 -0
- package/build/matrices/index.js +9 -0
- package/build/matrices/index.js.map +1 -0
- package/build/matrices/linear-algebra.d.ts +64 -0
- package/build/matrices/linear-algebra.d.ts.map +1 -0
- package/build/matrices/linear-algebra.js +253 -0
- package/build/matrices/linear-algebra.js.map +1 -0
- package/build/matrices/linear-algebra.spec.d.ts +2 -0
- package/build/matrices/linear-algebra.spec.d.ts.map +1 -0
- package/build/matrices/linear-algebra.spec.js +355 -0
- package/build/matrices/linear-algebra.spec.js.map +1 -0
- package/build/matrices/normalization.d.ts +62 -0
- package/build/matrices/normalization.d.ts.map +1 -0
- package/build/matrices/normalization.js +167 -0
- package/build/matrices/normalization.js.map +1 -0
- package/build/matrices/normalization.spec.d.ts +2 -0
- package/build/matrices/normalization.spec.d.ts.map +1 -0
- package/build/matrices/normalization.spec.js +335 -0
- package/build/matrices/normalization.spec.js.map +1 -0
- package/build/matrices/transformations.d.ts +484 -0
- package/build/matrices/transformations.d.ts.map +1 -0
- package/build/matrices/transformations.js +592 -0
- package/build/matrices/transformations.js.map +1 -0
- package/build/matrices/transformations.spec.d.ts +2 -0
- package/build/matrices/transformations.spec.d.ts.map +1 -0
- package/build/matrices/transformations.spec.js +755 -0
- package/build/matrices/transformations.spec.js.map +1 -0
- package/build/matrices/types.d.ts +134 -0
- package/build/matrices/types.d.ts.map +1 -0
- package/build/matrices/types.js +6 -0
- package/build/matrices/types.js.map +1 -0
- package/build/quaternions/asserts.d.ts +77 -0
- package/build/quaternions/asserts.d.ts.map +1 -0
- package/build/quaternions/asserts.js +175 -0
- package/build/quaternions/asserts.js.map +1 -0
- package/build/quaternions/asserts.spec.d.ts +2 -0
- package/build/quaternions/asserts.spec.d.ts.map +1 -0
- package/build/quaternions/asserts.spec.js +320 -0
- package/build/quaternions/asserts.spec.js.map +1 -0
- package/build/quaternions/conversions.d.ts +73 -0
- package/build/quaternions/conversions.d.ts.map +1 -0
- package/build/quaternions/conversions.js +179 -0
- package/build/quaternions/conversions.js.map +1 -0
- package/build/quaternions/conversions.spec.d.ts +2 -0
- package/build/quaternions/conversions.spec.d.ts.map +1 -0
- package/build/quaternions/conversions.spec.js +344 -0
- package/build/quaternions/conversions.spec.js.map +1 -0
- package/build/quaternions/core.d.ts +203 -0
- package/build/quaternions/core.d.ts.map +1 -0
- package/build/quaternions/core.js +374 -0
- package/build/quaternions/core.js.map +1 -0
- package/build/quaternions/core.spec.d.ts +2 -0
- package/build/quaternions/core.spec.d.ts.map +1 -0
- package/build/quaternions/core.spec.js +294 -0
- package/build/quaternions/core.spec.js.map +1 -0
- package/build/quaternions/index.d.ts +7 -0
- package/build/quaternions/index.d.ts.map +1 -0
- package/build/quaternions/index.js +7 -0
- package/build/quaternions/index.js.map +1 -0
- package/build/quaternions/interpolation.d.ts +54 -0
- package/build/quaternions/interpolation.d.ts.map +1 -0
- package/build/quaternions/interpolation.js +201 -0
- package/build/quaternions/interpolation.js.map +1 -0
- package/build/quaternions/interpolation.spec.d.ts +2 -0
- package/build/quaternions/interpolation.spec.d.ts.map +1 -0
- package/build/quaternions/interpolation.spec.js +64 -0
- package/build/quaternions/interpolation.spec.js.map +1 -0
- package/build/quaternions/predefined.d.ts +36 -0
- package/build/quaternions/predefined.d.ts.map +1 -0
- package/build/quaternions/predefined.js +42 -0
- package/build/quaternions/predefined.js.map +1 -0
- package/build/quaternions/predefined.spec.d.ts +2 -0
- package/build/quaternions/predefined.spec.d.ts.map +1 -0
- package/build/quaternions/predefined.spec.js +35 -0
- package/build/quaternions/predefined.spec.js.map +1 -0
- package/build/quaternions/types.d.ts +55 -0
- package/build/quaternions/types.d.ts.map +1 -0
- package/build/quaternions/types.js +7 -0
- package/build/quaternions/types.js.map +1 -0
- package/build/random.d.ts +66 -0
- package/build/random.d.ts.map +1 -0
- package/build/random.js +115 -0
- package/build/random.js.map +1 -0
- package/build/random.spec.d.ts +2 -0
- package/build/random.spec.d.ts.map +1 -0
- package/build/random.spec.js +267 -0
- package/build/random.spec.js.map +1 -0
- package/build/vectors/asserts.d.ts +182 -0
- package/build/vectors/asserts.d.ts.map +1 -0
- package/build/vectors/asserts.js +285 -0
- package/build/vectors/asserts.js.map +1 -0
- package/build/vectors/asserts.spec.d.ts +2 -0
- package/build/vectors/asserts.spec.d.ts.map +1 -0
- package/build/vectors/asserts.spec.js +260 -0
- package/build/vectors/asserts.spec.js.map +1 -0
- package/build/vectors/core.d.ts +507 -0
- package/build/vectors/core.d.ts.map +1 -0
- package/build/vectors/core.js +825 -0
- package/build/vectors/core.js.map +1 -0
- package/build/vectors/core.spec.d.ts +2 -0
- package/build/vectors/core.spec.d.ts.map +1 -0
- package/build/vectors/core.spec.js +343 -0
- package/build/vectors/core.spec.js.map +1 -0
- package/build/vectors/index.d.ts +6 -0
- package/build/vectors/index.d.ts.map +1 -0
- package/build/vectors/index.js +6 -0
- package/build/vectors/index.js.map +1 -0
- package/build/vectors/interpolation.d.ts +404 -0
- package/build/vectors/interpolation.d.ts.map +1 -0
- package/build/vectors/interpolation.js +585 -0
- package/build/vectors/interpolation.js.map +1 -0
- package/build/vectors/interpolation.spec.d.ts +2 -0
- package/build/vectors/interpolation.spec.d.ts.map +1 -0
- package/build/vectors/interpolation.spec.js +378 -0
- package/build/vectors/interpolation.spec.js.map +1 -0
- package/build/vectors/predefined.d.ts +191 -0
- package/build/vectors/predefined.d.ts.map +1 -0
- package/build/vectors/predefined.js +191 -0
- package/build/vectors/predefined.js.map +1 -0
- package/build/vectors/predefined.spec.d.ts +2 -0
- package/build/vectors/predefined.spec.d.ts.map +1 -0
- package/build/vectors/predefined.spec.js +333 -0
- package/build/vectors/predefined.spec.js.map +1 -0
- package/build/vectors/types.d.ts +62 -0
- package/build/vectors/types.d.ts.map +1 -0
- package/build/vectors/types.js +6 -0
- package/build/vectors/types.js.map +1 -0
- package/package.json +75 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { IMatrix, IMatrix1, IMatrix2, IMatrix3, IMatrix4, TMatrixResult } from './types.js';
|
|
2
|
+
export declare function MatrixCreate(): IMatrix1;
|
|
3
|
+
export declare function MatrixCreate(size: 1): IMatrix1;
|
|
4
|
+
export declare function MatrixCreate(size: 2): IMatrix2;
|
|
5
|
+
export declare function MatrixCreate(size: 3): IMatrix3;
|
|
6
|
+
export declare function MatrixCreate(size: 4): IMatrix4;
|
|
7
|
+
export declare function MatrixCreate(size: number): IMatrix;
|
|
8
|
+
export declare function MatrixCreate(rows: number, cols: number): IMatrix;
|
|
9
|
+
/**
|
|
10
|
+
* Returns the dimensions of a matrix as [rows, columns].
|
|
11
|
+
* @param matrix - The matrix to measure
|
|
12
|
+
* @returns {[number, number]} Tuple [rows, columns]. Returns [0, 0] for empty matrices.
|
|
13
|
+
* @throws {Error} If the input is not a valid matrix
|
|
14
|
+
* @example MatrixSize([[1, 2, 3], [4, 5, 6]]) // [2, 3]
|
|
15
|
+
*/
|
|
16
|
+
export declare function MatrixSize(matrix: IMatrix): [number, number];
|
|
17
|
+
/**
|
|
18
|
+
* Returns the size of a square matrix (number of rows/columns).
|
|
19
|
+
* @param matrix - The square matrix to measure
|
|
20
|
+
* @returns {number} The size (n for an n×n matrix)
|
|
21
|
+
* @throws {Error} If the matrix is not square
|
|
22
|
+
* @example MatrixSizeSquare([[1, 2], [3, 4]]) // 2
|
|
23
|
+
*/
|
|
24
|
+
export declare function MatrixSizeSquare(matrix: IMatrix): number;
|
|
25
|
+
/**
|
|
26
|
+
* Validates that the input is a well-formed matrix.
|
|
27
|
+
* @param matrix - The value to validate as a matrix
|
|
28
|
+
* @returns {boolean} True if the input is a valid matrix, false otherwise
|
|
29
|
+
* @example MatrixIsValid([[1, 2], [3, 4]]) // true
|
|
30
|
+
* @example MatrixIsValid([[1, 'invalid'], [3, 4]]) // false
|
|
31
|
+
*/
|
|
32
|
+
export declare function MatrixIsValid(matrix: unknown): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Checks if a matrix is square (equal number of rows and columns).
|
|
35
|
+
* @param matrix - The matrix to check
|
|
36
|
+
* @returns {boolean} True if the matrix is square, false otherwise
|
|
37
|
+
* @example MatrixIsSquare([[1, 2], [3, 4]]) // true (2×2)
|
|
38
|
+
* @example MatrixIsSquare([[1, 2, 3], [4, 5, 6]]) // false (3×2)
|
|
39
|
+
*/
|
|
40
|
+
export declare function MatrixIsSquare(matrix: IMatrix): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Checks if a matrix is a zero matrix (all elements are zero within tolerance).
|
|
43
|
+
* @param matrix - The matrix to check
|
|
44
|
+
* @param threshold - Tolerance for considering values as zero (default: 1e-14)
|
|
45
|
+
* @returns {boolean} True if all matrix elements are within threshold of zero
|
|
46
|
+
* @throws {Error} If the input is not a valid matrix
|
|
47
|
+
* @example MatrixIsZero([[0, 0], [0, 0]]) // true
|
|
48
|
+
* @example MatrixIsZero([[1e-15, 0], [0, 0]]) // true (within default threshold)
|
|
49
|
+
* @example MatrixIsZero([[0.1, 0], [0, 0]]) // false
|
|
50
|
+
*/
|
|
51
|
+
export declare function MatrixIsZero(matrix: IMatrix, threshold?: number): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Checks if a matrix is an identity matrix (1s on the main diagonal, 0s elsewhere).
|
|
54
|
+
* @param matrix - The matrix to check
|
|
55
|
+
* @param threshold - Tolerance for floating-point comparisons (default: 1e-14)
|
|
56
|
+
* @returns {boolean} True if the matrix is an identity matrix within tolerance
|
|
57
|
+
* @throws {Error} If the input is not a valid matrix
|
|
58
|
+
* @example MatrixIsIdentity([[1, 0], [0, 1]]) // true
|
|
59
|
+
* @example MatrixIsIdentity([[1, 0, 0], [0, 1, 0], [0, 0, 1]]) // true
|
|
60
|
+
* @example MatrixIsIdentity([[1, 1], [0, 1]]) // false
|
|
61
|
+
*/
|
|
62
|
+
export declare function MatrixIsIdentity(matrix: IMatrix, threshold?: number): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Checks if a matrix is symmetric (A = Aᵀ, i.e. A[i][j] === A[j][i] for all i, j).
|
|
65
|
+
* @param matrix - The matrix to check (must be square)
|
|
66
|
+
* @param threshold - Tolerance for floating-point comparisons (default: 1e-14)
|
|
67
|
+
* @returns {boolean} True if the matrix is symmetric within tolerance
|
|
68
|
+
* @throws {Error} If the input is not a valid matrix
|
|
69
|
+
* @example MatrixIsSymmetric([[1, 2], [2, 1]]) // true
|
|
70
|
+
* @example MatrixIsSymmetric([[1, 2], [3, 4]]) // false
|
|
71
|
+
* @example MatrixIsSymmetric([[1, 2, 3], [2, 5, 4], [3, 4, 6]]) // true
|
|
72
|
+
*/
|
|
73
|
+
export declare function MatrixIsSymmetric(matrix: IMatrix, threshold?: number): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Checks if a matrix is diagonal (all off-diagonal elements are zero within tolerance).
|
|
76
|
+
* A diagonal matrix has non-zero values only on its main diagonal.
|
|
77
|
+
* @param matrix - The matrix to check (must be square)
|
|
78
|
+
* @param threshold - Tolerance for considering values as zero (default: 1e-14)
|
|
79
|
+
* @returns {boolean} True if the matrix is diagonal within tolerance
|
|
80
|
+
* @throws {Error} If the input is not a valid matrix
|
|
81
|
+
* @example MatrixIsDiagonal([[3, 0], [0, 7]]) // true
|
|
82
|
+
* @example MatrixIsDiagonal([[1, 0, 0], [0, 5, 0], [0, 0, 2]]) // true
|
|
83
|
+
* @example MatrixIsDiagonal([[1, 2], [0, 1]]) // false
|
|
84
|
+
*/
|
|
85
|
+
export declare function MatrixIsDiagonal(matrix: IMatrix, threshold?: number): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Creates an identity matrix of the specified size.
|
|
88
|
+
* @param size - The dimensions of the square identity matrix (must be non-negative integer)
|
|
89
|
+
* @returns {IMatrix} A square identity matrix of size n×n
|
|
90
|
+
* @throws {Error} If size is negative or not an integer
|
|
91
|
+
* @example MatrixIdentity(2) // [[1, 0], [0, 1]]
|
|
92
|
+
* @example MatrixIdentity(3) // [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
|
|
93
|
+
*/
|
|
94
|
+
export declare function MatrixIdentity(size: 0): IMatrix;
|
|
95
|
+
export declare function MatrixIdentity(size: 1): IMatrix1;
|
|
96
|
+
export declare function MatrixIdentity(size: 2): IMatrix2;
|
|
97
|
+
export declare function MatrixIdentity(size: 3): IMatrix3;
|
|
98
|
+
export declare function MatrixIdentity(size: 4): IMatrix4;
|
|
99
|
+
export declare function MatrixIdentity(size: number): IMatrix;
|
|
100
|
+
/**
|
|
101
|
+
* Creates a deep copy of the given matrix.
|
|
102
|
+
* @param matrix - The matrix to clone (supports both IMatrix and IMatrixFlat formats)
|
|
103
|
+
* @returns {IMatrix | IMatrixFlat} A new matrix with identical values but independent memory allocation
|
|
104
|
+
* @throws {Error} If the input is not a valid matrix
|
|
105
|
+
* @example MatrixClone([[1, 2], [3, 4]]) // [[1, 2], [3, 4]] (independent copy)
|
|
106
|
+
* @example MatrixClone({data: Float64Array[1,2,3,4], rows: 2, columns: 2}) // New IMatrixFlat with copied data
|
|
107
|
+
*/
|
|
108
|
+
export declare function MatrixClone<T extends IMatrix>(matrix: T): TMatrixResult<T>;
|
|
109
|
+
/**
|
|
110
|
+
* Checks if two matrices are equal within a specified tolerance.
|
|
111
|
+
* @param a - First matrix to compare (supports both IMatrix and IMatrixFlat formats)
|
|
112
|
+
* @param b - Second matrix to compare (supports both IMatrix and IMatrixFlat formats)
|
|
113
|
+
* @param tolerance - Maximum allowed difference between corresponding elements (default: 1e-8)
|
|
114
|
+
* @returns {boolean} True if matrices are equal within tolerance, false otherwise
|
|
115
|
+
* @throws {Error} If either input is not a valid matrix or if matrix data is corrupted
|
|
116
|
+
* @example MatrixEquals([[1, 2]], [[1.0001, 2]], 0.001) // true
|
|
117
|
+
* @example MatrixEquals([[1, 2]], [[1, 3]]) // false
|
|
118
|
+
*/
|
|
119
|
+
export declare function MatrixEquals(a: IMatrix, b: IMatrix, tolerance?: number): boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Converts a matrix to a formatted string representation.
|
|
122
|
+
* @param matrix - The matrix to convert to string (supports both IMatrix and IMatrixFlat formats)
|
|
123
|
+
* @param precision - Number of decimal places for formatting (default: 2)
|
|
124
|
+
* @returns {string} A formatted string representation of the matrix
|
|
125
|
+
* @throws {Error} If the input is not a valid matrix
|
|
126
|
+
* @example MatrixToString([[1.23, 2.7]]) // "[ 1.23, 2.70 ]"
|
|
127
|
+
* @example MatrixToString([[1, 2], [3, 4]], 0) // "[ 1, 2 ]\n[ 3, 4 ]"
|
|
128
|
+
*/
|
|
129
|
+
export declare function MatrixToString(matrix: IMatrix, precision?: number): string;
|
|
130
|
+
/**
|
|
131
|
+
* Computes the rank of a matrix using Gaussian elimination.
|
|
132
|
+
* @param matrix - The input matrix (any dimensions, supports both IMatrix and IMatrixFlat formats)
|
|
133
|
+
* @param tolerance - Numerical tolerance for zero detection (default: 1e-10)
|
|
134
|
+
* @returns {number} The rank of the matrix (0 ≤ rank ≤ min(rows, columns))
|
|
135
|
+
* @throws {Error} If the matrix contains invalid values
|
|
136
|
+
* @example MatrixRank([[1, 2], [2, 4]]) // 1 (second row = 2 × first row)
|
|
137
|
+
* @example MatrixRank([[1, 0], [0, 1]]) // 2 (full rank)
|
|
138
|
+
*/
|
|
139
|
+
export declare function MatrixRank(matrix: IMatrix, tolerance?: number): number;
|
|
140
|
+
/**
|
|
141
|
+
* Computes the trace of a matrix (sum of main diagonal elements).
|
|
142
|
+
* @param matrix - The input matrix (can be square or rectangular, supports both IMatrix and IMatrixFlat formats)
|
|
143
|
+
* @returns {number} The trace value (sum of diagonal elements)
|
|
144
|
+
* @throws {Error} If the matrix contains invalid values
|
|
145
|
+
* @example MatrixTrace([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) // 15 (1 + 5 + 9)
|
|
146
|
+
* @example MatrixTrace([[1, 2], [3, 4], [5, 6]]) // 5 (1 + 4, rectangular matrix)
|
|
147
|
+
*/
|
|
148
|
+
export declare function MatrixTrace(matrix: IMatrix): number;
|
|
149
|
+
/**
|
|
150
|
+
* Returns the transpose of a matrix (rows become columns and vice versa).
|
|
151
|
+
* @param matrix - The matrix to transpose (can be any m×n matrix, supports both IMatrix and IMatrixFlat formats)
|
|
152
|
+
* @returns {IMatrix | IMatrixFlat} The transposed matrix with dimensions n×m (same format as input)
|
|
153
|
+
* @throws {Error} If the input is not a valid matrix
|
|
154
|
+
* @example MatrixTranspose([[1, 2, 3], [4, 5, 6]]) // [[1, 4], [2, 5], [3, 6]]
|
|
155
|
+
* @example MatrixTranspose([[1, 2], [3, 4]]) // [[1, 3], [2, 4]]
|
|
156
|
+
*/
|
|
157
|
+
export declare function MatrixTranspose<T extends IMatrix>(matrix: T): TMatrixResult<T>;
|
|
158
|
+
/**
|
|
159
|
+
* Applies a transformation function to each element of the matrix.
|
|
160
|
+
* @param matrix - The input matrix to transform (supports both IMatrix and IMatrixFlat formats)
|
|
161
|
+
* @param fn - Transformation function: (value, row, col) => transformedValue
|
|
162
|
+
* @returns {IMatrix | IMatrixFlat} A new matrix with transformed values (same dimensions and format as input)
|
|
163
|
+
* @throws {Error} If the input matrix is invalid or transformation function throws
|
|
164
|
+
* @example MatrixMap([[1, 2], [3, 4]], (value) => value * value) // [[1, 4], [9, 16]]
|
|
165
|
+
* @example MatrixMap([[1, 2], [3, 4]], (value, row, col) => value + row + col) // [[1, 3], [4, 6]]
|
|
166
|
+
*/
|
|
167
|
+
export declare function MatrixMap<T extends IMatrix>(matrix: T, fn: (value: number, row: number, col: number) => number): TMatrixResult<T>;
|
|
168
|
+
//# sourceMappingURL=core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/matrices/core.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAI5F,wBAAgB,YAAY,IAAI,QAAQ,CAAC;AAEzC,wBAAgB,YAAY,CAAC,IAAI,EAAE,CAAC,GAAG,QAAQ,CAAC;AAEhD,wBAAgB,YAAY,CAAC,IAAI,EAAE,CAAC,GAAG,QAAQ,CAAC;AAEhD,wBAAgB,YAAY,CAAC,IAAI,EAAE,CAAC,GAAG,QAAQ,CAAC;AAEhD,wBAAgB,YAAY,CAAC,IAAI,EAAE,CAAC,GAAG,QAAQ,CAAC;AAEhD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;AAEpD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;AA4DlE;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAS5D;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAKxD;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,OAAO,GA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AC,MAAM,EAAE,OAAO,EAAE,SAAS,GAAE,MAAU,GAAG,MAAM,CAW7E;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,GAAE,MAAc,GAAG,MAAM,CAiE7E;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAmBnD;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,OAAO,EAAE,MAAM,EAAE,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CA4B9E;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC,CAqBjI"}
|
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
import { AssertNumber } from '@pawells/typescript-common';
|
|
2
|
+
import { AssertMatrix, AssertMatrixRow, AssertMatrixValue } from './asserts.js';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a matrix with specified dimensions, initialized with zeros.
|
|
5
|
+
* @param rows - Number of rows (non-negative integer). If only this parameter is provided, creates a square matrix.
|
|
6
|
+
* @param cols - Number of columns (non-negative integer). Optional for square matrices.
|
|
7
|
+
* @returns {IMatrix | IMatrix1 | IMatrix2 | IMatrix3 | IMatrix4} Zero-filled matrix with specified dimensions
|
|
8
|
+
* @throws {Error} If rows or cols are negative or not integers
|
|
9
|
+
* @example MatrixCreate() // [[0]] (1x1 matrix)
|
|
10
|
+
* @example MatrixCreate(2) // [[0, 0], [0, 0]] (2x2 matrix)
|
|
11
|
+
* @example MatrixCreate(2, 3) // [[0, 0, 0], [0, 0, 0]] (2x3 matrix)
|
|
12
|
+
*/
|
|
13
|
+
export function MatrixCreate(rows, cols) {
|
|
14
|
+
// Handle no parameters - default to 1x1
|
|
15
|
+
if (rows === undefined) {
|
|
16
|
+
return [[0]];
|
|
17
|
+
}
|
|
18
|
+
// Handle single parameter - create square matrix
|
|
19
|
+
if (cols === undefined) {
|
|
20
|
+
// Return specific types for common square matrices
|
|
21
|
+
switch (rows) {
|
|
22
|
+
case 1:
|
|
23
|
+
return [[0]];
|
|
24
|
+
case 2:
|
|
25
|
+
return [
|
|
26
|
+
[0, 0],
|
|
27
|
+
[0, 0],
|
|
28
|
+
];
|
|
29
|
+
case 3:
|
|
30
|
+
return [
|
|
31
|
+
[0, 0, 0],
|
|
32
|
+
[0, 0, 0],
|
|
33
|
+
[0, 0, 0],
|
|
34
|
+
];
|
|
35
|
+
case 4:
|
|
36
|
+
return [
|
|
37
|
+
[0, 0, 0, 0],
|
|
38
|
+
[0, 0, 0, 0],
|
|
39
|
+
[0, 0, 0, 0],
|
|
40
|
+
[0, 0, 0, 0],
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// Validate parameters
|
|
45
|
+
const effectiveCols = cols ?? rows;
|
|
46
|
+
AssertNumber(rows, { integer: true, gte: 0 }, { message: 'Rows must be a non-negative integer' });
|
|
47
|
+
AssertNumber(effectiveCols, { integer: true, gte: 0 }, { message: 'Columns must be a non-negative integer' });
|
|
48
|
+
const result = [];
|
|
49
|
+
// Create each row filled with zeros
|
|
50
|
+
for (let i = 0; i < rows; i++) {
|
|
51
|
+
result.push(new Array(effectiveCols).fill(0));
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Returns the dimensions of a matrix as [rows, columns].
|
|
57
|
+
* @param matrix - The matrix to measure
|
|
58
|
+
* @returns {[number, number]} Tuple [rows, columns]. Returns [0, 0] for empty matrices.
|
|
59
|
+
* @throws {Error} If the input is not a valid matrix
|
|
60
|
+
* @example MatrixSize([[1, 2, 3], [4, 5, 6]]) // [2, 3]
|
|
61
|
+
*/
|
|
62
|
+
export function MatrixSize(matrix) {
|
|
63
|
+
// Basic validation without calling AssertMatrix to avoid circular dependency
|
|
64
|
+
if (!Array.isArray(matrix)) {
|
|
65
|
+
throw new Error('Input must be an array');
|
|
66
|
+
}
|
|
67
|
+
// Handle empty matrix or matrix with no columns
|
|
68
|
+
if (matrix.length === 0 || !Array.isArray(matrix[0]))
|
|
69
|
+
return [0, 0];
|
|
70
|
+
return [matrix.length, matrix[0]?.length ?? 0];
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Returns the size of a square matrix (number of rows/columns).
|
|
74
|
+
* @param matrix - The square matrix to measure
|
|
75
|
+
* @returns {number} The size (n for an n×n matrix)
|
|
76
|
+
* @throws {Error} If the matrix is not square
|
|
77
|
+
* @example MatrixSizeSquare([[1, 2], [3, 4]]) // 2
|
|
78
|
+
*/
|
|
79
|
+
export function MatrixSizeSquare(matrix) {
|
|
80
|
+
AssertMatrix(matrix, { square: true });
|
|
81
|
+
const [rows] = MatrixSize(matrix);
|
|
82
|
+
return rows;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Validates that the input is a well-formed matrix.
|
|
86
|
+
* @param matrix - The value to validate as a matrix
|
|
87
|
+
* @returns {boolean} True if the input is a valid matrix, false otherwise
|
|
88
|
+
* @example MatrixIsValid([[1, 2], [3, 4]]) // true
|
|
89
|
+
* @example MatrixIsValid([[1, 'invalid'], [3, 4]]) // false
|
|
90
|
+
*/
|
|
91
|
+
export function MatrixIsValid(matrix) {
|
|
92
|
+
try {
|
|
93
|
+
AssertMatrix(matrix);
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Checks if a matrix is square (equal number of rows and columns).
|
|
102
|
+
* @param matrix - The matrix to check
|
|
103
|
+
* @returns {boolean} True if the matrix is square, false otherwise
|
|
104
|
+
* @example MatrixIsSquare([[1, 2], [3, 4]]) // true (2×2)
|
|
105
|
+
* @example MatrixIsSquare([[1, 2, 3], [4, 5, 6]]) // false (3×2)
|
|
106
|
+
*/
|
|
107
|
+
export function MatrixIsSquare(matrix) {
|
|
108
|
+
try {
|
|
109
|
+
MatrixSizeSquare(matrix);
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Checks if a matrix is a zero matrix (all elements are zero within tolerance).
|
|
118
|
+
* @param matrix - The matrix to check
|
|
119
|
+
* @param threshold - Tolerance for considering values as zero (default: 1e-14)
|
|
120
|
+
* @returns {boolean} True if all matrix elements are within threshold of zero
|
|
121
|
+
* @throws {Error} If the input is not a valid matrix
|
|
122
|
+
* @example MatrixIsZero([[0, 0], [0, 0]]) // true
|
|
123
|
+
* @example MatrixIsZero([[1e-15, 0], [0, 0]]) // true (within default threshold)
|
|
124
|
+
* @example MatrixIsZero([[0.1, 0], [0, 0]]) // false
|
|
125
|
+
*/
|
|
126
|
+
export function MatrixIsZero(matrix, threshold = 1e-14) {
|
|
127
|
+
AssertMatrix(matrix);
|
|
128
|
+
const [rows, cols] = MatrixSize(matrix);
|
|
129
|
+
if (rows === 0 || cols === 0)
|
|
130
|
+
return true; // Empty matrix is considered zero
|
|
131
|
+
for (let row = 0; row < rows; row++) {
|
|
132
|
+
const matrixRow = matrix[row];
|
|
133
|
+
AssertMatrixRow(matrixRow, { rowIndex: row });
|
|
134
|
+
for (let col = 0; col < cols; col++) {
|
|
135
|
+
const value = matrixRow[col];
|
|
136
|
+
AssertMatrixValue(value, { rowIndex: row, columnIndex: col });
|
|
137
|
+
if (Math.abs(value) > threshold) {
|
|
138
|
+
return false; // Found a non-zero value
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return true; // All values are within the threshold
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Checks if a matrix is an identity matrix (1s on the main diagonal, 0s elsewhere).
|
|
146
|
+
* @param matrix - The matrix to check
|
|
147
|
+
* @param threshold - Tolerance for floating-point comparisons (default: 1e-14)
|
|
148
|
+
* @returns {boolean} True if the matrix is an identity matrix within tolerance
|
|
149
|
+
* @throws {Error} If the input is not a valid matrix
|
|
150
|
+
* @example MatrixIsIdentity([[1, 0], [0, 1]]) // true
|
|
151
|
+
* @example MatrixIsIdentity([[1, 0, 0], [0, 1, 0], [0, 0, 1]]) // true
|
|
152
|
+
* @example MatrixIsIdentity([[1, 1], [0, 1]]) // false
|
|
153
|
+
*/
|
|
154
|
+
export function MatrixIsIdentity(matrix, threshold = 1e-14) {
|
|
155
|
+
AssertMatrix(matrix);
|
|
156
|
+
const [rows, cols] = MatrixSize(matrix);
|
|
157
|
+
if (rows !== cols)
|
|
158
|
+
return false; // Identity must be square
|
|
159
|
+
for (let row = 0; row < rows; row++) {
|
|
160
|
+
const matrixRow = matrix[row];
|
|
161
|
+
AssertMatrixRow(matrixRow, { rowIndex: row });
|
|
162
|
+
for (let col = 0; col < cols; col++) {
|
|
163
|
+
const value = matrixRow[col];
|
|
164
|
+
AssertMatrixValue(value, { rowIndex: row, columnIndex: col });
|
|
165
|
+
const expected = row === col ? 1 : 0;
|
|
166
|
+
if (Math.abs(value - expected) > threshold)
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Checks if a matrix is symmetric (A = Aᵀ, i.e. A[i][j] === A[j][i] for all i, j).
|
|
174
|
+
* @param matrix - The matrix to check (must be square)
|
|
175
|
+
* @param threshold - Tolerance for floating-point comparisons (default: 1e-14)
|
|
176
|
+
* @returns {boolean} True if the matrix is symmetric within tolerance
|
|
177
|
+
* @throws {Error} If the input is not a valid matrix
|
|
178
|
+
* @example MatrixIsSymmetric([[1, 2], [2, 1]]) // true
|
|
179
|
+
* @example MatrixIsSymmetric([[1, 2], [3, 4]]) // false
|
|
180
|
+
* @example MatrixIsSymmetric([[1, 2, 3], [2, 5, 4], [3, 4, 6]]) // true
|
|
181
|
+
*/
|
|
182
|
+
export function MatrixIsSymmetric(matrix, threshold = 1e-14) {
|
|
183
|
+
AssertMatrix(matrix);
|
|
184
|
+
const [rows, cols] = MatrixSize(matrix);
|
|
185
|
+
if (rows !== cols)
|
|
186
|
+
return false; // Symmetry requires a square matrix
|
|
187
|
+
for (let row = 0; row < rows; row++) {
|
|
188
|
+
const matrixRow = matrix[row];
|
|
189
|
+
AssertMatrixRow(matrixRow, { rowIndex: row });
|
|
190
|
+
for (let col = row + 1; col < cols; col++) {
|
|
191
|
+
const upper = matrixRow[col];
|
|
192
|
+
AssertMatrixValue(upper, { rowIndex: row, columnIndex: col });
|
|
193
|
+
const lowerRow = matrix[col];
|
|
194
|
+
AssertMatrixRow(lowerRow, { rowIndex: col });
|
|
195
|
+
const lower = lowerRow[row];
|
|
196
|
+
AssertMatrixValue(lower, { rowIndex: col, columnIndex: row });
|
|
197
|
+
if (Math.abs(upper - lower) > threshold)
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Checks if a matrix is diagonal (all off-diagonal elements are zero within tolerance).
|
|
205
|
+
* A diagonal matrix has non-zero values only on its main diagonal.
|
|
206
|
+
* @param matrix - The matrix to check (must be square)
|
|
207
|
+
* @param threshold - Tolerance for considering values as zero (default: 1e-14)
|
|
208
|
+
* @returns {boolean} True if the matrix is diagonal within tolerance
|
|
209
|
+
* @throws {Error} If the input is not a valid matrix
|
|
210
|
+
* @example MatrixIsDiagonal([[3, 0], [0, 7]]) // true
|
|
211
|
+
* @example MatrixIsDiagonal([[1, 0, 0], [0, 5, 0], [0, 0, 2]]) // true
|
|
212
|
+
* @example MatrixIsDiagonal([[1, 2], [0, 1]]) // false
|
|
213
|
+
*/
|
|
214
|
+
export function MatrixIsDiagonal(matrix, threshold = 1e-14) {
|
|
215
|
+
AssertMatrix(matrix);
|
|
216
|
+
const [rows, cols] = MatrixSize(matrix);
|
|
217
|
+
if (rows !== cols)
|
|
218
|
+
return false; // Diagonality requires a square matrix
|
|
219
|
+
for (let row = 0; row < rows; row++) {
|
|
220
|
+
const matrixRow = matrix[row];
|
|
221
|
+
AssertMatrixRow(matrixRow, { rowIndex: row });
|
|
222
|
+
for (let col = 0; col < cols; col++) {
|
|
223
|
+
if (row === col)
|
|
224
|
+
continue; // Skip diagonal elements
|
|
225
|
+
const value = matrixRow[col];
|
|
226
|
+
AssertMatrixValue(value, { rowIndex: row, columnIndex: col });
|
|
227
|
+
if (Math.abs(value) > threshold)
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return true;
|
|
232
|
+
}
|
|
233
|
+
export function MatrixIdentity(size) {
|
|
234
|
+
AssertNumber(size, { integer: true, gte: 0 }, { message: 'Size must be a non-negative integer' });
|
|
235
|
+
const result = MatrixCreate(size, size);
|
|
236
|
+
// Set diagonal elements to 1
|
|
237
|
+
for (let i = 0; i < size; i++) {
|
|
238
|
+
const row = result[i];
|
|
239
|
+
AssertMatrixRow(row, { rowIndex: i });
|
|
240
|
+
row[i] = 1;
|
|
241
|
+
}
|
|
242
|
+
return result;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Creates a deep copy of the given matrix.
|
|
246
|
+
* @param matrix - The matrix to clone (supports both IMatrix and IMatrixFlat formats)
|
|
247
|
+
* @returns {IMatrix | IMatrixFlat} A new matrix with identical values but independent memory allocation
|
|
248
|
+
* @throws {Error} If the input is not a valid matrix
|
|
249
|
+
* @example MatrixClone([[1, 2], [3, 4]]) // [[1, 2], [3, 4]] (independent copy)
|
|
250
|
+
* @example MatrixClone({data: Float64Array[1,2,3,4], rows: 2, columns: 2}) // New IMatrixFlat with copied data
|
|
251
|
+
*/
|
|
252
|
+
export function MatrixClone(matrix) {
|
|
253
|
+
AssertMatrix(matrix);
|
|
254
|
+
// Create a deep copy by mapping each row to a new array
|
|
255
|
+
return matrix.map((row) => [...row]);
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Checks if two matrices are equal within a specified tolerance.
|
|
259
|
+
* @param a - First matrix to compare (supports both IMatrix and IMatrixFlat formats)
|
|
260
|
+
* @param b - Second matrix to compare (supports both IMatrix and IMatrixFlat formats)
|
|
261
|
+
* @param tolerance - Maximum allowed difference between corresponding elements (default: 1e-8)
|
|
262
|
+
* @returns {boolean} True if matrices are equal within tolerance, false otherwise
|
|
263
|
+
* @throws {Error} If either input is not a valid matrix or if matrix data is corrupted
|
|
264
|
+
* @example MatrixEquals([[1, 2]], [[1.0001, 2]], 0.001) // true
|
|
265
|
+
* @example MatrixEquals([[1, 2]], [[1, 3]]) // false
|
|
266
|
+
*/
|
|
267
|
+
export function MatrixEquals(a, b, tolerance = 1e-8) {
|
|
268
|
+
AssertMatrix(a);
|
|
269
|
+
AssertMatrix(b);
|
|
270
|
+
AssertNumber(tolerance, { gte: 0 }, { message: 'Tolerance must be a non-negative number' });
|
|
271
|
+
const [rowsA, colsA] = MatrixSize(a);
|
|
272
|
+
const [rowsB, colsB] = MatrixSize(b);
|
|
273
|
+
if (rowsA !== rowsB || colsA !== colsB) {
|
|
274
|
+
return false;
|
|
275
|
+
}
|
|
276
|
+
for (let row = 0; row < rowsA; row++) {
|
|
277
|
+
const rowA = a[row];
|
|
278
|
+
const rowB = b[row];
|
|
279
|
+
AssertMatrixRow(rowA, { rowIndex: row });
|
|
280
|
+
AssertMatrixRow(rowB, { rowIndex: row });
|
|
281
|
+
for (let col = 0; col < colsA; col++) {
|
|
282
|
+
const valA = rowA[col];
|
|
283
|
+
const valB = rowB[col];
|
|
284
|
+
AssertMatrixValue(valA, { rowIndex: row, columnIndex: col });
|
|
285
|
+
AssertMatrixValue(valB, { rowIndex: row, columnIndex: col });
|
|
286
|
+
if (Math.abs(valA - valB) > tolerance) {
|
|
287
|
+
return false;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return true;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Converts a matrix to a formatted string representation.
|
|
295
|
+
* @param matrix - The matrix to convert to string (supports both IMatrix and IMatrixFlat formats)
|
|
296
|
+
* @param precision - Number of decimal places for formatting (default: 2)
|
|
297
|
+
* @returns {string} A formatted string representation of the matrix
|
|
298
|
+
* @throws {Error} If the input is not a valid matrix
|
|
299
|
+
* @example MatrixToString([[1.23, 2.7]]) // "[ 1.23, 2.70 ]"
|
|
300
|
+
* @example MatrixToString([[1, 2], [3, 4]], 0) // "[ 1, 2 ]\n[ 3, 4 ]"
|
|
301
|
+
*/
|
|
302
|
+
export function MatrixToString(matrix, precision = 2) {
|
|
303
|
+
AssertMatrix(matrix);
|
|
304
|
+
AssertNumber(precision, { integer: true, gte: 0 }, { message: 'Precision must be a non-negative integer' });
|
|
305
|
+
return matrix
|
|
306
|
+
.map((row) => '[ ' + row
|
|
307
|
+
.map((val) => {
|
|
308
|
+
return typeof val === 'number' ? val.toFixed(precision) : String(val);
|
|
309
|
+
})
|
|
310
|
+
.join(', ') + ' ]')
|
|
311
|
+
.join('\n');
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Computes the rank of a matrix using Gaussian elimination.
|
|
315
|
+
* @param matrix - The input matrix (any dimensions, supports both IMatrix and IMatrixFlat formats)
|
|
316
|
+
* @param tolerance - Numerical tolerance for zero detection (default: 1e-10)
|
|
317
|
+
* @returns {number} The rank of the matrix (0 ≤ rank ≤ min(rows, columns))
|
|
318
|
+
* @throws {Error} If the matrix contains invalid values
|
|
319
|
+
* @example MatrixRank([[1, 2], [2, 4]]) // 1 (second row = 2 × first row)
|
|
320
|
+
* @example MatrixRank([[1, 0], [0, 1]]) // 2 (full rank)
|
|
321
|
+
*/
|
|
322
|
+
export function MatrixRank(matrix, tolerance = 1e-10) {
|
|
323
|
+
AssertMatrix(matrix);
|
|
324
|
+
AssertNumber(tolerance, { gte: 0 }, { message: 'Tolerance must be a non-negative number' });
|
|
325
|
+
const [rows, cols] = MatrixSize(matrix);
|
|
326
|
+
if (rows === 0 || cols === 0)
|
|
327
|
+
return 0;
|
|
328
|
+
// Make a deep copy to avoid mutating the input
|
|
329
|
+
const mat = matrix.map((row) => [...row]);
|
|
330
|
+
let rank = 0;
|
|
331
|
+
const rowUsed = new Array(rows).fill(false);
|
|
332
|
+
for (let col = 0; col < cols; col++) {
|
|
333
|
+
let pivotRow = -1;
|
|
334
|
+
for (let row = 0; row < rows; row++) {
|
|
335
|
+
const matrixRow = mat[row];
|
|
336
|
+
AssertMatrixRow(matrixRow, { rowIndex: row });
|
|
337
|
+
const value = matrixRow[col];
|
|
338
|
+
AssertMatrixValue(value, { rowIndex: row, columnIndex: col });
|
|
339
|
+
if (!rowUsed[row] && Math.abs(value) > tolerance) {
|
|
340
|
+
pivotRow = row;
|
|
341
|
+
break;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
if (pivotRow === -1)
|
|
345
|
+
continue;
|
|
346
|
+
rowUsed[pivotRow] = true;
|
|
347
|
+
rank++;
|
|
348
|
+
// Eliminate this column in all other rows
|
|
349
|
+
for (let row = 0; row < rows; row++) {
|
|
350
|
+
if (row !== pivotRow) {
|
|
351
|
+
const currentRow = mat[row];
|
|
352
|
+
const pivotRowData = mat[pivotRow];
|
|
353
|
+
AssertMatrixRow(currentRow, { rowIndex: row });
|
|
354
|
+
AssertMatrixRow(pivotRowData, { rowIndex: pivotRow });
|
|
355
|
+
const pivotValue = pivotRowData[col];
|
|
356
|
+
const currentValue = currentRow[col];
|
|
357
|
+
AssertMatrixValue(pivotValue, { rowIndex: pivotRow, columnIndex: col });
|
|
358
|
+
AssertMatrixValue(currentValue, { rowIndex: row, columnIndex: col });
|
|
359
|
+
const factor = currentValue / pivotValue;
|
|
360
|
+
for (let k = col; k < cols; k++) {
|
|
361
|
+
const pivotK = pivotRowData[k];
|
|
362
|
+
const currentK = currentRow[k];
|
|
363
|
+
AssertMatrixValue(pivotK, { rowIndex: pivotRow, columnIndex: k });
|
|
364
|
+
AssertMatrixValue(currentK, { rowIndex: row, columnIndex: k });
|
|
365
|
+
currentRow[k] = currentK - (factor * pivotK);
|
|
366
|
+
const updatedValue = currentRow[k];
|
|
367
|
+
AssertMatrixValue(updatedValue, { rowIndex: row, columnIndex: k });
|
|
368
|
+
if (Math.abs(updatedValue) < tolerance) {
|
|
369
|
+
currentRow[k] = 0;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
return rank;
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Computes the trace of a matrix (sum of main diagonal elements).
|
|
379
|
+
* @param matrix - The input matrix (can be square or rectangular, supports both IMatrix and IMatrixFlat formats)
|
|
380
|
+
* @returns {number} The trace value (sum of diagonal elements)
|
|
381
|
+
* @throws {Error} If the matrix contains invalid values
|
|
382
|
+
* @example MatrixTrace([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) // 15 (1 + 5 + 9)
|
|
383
|
+
* @example MatrixTrace([[1, 2], [3, 4], [5, 6]]) // 5 (1 + 4, rectangular matrix)
|
|
384
|
+
*/
|
|
385
|
+
export function MatrixTrace(matrix) {
|
|
386
|
+
AssertMatrix(matrix);
|
|
387
|
+
const [rows, cols] = MatrixSize(matrix);
|
|
388
|
+
let trace = 0;
|
|
389
|
+
// The trace is the sum of the diagonal elements (i.e., elements where row === col)
|
|
390
|
+
const n = Math.min(rows, cols);
|
|
391
|
+
for (let i = 0; i < n; i++) {
|
|
392
|
+
const row = matrix[i];
|
|
393
|
+
AssertMatrixRow(row, { rowIndex: i });
|
|
394
|
+
const val = row[i];
|
|
395
|
+
AssertMatrixValue(val, { rowIndex: i, columnIndex: i });
|
|
396
|
+
trace += val;
|
|
397
|
+
}
|
|
398
|
+
return trace;
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Returns the transpose of a matrix (rows become columns and vice versa).
|
|
402
|
+
* @param matrix - The matrix to transpose (can be any m×n matrix, supports both IMatrix and IMatrixFlat formats)
|
|
403
|
+
* @returns {IMatrix | IMatrixFlat} The transposed matrix with dimensions n×m (same format as input)
|
|
404
|
+
* @throws {Error} If the input is not a valid matrix
|
|
405
|
+
* @example MatrixTranspose([[1, 2, 3], [4, 5, 6]]) // [[1, 4], [2, 5], [3, 6]]
|
|
406
|
+
* @example MatrixTranspose([[1, 2], [3, 4]]) // [[1, 3], [2, 4]]
|
|
407
|
+
*/
|
|
408
|
+
export function MatrixTranspose(matrix) {
|
|
409
|
+
AssertMatrix(matrix);
|
|
410
|
+
const [rows, cols] = MatrixSize(matrix);
|
|
411
|
+
// Note: result dimensions are swapped (columns become rows)
|
|
412
|
+
const result = [];
|
|
413
|
+
// Initialize result matrix with swapped dimensions
|
|
414
|
+
for (let i = 0; i < cols; i++) {
|
|
415
|
+
result.push(new Array(rows).fill(0));
|
|
416
|
+
}
|
|
417
|
+
for (let row = 0; row < rows; row++) {
|
|
418
|
+
const matrixRow = matrix[row];
|
|
419
|
+
AssertMatrixRow(matrixRow, { rowIndex: row });
|
|
420
|
+
for (let col = 0; col < cols; col++) {
|
|
421
|
+
const val = matrixRow[col];
|
|
422
|
+
AssertMatrixValue(val, { rowIndex: row, columnIndex: col });
|
|
423
|
+
// Swap row and column indices in the result
|
|
424
|
+
const resultCol = result[col];
|
|
425
|
+
AssertMatrixRow(resultCol, { rowIndex: col });
|
|
426
|
+
resultCol[row] = val;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
return result;
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Applies a transformation function to each element of the matrix.
|
|
433
|
+
* @param matrix - The input matrix to transform (supports both IMatrix and IMatrixFlat formats)
|
|
434
|
+
* @param fn - Transformation function: (value, row, col) => transformedValue
|
|
435
|
+
* @returns {IMatrix | IMatrixFlat} A new matrix with transformed values (same dimensions and format as input)
|
|
436
|
+
* @throws {Error} If the input matrix is invalid or transformation function throws
|
|
437
|
+
* @example MatrixMap([[1, 2], [3, 4]], (value) => value * value) // [[1, 4], [9, 16]]
|
|
438
|
+
* @example MatrixMap([[1, 2], [3, 4]], (value, row, col) => value + row + col) // [[1, 3], [4, 6]]
|
|
439
|
+
*/
|
|
440
|
+
export function MatrixMap(matrix, fn) {
|
|
441
|
+
AssertMatrix(matrix);
|
|
442
|
+
const [rows, cols] = MatrixSize(matrix);
|
|
443
|
+
const result = [];
|
|
444
|
+
for (let row = 0; row < rows; row++) {
|
|
445
|
+
const matrixRow = matrix[row];
|
|
446
|
+
AssertMatrixRow(matrixRow, { rowIndex: row });
|
|
447
|
+
const newRow = [];
|
|
448
|
+
for (let col = 0; col < cols; col++) {
|
|
449
|
+
const val = matrixRow[col];
|
|
450
|
+
AssertMatrixValue(val, { rowIndex: row, columnIndex: col });
|
|
451
|
+
newRow.push(fn(val, row, col));
|
|
452
|
+
}
|
|
453
|
+
result.push(newRow);
|
|
454
|
+
}
|
|
455
|
+
return result;
|
|
456
|
+
}
|
|
457
|
+
//# sourceMappingURL=core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/matrices/core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAmBhF;;;;;;;;;GASG;AACH,MAAM,UAAU,YAAY,CAAC,IAAa,EAAE,IAAa;IACxD,wCAAwC;IACxC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,CAAC,CAAC,CAAC,CAAC,CAAa,CAAC;IAC1B,CAAC;IAED,iDAAiD;IACjD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACxB,mDAAmD;QACnD,QAAQ,IAAI,EAAE,CAAC;YACd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