Giter Site home page Giter Site logo

rindow / rindow-math-matrix Goto Github PK

View Code? Open in Web Editor NEW
10.0 4.0 3.0 597 KB

The fundamental package for scientific matrix operation

Home Page: https://rindow.github.io/mathematics/

License: BSD 3-Clause "New" or "Revised" License

PHP 99.99% Shell 0.01% Batchfile 0.01%
php mathematics n-dimensional array scientific-computing machine-learning php8 hpc acceleration gpu

rindow-math-matrix's Introduction

The fundamental package for scientific matrix operation

Status: Build Status Downloads Latest Stable Version License

Rindow Math Matrix is the fundamental package for scientific matrix operation

  • A powerful N-dimensional array object
  • Sophisticated (broadcasting) functions
  • BLAS functions
  • Functions useful for machine learning
  • Tools for integrating C/C++ through the FFI (OpenBLAS,Rindow-Matlib,CLBlast etc.)
  • GPU support on your laptop without n-vidia (OpenCL with Intel,AMD etc.)
  • Useful linear algebra and random number capabilities

Please see the documents on Rindow mathematics project web pages.

Requirements

  • PHP 8.1 or PHP8.2 or PHP8.3
  • PHP7.2, PHP7.3, PHP7.4 and PHP 8.0 are not supported in this release. Please use Release 1.1, which supports them.

Strong recommend

You can perform very fast N-dimensional array operations in conjunction

Please see the rindow-math-matrix-matlibffi to setup plug-in and pre-build binaries.

How to Setup

Set it up using composer.

$ composer require rindow/rindow-math-matrix

You can use it as is, but you will need to speed it up to process at a practical speed.

And then, Set up pre-build binaries for the required high-speed calculation libraries. Click here for details.

$ composer require rindow/rindow-math-matrix-matlibffi

Sample programs

<?php
// sample.php
include __DIR__.'/vendor/autoload.php';
use Rindow\Math\Matrix\MatrixOperator;

$mo = new MatrixOperator();
$a = $mo->array([[1,2],[3,4]]);
$b = $mo->array([[2,3],[4,5]]);
$c = $mo->cross($a,$b);
echo $mo->toString($c,indent:true)."\n";
$ php sample.php
[
 [10,13],
 [22,29]
]

rindow-math-matrix's People

Contributors

codewithkyrian avatar yuichiis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

rindow-math-matrix's Issues

Problem with running under Windows

I tried to check out the library, but I ran into the following problem when trying to use your example code (https://rindow.github.io/mathematics/openblas/mathlibrary.html#usage-on-php):

PHP Fatal error: Uncaught Error: Class "Interop\Polite\Math\Matrix\NDArray" not found in E:\tmp\rindow\rin.php:3

Following extensions are loaded in php_ini:

extension=rindow_openblas
extension=rindow_opencl
extension=rindow_clblast

Could you advise please, what could be the problem?
My environement is Windows 10 with PHP 8.1.15 Thread Safe.

State of Rindow Matlib on macOS (OSX)

Is there any particular reason why there's zero support for rindow matrix on macOS- including most of the accompanying acceleration and GPU libraries like rindow-matlib-ffi, rindow-clbast-ffi, etc. I'm working on a Mac and I'd really love to test things here.

Is rindow_clblast used for matrix operations?

Hi @yuichiis ,
I have to say that speed improvement is impressive! I have 10x acceleration, what means that calculations done in the past for 7 days are now calculated in just a few hours. I've found that this can be even more productive, when using threads from PHP parallel extension (to be honest it's a bit surprising to me - does this mean GPU units still have some free time when using rindow extenstion?). And is was enough that only one function (matrices multiplication = cross product) was migrated. Thank you for your excellent work with parallelism in PHP!
Since time is crutial for my purposes, I must resign from any unncecessary code. That's why I avoid using composer/autoloader (well, checking PHP version against 5.6 and cascade of includes and function calls each time is time-wasting). So I found minimal configuration that works:

include('MatrixOperator.php');
include('NDArray.php');
include('PhpBlas.php');
include('PhpLapack.php');
include('PhpMath.php');
include('MatrixOpelatorFunctions.php');
include('NDArrayPhp.php');
include('Buffer.php');
include('LinearBuffer.php');
include('OpenBlasBuffer.php');
include('BLAS.php');
use Rindow\Math\Matrix\MatrixOperator;
use Interop\Polite\Math\Matrix\NDArray;

And in the php.ini I added:

extension=rindow_openblas
extension=rindow_opencl

As you noticed, there is nothing about rindow_clblast . Does it means that this extension is not for matrix manipulation? If I add it, will I get extra speed up in any way?

TypeError: a must implement interface Rindow\OpenCL\Buffer

Hello,
When I apply GPU acceleration and try to perform matrix multiplication, the LinearAlgebraCL class calls gemm and fails returning 'TypeError: a must implement interface Rindow\OpenCL\Buffer'. In this case 'a' is the OpenBlasBuffer. I think I've installed everything correctly and it appears that disabling gpu accel works fine. Any advice would be greatly appreciated.

Floating numbers in cross calculations

Hi!
I succesfully set up the enviroment and started play with the library. I hope to use it my scientific research - matrix operations consumes 99.8% of time of my algorithms execution :|.
One of the most time consuming operation is cross product of matrices. My matrices are filled with float numbers and unfortunatelly I can not run the Rindow for floats. It works perfectly for int64, however if I switch type to float is hangs completly (for float32) or produce ** On entry to SSYR2K parameter number 1 had an illegal value message (for float64). Is it the known issue? Can I workaroud it in any way? My env, Win10+PHP 8.1

Here is the test script:

<?php

include('vendor/autoload.php');

use Rindow\Math\Matrix\MatrixOperator;
use Interop\Polite\Math\Matrix\NDArray;

$mo = new MatrixOperator;
$mo->setDefaultFloatType(NDArray::float64);


print('A');
$a = $mo->array([[1,2,3],[4,5,6],[7,8,9]]);
print('B');
$b = $mo->array([[2,3,4],[5,6,7],[8,9,1]]);
print('C');
$c = $mo->cross($a,$b);
print('D');
print_r($c->toArray());

?>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.