@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.
- package/build/angles.d.ts +28 -18
- package/build/angles.d.ts.map +1 -1
- package/build/angles.js +28 -18
- package/build/angles.js.map +1 -1
- package/build/clamp.d.ts +5 -3
- package/build/clamp.d.ts.map +1 -1
- package/build/clamp.js +5 -3
- package/build/clamp.js.map +1 -1
- package/build/interpolation.d.ts +158 -96
- package/build/interpolation.d.ts.map +1 -1
- package/build/interpolation.js +158 -96
- package/build/interpolation.js.map +1 -1
- package/build/matrices/_exports.d.ts +13 -0
- package/build/matrices/_exports.d.ts.map +1 -0
- package/build/matrices/_exports.js +13 -0
- package/build/matrices/_exports.js.map +1 -0
- package/build/matrices/arithmetic.d.ts +170 -181
- package/build/matrices/arithmetic.d.ts.map +1 -1
- package/build/matrices/arithmetic.js +192 -202
- package/build/matrices/arithmetic.js.map +1 -1
- package/build/matrices/asserts.d.ts +240 -109
- package/build/matrices/asserts.d.ts.map +1 -1
- package/build/matrices/asserts.js +287 -87
- package/build/matrices/asserts.js.map +1 -1
- package/build/matrices/core.d.ts +29 -29
- package/build/matrices/core.js +1 -1
- package/build/matrices/decompositions.d.ts +102 -104
- package/build/matrices/decompositions.d.ts.map +1 -1
- package/build/matrices/decompositions.js +87 -89
- package/build/matrices/decompositions.js.map +1 -1
- package/build/matrices/index.d.ts +3 -2
- package/build/matrices/index.d.ts.map +1 -1
- package/build/matrices/index.js +5 -2
- package/build/matrices/index.js.map +1 -1
- package/build/matrices/linear-algebra.d.ts +12 -12
- package/build/matrices/linear-algebra.js +4 -4
- package/build/matrices/normalization.d.ts +8 -8
- package/build/matrices/transformations.d.ts +184 -165
- package/build/matrices/transformations.d.ts.map +1 -1
- package/build/matrices/transformations.js +99 -80
- package/build/matrices/transformations.js.map +1 -1
- package/build/matrices/types.d.ts +12 -12
- package/build/matrices/types.d.ts.map +1 -1
- package/build/quaternions/_exports.d.ts +11 -0
- package/build/quaternions/_exports.d.ts.map +1 -0
- package/build/quaternions/_exports.js +11 -0
- package/build/quaternions/_exports.js.map +1 -0
- package/build/quaternions/asserts.d.ts +115 -7
- package/build/quaternions/asserts.d.ts.map +1 -1
- package/build/quaternions/asserts.js +162 -8
- package/build/quaternions/asserts.js.map +1 -1
- package/build/quaternions/conversions.d.ts +31 -21
- package/build/quaternions/conversions.d.ts.map +1 -1
- package/build/quaternions/conversions.js +28 -18
- package/build/quaternions/conversions.js.map +1 -1
- package/build/quaternions/core.d.ts +67 -39
- package/build/quaternions/core.d.ts.map +1 -1
- package/build/quaternions/core.js +67 -39
- package/build/quaternions/core.js.map +1 -1
- package/build/quaternions/index.d.ts +3 -2
- package/build/quaternions/index.d.ts.map +1 -1
- package/build/quaternions/index.js +5 -2
- package/build/quaternions/index.js.map +1 -1
- package/build/quaternions/interpolation.d.ts +15 -9
- package/build/quaternions/interpolation.d.ts.map +1 -1
- package/build/quaternions/interpolation.js +15 -9
- package/build/quaternions/interpolation.js.map +1 -1
- package/build/quaternions/predefined.d.ts +9 -3
- package/build/quaternions/predefined.d.ts.map +1 -1
- package/build/quaternions/predefined.js +9 -3
- package/build/quaternions/predefined.js.map +1 -1
- package/build/quaternions/types.d.ts +3 -3
- package/build/vectors/_exports.d.ts +10 -0
- package/build/vectors/_exports.d.ts.map +1 -0
- package/build/vectors/_exports.js +10 -0
- package/build/vectors/_exports.js.map +1 -0
- package/build/vectors/asserts.d.ts +153 -49
- package/build/vectors/asserts.d.ts.map +1 -1
- package/build/vectors/asserts.js +202 -52
- package/build/vectors/asserts.js.map +1 -1
- package/build/vectors/core.d.ts +216 -137
- package/build/vectors/core.d.ts.map +1 -1
- package/build/vectors/core.js +212 -149
- package/build/vectors/core.js.map +1 -1
- package/build/vectors/index.d.ts +1 -0
- package/build/vectors/index.d.ts.map +1 -1
- package/build/vectors/index.js +3 -0
- package/build/vectors/index.js.map +1 -1
- package/build/vectors/interpolation.d.ts +39 -27
- package/build/vectors/interpolation.d.ts.map +1 -1
- package/build/vectors/interpolation.js +39 -27
- package/build/vectors/interpolation.js.map +1 -1
- package/build/vectors/predefined.d.ts +48 -24
- package/build/vectors/predefined.d.ts.map +1 -1
- package/build/vectors/predefined.js +38 -18
- package/build/vectors/predefined.js.map +1 -1
- package/package.json +3 -3
|
@@ -10,31 +10,36 @@ import { MatrixSize } from './core.js';
|
|
|
10
10
|
* @class MatrixError
|
|
11
11
|
* @extends Error
|
|
12
12
|
* @example
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
* ```typescript
|
|
14
|
+
* ```typescript
|
|
15
|
+
* try {
|
|
16
|
+
* AssertMatrix(invalidMatrix);
|
|
17
|
+
* } catch (error) {
|
|
18
|
+
* if (error instanceof MatrixError) {
|
|
19
|
+
* console.log('Matrix validation failed:', error.message);
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
* ```
|
|
22
24
|
*/
|
|
23
25
|
export class MatrixError extends Error {
|
|
26
|
+
code = 'MATRIX_ERROR';
|
|
24
27
|
/**
|
|
25
28
|
* Creates a new MatrixError instance.
|
|
26
29
|
*
|
|
27
|
-
* @param message -
|
|
30
|
+
* @param message - Error message describing the validation failure
|
|
31
|
+
* @param options - Optional error context
|
|
32
|
+
* @param options.cause - Original error that caused this error
|
|
28
33
|
*/
|
|
29
|
-
constructor(message) {
|
|
30
|
-
super(message);
|
|
34
|
+
constructor(message, options) {
|
|
35
|
+
super(message, options);
|
|
31
36
|
this.name = 'MatrixError';
|
|
32
37
|
// Maintains proper prototype chain for instanceof checks
|
|
33
38
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
34
39
|
}
|
|
35
40
|
}
|
|
36
41
|
/**
|
|
37
|
-
* Validates that an unknown value is a valid matrix conforming to the
|
|
42
|
+
* Validates that an unknown value is a valid matrix conforming to the TMatrix interface.
|
|
38
43
|
*
|
|
39
44
|
* This function performs comprehensive validation of matrix structure including:
|
|
40
45
|
* - Type checking to ensure the value is a proper matrix
|
|
@@ -48,16 +53,16 @@ export class MatrixError extends Error {
|
|
|
48
53
|
* @throws {IAssertException} When the matrix doesn't meet the specified criteria
|
|
49
54
|
*
|
|
50
55
|
* @example
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
* ```typescript
|
|
57
|
+
* ```typescript
|
|
58
|
+
* // Validate a 3x3 square matrix
|
|
59
|
+
* AssertMatrix(someValue, { square: true, size: 3 });
|
|
60
|
+
* // Validate minimum dimensions
|
|
61
|
+
* AssertMatrix(someValue, { minRows: 2, minColumns: 3 });
|
|
62
|
+
* // Validate exact dimensions
|
|
63
|
+
* AssertMatrix(someValue, { rows: 4, columns: 5 });
|
|
64
|
+
* ```
|
|
65
|
+
* ```
|
|
61
66
|
*/
|
|
62
67
|
export function AssertMatrix(matrix, args = {}, exception = {}) {
|
|
63
68
|
// Initialize the exception with the default MatrixError class if not provided
|
|
@@ -154,16 +159,16 @@ export function AssertMatrix(matrix, args = {}, exception = {}) {
|
|
|
154
159
|
* @throws {MatrixError} When the row is not a valid array of finite numbers
|
|
155
160
|
*
|
|
156
161
|
* @example
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
162
|
+
* ```typescript
|
|
163
|
+
* ```typescript
|
|
164
|
+
* // Validate a matrix row
|
|
165
|
+
* AssertMatrixRow([1, 2, 3, 4]);
|
|
166
|
+
* // Validate with row index in exception for better error messages
|
|
167
|
+
* AssertMatrixRow([1, 2, 3, 4], { rowIndex: 0 });
|
|
168
|
+
* // This would throw MatrixError
|
|
169
|
+
* AssertMatrixRow([1, '2', 3]); // Contains non-numeric value
|
|
170
|
+
* ```
|
|
171
|
+
* ```
|
|
167
172
|
*/
|
|
168
173
|
export function AssertMatrixRow(row, exception = {}) {
|
|
169
174
|
// Initialize the exception with the default MatrixError class if not provided
|
|
@@ -197,18 +202,18 @@ export function AssertMatrixRow(row, exception = {}) {
|
|
|
197
202
|
* @throws {MatrixError} When the value is not a finite number
|
|
198
203
|
*
|
|
199
204
|
* @example
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
205
|
+
* ```typescript
|
|
206
|
+
* ```typescript
|
|
207
|
+
* // Validate a matrix element
|
|
208
|
+
* AssertMatrixValue(42);
|
|
209
|
+
* // Validate with position information for better error messages
|
|
210
|
+
* AssertMatrixValue(3.14, { rowIndex: 0, columnIndex: 1 });
|
|
211
|
+
* // These would throw MatrixError
|
|
212
|
+
* AssertMatrixValue(NaN); // Not a number
|
|
213
|
+
* AssertMatrixValue(Infinity); // Not a finite number
|
|
214
|
+
* AssertMatrixValue('5'); // Not a number type
|
|
215
|
+
* ```
|
|
216
|
+
* ```
|
|
212
217
|
*/
|
|
213
218
|
export function AssertMatrixValue(value, exception = {}) {
|
|
214
219
|
// Initialize the exception with the default MatrixError class if not provided
|
|
@@ -218,7 +223,14 @@ export function AssertMatrixValue(value, exception = {}) {
|
|
|
218
223
|
const position = exception.rowIndex !== undefined && exception.columnIndex !== undefined ? ` at row ${exception.rowIndex}, column ${exception.columnIndex}` : '';
|
|
219
224
|
SetExceptionMessage(exception, `Matrix value${position} must be a finite number`);
|
|
220
225
|
// Delegate to the general number assertion which handles finite number validation
|
|
221
|
-
|
|
226
|
+
// Wrap any thrown error as MatrixError to maintain consistent error handling
|
|
227
|
+
try {
|
|
228
|
+
AssertNumber(value, { finite: true }, exception);
|
|
229
|
+
}
|
|
230
|
+
catch {
|
|
231
|
+
// Re-throw as MatrixError to maintain API contract
|
|
232
|
+
throw new MatrixError(exception.message ?? 'Matrix value must be a finite number');
|
|
233
|
+
}
|
|
222
234
|
}
|
|
223
235
|
/**
|
|
224
236
|
* Validates compatibility between two matrices for mathematical operations.
|
|
@@ -234,13 +246,14 @@ export function AssertMatrixValue(value, exception = {}) {
|
|
|
234
246
|
* @throws {IAssertException} When the matrices are not compatible
|
|
235
247
|
*
|
|
236
248
|
* @example
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
249
|
+
* ```typescript
|
|
250
|
+
* ```typescript
|
|
251
|
+
* // Validate matrices for multiplication (A columns must equal B rows)
|
|
252
|
+
* AssertMatrices(matrixA, matrixB);
|
|
253
|
+
* // Allow transposed compatibility
|
|
254
|
+
* AssertMatrices(matrixA, matrixB, { transposition: true });
|
|
255
|
+
* ```
|
|
256
|
+
* ```
|
|
244
257
|
*/
|
|
245
258
|
export function AssertMatrices(a, b, args = {}, exception = {}) {
|
|
246
259
|
// Initialize the exception with the default MatrixError class if not provided
|
|
@@ -248,7 +261,7 @@ export function AssertMatrices(a, b, args = {}, exception = {}) {
|
|
|
248
261
|
// First validation: ensure both inputs are valid matrices
|
|
249
262
|
AssertMatrix(a, {}, exception);
|
|
250
263
|
AssertMatrix(b, {}, exception);
|
|
251
|
-
// Safe cast to
|
|
264
|
+
// Safe cast to TMatrix since we've validated both inputs
|
|
252
265
|
const matrixA = a;
|
|
253
266
|
const matrixB = b;
|
|
254
267
|
// Extract dimensions from both matrices for compatibility checking
|
|
@@ -292,13 +305,14 @@ export function AssertMatrices(a, b, args = {}, exception = {}) {
|
|
|
292
305
|
* @throws {IAssertException} When the matrix is not a valid 1x1 matrix
|
|
293
306
|
*
|
|
294
307
|
* @example
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
308
|
+
* ```typescript
|
|
309
|
+
* ```typescript
|
|
310
|
+
* // Validate a 1x1 matrix
|
|
311
|
+
* AssertMatrix1([[5]]);
|
|
312
|
+
* // This would throw an exception
|
|
313
|
+
* AssertMatrix1([[1, 2]]); // Too many columns
|
|
314
|
+
* ```
|
|
315
|
+
* ```
|
|
302
316
|
*/
|
|
303
317
|
export function AssertMatrix1(matrix, exception = {}) {
|
|
304
318
|
// Initialize the exception with the default MatrixError class if not provided
|
|
@@ -318,13 +332,14 @@ export function AssertMatrix1(matrix, exception = {}) {
|
|
|
318
332
|
* @throws {IAssertException} When the matrix is not a valid 2x2 matrix
|
|
319
333
|
*
|
|
320
334
|
* @example
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
335
|
+
* ```typescript
|
|
336
|
+
* ```typescript
|
|
337
|
+
* // Validate a 2x2 matrix
|
|
338
|
+
* AssertMatrix2([[1, 2], [3, 4]]);
|
|
339
|
+
* // This would throw an exception
|
|
340
|
+
* AssertMatrix2([[1, 2, 3], [4, 5, 6]]); // Too many columns
|
|
341
|
+
* ```
|
|
342
|
+
* ```
|
|
328
343
|
*/
|
|
329
344
|
export function AssertMatrix2(matrix, exception = {}) {
|
|
330
345
|
// Initialize the exception with the default MatrixError class if not provided
|
|
@@ -344,13 +359,14 @@ export function AssertMatrix2(matrix, exception = {}) {
|
|
|
344
359
|
* @throws {IAssertException} When the matrix is not a valid 3x3 matrix
|
|
345
360
|
*
|
|
346
361
|
* @example
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
362
|
+
* ```typescript
|
|
363
|
+
* ```typescript
|
|
364
|
+
* // Validate a 3x3 matrix
|
|
365
|
+
* AssertMatrix3([[1, 2, 3], [4, 5, 6], [7, 8, 9]]);
|
|
366
|
+
* // This would throw an exception
|
|
367
|
+
* AssertMatrix3([[1, 2], [3, 4]]); // Too few rows and columns
|
|
368
|
+
* ```
|
|
369
|
+
* ```
|
|
354
370
|
*/
|
|
355
371
|
export function AssertMatrix3(matrix, exception = {}) {
|
|
356
372
|
// Initialize the exception with the default MatrixError class if not provided
|
|
@@ -370,18 +386,19 @@ export function AssertMatrix3(matrix, exception = {}) {
|
|
|
370
386
|
* @throws {IAssertException} When the matrix is not a valid 4x4 matrix
|
|
371
387
|
*
|
|
372
388
|
* @example
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
389
|
+
* ```typescript
|
|
390
|
+
* ```typescript
|
|
391
|
+
* // Validate a 4x4 matrix
|
|
392
|
+
* AssertMatrix4([
|
|
393
|
+
* [1, 2, 3, 4],
|
|
394
|
+
* [5, 6, 7, 8],
|
|
395
|
+
* [9, 10, 11, 12],
|
|
396
|
+
* [13, 14, 15, 16]
|
|
397
|
+
* ]);
|
|
398
|
+
* // This would throw an exception
|
|
399
|
+
* AssertMatrix4([[1, 2], [3, 4]]); // Too few rows and columns
|
|
400
|
+
* ```
|
|
401
|
+
* ```
|
|
385
402
|
*/
|
|
386
403
|
export function AssertMatrix4(matrix, exception = {}) {
|
|
387
404
|
// Initialize the exception with the default MatrixError class if not provided
|
|
@@ -390,4 +407,187 @@ export function AssertMatrix4(matrix, exception = {}) {
|
|
|
390
407
|
// This ensures the matrix is exactly 4 rows by 4 columns
|
|
391
408
|
AssertMatrix(matrix, { square: true, size: 4 }, exception);
|
|
392
409
|
}
|
|
410
|
+
/**
|
|
411
|
+
* Validates that an unknown value is a valid matrix without throwing an error.
|
|
412
|
+
*
|
|
413
|
+
* This function performs the same validation as AssertMatrix but returns
|
|
414
|
+
* a boolean instead of throwing an exception, making it suitable for
|
|
415
|
+
* conditional logic where exceptions are not desired.
|
|
416
|
+
*
|
|
417
|
+
* @param matrix - The value to validate as a matrix
|
|
418
|
+
* @param args - Validation configuration options
|
|
419
|
+
* @returns true if the matrix is valid, false otherwise
|
|
420
|
+
*
|
|
421
|
+
* @example
|
|
422
|
+
* ```typescript
|
|
423
|
+
* if (ValidateMatrix(someValue, { square: true })) {
|
|
424
|
+
* // Process the valid square matrix
|
|
425
|
+
* }
|
|
426
|
+
* ```
|
|
427
|
+
*/
|
|
428
|
+
export function ValidateMatrix(matrix, args = {}) {
|
|
429
|
+
try {
|
|
430
|
+
AssertMatrix(matrix, args);
|
|
431
|
+
return true;
|
|
432
|
+
}
|
|
433
|
+
catch {
|
|
434
|
+
return false;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Validates that an unknown value is a valid 1×1 matrix without throwing an error.
|
|
439
|
+
*
|
|
440
|
+
* @param matrix - The value to validate as a 1×1 matrix
|
|
441
|
+
* @returns true if the matrix is valid, false otherwise
|
|
442
|
+
*
|
|
443
|
+
* @example
|
|
444
|
+
* ```typescript
|
|
445
|
+
* if (ValidateMatrix1(someValue)) {
|
|
446
|
+
* // Process the valid 1×1 matrix
|
|
447
|
+
* }
|
|
448
|
+
* ```
|
|
449
|
+
*/
|
|
450
|
+
export function ValidateMatrix1(matrix) {
|
|
451
|
+
try {
|
|
452
|
+
AssertMatrix1(matrix);
|
|
453
|
+
return true;
|
|
454
|
+
}
|
|
455
|
+
catch {
|
|
456
|
+
return false;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Validates that an unknown value is a valid 2×2 matrix without throwing an error.
|
|
461
|
+
*
|
|
462
|
+
* @param matrix - The value to validate as a 2×2 matrix
|
|
463
|
+
* @returns true if the matrix is valid, false otherwise
|
|
464
|
+
*
|
|
465
|
+
* @example
|
|
466
|
+
* ```typescript
|
|
467
|
+
* if (ValidateMatrix2(someValue)) {
|
|
468
|
+
* // Process the valid 2×2 matrix
|
|
469
|
+
* }
|
|
470
|
+
* ```
|
|
471
|
+
*/
|
|
472
|
+
export function ValidateMatrix2(matrix) {
|
|
473
|
+
try {
|
|
474
|
+
AssertMatrix2(matrix);
|
|
475
|
+
return true;
|
|
476
|
+
}
|
|
477
|
+
catch {
|
|
478
|
+
return false;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Validates that an unknown value is a valid 3×3 matrix without throwing an error.
|
|
483
|
+
*
|
|
484
|
+
* @param matrix - The value to validate as a 3×3 matrix
|
|
485
|
+
* @returns true if the matrix is valid, false otherwise
|
|
486
|
+
*
|
|
487
|
+
* @example
|
|
488
|
+
* ```typescript
|
|
489
|
+
* if (ValidateMatrix3(someValue)) {
|
|
490
|
+
* // Process the valid 3×3 matrix
|
|
491
|
+
* }
|
|
492
|
+
* ```
|
|
493
|
+
*/
|
|
494
|
+
export function ValidateMatrix3(matrix) {
|
|
495
|
+
try {
|
|
496
|
+
AssertMatrix3(matrix);
|
|
497
|
+
return true;
|
|
498
|
+
}
|
|
499
|
+
catch {
|
|
500
|
+
return false;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Validates that an unknown value is a valid 4×4 matrix without throwing an error.
|
|
505
|
+
*
|
|
506
|
+
* @param matrix - The value to validate as a 4×4 matrix
|
|
507
|
+
* @returns true if the matrix is valid, false otherwise
|
|
508
|
+
*
|
|
509
|
+
* @example
|
|
510
|
+
* ```typescript
|
|
511
|
+
* if (ValidateMatrix4(someValue)) {
|
|
512
|
+
* // Process the valid 4×4 matrix
|
|
513
|
+
* }
|
|
514
|
+
* ```
|
|
515
|
+
*/
|
|
516
|
+
export function ValidateMatrix4(matrix) {
|
|
517
|
+
try {
|
|
518
|
+
AssertMatrix4(matrix);
|
|
519
|
+
return true;
|
|
520
|
+
}
|
|
521
|
+
catch {
|
|
522
|
+
return false;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Validates that an unknown value is a valid matrix row without throwing an error.
|
|
527
|
+
*
|
|
528
|
+
* @param row - The value to validate as a matrix row
|
|
529
|
+
* @returns true if the row is valid, false otherwise
|
|
530
|
+
*
|
|
531
|
+
* @example
|
|
532
|
+
* ```typescript
|
|
533
|
+
* if (ValidateMatrixRow([1, 2, 3])) {
|
|
534
|
+
* // Process the valid row
|
|
535
|
+
* }
|
|
536
|
+
* ```
|
|
537
|
+
*/
|
|
538
|
+
export function ValidateMatrixRow(row) {
|
|
539
|
+
try {
|
|
540
|
+
AssertMatrixRow(row);
|
|
541
|
+
return true;
|
|
542
|
+
}
|
|
543
|
+
catch {
|
|
544
|
+
return false;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* Validates that an unknown value is a valid matrix value (finite number) without throwing an error.
|
|
549
|
+
*
|
|
550
|
+
* @param value - The value to validate as a matrix element
|
|
551
|
+
* @returns true if the value is valid, false otherwise
|
|
552
|
+
*
|
|
553
|
+
* @example
|
|
554
|
+
* ```typescript
|
|
555
|
+
* if (ValidateMatrixValue(someValue)) {
|
|
556
|
+
* // Process the valid numeric value
|
|
557
|
+
* }
|
|
558
|
+
* ```
|
|
559
|
+
*/
|
|
560
|
+
export function ValidateMatrixValue(value) {
|
|
561
|
+
try {
|
|
562
|
+
AssertMatrixValue(value);
|
|
563
|
+
return true;
|
|
564
|
+
}
|
|
565
|
+
catch {
|
|
566
|
+
return false;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* Validates that two unknown values are compatible matrices without throwing an error.
|
|
571
|
+
*
|
|
572
|
+
* @param a - The first matrix to validate
|
|
573
|
+
* @param b - The second matrix to validate
|
|
574
|
+
* @param args - Validation configuration options
|
|
575
|
+
* @returns true if both matrices are valid and compatible, false otherwise
|
|
576
|
+
*
|
|
577
|
+
* @example
|
|
578
|
+
* ```typescript
|
|
579
|
+
* if (ValidateMatrices(matrixA, matrixB, { transposition: true })) {
|
|
580
|
+
* // Process the valid and compatible matrices
|
|
581
|
+
* }
|
|
582
|
+
* ```
|
|
583
|
+
*/
|
|
584
|
+
export function ValidateMatrices(a, b, args = {}) {
|
|
585
|
+
try {
|
|
586
|
+
AssertMatrices(a, b, args);
|
|
587
|
+
return true;
|
|
588
|
+
}
|
|
589
|
+
catch {
|
|
590
|
+
return false;
|
|
591
|
+
}
|
|
592
|
+
}
|
|
393
593
|
//# sourceMappingURL=asserts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asserts.js","sourceRoot":"","sources":["../../src/matrices/asserts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAoB,YAAY,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEnJ,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AA2FvC
|
|
1
|
+
{"version":3,"file":"asserts.js","sourceRoot":"","sources":["../../src/matrices/asserts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAoB,YAAY,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEnJ,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AA2FvC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK;IACrB,IAAI,GAAW,cAAc,CAAC;IAE9C;;;;;;OAMG;IACH,YAAY,OAAe,EAAE,OAA6B;QACzD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,yDAAyD;QACzD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACnD,CAAC;CACD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,YAAY,CAAC,MAAe,EAAE,OAA0B,EAAE,EAAE,YAAoC,EAAE;IACj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AI,CAAC;QACJ,iBAAiB,CAAC,KAAK,CAAC,CAAC;QACzB,OAAO,IAAI,CAAC;IACb,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,KAAK,CAAC;IACd,CAAC;AACF,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,gBAAgB,CAAC,CAAU,EAAE,CAAU,EAAE,OAA4B,EAAE;IACtF,IAAI,CAAC;QACJ,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;QAC3B,OAAO,IAAI,CAAC;IACb,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,KAAK,CAAC;IACd,CAAC;AACF,CAAC"}
|
package/build/matrices/core.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function MatrixCreate():
|
|
3
|
-
export declare function MatrixCreate(size: 1):
|
|
4
|
-
export declare function MatrixCreate(size: 2):
|
|
5
|
-
export declare function MatrixCreate(size: 3):
|
|
6
|
-
export declare function MatrixCreate(size: 4):
|
|
7
|
-
export declare function MatrixCreate(size: number):
|
|
8
|
-
export declare function MatrixCreate(rows: number, cols: number):
|
|
1
|
+
import { TMatrix, TMatrix1, TMatrix2, TMatrix3, TMatrix4, TMatrixResult } from './types.js';
|
|
2
|
+
export declare function MatrixCreate(): TMatrix1;
|
|
3
|
+
export declare function MatrixCreate(size: 1): TMatrix1;
|
|
4
|
+
export declare function MatrixCreate(size: 2): TMatrix2;
|
|
5
|
+
export declare function MatrixCreate(size: 3): TMatrix3;
|
|
6
|
+
export declare function MatrixCreate(size: 4): TMatrix4;
|
|
7
|
+
export declare function MatrixCreate(size: number): TMatrix;
|
|
8
|
+
export declare function MatrixCreate(rows: number, cols: number): TMatrix;
|
|
9
9
|
/**
|
|
10
10
|
* Returns the dimensions of a matrix as [rows, columns].
|
|
11
11
|
* @param matrix - The matrix to measure
|
|
@@ -13,7 +13,7 @@ export declare function MatrixCreate(rows: number, cols: number): IMatrix;
|
|
|
13
13
|
* @throws {Error} If the input is not a valid matrix
|
|
14
14
|
* @example MatrixSize([[1, 2, 3], [4, 5, 6]]) // [2, 3]
|
|
15
15
|
*/
|
|
16
|
-
export declare function MatrixSize(matrix:
|
|
16
|
+
export declare function MatrixSize(matrix: TMatrix): [number, number];
|
|
17
17
|
/**
|
|
18
18
|
* Returns the size of a square matrix (number of rows/columns).
|
|
19
19
|
* @param matrix - The square matrix to measure
|
|
@@ -21,7 +21,7 @@ export declare function MatrixSize(matrix: IMatrix): [number, number];
|
|
|
21
21
|
* @throws {Error} If the matrix is not square
|
|
22
22
|
* @example MatrixSizeSquare([[1, 2], [3, 4]]) // 2
|
|
23
23
|
*/
|
|
24
|
-
export declare function MatrixSizeSquare(matrix:
|
|
24
|
+
export declare function MatrixSizeSquare(matrix: TMatrix): number;
|
|
25
25
|
/**
|
|
26
26
|
* Validates that the input is a well-formed matrix.
|
|
27
27
|
* @param matrix - The value to validate as a matrix
|
|
@@ -37,7 +37,7 @@ export declare function MatrixIsValid(matrix: unknown): boolean;
|
|
|
37
37
|
* @example MatrixIsSquare([[1, 2], [3, 4]]) // true (2×2)
|
|
38
38
|
* @example MatrixIsSquare([[1, 2, 3], [4, 5, 6]]) // false (3×2)
|
|
39
39
|
*/
|
|
40
|
-
export declare function MatrixIsSquare(matrix:
|
|
40
|
+
export declare function MatrixIsSquare(matrix: TMatrix): boolean;
|
|
41
41
|
/**
|
|
42
42
|
* Checks if a matrix is a zero matrix (all elements are zero within tolerance).
|
|
43
43
|
* @param matrix - The matrix to check
|
|
@@ -48,7 +48,7 @@ export declare function MatrixIsSquare(matrix: IMatrix): boolean;
|
|
|
48
48
|
* @example MatrixIsZero([[1e-15, 0], [0, 0]]) // true (within default threshold)
|
|
49
49
|
* @example MatrixIsZero([[0.1, 0], [0, 0]]) // false
|
|
50
50
|
*/
|
|
51
|
-
export declare function MatrixIsZero(matrix:
|
|
51
|
+
export declare function MatrixIsZero(matrix: TMatrix, threshold?: number): boolean;
|
|
52
52
|
/**
|
|
53
53
|
* Checks if a matrix is an identity matrix (1s on the main diagonal, 0s elsewhere).
|
|
54
54
|
* @param matrix - The matrix to check
|
|
@@ -59,7 +59,7 @@ export declare function MatrixIsZero(matrix: IMatrix, threshold?: number): boole
|
|
|
59
59
|
* @example MatrixIsIdentity([[1, 0, 0], [0, 1, 0], [0, 0, 1]]) // true
|
|
60
60
|
* @example MatrixIsIdentity([[1, 1], [0, 1]]) // false
|
|
61
61
|
*/
|
|
62
|
-
export declare function MatrixIsIdentity(matrix:
|
|
62
|
+
export declare function MatrixIsIdentity(matrix: TMatrix, threshold?: number): boolean;
|
|
63
63
|
/**
|
|
64
64
|
* Checks if a matrix is symmetric (A = Aᵀ, i.e. A[i][j] === A[j][i] for all i, j).
|
|
65
65
|
* @param matrix - The matrix to check (must be square)
|
|
@@ -70,7 +70,7 @@ export declare function MatrixIsIdentity(matrix: IMatrix, threshold?: number): b
|
|
|
70
70
|
* @example MatrixIsSymmetric([[1, 2], [3, 4]]) // false
|
|
71
71
|
* @example MatrixIsSymmetric([[1, 2, 3], [2, 5, 4], [3, 4, 6]]) // true
|
|
72
72
|
*/
|
|
73
|
-
export declare function MatrixIsSymmetric(matrix:
|
|
73
|
+
export declare function MatrixIsSymmetric(matrix: TMatrix, threshold?: number): boolean;
|
|
74
74
|
/**
|
|
75
75
|
* Checks if a matrix is diagonal (all off-diagonal elements are zero within tolerance).
|
|
76
76
|
* A diagonal matrix has non-zero values only on its main diagonal.
|
|
@@ -82,21 +82,21 @@ export declare function MatrixIsSymmetric(matrix: IMatrix, threshold?: number):
|
|
|
82
82
|
* @example MatrixIsDiagonal([[1, 0, 0], [0, 5, 0], [0, 0, 2]]) // true
|
|
83
83
|
* @example MatrixIsDiagonal([[1, 2], [0, 1]]) // false
|
|
84
84
|
*/
|
|
85
|
-
export declare function MatrixIsDiagonal(matrix:
|
|
85
|
+
export declare function MatrixIsDiagonal(matrix: TMatrix, threshold?: number): boolean;
|
|
86
86
|
/**
|
|
87
87
|
* Creates an identity matrix of the specified size.
|
|
88
88
|
* @param size - The dimensions of the square identity matrix (must be non-negative integer)
|
|
89
|
-
* @returns {
|
|
89
|
+
* @returns {TMatrix} A square identity matrix of size n×n
|
|
90
90
|
* @throws {Error} If size is negative or not an integer
|
|
91
91
|
* @example MatrixIdentity(2) // [[1, 0], [0, 1]]
|
|
92
92
|
* @example MatrixIdentity(3) // [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
|
|
93
93
|
*/
|
|
94
|
-
export declare function MatrixIdentity(size: 0):
|
|
95
|
-
export declare function MatrixIdentity(size: 1):
|
|
96
|
-
export declare function MatrixIdentity(size: 2):
|
|
97
|
-
export declare function MatrixIdentity(size: 3):
|
|
98
|
-
export declare function MatrixIdentity(size: 4):
|
|
99
|
-
export declare function MatrixIdentity(size: number):
|
|
94
|
+
export declare function MatrixIdentity(size: 0): TMatrix;
|
|
95
|
+
export declare function MatrixIdentity(size: 1): TMatrix1;
|
|
96
|
+
export declare function MatrixIdentity(size: 2): TMatrix2;
|
|
97
|
+
export declare function MatrixIdentity(size: 3): TMatrix3;
|
|
98
|
+
export declare function MatrixIdentity(size: 4): TMatrix4;
|
|
99
|
+
export declare function MatrixIdentity(size: number): TMatrix;
|
|
100
100
|
/**
|
|
101
101
|
* Creates a deep copy of the given matrix.
|
|
102
102
|
* @param matrix - The matrix to clone
|
|
@@ -104,7 +104,7 @@ export declare function MatrixIdentity(size: number): IMatrix;
|
|
|
104
104
|
* @throws {Error} If the input is not a valid matrix
|
|
105
105
|
* @example MatrixClone([[1, 2], [3, 4]]) // [[1, 2], [3, 4]] (independent copy)
|
|
106
106
|
*/
|
|
107
|
-
export declare function MatrixClone<T extends
|
|
107
|
+
export declare function MatrixClone<T extends TMatrix>(matrix: T): TMatrixResult<T>;
|
|
108
108
|
/**
|
|
109
109
|
* Checks if two matrices are equal within a specified tolerance.
|
|
110
110
|
* @param a - First matrix to compare
|
|
@@ -115,7 +115,7 @@ export declare function MatrixClone<T extends IMatrix>(matrix: T): TMatrixResult
|
|
|
115
115
|
* @example MatrixEquals([[1, 2]], [[1.0001, 2]], 0.001) // true
|
|
116
116
|
* @example MatrixEquals([[1, 2]], [[1, 3]]) // false
|
|
117
117
|
*/
|
|
118
|
-
export declare function MatrixEquals(a:
|
|
118
|
+
export declare function MatrixEquals(a: TMatrix, b: TMatrix, tolerance?: number): boolean;
|
|
119
119
|
/**
|
|
120
120
|
* Converts a matrix to a formatted string representation.
|
|
121
121
|
* @param matrix - The matrix to convert to string
|
|
@@ -125,7 +125,7 @@ export declare function MatrixEquals(a: IMatrix, b: IMatrix, tolerance?: number)
|
|
|
125
125
|
* @example MatrixToString([[1.23, 2.7]]) // "[ 1.23, 2.70 ]"
|
|
126
126
|
* @example MatrixToString([[1, 2], [3, 4]], 0) // "[ 1, 2 ]\n[ 3, 4 ]"
|
|
127
127
|
*/
|
|
128
|
-
export declare function MatrixToString(matrix:
|
|
128
|
+
export declare function MatrixToString(matrix: TMatrix, precision?: number): string;
|
|
129
129
|
/**
|
|
130
130
|
* Computes the rank of a matrix using Gaussian elimination.
|
|
131
131
|
* @param matrix - The input matrix (any dimensions)
|
|
@@ -135,7 +135,7 @@ export declare function MatrixToString(matrix: IMatrix, precision?: number): str
|
|
|
135
135
|
* @example MatrixRank([[1, 2], [2, 4]]) // 1 (second row = 2 × first row)
|
|
136
136
|
* @example MatrixRank([[1, 0], [0, 1]]) // 2 (full rank)
|
|
137
137
|
*/
|
|
138
|
-
export declare function MatrixRank(matrix:
|
|
138
|
+
export declare function MatrixRank(matrix: TMatrix, tolerance?: number): number;
|
|
139
139
|
/**
|
|
140
140
|
* Computes the trace of a matrix (sum of main diagonal elements).
|
|
141
141
|
* @param matrix - The input matrix (can be square or rectangular)
|
|
@@ -144,7 +144,7 @@ export declare function MatrixRank(matrix: IMatrix, tolerance?: number): number;
|
|
|
144
144
|
* @example MatrixTrace([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) // 15 (1 + 5 + 9)
|
|
145
145
|
* @example MatrixTrace([[1, 2], [3, 4], [5, 6]]) // 5 (1 + 4, rectangular matrix)
|
|
146
146
|
*/
|
|
147
|
-
export declare function MatrixTrace(matrix:
|
|
147
|
+
export declare function MatrixTrace(matrix: TMatrix): number;
|
|
148
148
|
/**
|
|
149
149
|
* Returns the transpose of a matrix (rows become columns and vice versa).
|
|
150
150
|
* @param matrix - The matrix to transpose (can be any m×n matrix)
|
|
@@ -153,7 +153,7 @@ export declare function MatrixTrace(matrix: IMatrix): number;
|
|
|
153
153
|
* @example MatrixTranspose([[1, 2, 3], [4, 5, 6]]) // [[1, 4], [2, 5], [3, 6]]
|
|
154
154
|
* @example MatrixTranspose([[1, 2], [3, 4]]) // [[1, 3], [2, 4]]
|
|
155
155
|
*/
|
|
156
|
-
export declare function MatrixTranspose<T extends
|
|
156
|
+
export declare function MatrixTranspose<T extends TMatrix>(matrix: T): TMatrixResult<T>;
|
|
157
157
|
/**
|
|
158
158
|
* Applies a transformation function to each element of the matrix.
|
|
159
159
|
* @param matrix - The input matrix to transform
|
|
@@ -163,5 +163,5 @@ export declare function MatrixTranspose<T extends IMatrix>(matrix: T): TMatrixRe
|
|
|
163
163
|
* @example MatrixMap([[1, 2], [3, 4]], (value) => value * value) // [[1, 4], [9, 16]]
|
|
164
164
|
* @example MatrixMap([[1, 2], [3, 4]], (value, row, col) => value + row + col) // [[1, 3], [4, 6]]
|
|
165
165
|
*/
|
|
166
|
-
export declare function MatrixMap<T extends
|
|
166
|
+
export declare function MatrixMap<T extends TMatrix>(matrix: T, fn: (value: number, row: number, col: number) => number): TMatrixResult<T>;
|
|
167
167
|
//# sourceMappingURL=core.d.ts.map
|