Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

Commit

Permalink
added eigen value matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
Parvez Khan committed Dec 28, 2023
1 parent 5dade7e commit 880b5e0
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions website/eigenvalues.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

// Install PHPMatrix library using Composer:
// composer require jameshalsall/php-matrix

require 'vendor/autoload.php';

use Matrix\Matrix;

function findEigenvalues($matrix)
{
// Create a Matrix object from the input array
$matrixObj = new Matrix($matrix);

// Get the eigenvalues
$eigenvalues = $matrixObj->eigenvalues();

// Output the eigenvalues
foreach ($eigenvalues as $eigenvalue) {
echo $eigenvalue . PHP_EOL;
}
}

// Example input matrix
$inputMatrix = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
];

// Find and display the eigenvalues
findEigenvalues($inputMatrix);

0 comments on commit 880b5e0

Please sign in to comment.