Skip to content

Commit 627b7b7

Browse files
committed
Matrix class added; Removed deprecations from tests, README updated.
1 parent f31f532 commit 627b7b7

File tree

6 files changed

+630
-10
lines changed

6 files changed

+630
-10
lines changed

README.md

+107
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,113 @@ The TreeSet class features:
413413
- Custom ordering via __toString for objects
414414
- AVL tree self-balancing
415415

416+
### Matrix
417+
418+
The `Matrix` class provides a robust implementation for matrix operations in PHP, supporting various mathematical operations and transformations commonly used in linear algebra, computer graphics, and scientific computing.
419+
420+
#### Features
421+
422+
- Basic matrix operations (addition, subtraction, multiplication)
423+
- Scalar multiplication
424+
- Matrix transposition
425+
- Determinant calculation
426+
- Identity and zero matrix creation
427+
- Row and column access
428+
- Input validation and error handling
429+
430+
#### Basic Usage
431+
432+
```php
433+
use Daedalus\Matrix;
434+
435+
// Create a 2x2 matrix
436+
$matrix1 = new Matrix([
437+
[1, 2],
438+
[3, 4]
439+
]);
440+
441+
// Create another 2x2 matrix
442+
$matrix2 = new Matrix([
443+
[5, 6],
444+
[7, 8]
445+
]);
446+
447+
// Matrix addition
448+
$sum = $matrix1->add($matrix2);
449+
450+
// Matrix multiplication
451+
$product = $matrix1->multiply($matrix2);
452+
453+
// Scale matrix
454+
$scaled = $matrix1->scale(2);
455+
456+
// Get determinant
457+
$det = $matrix1->determinant();
458+
459+
// Create special matrices
460+
$identity = Matrix::identity(3); // 3x3 identity matrix
461+
$zero = Matrix::zero(2, 3); // 2x3 zero matrix
462+
```
463+
464+
#### Advanced Operations
465+
466+
```php
467+
// Matrix transposition
468+
$matrix = new Matrix([
469+
[1, 2, 3],
470+
[4, 5, 6]
471+
]);
472+
$transposed = $matrix->transpose();
473+
474+
// Access and modify elements
475+
$value = $matrix->get(0, 1); // Get element at row 0, column 1
476+
$matrix->set(1, 2, 10); // Set element at row 1, column 2
477+
478+
// Get matrix properties
479+
$rows = $matrix->getRows(); // Number of rows
480+
$cols = $matrix->getCols(); // Number of columns
481+
```
482+
483+
#### Real-World Use Cases
484+
485+
1. Scientific Computing
486+
- Solving systems of linear equations
487+
- Statistical calculations
488+
- Data transformations
489+
- Numerical analysis
490+
491+
2. Computer Graphics
492+
- 2D/3D transformations
493+
- Image processing
494+
- Game development
495+
- Animation calculations
496+
497+
3. Machine Learning
498+
- Feature transformation
499+
- Covariance matrices
500+
- Principal Component Analysis
501+
- Neural network calculations
502+
503+
4. Financial Applications
504+
- Portfolio optimization
505+
- Risk analysis
506+
- Asset correlation matrices
507+
- Time series analysis
508+
509+
5. Engineering Applications
510+
- Structural analysis
511+
- Circuit calculations
512+
- Signal processing
513+
- Control systems
514+
515+
#### Performance Considerations
516+
517+
- Efficient implementation for basic operations
518+
- Optimized memory usage
519+
- Input validation for matrix compatibility
520+
- Exception handling for invalid operations
521+
- Type safety for numeric operations
522+
416523
### Enhanced Array Object
417524

418525
A PHP library that provides an enhanced version of PHP's ArrayObject with additional features like type safety, event handling, immutability options, and a PSR-11 compliant dependency injection container.

phpunit.xml

-7
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@
1616
</testsuite>
1717
</testsuites>
1818

19-
<coverage>
20-
<report>
21-
<html outputDirectory="coverage"/>
22-
<clover outputFile="coverage.xml"/>
23-
</report>
24-
</coverage>
25-
2619
<source>
2720
<include>
2821
<directory>src</directory>

src/HashSet.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
* @package Daedalus
1212
*/
13-
class HashSet implements \Iterator, \Countable, \Serializable
13+
class HashSet implements \Iterator, \Countable
1414
{
1515
/** @var array[] Array of buckets for hash collisions */
1616
private array $buckets = [];

0 commit comments

Comments
 (0)