Is there a good PHP library for vectors and matric

2019-01-27 13:46发布

问题:

I need a PHP library for vectors and matrices. The library I'm looking for should include functions like matrix multiplication, vector cosine similarity, convolution etc.

I also expect such a library to have a proper compact internal representation of sparse vectors and matrices.

I'm using PHP 5.2.

回答1:

There is

  • http://pear.php.net/package/Math_Matrix and
  • http://pear.php.net/package/Math_Vector/

and a number of other related PEAR packages about Math

  • http://pear.php.net/search.php?q=math&in=packages&x=0&y=0&p=1

I do not know if they suit your needs though. See for yourself.



回答2:

There used to be a PHP4 port of the JAMA matrix library at http://www.phpmath.com but it seems to have disappeared from the site. We use it in PHPExcel (though I've updated it a bit to PHP5)



回答3:

There is this library:

https://sourceforge.net/projects/phpmatrixlib/

it contains matrix multiply, inverse, transpose and determinant