Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Looking for actively maintained matrix math library for php

Tags:

php

math

matrix

Does anyone know where I might find a PHP matrix math library which is still actively maintained?

I need to be able to do the basic matrix operations like reduce, transpose (including non-square matrices), invert, determinant, etc.

This question was asked in the past, then closed with no answers. Now I need an answer to the same question. See these links to related questions:

Matrix artihmetic in PHP? https://stackoverflow.com/questions/435074/matrix-arithmetic-in-php-again

I was in the process of installing the pear Math_Matrix library when I saw these and realized it wouldn't help me. (Thanks Ben for putting that comment about transpose in your question.)

I can code this stuff myself, but I would make me happier to see that there is a library for this somewhere.

like image 482
Mnebuerquo Avatar asked Feb 21 '09 20:02

Mnebuerquo


3 Answers

You might do better to do your matrix manipulations in another language and call that code from PHP. The PHP community isn't typically concerned with matrix computation, so I imagine it will be challenging to find what you want. But there are plenty of math libraries in other languages. For example, you might try Python (SciPy), though I don't know how hard it is to mix PHP and Python. I don't know PHP, but most languages have a way to call C, and from C you could call the Gnu Scientific Library, for example.

By the way, there's hardly ever a reason to invert a matrix. Most problems that appear to require matrix inversion actually require solving linear systems. The latter is more stable. Also, some libraries may not have a matrix inversion routine per se because they assume people will use a factorization routine (e.g. Cholesky) and repeated solve systems of equations.

like image 51
John D. Cook Avatar answered Nov 14 '22 17:11

John D. Cook


It is not really a library but there is a lot of usefull php math code (including operations on matrices) on this page:

http://www.phpmath.com/home

I hope this will help

like image 36
Amorphous Avatar answered Nov 14 '22 17:11

Amorphous


I've used this one which is quite good: https://github.com/mcordingley/LinearAlgebra

Also this one looks ok: http://numphp.org/

like image 2
Claudiu Creanga Avatar answered Nov 14 '22 16:11

Claudiu Creanga