New extension proposal: PHP LAPACK (linear algebra)
| From: | Ian Barber | Date: | Mon, 06 Feb 2012 20:05:11 +0000 |
| Subject: | New extension proposal: PHP LAPACK (linear algebra) | ||
| Groups: | php.pecl.dev | ||
| Request: | Send a blank email to pecl-dev+get-9103@lists.php.net to get a copy of this message | ||
Hi all,
I've wrapped a few functions from the LAPACK* linear algebra library (new
BSD licensed) in a simple PHP extension. Code is on github -
https://github.com/ianbarber/php-lapack
Would love to hear any feedback/suggestions on the code (and also the API
if anyone has experience with the library). Currently is designed as a
series of static functions, as the underlying library is a series of
optimised routines, so it looks like:
<?php
$a = array(
array( 7.52, -1.10, -7.95, 1.08 ),
array(-0.76, 0.62, 9.34, -7.10 ),
array( 5.13, 6.62, -5.66, 0.87 ),
array(-4.75, 8.52, 5.75, 5.30 ),
array( 1.33, 4.91, -5.49, -3.52 ),
array(-2.40, -6.77, 2.34, 3.95 ),
);
$result = Lapack::singularValues($a);
foreach($result as $k => $r) {
foreach($r as $ik => $ir) {
$result[$k][$ik] = round($ir, 2);
}
}
var_dump($result);
?>
--EXPECT--
array(1) {
[0]=>
array(4) {
[0]=>
float(18.37)
[1]=>
float(13.63)
[2]=>
float(10.85)
[3]=>
float(4.49)
}
}
The aim is to work through the most useful functions (generally ones which
solve complete classes of problems), and potentially expose some of the
lower level functions if there is demand. I'm not shooting for a super
optimised version for large data sets, just something workable for day to
day LA requirements.
Thanks!
Ian
*http://www.netlib.org/lapack/