Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aboks/power-iteration
Implementation of the Power Iteration method for finding eigenvalues of a matrix, using math-php
https://github.com/aboks/power-iteration
eigenvalues eigenvectors linear-algebra mathematics php
Last synced: about 2 months ago
JSON representation
Implementation of the Power Iteration method for finding eigenvalues of a matrix, using math-php
- Host: GitHub
- URL: https://github.com/aboks/power-iteration
- Owner: aboks
- License: mit
- Created: 2018-02-19T19:21:07.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-06-27T19:07:51.000Z (over 2 years ago)
- Last Synced: 2024-04-13T00:47:28.627Z (10 months ago)
- Topics: eigenvalues, eigenvectors, linear-algebra, mathematics, php
- Language: PHP
- Size: 41 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![Continuous Integration](https://github.com/aboks/power-iteration/workflows/Continuous%20Integration/badge.svg)
[![Latest Stable Version](https://poser.pugx.org/aboks/power-iteration/v/stable)](https://packagist.org/packages/aboks/power-iteration)PowerIteration
==============
Implementation of the Power Iteration method for finding (dominant) eigenvalues and the corresponding eigenvectors of a matrix, using the excellent [math-php](https://github.com/markrogoyski/math-php) library.
Installation
------------
Install using composer:
```
$ composer require aboks/power-iteration
```Basic usage
-----------
```php
getDominantEigenpair(MatrixFactory::create([
[2, 1],
[0, 1]
]));
var_dump($dominant_eigenpair->getEigenvalue()); // 2
var_dump($dominant_eigenpair->getEigenvector()); // Vector([1, 0]), or a scalar multiple
```Advanced usage
--------------### Calculating the least dominant eigenpair
In most situations, one is interested in the dominant eigenvalue and its corresponding eigenvector. It is also possible to calculate the least dominant eigenpair however:
```php
getLeastDominantEigenpair(MatrixFactory::create([
[2, 1],
[0, 1]
]));
var_dump($dominant_eigenpair->getEigenvalue()); // 1
var_dump($dominant_eigenpair->getEigenvector()); // Vector([√2, -√2]), or a scalar multiple
```Customizations
--------------### Stopping criterion
By default, the power iteration runs for 1000 iterations. The stopping criterion can be altered by passing an instance of `StoppingCriterion` as the first argument to `PowerIteration`:
```php